@saywright/studio 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +0 -6
  2. package/dist/bridge.js +1188 -210
  3. package/dist/cli.mjs +9464 -7528
  4. package/dist/client/assets/CommandPalette-BM1BSUxc.js +1 -0
  5. package/dist/client/assets/CommandPalette-BM1BSUxc.js.br +0 -0
  6. package/dist/client/assets/CommandPalette-BM1BSUxc.js.gz +0 -0
  7. package/dist/client/assets/HelpDialog-Bc6yjiVi.js +1 -0
  8. package/dist/client/assets/HelpDialog-Bc6yjiVi.js.br +0 -0
  9. package/dist/client/assets/HelpDialog-Bc6yjiVi.js.gz +0 -0
  10. package/dist/client/assets/ReportView-DKcggbSt.js +4 -0
  11. package/dist/client/assets/ReportView-DKcggbSt.js.br +0 -0
  12. package/dist/client/assets/ReportView-DKcggbSt.js.gz +0 -0
  13. package/dist/client/assets/SettingsDialog-CIpvauuY.js +1 -0
  14. package/dist/client/assets/SettingsDialog-CIpvauuY.js.br +0 -0
  15. package/dist/client/assets/SettingsDialog-CIpvauuY.js.gz +0 -0
  16. package/dist/client/assets/arrow-left-5LUh_bW3.js +1 -0
  17. package/dist/client/assets/brand-BcIB43Uo.js +57 -0
  18. package/dist/client/assets/brand-BcIB43Uo.js.br +0 -0
  19. package/dist/client/assets/brand-BcIB43Uo.js.gz +0 -0
  20. package/dist/client/assets/footprints-CfMi7MiN.js +1 -0
  21. package/dist/client/assets/index-BrM0s_jp.css +2 -0
  22. package/dist/client/assets/index-BrM0s_jp.css.br +0 -0
  23. package/dist/client/assets/index-BrM0s_jp.css.gz +0 -0
  24. package/dist/client/assets/index-D1ooswLS.js +19 -0
  25. package/dist/client/assets/index-D1ooswLS.js.br +0 -0
  26. package/dist/client/assets/index-D1ooswLS.js.gz +0 -0
  27. package/dist/client/assets/refresh-cw-BM1RSPTL.js +1 -0
  28. package/dist/client/index.html +3 -5
  29. package/dist/client/index.html.br +0 -0
  30. package/dist/client/index.html.gz +0 -0
  31. package/dist/sample/package.json +1 -1
  32. package/dist/sample/src/App.tsx +3 -2
  33. package/dist/sample/src/lib/route.ts +3 -2
  34. package/dist/sample/src/pages/Account.tsx +88 -0
  35. package/dist/sample/src/styles.css +5 -0
  36. package/package.json +1 -2
  37. package/dist/client/assets/Calibration-xY4YDLzU.js +0 -1
  38. package/dist/client/assets/Calibration-xY4YDLzU.js.br +0 -0
  39. package/dist/client/assets/Calibration-xY4YDLzU.js.gz +0 -0
  40. package/dist/client/assets/CommandPalette-BA3akF-p.js +0 -1
  41. package/dist/client/assets/CommandPalette-BA3akF-p.js.br +0 -0
  42. package/dist/client/assets/CommandPalette-BA3akF-p.js.gz +0 -0
  43. package/dist/client/assets/HelpDialog-C6qmdEwi.js +0 -1
  44. package/dist/client/assets/HelpDialog-C6qmdEwi.js.br +0 -0
  45. package/dist/client/assets/HelpDialog-C6qmdEwi.js.gz +0 -0
  46. package/dist/client/assets/ReportView-Bj9xxLCi.js +0 -4
  47. package/dist/client/assets/ReportView-Bj9xxLCi.js.br +0 -0
  48. package/dist/client/assets/ReportView-Bj9xxLCi.js.gz +0 -0
  49. package/dist/client/assets/SettingsDialog-VrACcdUX.js +0 -1
  50. package/dist/client/assets/SettingsDialog-VrACcdUX.js.br +0 -0
  51. package/dist/client/assets/SettingsDialog-VrACcdUX.js.gz +0 -0
  52. package/dist/client/assets/button-B2NFEpCs.js +0 -18
  53. package/dist/client/assets/button-B2NFEpCs.js.br +0 -0
  54. package/dist/client/assets/button-B2NFEpCs.js.gz +0 -0
  55. package/dist/client/assets/camera-BD9K1f5I.js +0 -1
  56. package/dist/client/assets/confirm-D1U-bFIL.js +0 -41
  57. package/dist/client/assets/confirm-D1U-bFIL.js.br +0 -0
  58. package/dist/client/assets/confirm-D1U-bFIL.js.gz +0 -0
  59. package/dist/client/assets/footprints-DiYtIryA.js +0 -1
  60. package/dist/client/assets/index-BakNwOFF.css +0 -2
  61. package/dist/client/assets/index-BakNwOFF.css.br +0 -0
  62. package/dist/client/assets/index-BakNwOFF.css.gz +0 -0
  63. package/dist/client/assets/index-DUAtV_Av.js +0 -18
  64. package/dist/client/assets/index-DUAtV_Av.js.br +0 -0
  65. package/dist/client/assets/index-DUAtV_Av.js.gz +0 -0
  66. package/dist/client/assets/preload-helper-BLdHbfdN.js +0 -1
  67. package/dist/client/assets/preload-helper-BLdHbfdN.js.br +0 -0
  68. package/dist/client/assets/preload-helper-BLdHbfdN.js.gz +0 -0
  69. package/dist/client/assets/refresh-cw-Dobx2YmO.js +0 -1
  70. package/dist/client/assets/tracker.worker-DWwj76VA.js +0 -41
  71. package/dist/client/assets/tracker.worker-DWwj76VA.js.br +0 -0
  72. package/dist/client/assets/tracker.worker-DWwj76VA.js.gz +0 -0
  73. package/dist/client/assets/vision_bundle-ByYCzljp.js +0 -41
  74. package/dist/client/assets/vision_bundle-ByYCzljp.js.br +0 -0
  75. package/dist/client/assets/vision_bundle-ByYCzljp.js.gz +0 -0
@@ -0,0 +1,57 @@
1
+ import{a as e,i as t,o as n,r,t as i}from"./cn-Wq33h1G4.js";var a=e((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return l(e,t,null,n)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.0`})),o=e(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=a()})),s=n(t(),1),c=class extends Error{status;code;constructor(e,t,n){super(t),this.status=e,this.code=n}};async function l(e,t,n,r){let i;try{i=await fetch(`/api${t}`,{method:e,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n),signal:r})}catch(e){throw e.name===`AbortError`?e:new c(0,"The studio isn’t responding. Is it still running? Start it again with `npx @saywright/studio`.")}let a;try{a=await i.text()}catch(e){throw e.name===`AbortError`?e:new c(0,`The studio server stopped answering midway. Try again.`)}let o={};if(a)try{o=JSON.parse(a)}catch{if(i.ok)throw new c(i.status,`The studio sent an answer it couldn’t read. Try again.`)}if(!i.ok)throw new c(i.status,o.error??`Request failed (${i.status})`,o.code);return o}var u={get:(e,t)=>l(`GET`,e,void 0,t),post:(e,t={},n)=>l(`POST`,e,t,n),put:(e,t={})=>l(`PUT`,e,t),delete:e=>l(`DELETE`,e)};function d(e,t){let n=null,r=!1,i=null,a=!1,o=()=>{n=new EventSource(`/api/events`),n.onopen=()=>{t?.(a),a=!0};for(let[t,r]of Object.entries(e))n.addEventListener(t,e=>{try{r(JSON.parse(e.data))}catch{}});n.onerror=()=>{n?.close(),r||(i=setTimeout(o,1500))}};return o(),()=>{r=!0,i&&clearTimeout(i),n?.close()}}var f=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},p=(e=>e?f(e):f),m=e=>e;function h(e,t=m){let n=s.useSyncExternalStore(e.subscribe,s.useCallback(()=>t(e.getState()),[e,t]),s.useCallback(()=>t(e.getInitialState()),[e,t]));return s.useDebugValue(n),n}var g=e=>{let t=p(e),n=e=>h(t,e);return Object.assign(n,t),n},_=(e=>e?g(e):g),v=_()(()=>({apps:[],active:null,runs:{},cloneDir:``,launcherPref:!0,launcher:!1,linking:null,attachTo:null,opening:null,pending:null,cloneLog:[],loaded:!1})),y=v.setState,b=v.getState;function x(e){y({apps:e.apps,active:e.active,runs:Object.fromEntries(e.runs.map(e=>[e.app,e])),cloneDir:e.cloneDir,launcherPref:e.launcher,loaded:!0})}var S=()=>void 0,C=null,w=e=>{let t=e!==C;C=e,S(t)},T={async init(e){S=e,await this.refresh(),C=b().active},async refresh(){try{x(await u.get(`/apps`))}catch{}},async reconnected(){let e=b().active;await this.refresh();let t=b();e&&!t.active&&!t.opening&&t.apps.some(t=>t.id===e)&&await this.open(e)},show(e,t){this.refresh(),y(e?{launcher:!0,linking:e,attachTo:t??null}:{launcher:!0})},setLinking(e){y(e?{linking:e}:{linking:null,attachTo:null})},async attachFolder(e,t){let n=await u.post(`/apps/${encodeURIComponent(e)}/folder`,{root:t.root});return x(n.state),n.app},hide(){b().active&&y({launcher:!1})},serverEvent(e){let t=e;t.kind===`run`&&t.run?y({runs:{...b().runs,[t.run.app]:t.run}}):t.kind===`opening`&&t.id?y({opening:{id:t.id,env:t.env??``,step:t.step??`Opening`}}):t.kind===`clone`&&t.line?y({cloneLog:[...b().cloneLog,t.line].slice(-80)}):t.kind===`active`?(y({active:t.id??null,opening:null,launcher:!t.id}),w(t.id??null),this.refresh()):(t.kind===`linked`||t.kind===`unlinked`)&&this.refresh()},async open(e,t,n){y({opening:{id:e,env:t??``,step:`Opening`},pending:null});try{return x(await u.post(`/apps/${e}/open`,{env:t,decide:n})),y({opening:null,launcher:!1}),w(e),!0}catch(n){let r=n instanceof c?n:null;return r?.code===`previews`?(y({opening:null,pending:{id:e,env:t,message:r.message}}),!1):(y({opening:{id:e,env:t??``,step:`Failed`,error:n instanceof Error?n.message:String(n),code:r?.code}}),!1)}},dismissOpening(){y({opening:null,pending:null})},async probeFolder(e){return(await u.post(`/apps/probe`,{folder:e})).probe},async probeUrl(e){return(await u.post(`/apps/probe`,{url:e})).probe},async folders(e){return u.get(`/apps/folders${e?`?path=${encodeURIComponent(e)}`:``}`)},async clone(e,t){return y({cloneLog:[]}),(await u.post(`/apps/clone`,{repo:e,dir:t})).probe},async link(e,t){let n=await u.post(`/apps`,{probe:e,...t,open:!1});return x(n.state),this.open(n.app.id),n.app},async sample(){y({opening:{id:`sample`,env:``,step:`Starting the sample shop`}});try{x(await u.post(`/apps/sample`,{})),y({opening:null,launcher:!1}),w(b().active)}catch(e){y({opening:{id:`sample`,env:``,step:`Failed`,error:e instanceof Error?e.message:String(e),code:e instanceof c?e.code:void 0}})}},async install(e){y({opening:{id:e,env:``,step:`Installing dependencies`}});try{return x(await u.post(`/apps/${e}/install`,{})),y({opening:null}),!0}catch(t){return y({opening:{id:e,env:``,step:`Failed`,error:t instanceof Error?t.message:String(t)}}),!1}},async stop(e){x(await u.post(`/apps/${e}/stop`,{}))},async remove(e){x(await u.delete(`/apps/${e}`))},async update(e,t){x((await u.put(`/apps/${e}`,t)).state)},async addEnv(e,t,n){x((await u.post(`/apps/${e}/envs`,{url:t,label:n})).state)},async removeEnv(e,t){x((await u.delete(`/apps/${e}/envs/${t}`)).state)},async setLauncherPref(e){x(await u.put(`/apps/launcher`,{on:e}))},async setCloneDir(e){x(await u.put(`/apps/clone-dir`,{dir:e}))},async close(){x(await u.post(`/apps/close`,{})),y({launcher:!0}),w(null)}},E=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),ee={mod:[`⌘`,`Ctrl`],ctrl:[`⌃`,`Ctrl`],alt:[`⌥`,`Alt`],shift:[`⇧`,`Shift`]},te={enter:`↵`,esc:`Esc`,space:`Space`,up:`↑`,down:`↓`,left:`←`,right:`→`};function ne(e,t=E){return e.split(`+`).map(e=>{let n=e.trim(),r=n.toLowerCase();return ee[r]?ee[r][+!t]:te[r]??(n.length===1?n.toUpperCase():n)})}function D(e,t=E){let n=ne(e,t);return t?n.reduce((e,t,r)=>e+(r&&(t.length>1||n[r-1].length>1)?` `:``)+t,``):n.join(` `)}function re(e){return e==null?`—`:e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(+(e<1e4))} s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function ie(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return`just now`;if(n<60)return`${n}s ago`;let r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function ae(e){try{let t=new URL(e),n=`${t.pathname}${t.search}${t.hash}`;return`${t.host}${n===`/`?``:n}`}catch{return e}}function oe(e){return e.split(`/`).pop()??e}function se(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function ce(e){return e>0&&e<.01?`<$0.01`:`$${e.toFixed(e>=100?0:2)}`}function le(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(Math.round(e))}function ue(e,t){if(!e||!t||e===t)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\d+/g,`\\d+`);return n===t||!/\\d\+/.test(n)?e:new RegExp(n).exec(e)?.[0]??e}function de(e){let t=e.toLowerCase().replace(/[.!?“”"'‘’]/g,``).replace(/\s+/g,` `).trim();return/^(?:be )?(?:un(?:checked|ticked|selected)|not (?:be )?(?:checked|ticked|selected|chosen|on)|deselected|cleared|off|غير (?:محدد|مفعل|مختار))$/.test(t)?`not checked`:/^(?:be )?(?:checked|ticked|selected|chosen|on|محدد|مفعل|مختار)$/.test(t)?`checked`:null}function fe(e,t=e=>`“${e}”`){return e.field===`checked`?e.expected===`not checked`?`should not be checked`:`should be checked`:e.field===`select`?`should have ${t(e.expected)} chosen`:`should show ${t(e.expected)}`}function pe(e,t){let n=e=>Math.max(0,Math.min(t,e.after??t)),r=e.map((e,t)=>({i:t,at:n(e)})).sort((e,t)=>e.at-t.at||e.i-t.i),i=Array.from({length:e.length},()=>0);return r.forEach((e,t)=>i[e.i]=t+1),i}var me=`•••`,he=`SAYWRIGHT_SECRET_`;function ge(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[^\p{L}\p{N}]+/gu,` `).trim().toLowerCase()}var _e=RegExp(`\\b(?:`+`pass(?:word|wd|code|phrase|key)s?.pwd.pw.secrets?.tokens?.api ?keys?.access ?keys?.secret ?keys?.private ?keys?.client ?secrets?.licen[cs]e ?keys?.product ?keys?.activation ?(?:keys?|codes?).recovery ?(?:keys?|codes?).backup ?codes?.auth(?:entication|orization)? ?codes?.otp.totp.one ?time ?(?:codes?|passwords?|passcodes?|pins?).(?:verification|security|confirmation|sms|2fa|mfa) ?codes?.2fa.mfa.cvv2?.cvc2?.csc.card ?(?:numbers?|num|no|codes?|verification|holder|security|expiry|expiration|exp|cvc|cvv).name ?on ?card.credit ?cards?.debit ?cards?.cc ?(?:number|num|no|exp|expiry|csc|cvc|cvv|name|given|family|type).iban.account ?(?:numbers?|num|no).routing ?(?:numbers?|num|no).sort ?codes?.ssn.social ?security.tax ?id.national ?id.passports?.pins?(?: ?codes?)?.(?:recovery|seed|secret|backup|mnemonic) ?(?:phrases?|words?).mnemonics?.(?:security|secret) ?(?:questions?|answers?).memorable ?(?:words?|information|info).mother s maiden name`.split(`.`).join(`|`)+`)\\b`),ve=/كلمة (?:ال)?(?:مرور|سر)|(?:ال)?رمز (?:ال)?(?:سري|تحقق|التحقق|أمان|الأمان|المرور)|رقم (?:ال)?(?:بطاقة|حساب|سري)|آيبان/;function ye(e){return _e.test(ge(e))||ve.test(e)}var be=new Set([`enter`,`your`,`the`,`a`,`an`,`please`,`type`,`confirm`,`confirmation`,`repeat`,`again`,`re`,`retype`,`field`,`here`,`of`,`required`,`optional`]),xe=new Set([`new`,`old`,`current`,`previous`,`admin`,`master`,`root`]);function Se(e){let t=ge(e),n=_e.exec(t),r;if(n){let e=t.slice(0,n.index).trim().split(` `).pop()??``;r=[...xe.has(e)?[e]:[],...n[0].split(` `)]}else r=t.split(` `).filter(e=>e&&!be.has(e)&&/^[a-z0-9]+$/.test(e)).slice(0,3);return r.length?r.join(`_`).toUpperCase().slice(0,40):/كلمة (?:ال)?(?:مرور|سر)/.test(e)?`PASSWORD`:/تحقق|التحقق/.test(e)?`VERIFICATION_CODE`:/بطاقة/.test(e)?`CARD_NUMBER`:`SECRET`}function Ce(e){return he+(e.toUpperCase().replace(/[^A-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`SECRET`)}var we=/\b\d(?:[ -]?\d){12,22}\b/g,Te=[/\beyJ[\w-]{6,}\.eyJ[\w-]{6,}\.[\w-]{6,}/g,/\b(?:sk|rk)-[\w-]{16,}/g,/\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}/g,/\bgh[pousr]_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bglpat-[\w-]{16,}/g,/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,/\bnpm_[A-Za-z0-9]{30,}/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{35}/g,/\bwhsec_[A-Za-z0-9]{16,}/g,/\bSG\.[\w-]{16,}\.[\w-]{16,}/g,/(?<=\b(?:aws_?secret_?access_?key|secret_?access_?key|client_?secret|api_?secret|private_?key|access_?token|refresh_?token|auth_?token|password|passwd)["']?\s*[:=]\s*["']?)[^\s"',;}{]{8,}/gi,/\b[a-z]{2,8}_(?:(?:live|test)_)?(?=[A-Za-z0-9]{20,}\b)(?=[A-Za-z0-9]*\d)(?=[A-Za-z0-9]*[a-z])(?=[A-Za-z0-9]*[A-Z])[A-Za-z0-9]{20,}\b/g,/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/g,/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g];function Ee(e){let t=0;for(let n=0;n<e.length;n++){let r=Number(e[e.length-1-n]);n%2&&(r=r*2>9?r*2-9:r*2),t+=r}return t%10==0}function De(e){let t=e.replace(/\D/g,``);if(t.length<13||t.length>19||!/^[2-6]/.test(t)||!Ee(t))return!1;if(/^\d+$/.test(e))return!0;if(e.includes(` `)&&e.includes(`-`))return!1;let n=e.split(/[ -]/);return n.every(e=>/^\d+$/.test(e))&&n.slice(0,-1).every(e=>e.length>=4&&e.length<=6)&&n[n.length-1].length<=6}function Oe(e){let t=e.split(/(?<=\d)(?=[ -])/);for(let e=t.length;e>0;e--){let n=t.slice(0,e).join(``);if(De(n))return`•••• ${n.replace(/\D/g,``).slice(-4)}${t.slice(e).join(``)}`}return e}function ke(e){if(!e)return e;let t=e.replace(we,Oe);t=t.replace(/\b([a-z][a-z0-9+.-]*:\/\/[^\s:@/]+:)([^\s@/]+)@/gi,(e,t)=>`${t}${me}@`);for(let e of Te)t=t.replace(e,e=>e.startsWith(`Bearer`)?`Bearer ${me}`:me);return t}function Ae(e){let t=e.trim();return t.length<12?!1:ke(t)!==t||/^[a-f0-9]{32,}$/i.test(t)&&/\d/.test(t)&&/[a-f]/i.test(t)?!0:/^[A-Za-z0-9+/_=-]{24,}$/.test(t)&&/\d/.test(t)&&/[a-z]/.test(t)&&/[A-Z]/.test(t)}var je=`saywright`;function Me(e,t){return t.v<(e.oldest??e.v)?`plugin`:e.v<(t.oldest??t.v)?`studio`:null}function Ne(e){return!!e&&typeof e==`object`&&e.ns===`saywright`&&typeof e.type==`string`}var Pe=e=>Ce(e).slice(he.length);function Fe(e){return`${Array.from((e.locator??``).matchAll(/'((?:[^'\\]|\\.)*)'/g),e=>e[1]).join(` `)} ${/“([^”]*)”[^“]*$/.exec(e.description)?.[1]??``}`}function Ie(e){return e.map(e=>{if(e.kind!==`fill`||e.checked!==void 0)return e;if(e.secret)return{...e,value:``,secret:Pe(e.secret)};if(!e.select&&!e.values&&/^Choose “/.test(e.description))return{...e,values:[e.value??``]};if(e.select||e.values)return e;let t=Fe(e);if(ye(t)||Ae(e.value??``)){let n=/ into (.+)$/.exec(e.description)?.[1];return{...e,value:``,secret:Pe(Se(/'([^']*)'/.exec(e.locator??``)?.[1]??t)),description:n?`Type ${me} into ${n}`:`Type ${me}`}}return{...e,value:ke(e.value??``),description:ke(e.description)}})}var Le=class{frame=null;origin=`*`;nextReq=1;seq=0;pending=new Map;oneShot=new Map;helloTimer=null;ready=!1;url=``;outdated=null;onReady=null;onProbe=null;onRecorded=null;onNavigated=null;onMouse=null;onKey=null;onSession=null;onMoment=null;onOutdated=null;attach(e,t){this.detach(),this.frame=e,this.origin=new URL(t).origin,window.addEventListener(`message`,this.onMessage);let n=!1;try{n=e.contentWindow?.location.href!==`about:blank`}catch{n=!0}n&&this.sayHello()}sayHello(){this.ready=!1,this.outdated=null,this.helloTimer&&clearInterval(this.helloTimer);let e=()=>this.post({type:`hello`,v:1,oldest:1});e(),this.helloTimer=setInterval(()=>{this.ready||this.outdated?this.helloTimer&&clearInterval(this.helloTimer):e()},400)}detach(){window.removeEventListener(`message`,this.onMessage),this.helloTimer&&clearInterval(this.helloTimer);for(let e of this.pending.values())clearTimeout(e.timer);this.pending.clear(),this.frame=null,this.ready=!1}post(e){let t=this.frame?.contentWindow;if(t)try{t.postMessage({ns:je,...e},this.origin)}catch{}}onMessage=e=>{if(!this.frame||e.source!==this.frame.contentWindow||e.origin!==this.origin||!Ne(e.data))return;let t=e.data;switch(t.type){case`ready`:{let e=Me({v:1,oldest:1},{v:Number(t.v)||0,oldest:t.oldest});if(e){this.outdated=e,this.helloTimer&&clearInterval(this.helloTimer),this.onOutdated?.(e);break}this.ready=!0,this.url=t.url,this.wanted&&this.post({type:`session`,on:!0,...this.wanted}),this.onReady?.({url:t.url,title:t.title});break}case`probe`:{let e=this.oneShot.get(t.seq);e?(this.oneShot.delete(t.seq),e(t)):t.seq===this.seq&&this.onProbe?.(t);break}case`reply`:{let e=this.pending.get(t.reqId);e&&(clearTimeout(e.timer),this.pending.delete(t.reqId),e.resolve(t));break}case`recorded`:this.onRecorded?.(t.action);break;case`progress`:{let e=this.pending.get(t.reqId);e?.wait(),e?.progress?.(t.done);break}case`navigated`:this.url=t.url,this.onNavigated?.({url:t.url,title:t.title});break;case`mouse`:this.onMouse?.(t.x===null||t.y===null?null:{x:t.x,y:t.y});break;case`key`:this.onKey?.(t.key,t.down);break;case`session`:this.starting&&t.id===this.starting.id&&(this.starting.done(),this.starting=null),this.onSession?.({id:t.id,events:t.events,issues:t.issues});break;case`moment`:this.onMoment?.(t.reason)}};probe(e,t,n,r,i,a=!1){this.ready&&this.post({type:`probe`,seq:++this.seq,x:e,y:t,radius:n,deep:r,track:i,sticky:a})}probeAt(e,t,n,r){if(!this.ready)return Promise.resolve(null);let i=++this.seq;return new Promise(a=>{let o=setTimeout(()=>{this.oneShot.delete(i),a(null)},600);this.oneShot.set(i,e=>{clearTimeout(o),a(e?.hit??null)}),this.post({type:`probe`,seq:i,x:e,y:t,radius:n,deep:r,track:[]})})}request(e,t=2e3,n){return new Promise(r=>{if(!this.ready)return r({ns:je,type:`reply`,reqId:0,ok:!1,error:`app not connected`});let i=this.nextReq++,a=()=>{this.pending.delete(i),r({ns:je,type:`reply`,reqId:i,ok:!1,error:`timeout`})},o={resolve:r,timer:setTimeout(a,t),wait:()=>{clearTimeout(o.timer),o.timer=setTimeout(a,t)},progress:n};this.pending.set(i,o),this.post({...e,reqId:i})})}async reveal(e,t,n){let r=await this.request({type:`reveal`,reqId:0,id:e,src:t,index:n});return r.ok?r.info??null:null}async review(e,t,n){let r=await this.request({type:`review`,reqId:0,experts:e,axe:t},3e4,n);if(!r.ok)throw Error(r.error===`timeout`?`The page took too long to check.`:r.error??`The page couldn’t be checked.`);return r.review??null}async describe(e){let t=await this.request({type:`describe`,reqId:0,id:e});return t.ok?t.info??null:null}async locator(e,t){let n=await this.request({type:`locator`,reqId:0,id:e,...t?{check:t}:{}});return n.ok&&n.locator&&n.info?{locator:n.locator,info:n.info,checked:n.checked,option:n.option,chosen:n.chosen}:null}async step(e,t){let n=await this.request({type:`step`,reqId:0,id:e,to:t});return n.ok?n.info??null:null}async find(e,t,n=`any`){let r=await this.request({type:`find`,reqId:0,id:e??0,what:t,where:n});return r.ok?r.info??null:null}async replay(e,t,n=!1,r,i=5e3){let a=await this.request({type:`replay`,reqId:0,locator:e,step:t,read:n,like:r},i);return{ok:a.ok,info:a.info??null,text:a.text,error:a.error}}async explore(){let e=await this.request({type:`explore`,reqId:0},4e3);return e.ok?e.snapshot??null:null}goto(e){this.post({type:`goto`,url:e})}async reload(e){return(await this.request({type:`flush`,reqId:0},1500)).ok?(this.goto(e),!0):!1}async resolve(e,t){let n=await this.request({type:`resolve`,reqId:0,src:e,index:t});return n.ok?n.info??null:null}async click(e,t){let n=await this.request({type:`click`,reqId:0,x:e,y:t});return{ok:n.ok,info:n.info??null}}async type(e,t=!1){let n=await this.request({type:`type`,reqId:0,text:e,submit:t});return{ok:n.ok,error:n.error}}scroll(e,t,n,r){this.post({type:`scroll`,x:e,y:t,dx:n,dy:r})}record(e){this.post({type:`record`,on:e})}async flushRecorder(){await this.request({type:`flush`,reqId:0},400)}trackMouse(e){this.post({type:`mouse`,on:e})}forwardKeys(e){this.post({type:`keys`,on:e})}starting=null;wanted=null;session(e,t,n,r){return this.wanted=e&&t&&n?{id:t,endpoint:n,key:r}:null,this.post({type:`session`,on:e,id:t,endpoint:n,key:r}),!e||!t?Promise.resolve(!0):(this.starting?.done(),new Promise(e=>{let n=setTimeout(()=>{this.starting?.id===t&&(this.starting=null),e(!1)},3e3);this.starting={id:t,done:()=>{clearTimeout(n),e(!0)}}}))}mark(e,t){this.post({type:`mark`,note:e,via:t})}};function Re(e){return e.replace(/[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]/g,``).replace(/ـ/g,``).replace(/[أإآٱ]/g,`ا`).replace(/ى/g,`ي`).replace(/ة/g,`ه`).replace(/ؤ/g,`و`).replace(/ئ/g,`ي`).replace(/[\u0660-\u0669]/g,e=>String(e.charCodeAt(0)-1632))}function ze(e){return Re(e.normalize(`NFKC`)).toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/'(?!\w)|(?<!\w)'/g,` `).replace(/\s+/g,` `).trim()}function Be(e,t){let n=e.length,r=t.length,i=Array.from({length:r+1},(e,t)=>t);for(let a=1;a<=n;a++){let n=[a];for(let o=1;o<=r;o++)n[o]=Math.min(i[o]+1,n[o-1]+1,i[o-1]+(e[a-1]===t[o-1]?0:1));i=n}return i[r]}function Ve(e,t){let n=ze(e).split(` `).filter(Boolean),r=ze(t).split(` `).filter(Boolean);return n.length?Be(n,r)/n.length:+!!r.length}var He=/^(?:و)?(?:هذا|هذه|هذي|هاذا|هاذي|ده|دي|دا|ديه|دى|ذا|ذلك|ذاك|تلك|هذاك|هذيك|دول|دولا|هدول|هؤلاء|هيدا|هيدي|هاد|هادا|هادي|هنا|هناك|هون|هنيه|هنيك|هيك)$/;function Ue(e){return Re(e.normalize(`NFKC`)).replace(/(\d)\s?[٫,]\s?(\d)/g,`$1.$2`).replace(/(\d)٬(\d)/g,`$1$2`).replace(/[^\p{L}\p{N}\s$.]/gu,` `).replace(/\s+/g,` `).trim()}function We(e){return e.replace(/^(?:و|ف)?(?:بال|لل|ال|بل|كال)(?=..)/,``)}function Ge(e,t){let n=We(e);return t.some(t=>n===t||e===t||t.length>=5&&Math.abs(n.length-t.length)<=1&&Be([...n],[...t])<=1)}function Ke(e,t){return e.some(e=>Ge(e,t))}var qe={red:[`احمر`,`حمرا`,`حمراء`,`الحمر`,`احمرا`],green:[`اخضر`,`خضرا`,`خضراء`,`اخضرا`],blue:[`ازرق`,`زرقا`,`زرقاء`,`كحلي`,`ازرقا`],yellow:[`اصفر`,`صفرا`,`صفراء`,`اصفرا`],orange:[`برتقالي`,`برتقاني`,`اورنج`],purple:[`بنفسجي`,`موف`,`ليلكي`],pink:[`وردي`,`بمبي`,`زهري`,`بينك`],black:[`اسود`,`سودا`,`سوداء`,`اسودا`],white:[`ابيض`,`بيضا`,`بيضاء`,`ابيضا`],gray:[`رمادي`,`رصاصي`,`سكني`]},Je=[`كبر`,`كبره`,`كبرها`,`كبري`,`اكبر`,`كبير`,`كبيره`,`كبيرة`,`تكبير`,`وسع`,`وسعه`,`اوسع`,`طول`,`اطول`,`زود`],Ye=[`صغر`,`صغره`,`صغرها`,`صغري`,`اصغر`,`صغير`,`صغيره`,`تصغير`,`قلل`,`قصر`,`اقصر`,`ضيق`,`نقص`],Xe=[`مسافه`,`مسافات`,`المسافه`,`فراغ`,`بادينج`,`هوامش`,`هامش`,`تباعد`],Ze=`خلي.خليه.خليها.خلّي.اجعل.اجعله.اجعلها.اجعلي.اجعلوه.خلو.خلوه.غير.غيره.غيرها.غيّر.غيري.غيروه.لون.لونه.لونها.حول.حوله.حولها.اعمل.اعمله.اعملها.خليلي.سوي.سويه.خلّيه`.split(`.`),Qe=[`احذف`,`احذفه`,`احذفها`,`احذفي`,`امسح`,`امسحه`,`امسحها`,`امسحي`,`شيل`,`شيله`,`شيلها`,`شيلي`,`اخفي`,`اخفيه`,`اخفيها`,`حذف`,`ازل`,`ازله`,`الغي ده`],$e=[`انقل`,`انقله`,`انقلها`,`حرك`,`حركه`,`حركها`,`حط`,`حطه`,`حطها`,`ضع`,`ضعه`,`نقل`],et=[`فوق`,`اعلي`,`قبل`],tt=[`تحت`,`اسفل`,`بعد`],nt=[[/^(?:تراجع|تراجع عن (?:ده|هذا|ذلك|التغيير)|ارجع|رجع|رجعها|رجعه|ارجعها|الغي التغيير|الغي التعديل|رجعه زي ما كان|ارجع زي ما كان|بلاش التغيير|بلاش ده|undo)$/,`undo`],[/^(?:احتفظ(?: به| بها| بالتغيير)?|احفظ(?:ه|ها| التغيير)?|اعتمد(?:ه|ها)?|تمام|تمام كده|تمام كدا|ممتاز|حلو|حلو كده|كويس|موافق|خليه كده|خليها كده|ابقيه|ابقيها|keep it|keep)$/,`keep it`],[/^(?:الغاء|الغ|الغي|إلغاء|بطل|وقف|توقف|خلاص|لا خلاص|اسكت|سيبك|cancel|stop)$/,`cancel`],[/^(?:(?:ا?نزل|نزل|انزلي)(?: لتحت| تحت| شويه| لأسفل| للاسفل)?|سكرول (?:لتحت|تحت|داون)|scroll down)$/,`scroll down`],[/^(?:(?:ا?طلع|اطلعي|اصعد)(?: لفوق| فوق| شويه| لأعلي| للاعلي)?|سكرول (?:لفوق|فوق|اب)|scroll up)$/,`scroll up`],[/^(?:شغل|جرب|نفذ|اعمل رن ل|ران)(?: ال)?(?:اختبار|تيست|تست|test)$/,`run the test`],[/^(?:اكتب|اعمل|انشئ|ولد|سوي|جهز)(?: لي)? (?:ال)?(?:اختبار|تيست|تست|test)(?: ل(?:ده|هذا|ها|ه))?$/,`generate a test`],[/^(?:اصلح(?:ه|ها)?|صلح(?:ه|ها)?|صلح المشكله|اصلح المشكله|صلح الغلط|اصلح الخطا|fix it)$/,`fix it`],[/^(?:اختار|حدد)(?: ال)?(?:اب|الاب|الحاويه|الكونتينر|اللي فوقه|العنصر الاكبر)$/,`select parent`],[/^(?:(?:اختار|حدد|اختر) )?(?:اللي (?:جواه|جواها|جوه|جوا|داخله|داخلها|بداخله)|العنصر اللي (?:جواه|جوه|جوا|داخله)|الابن|ادخل(?: جواه| جوه| جوا| جواها)?)$/,`select the child`],[/^(?:(?:اختار|حدد|اختر) )?(?:التالي|اللي بعده|اللي بعدها|اللي بعد كده|اللي بعد كدا|الجاي|اللي جنبه)$/,`select next`],[/^(?:(?:اختار|حدد|اختر) )?(?:السابق|اللي قبله|اللي قبلها|اللي قبل كده|اللي قبل كدا)$/,`select previous`],[/^(?:الغي التحديد|الغ التحديد|شيل التحديد|بلاش تحديد|امسح التحديد|الغاء التحديد|مش عايز اختار حاجه)$/,`deselect`],[/^(?:و?(?:ده|دي|هذا|هذه|هذي|ذا|هاد|هيدا) (?:كمان|ايضا|برضه|برضو)|ضيف (?:ده|دي|هذا|هذه)|اضف (?:هذا|هذه|ده|دي)|وده|ودي|وهذا|وهذه)$/,`add this`],[/^(?:امسح(?: الكل| كله)?|نظف|clear)$/,`clear`],[/^(?:مساعده|ساعدني|help)$/,`help`]],rt=[[`تراجع`,`undo`],[`ارجع`,`undo`],[`احتفظ به`,`keep it`],[`احتفظ`,`keep it`],[`احفظ`,`keep it`],[`اعتمد`,`keep it`],[`الغاء`,`cancel`],[`انزل لتحت`,`scroll down`],[`اطلع لفوق`,`scroll up`],[`اصلحه`,`fix it`],[`شغل الاختبار`,`run the test`]],it=[[[`زر`,`زرار`,`بوتون`,`بتن`],`button`],[[`كارت`,`كرت`,`بطاقه`,`كارد`],`card`],[[`صوره`,`صور`,`ايقونه`,`لوجو`,`شعار`],`image`],[[`عنوان`,`تايتل`,`هيدنج`],`heading`],[[`لينك`,`رابط`],`link`],[[`قائمه`,`قايمه`,`ليسته`,`لسته`,`منيو`],`list`],[[`خانه`,`حقل`,`مربع`,`انبوت`],`field`],[[`نص`,`كلام`,`سطر`,`جمله`],`text`],[[`فورم`,`نموذج`,`استماره`],`form`],[[`جدول`],`table`],[[`هيدر`,`راس الصفحه`],`header`],[[`فوتر`,`تذييل`],`footer`],[[`قسم`,`سكشن`,`جزء`],`section`],[[`سعر`,`السعر`],`price`]];function at(e){let t=/^(?:اختار|اختر|حدد|اختاري|حددي) (.+?)(?: (اللي جواه|اللي جوه|جواه|جوه|اللي حواليه|اللي فوقه|حواليه))?$/.exec(e);if(!t)return null;let n=We(t[1]),r=it.find(([e])=>e.some(e=>We(e)===n||e.length>=4&&Be([...n],[...We(e)])<=1))?.[1];return r?`select the ${r}${t[2]?/جو/.test(t[2])?` inside`:` outside`:``}`:null}var ot=[[/^(?:علم|علّم|ضع علامه|حط علامه|حط عليها علامه|سجل(?: ملاحظه| ده| هنا)?|مارك|mark)(?: هنا| ده| هذا| اللحظه دي)?$/,`mark`]],st={صفر:0,واحد:1,واحده:1,اثنين:2,اتنين:2,اثنان:2,ثلاثه:3,تلاته:3,ثلاث:3,تلات:3,اربعه:4,اربع:4,خمسه:5,خمس:5,سته:6,ست:6,سبعه:7,سبع:7,ثمانيه:8,تمانيه:8,ثماني:8,ثمان:8,تمن:8,تسعه:9,تسع:9,عشره:10,عشر:10,حداشر:11,احدعشر:11,اتناشر:12,عشرين:20,عشرون:20,ثلاثين:30,تلاتين:30,ثلاثون:30,اربعين:40,اربعون:40,خمسين:50,خمسون:50,ستين:60,ستون:60,سبعين:70,سبعون:70,ثمانين:80,تمانين:80,ثمانون:80,تسعين:90,تسعون:90,ميه:100,مائه:100,مية:100,مئه:100,ميتين:200,مئتين:200,الف:1e3};function ct(e){let t=Ue(e),n=/(\d+(?:[.,]\d+)?)\s*(دولار|\$|جنيه|ريال|درهم|يورو)?/.exec(t);if(n)return{value:Number(n[1].replace(`,`,`.`)),currency:n[2]??null};let r=t.split(` `),i=0,a=0,o=0,s=!1,c=!1,l=null;for(let e of r){let t=e.replace(/^و(?=.)/,``);if(/^(دولار|دولارات|جنيه|جنيهات|ريال|درهم|يورو)$/.test(t)){l=t,i+=o,o=0,c=!0;continue}if(/^(سنت|سنتات|قرش|قروش|هلله|فلس)$/.test(t)){a+=o,o=0;continue}let n=st[t];n!==void 0&&(s=!0,n===100||n===1e3?o=(o||1)*n:o+=n)}return s?(c?a+=o:i+=o,{value:i+Math.min(99,a)/100,currency:l}):null}function lt(e,t){let n=Number.isInteger(e)?String(e):e.toFixed(2);return t&&/دولار|\$/.test(t)?`$${n}`:t?n:`$${n}`}function ut(e){let t=Ue(e);if(!t||!/[؀-ۿ]/.test(t))return null;for(let[e,n]of nt)if(e.test(t))return{text:n,kind:`control`};for(let[e,n]of ot)if(e.test(t))return{text:n,kind:`session`};let n=at(t);if(n)return{text:n,kind:`control`};let r=t.split(` `);if(r.length<=2){let e=[...t.replace(/ /g,``)];for(let[t,n]of rt){let r=[...t.replace(/ /g,``)],i=r.length>=7?2:+(r.length>=4);if(Be(e,r)<=i)return{text:n,kind:`control`}}}let i=r.some(e=>He.test(e))?`this`:`it`;if(/(?:المفروض|المفروض انه|من المفروض|يفترض|لازم|يجب ان|ينبغي ان|المتوقع)\s/.test(t+` `)||/^(?:يكون|تكون|يبقي|تبقي)\s/.test(t)){let e=ct(t);if(e)return{text:`${i} should show ${lt(e.value,e.currency)}`,kind:`check`}}let a=Object.entries(qe).find(([,e])=>Ke(r,e))?.[0],o=Ke(r,Xe),s=Ke(r,Je),c=Ke(r,Ye);return a&&(Ke(r,Ze)||r.length<=3)?{text:`make ${i} ${a}`,kind:`edit`}:o&&(s||c||Ke(r,[`زود`,`زوّد`,`قلل`,`كتر`,`اكتر`,`اقل`]))?{text:`${s||Ke(r,[`زود`,`زوّد`,`كتر`,`اكتر`])?`more`:`less`} space between these`,kind:`edit`}:s&&!c?{text:`make ${i} bigger`,kind:`edit`}:c&&!s?{text:`make ${i} smaller`,kind:`edit`}:Ke(r,Qe)?{text:`remove ${i}`,kind:`edit`}:Ke(r,$e)&&(Ke(r,et)||Ke(r,tt))?{text:`move this ${Ke(r,et)?`above`:`below`} that`,kind:`edit`}:/(?:اجعل|خلي|خليه|خليها|اعمل)\s+(?:\S+\s+)?(?:زي|مثل|شبه|نفس شكل)\s/.test(t+` `)?{text:`make this look like that`,kind:`edit`}:null}var dt={zero:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19},ft={twenty:20,thirty:30,forty:40,fifty:50,sixty:60,seventy:70,eighty:80,ninety:90};function pt(e){let t=0,n=0,r=!1;for(let i of e.toLowerCase().replace(/-/g,` `).split(/\s+/).filter(Boolean))if(!(i===`and`&&r)){if(i in dt)n+=dt[i];else if(i in ft)n+=ft[i];else if(i===`hundred`)n=(n||1)*100;else if(i===`thousand`)t+=(n||1)*1e3,n=0;else if(/^\d+$/.test(i))n+=Number(i);else return null;r=!0}return r?t+n:null}function mt(e){let t=/^(.+?)\s+(?:dollars?|bucks)(?:\s+(?:and\s+)?(.+?)(?:\s+cents?)?)?$/i.exec(e.trim());if(!t)return null;let n=pt(t[1]);if(n===null)return null;if(!t[2])return`$${n}`;let r=pt(t[2]);return r===null||r>99?null:`$${n}.${String(r).padStart(2,`0`)}`}function ht(e){return e.replace(/[٠-٩]/g,e=>String(e.charCodeAt(0)-1632)).replace(/[۰-۹]/g,e=>String(e.charCodeAt(0)-1776)).replace(/(\d)\s?٫\s?(\d)/g,`$1.$2`).replace(/(\d)٬(\d)/g,`$1$2`)}var gt=`(?:US\\$|[$€£¥₹]|E£)`,_t=`(?:USD|EUR|GBP|EGP|SAR|AED|dollars?|bucks|euros?|pounds?|دولار(?:ات)?|جنيه(?:ات)?|ريال(?:ات)?|درهم|يورو)`,vt=`\\d{1,3}(?:,\\d{3})+(?:\\.\\d+)?|\\d+(?:[.,]\\d+)?`,yt=RegExp(`(${gt})\\s?(${vt})|(${vt})\\s?(?:(${gt})(?!\\s?\\d)|(${_t})(?!\\p{L}))`,`giu`);function bt(e){return Number(/^\d+,\d{1,2}$/.test(e)?e.replace(`,`,`.`):e.replace(/,/g,``))}function xt(e){let t=ht(e),n=[];for(let e of t.matchAll(yt))n.push({value:bt(e[2]??e[3]),currency:e[1]??e[4]??e[5],index:e.index??0});return n}function St(e,t){let n=Number.isInteger(e)?String(e):e.toFixed(2),r=t.toLowerCase();return/^(?:us\$|\$|usd|dollars?|bucks|دولار(?:ات)?)$/.test(r)?`$${n}`:/^(?:€|eur|euros?|يورو)$/.test(r)?`€${n}`:/^(?:£|gbp|pounds?)$/.test(r)?`£${n}`:/^(?:e£|egp|جنيه(?:ات)?)$/.test(r)?`${n} EGP`:/^\p{L}/u.test(t)?`${n} ${t}`:`${t}${n}`}var Ct=/\b(?:should|must|needs? to|ought to|(?:is|are) supposed to|has to|have to)\s+(?:be|say|show|read|display|equal|contain|have|include|cost|come to)\b|\bexpected\b/gi,wt=/(?:من المفروض|المفروض|يفترض|لازم|يجب ان|يجب أن|ينبغي ان|ينبغي أن|المتوقع)/g;function Tt(e){let t=e.replace(/(?:[.!?](?!\d)|,?\s+(?:but|instead|and not|not)\b|\s+(?:مش|وليس|بدل|بس)\s).*$/is,``).trim(),n=xt(t)[0];if(n)return St(n.value,n.currency);let r=/(?:^|\s)(\d+\.\d{2})$/.exec(ht(t));if(r)return r[1];let i=mt(t.replace(/^(?:be|say|show|read|display|equal|contain|have|include|cost|come to)\s+/i,``).replace(/[.!?,]+$/,``));if(i)return i;if(/[؀-ۿ]/.test(t)){let e=ct(t);if(e&&e.currency)return St(e.value,e.currency)}let a=/["“«]([^"”»]{1,80})["”»]/.exec(e);return a?a[1].trim():null}function Et(e){let t=e.trim();if(!t)return null;let n=[...t.matchAll(Ct),...t.matchAll(wt)].sort((e,t)=>(t.index??0)-(e.index??0));for(let e of n){let n=(e.index??0)+e[0].length,r=Tt(t.slice(n));if(r)return{expected:r,at:Dt(t,e.index??0)/t.length}}return null}function Dt(e,t){let n=0;for(let r of e.slice(0,t).matchAll(/[.!?؟]\s+/g))n=(r.index??0)+r[0].length;return n}function Ot(e,t){return Math.round(e.start+(e.end-e.start)*t.at)}function kt(e,t){let n=xt(t)[0]?.value??(At.test(ht(t))?Number(ht(t).trim()):null);if(n===null)return jt(e).includes(jt(t));let r=xt(e);return(r.length?r.map(e=>e.value):[...ht(e).matchAll(/\d+(?:\.\d+)?/g)].map(e=>Number(e[0]))).some(e=>Math.abs(e-n)<.005)}var At=/^\s*\d+\.\d{2}\s*$/,jt=e=>e.toLowerCase().replace(/[\s,]/g,``);function Mt(e){return e.toLowerCase().replace(/[’']/g,`'`).replace(/[^a-z0-9'$.\s-]/g,` `).replace(/\.(?=\s|$)/g,` `).replace(/\s+/g,` `).trim().replace(/^(ok|okay|hey|um|uh|so|and|now|please|alright|all right)\s+/,``).replace(/\s+(please|thanks|thank you|now)$/,``).trim()}var Nt=`(?:card|button|link|image|picture|photo|icon|logo|heading|title|header|footer|form|list|item|row|field|input|menu|navbar|nav|section|table|price|label|text|paragraph|dialog|modal|sidebar|banner|badge|avatar|tab|panel|box|cell|column|chart|summary|total)s?`,Pt=[[/^(keep|keep (it|that|this|them|both|all|these|those|the changes?)|looks (good|great)|ship it|accept( it| that)?|approve( it)?|perfect|that's (good|great|it)|yes|yeah|yep|yes keep( it)?|lgtm)$/,{kind:`keep`}],[/^(undo|undo (it|that|this|the change)|revert( it| that)?|go back|discard( it| that)?|nope|no|reject( it| that)?|take (it|that) back|put it back)$/,{kind:`undo`}],[/^(cancel|stop|never ?mind|forget (it|that)|abort)$/,{kind:`cancel`}],[/^((select )?(the )?parent|go up( a level| one level)?|(go |one )?(level )?up one level|select (the )?(container|wrapper)|(go |select )?outside( it| this)?|zoom out)$/,{kind:`parent`}],[/^((select |go )?(inside|in)( it| this| one level)?|go down( a level| one level)|one level down|(select |pick )?(the )?(child|first child|inner (one|element|part)|one inside|thing inside)|zoom in)$/,{kind:`nav`,to:`child`}],[/^((select |pick |go to )?(the )?next( one| sibling| item| element| card| row)?)$/,{kind:`nav`,to:`next`}],[/^((select |pick |go to )?(the )?(previous|prev|one before)( one| sibling| item| element| card| row)?)$/,{kind:`nav`,to:`prev`}],[/^(clear|clear (the )?(pins|selection|all|everything)|deselect( all| everything| it| this| that)?|unselect( it| this| that| all)?|unpin( all| everything)?|select nothing)$/,{kind:`clear`}],[/^(start recording|record( a bug| this)?|(switch to |go to )?(record|write( a)? test) mode)$/,{kind:`mode`,mode:`record`}],[/^((stop recording)|(switch to |go to )?edit mode|edit)$/,{kind:`mode`,mode:`edit`}],[/^((switch to |go to )?use mode|use the app|let me use (it|the app)|interact)$/,{kind:`mode`,mode:`use`}],[/^((generate|make|write|create|save)( me)?( a| the)? (test|spec|playwright test)|turn (this|that|it) into a test)$/,{kind:`generate`}],[/^((run|rerun|re-run|try)( the| that| this| my)? (test|spec)( again)?|run it( again)?|test it)$/,{kind:`run`}],[/^(fix (it|this|that|the bug|this bug|that bug|the test|the failure)( please)?)$/,{kind:`fix`}],[/^((click|press|tap|hit)( on)?( (this|that|it|here))?)$/,{kind:`click`}],[/^scroll (up|down)( a bit| more)?$/,e=>({kind:`scroll`,dir:e[1]})],[/^(scroll|go) to (the )?(top|bottom)$/,e=>({kind:`scroll`,dir:e[3]})],[/^(reload|refresh)( the)?( app| page)?$/,{kind:`reload`}],[/^(help|what can i (say|do)|show (me )?(the )?(help|shortcuts|gestures|commands))$/,{kind:`help`}],[/^((open|show)( (this|that|it))? in (the |my )?(editor|code|vs ?code|cursor)|show (me )?the code( for (this|that|it))?|go to (the )?code)$/,{kind:`open`}],[/^select (this|that|it)$/,{kind:`select`}],[/^((pin|add) (this|that|it)( too| as well| also| to (the )?selection)?|(select )?(this|that) too|(and|also) (this|that)( one)?|(this|that) as well)$/,{kind:`add`}],[/^(?:select|pick|choose|grab|highlight) (?:the )?(?!(?:this|that|it|all|everything|nothing|none)$)([a-z][a-z -]{1,24}?)(?: (inside it|inside this|inside|in it|in this|around it|around this|outside it|outside))?(?: instead)?$/,Ft],[RegExp(`^the ((?:[a-z]+ )?${Nt})(?: (inside it|inside|in it|around it|outside|instead))?$`),Ft],[RegExp(`^(?:the )?(${Nt}) (inside)$`),Ft]];function Ft(e){let t=!e[2]||e[2]===`instead`?`any`:/^(inside|in )/.test(e[2])?`in`:`out`;return{kind:`find`,what:e[1].trim(),where:t}}function It(e,t){let n=/^\s*type\s+(.+?)(?:\s+and\s+(?:press\s+|hit\s+)?(enter|submit|return))?[.!]?\s*$/i.exec(e);if(n)return{kind:`type`,text:n[1].replace(/^["“'‘]|["”'’]$/g,``),submit:!!n[2]};let r=Mt(e);if(!r)return null;for(let[e,n]of Pt){let i=e.exec(r);if(!i)continue;let a=typeof n==`function`?n(i):n;return a.kind===`fix`&&!t.hasFailingTest?null:a}return null}function Lt(e){let t=/^(?:(?:but|and|so)\s+)?(?:(this|that|it|the [\w\s-]{1,30}?)\s+)?(?:should|must|ought to|is supposed to)\s*(?:not|n['’]t)\s+be\s+(?:checked|ticked|selected|chosen|on)[.!?]*$/i.exec(e.trim());if(t)return{subject:t[1]?.toLowerCase()??null,expected:`not checked`};let n=/^(?:(?:but|and|so)\s+)?(?:(this|that|it|the [\w\s-]{1,30}?)\s+)?(?:should|must|needs to|ought to|is supposed to|has to)\s+(?:be|say|show|read|display|equal|contain|have|include)\s+(.+)$/i.exec(e.trim());if(!n)return null;let r=n[2].replace(/\s+(?:but|instead|and not|not)\b.*$/i,``).replace(/[.!?]+$/,``).trim();r=r.replace(/^["“'‘]|["”'’]$/g,``).trim();let i=/^(\d+(?:[.,]\d{1,2})?)\s*(?:dollars|bucks|usd)$/i.exec(r);return r=i?`$${i[1]}`:mt(r)??r,r?{subject:n[1]?.toLowerCase()??null,expected:r}:null}function Rt(e,t){let n=new Map(t.timeline.map(e=>[e.id,e])),r=new Set;for(let i of e.evidence){let e=n.get(i);if(e)r.add(e);else{let e=t.issues.find(e=>e.id===i);for(let t of e?.evidence??[]){let e=n.get(t);e&&r.add(e)}}}return Array.from(r).sort((e,t)=>e.t-t.t)}function zt(e,t){let n=Array.from(new Set(t.filter(e=>e.kind===`speech`).map(e=>`“${e.text}”`))),r=Array.from(new Set(t.filter(e=>e.kind!==`speech`&&e.kind!==`shot`).map(e=>e.text)));return[`What happened: ${e.what}`,e.expected?`Expected: ${e.expected}`:``,e.shown&&e.shown!==e.location?`Showed at: ${e.shown}`:``,e.location?`Likely cause: ${e.location}`:``,e.fix?`Suggested fix: ${e.fix}`:``,n.length?`The tester said: ${n.join(` `)}`:``,r.length?`Recorded: ${r.slice(0,5).join(`; `)}`:``].filter(Boolean)}var Bt=class{samples=[];push(e,t){let n=this.samples[this.samples.length-1];if(n&&n.t>=e)return;this.samples.push({t:e,el:t});let r=e-2e4;for(;this.samples.length&&this.samples[0].t<r;)this.samples.shift()}clear(){this.samples=[]}at(e){for(let t=this.samples.length-1;t>=0;t--)if(this.samples[t].t<=e)return this.samples[t].el;return null}dwellWinner(e,t){let n=new Map;for(let r=0;r<this.samples.length;r++){let i=this.samples[r],a=r+1<this.samples.length?this.samples[r+1].t:t,o=Math.max(i.t,e),s=Math.min(a,t);if(s<=o||!i.el)continue;let c=n.get(i.el.id)??{el:i.el,ms:0};c.ms+=s-o,n.set(i.el.id,c)}let r=null;for(let e of n.values())(!r||e.ms>r.ms)&&(r=e);return r?.el??null}},Vt=/^(this|that|these|those|here|there|it)$/i,Ht=/^(that|those|there|ذلك|ذاك|تلك|هذاك|هذيك|هناك|هنيك)$/i,Ut={lagMs:380,windowMs:650},Wt=e=>/[\u0600-\u06FF]/.test(e)?Re(e).replace(/[^\u0600-\u06FF]/g,``).replace(/^و(?=..)/,``):e.toLowerCase().replace(/[^a-z']/g,``);function Gt(e,t,n){let r=[],i=n.pins.slice();return e.forEach((e,a)=>{let o=Wt(e.text);if(!Vt.test(o)&&!He.test(o))return;if(o===`it`&&r.length){r.push({...r[r.length-1],word:o,index:a,t:e.t});return}if(i.length){r.push({word:o,index:a,t:e.t,el:i.shift(),via:`pin`});return}let s=e.t-n.lagMs,c=t.dwellWinner(s-n.windowMs,s+150)??t.at(s),l=c?`pointing`:`unresolved`;!c&&!r.length&&n.selection&&(c=n.selection,l=`selection`),c&&Ht.test(o)&&r.some(e=>e.el?.id===c.id&&!Ht.test(e.word))&&(c=null,l=`unresolved`),r.push({word:o,index:a,t:e.t,el:c,via:l})}),r}function Kt(e,t,n){return e.length?e:t?[t]:n?[n]:[]}function qt(e){return e.pins.length?e.pins:e.selection?[e.selection]:[]}function Jt(e,t){let n=new Set,r=e.filter(e=>!n.has(e.id)&&(n.add(e.id),!0)).slice(-8);return{selection:t&&r.find(e=>e.id===t.id)||r[r.length-1]||null,pins:r.length>1?r:[]}}function Yt(e,t){return e.some(e=>e.id===t.id)?e.filter(e=>e.id!==t.id):[...e,t]}function Xt(e,t){return e?t.some(t=>t.id===e.id)?t.length===1?{tap:`deselect`,hold:`none`}:{tap:`only`,hold:`remove`}:{tap:`select`,hold:t.length?`add`:`none`}:{tap:t.length?`clear`:`none`,hold:`none`}}function Zt(e,t){let{tap:n}=Xt(t,qt(e));return n===`select`||n===`only`?Jt([t]):n===`deselect`||n===`clear`?Jt([]):e}function Qt(e,t){if(!t)return e;let n=qt(e),r=Yt(n,t);return Jt(r,r.length>n.length?t:e.selection)}function $t(e,t,n){return Jt(qt(e).map(e=>e.id===t.id?n:e),n)}function en(e){let t=[e.url,e.dialog??``,e.text,...e.controls.map(e=>`${e.role}|${e.name}|${e.field?`${e.field.value}|${e.field.checked??``}`:``}|${e.disabled}`)],n=2166136261;for(let e of t.join(`
2
+ `))n^=e.codePointAt(0),n=Math.imul(n,16777619);return(n>>>0).toString(36)}var tn=/\b(delete|remove account|destroy|erase|deactivate|close (?:my )?account|log ?out|sign ?out|unsubscribe|pay|purchase|buy now|place (?:the |my )?order|confirm (?:order|payment|purchase)|send|transfer|withdraw|publish|deploy|reset all)\b|حذف|احذف|إلغاء الاشتراك|تسجيل الخروج|خروج|ادفع|دفع|شراء|اشتر|إرسال|أرسل|تحويل|نشر/i,nn=e=>tn.test(e);function rn(e,t,n){return n||!t?!1:nn(t.name)?!0:e.kind===`press`&&(e.value||`Enter`)===`Enter`&&!!t.submits&&nn(t.submits)}function an(e,t){let n=t?`“${t.name||t.role}”`:``;switch(e.kind){case`click`:return`Clicked ${n}`;case`fill`:{let r=e.value??``;return`Typed ${t?.field?.secret||ye(t?.name??``)||Ae(r)?me:`“${ke(r)}”`} into ${n}`}case`select`:return`Chose “${e.value??``}” in ${n}`;case`check`:return`${e.value===`off`?`Unticked`:`Ticked`} ${n}`;case`press`:return t?`Pressed ${e.value||`Enter`} in ${n}`:`Pressed ${e.value||`Enter`}`;case`scroll`:return`Scrolled down`;case`back`:return`Went back`;case`goto`:return`Opened ${e.value??`/`}`;case`done`:return`Finished`}}var on=e=>new Promise(t=>setTimeout(t,e)),sn=3,cn=class{host;running=!1;stopped=!1;constructor(e){this.host=e}stop(){this.stopped=!0}async connected(e){let t=performance.now()+e;for(;!this.host.connected();){if(performance.now()>t||this.stopped)return!1;await on(100)}return!0}async look(){for(let e=0;e<4&&!this.stopped;e++){if(await this.connected(5e3)){let e=await this.host.bridge.explore();if(e)return e}await on(500)}return null}async act(e,t,n,r){let i=e.control?t.controls[e.control-1]:void 0,a=new URL(t.url).origin;switch(e.kind){case`click`:case`fill`:case`select`:case`check`:case`press`:{if(e.kind===`press`&&!i){let t=await this.host.bridge.replay(`page.locator('body')`,{kind:`press`,key:e.value||`Enter`},!1,void 0,4e3);return t.ok?{ok:!0}:{ok:!1,error:t.error??`failed`}}if(!i)return{ok:!1,error:`not on the page`};if(rn(e,i,!!r.allowRisky))return{ok:!1,error:`not allowed`};let t=await this.host.bridge.replay(i.locator,void 0,!1,void 0,2500);if(!t.ok||!t.info)return{ok:!1,error:t.error??`missing`};this.host.point(t.info,!1),await on(400);let n=e.kind===`click`?{kind:`click`}:e.kind===`press`?{kind:`press`,key:e.value||`Enter`}:e.kind===`check`?{kind:`fill`,checked:e.value!==`off`}:{kind:`fill`,value:e.value??``},a=await this.host.bridge.replay(i.locator,n,!1,void 0,4e3);return this.host.point(t.info,!0),a.ok?{ok:!0}:{ok:!1,error:a.error??`failed`}}case`scroll`:{let[e,n]=t.viewport;return this.host.bridge.scroll(e/2,n/2,0,Math.round(n*.8)),{ok:!0}}case`back`:return n?(this.host.bridge.goto(n),{ok:!0}):{ok:!1,error:`no page before this one`};case`goto`:{let n=new URL(e.value||`/`,t.url);return n.origin===a?(this.host.bridge.goto(n.href),{ok:!0}):{ok:!1,error:`outside the app`}}case`done`:return{ok:!0}}}async run(e){if(this.running)return;this.running=!0,this.stopped=!1;let t={phase:`starting`,goal:e.goal,step:0,total:e.maxSteps,description:`Starting a test session`,found:0};this.host.show({...t});let n=null,r=null,i=[],a=[],o=[],s=0,c=Date.now(),l=!1;try{await u.post(`/autopilot/ready`,{});let l=await u.post(`/sessions`,{name:(e.goal?`Autopilot: ${e.goal}`:`Autopilot`).slice(0,120),appUrl:this.host.appUrl(),source:`autopilot`,lang:`en`,replace:!0});if(n=l.session.id,!await this.host.bridge.session(!0,n,location.origin,l.key))throw Error(`not-recording`);r=this.host.enterUse();for(let r=1;r<=e.maxSteps&&!this.stopped;r++){Object.assign(t,{phase:`thinking`,step:r,description:r===1?`Reading the page`:t.description}),this.host.show({...t});let l=await this.look();if(!l)throw Error(`Your app stopped answering: is it still running?`);o[o.length-1]!==l.url&&o.push(l.url);let{turn:d}=await u.post(`/autopilot/turn`,{session:n,goal:e.goal,step:r,maxSteps:e.maxSteps,allowRisky:e.allowRisky,since:c,snapshot:l,history:i,reported:a});if(a.push(...d.findings.map(e=>e.title)),Object.assign(t,{phase:`acting`,description:d.thought,found:a.length}),this.host.show({...t}),d.action.kind===`done`||this.stopped)break;let f=this.host.connections();c=Date.now();let p=d.action.control?l.controls[d.action.control-1]:void 0,m=await this.act(d.action,l,o[o.length-2]??null,e);await on(900),this.host.connections()!==f&&await this.connected(1e4);let h=d.action.kind===`press`&&p?.submits?`pressing Enter in “${p.name}”, which sends the form with “${p.submits}”`:null,g=m.error===`not allowed`?`Skipped ${h??(p?`“${p.name}”`:`a control`)} (not allowed)`:an(d.action,p);if(m.error===`not allowed`){let e={type:`autopilot`,did:g,why:`Not allowed: “Let it delete, pay, send and sign out” is off.`,t:Date.now(),seq:Date.now()*100+Math.floor(Math.random()*100)};u.post(`/sessions/${n}/studio-events`,{events:[e]}).catch(()=>void 0)}if(i.push({n:r,did:g,ok:m.ok,...m.error?{error:m.error}:{},url:this.host.appUrl()||l.url,page:en(l)}),s=m.ok?0:s+1,s>=sn){this.host.notify(`Autopilot stopped: its last steps didn’t work.`);break}}Object.assign(t,{phase:`finishing`,description:`Writing the report`}),this.host.show({...t}),this.host.point(null,!1),await on(1e3)}catch(e){l=!0;let t=e instanceof Error?e.message:String(e);this.host.notify(t===`not-recording`?`Autopilot couldn’t start: your app didn’t start recording.`:`Autopilot ${n&&i.length?`stopped`:`couldn’t start`}: ${t}`)}finally{let e=l&&!i.length;n&&(await this.host.bridge.session(!1),await u.post(`/sessions/${n}/stop`,{}).catch(()=>void 0),e&&await u.delete(`/sessions/${n}`).catch(()=>void 0)),r?.(),this.host.show(null),this.host.point(null,!1),this.running=!1,n&&!e&&this.host.openReport(n)}}},ln=e=>e.locator?.startsWith(`page.locator('[data-ds-src=`)?{tag:e.tag,name:e.name,text:e.text,...e.shape?{shape:e.shape}:{}}:void 0,un=e=>new Promise(t=>setTimeout(t,e));function dn(e,t){if(!e||!t?.locator)return null;let n=Et(e.text);return n?{expected:n.expected,locator:t.locator,like:ln(t),t:Ot(e,n),el:t}:null}function fn(e){let t=e.analysis;if(!t)return[];let n=[];for(let e of t.issues){if(e.kind!==`said`)continue;let r=dn(t.transcript.find(t=>t.start===e.t),e.el);r&&n.push({issue:e.id,...r})}for(let r of e.report?.findings??[]){let e=pn(r,t);e&&n.push({finding:r.id,...e})}return n}function pn(e,t){let n=Rt(e,t);for(let e of n){let n=e.kind===`speech`?t.transcript.find(t=>t.start===e.t):void 0,r=dn(n,n?.el);if(r)return r}for(let{el:r,t:i}of _n(n,t)){let t=r.locator?hn(e,r):null;if(r.locator&&t)return{expected:t,locator:r.locator,like:ln(r),t:i,el:r}}return null}function mn(e,t){let n=Rt(e,t)[0]?.t??1/0,r=[...t.transcript.map(e=>({el:e.el,t:e.start})),...t.issues.map(e=>({el:e.el,t:e.t}))].filter(e=>!!e.el?.locator).sort((e,t)=>Math.abs(e.t-n)-Math.abs(t.t-n));for(let{el:t,t:n}of r){let r=gn(e.expected??``,t);if(r)return{expected:r,locator:t.locator,like:ln(t),t:n,el:t}}return null}function hn(e,t){let n=Et(e.quote??``);if(n)return n.expected;let r=xt(e.expected??``);return r.length===1?St(r[0].value,r[0].currency):gn(e.expected??``,t)}function gn(e,t){let n=(t.label||t.text).toLowerCase().match(/\p{L}{3,}/gu)??[],r=xt(e).find(t=>n.some(n=>e.toLowerCase().slice(Math.max(0,t.index-24),t.index).includes(n)));return r?St(r.value,r.currency):null}function _n(e,t){let n=[];for(let r of e){let e=r.kind===`speech`?t.transcript.find(e=>e.start===r.t):null,i=r.issue?t.issues.find(e=>e.id===r.issue):null,a=e?.el??i?.el;a&&!n.some(e=>e.el.src===a.src&&e.el.label===a.label)&&n.push({el:a,t:r.t})}return n}var vn=class{host;running=null;stopped=!1;constructor(e){this.host=e}stop(){this.stopped=!0}async connected(e){let t=performance.now()+e;for(;!this.host.connected();){if(performance.now()>t)return!1;await un(100)}return!0}async locate(e,t,n=6e3){let r=performance.now()+n,i=`missing`;for(;;){if(await this.connected(5e3)){let n=await this.host.bridge.replay(e,void 0,!1,t,1500);if(n.ok&&n.info)return{info:n.info};if(i=n.error??i,i===`unreadable`)return{info:null,error:i}}else i=`disconnected`;if(performance.now()>r||this.stopped)return{info:null,error:i};await un(250)}}async read(e){let t=performance.now()+1500;for(;;){let n=await this.connected(3e3)?await this.host.bridge.replay(e.locator,void 0,!0,e.like):null,r=n?.ok?n.text??``:null,i=r!==null&&kt(r,e.expected);if(i||performance.now()>t||this.stopped)return{actual:r,ok:i};await un(250)}}async run(e){let t=e.analysis;if(!t||this.running)return;this.running=e.meta.id,this.stopped=!1;let n=t.steps.filter(e=>e.kind!==`navigate`&&!!e.locator),r=fn(e).sort((e,t)=>e.t-t.t),i=[],a={id:e.meta.id,name:e.meta.name,phase:`starting`,step:0,total:n.length,description:`Opening the page the session started on`,target:null};this.host.show({...a});let o=null,s=null,c=0,l;try{let d=t.steps.find(e=>e.kind===`navigate`)?.url??t.pages[0]?.url??e.meta.appUrl,f=new URL(this.host.appUrl()||d),p=new URL(d,f),m=this.host.connections();this.host.bridge.goto(`${f.origin}${p.pathname}${p.search}${p.hash}`);let h=performance.now()+15e3;for(;!(this.host.connections()>m&&this.host.connected());){if(performance.now()>h)throw Error(`Your app didn’t load again: is it still running?`);if(this.stopped)throw Error(`stopped`);await un(100)}await un(700);let{session:g,key:_}=await u.post(`/sessions`,{name:`Replay of ${e.meta.name}`.slice(0,120),appUrl:this.host.appUrl(),source:`replay`,replayOf:e.meta.id,lang:e.meta.lang});if(o=g.id,!await this.host.bridge.session(!0,o,location.origin,_))throw Error(`not-recording`);s=this.host.enterUse();let v=[...new Set(n.flatMap(e=>e.secret?[e.secret]:[]))],y=v.length?(await u.post(`/tests/secrets/values`,{names:v}).catch(()=>({values:{}}))).values??{}:{},b=0,x=async e=>{for(;b<r.length&&r[b].t<=e;){let e=r[b++],{actual:t,ok:n}=i.find((t,n)=>r[n].locator===e.locator&&r[n].t===e.t&&t.expected===e.expected)??await this.read(e);i.push({finding:e.finding,issue:e.issue,expected:e.expected,actual:t,ok:n})}};for(let e=0;e<n.length;e++){if(this.stopped){l={i:e,t:n[e].t,description:n[e].description,descriptionAr:n[e].descriptionAr,reason:`stopped`};break}let t=n[e];await x(t.t),Object.assign(a,{phase:`playing`,step:e+1,description:t.description,target:null}),this.host.show({...a});let r=await this.locate(t.locator,t.like);if(!r.info){l={i:e,t:t.t,description:t.description,descriptionAr:t.descriptionAr,reason:r.error??`missing`};break}a.target=r.info,this.host.show({...a}),this.host.point(r.info,!1),await un(450);let i=t.secret?y[t.secret.toUpperCase()]:t.value;if(t.secret&&!i){l={i:e,t:t.t,description:t.description,descriptionAr:t.descriptionAr,reason:`secret`};break}let o=await this.host.bridge.replay(t.locator,{kind:t.kind,value:i,key:t.key,checked:t.checked,select:t.select},!1,t.like);if(!o.ok){l={i:e,t:t.t,description:t.description,descriptionAr:t.descriptionAr,reason:o.error??`failed`};break}this.host.point(r.info,!0),c++,a.target=null,this.host.show({...a});let s=n[e+1]?n[e+1].t-t.t:1200;await un(Math.max(500,Math.min(1800,s)))}l||await x(1/0),Object.assign(a,{phase:`finishing`,description:`Comparing with the session`,target:null}),this.host.show({...a}),this.host.point(null,!1),await un(1200)}catch(e){let t=e instanceof Error?e.message:String(e),r=n[c];!l&&r&&(l={i:c,t:r.t,description:r.description,descriptionAr:r.descriptionAr,reason:t===`stopped`||t===`not-recording`?t:`error`}),t!==`stopped`&&this.host.notify(t===`not-recording`?`The replay couldn’t run: your app didn’t start recording it.`:`The replay couldn’t run: ${t}`)}finally{if(o){await this.host.bridge.session(!1),await u.post(`/sessions/${o}/stop`,{}).catch(()=>void 0);let t={steps:{total:n.length,done:c,failed:l},checks:i};await u.put(`/sessions/${e.meta.id}/verify`,{replay:o,outcome:t}).catch(()=>void 0)}s?.(),this.host.show(null),this.host.point(null,!1),this.running=null,o&&this.host.openReport(e.meta.id)}}},yn=4e3,bn=0,xn=class{deps;current=null;queue=[];constructor(e){this.deps=e}get busy(){return!!this.current}has(e){return this.current?.job.kind===e||this.queue.some(t=>t.job.kind===e)}ask(e){return this.current&&this.queue.length>=3?null:new Promise(t=>{let n={id:`r${++bn}-${Date.now().toString(36)}`,job:e,done:t,stopped:!1};if(!this.current)return void this.begin(n,!0);this.queue.push(n),this.publish()})}stop(){let e=this.current;if(!e)return null;let t=this.queue.splice(0);for(let e of t)e.done();return this.publish(),e.stopped||(e.stopped=!0,this.deps.stopping(e.id),this.deps.cancel(e.id),setTimeout(()=>this.current===e&&this.release(e),yn)),t.length}async begin(e,t){this.current=e,this.deps.started({id:e.id,text:e.job.text,kind:e.job.kind,step:e.job.step,startedAt:Date.now()},t);try{await e.job.run(e.id,()=>e.stopped)}catch(t){e.stopped||this.deps.fail(t)}finally{e.done(),this.current===e&&this.release(e)}}release(e){this.deps.ended(e.id),this.current=null;let t=this.queue.shift();this.publish(),t&&this.begin(t,!1)}publish(){this.deps.waiting(this.queue.map(e=>({id:e.id,text:e.job.text})))}},Sn=[],Cn=new Set,wn=new Set([`SCRIPT`,`STYLE`,`LINK`,`TEMPLATE`]),Tn=new WeakSet;function En(e){Tn.add(e)}function Dn(e){return e.defaultPrevented&&!Tn.has(e)}function On(){return Sn.length>0}function kn(){return Sn[Sn.length-1]??null}function An(e){return Sn.includes(e)||Sn.push(e),jn(),()=>{let t=Sn.indexOf(e);t>=0&&Sn.splice(t,1),jn()}}function jn(){let e=kn(),t=new Set;for(let n=e;n&&n!==document.body;n=n.parentElement)for(let e of n.parentElement?.children??[])e!==n&&!wn.has(e.tagName)&&!e.hasAttribute(`data-layer-backdrop`)&&t.add(e);for(let e of Cn)t.has(e)||(e.removeAttribute(`inert`),Cn.delete(e));for(let e of t)e.hasAttribute(`inert`)||(e.setAttribute(`inert`,``),Cn.add(e))}var Mn=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex], [contenteditable="true"]`;function Nn(e){return[...e.querySelectorAll(Mn)].filter(e=>e.tabIndex>=0&&!e.closest(`[inert]`)&&e.getClientRects().length>0)}function Pn(e,t){let n=Nn(t),r=document.activeElement;if(!n.length){e.preventDefault(),t.focus();return}let i=n[0],a=n[n.length-1],o=!!r&&t.contains(r);e.shiftKey&&(!o||r===i)?(e.preventDefault(),a.focus()):!e.shiftKey&&(!o||r===a)&&(e.preventDefault(),i.focus())}var Fn=16e3,In=Fn/2,Ln=`class C extends AudioWorkletProcessor{constructor(){super();this.b=new Float32Array(512);this.n=0}process(i){const c=i[0]&&i[0][0];if(c){for(let k=0;k<c.length;k++){this.b[this.n++]=c[k];if(this.n===512){this.port.postMessage({time:currentTime+(k+1)/sampleRate,data:this.b.slice(0)});this.n=0}}}return true}}registerProcessor('saywright-session-mic',C)`,Rn=class{onChunk;onSpeechStart;ctx=null;stream=null;node=null;buf=new Int16Array(In);fill=0;bufT=0;paused=!1;lastPerf=0;level=0;lastVoice=0;lastSound=0;startedAt=0;noise=.004;streak=0;constructor(e,t){this.onChunk=e,this.onSpeechStart=t}get open(){return!!this.node}async start(e){if(this.node)return;this.stream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,...e?{deviceId:{exact:e}}:{}}});let t=new AudioContext({sampleRate:Fn});this.ctx=t;let n=URL.createObjectURL(new Blob([Ln],{type:`text/javascript`}));try{await t.audioWorklet.addModule(n)}finally{URL.revokeObjectURL(n)}let r=t.createMediaStreamSource(this.stream),i=new AudioWorkletNode(t,`saywright-session-mic`);i.port.onmessage=e=>{this.ctx&&this.ingest(e.data.data,this.toWall(e.data.time))};let a=t.createGain();a.gain.value=0,r.connect(i).connect(a).connect(t.destination),this.node=i,this.startedAt=Date.now(),t.state===`suspended`&&await t.resume().catch(()=>void 0)}toWall(e){let t=this.ctx,n=t.getOutputTimestamp?.(),r;return r=n&&n.contextTime!==void 0&&n.performanceTime!==void 0&&n.performanceTime>0?n.performanceTime+(e-n.contextTime)*1e3:performance.now()-(t.currentTime-e)*1e3,r=Math.max(r,this.lastPerf),this.lastPerf=r,performance.timeOrigin+r}ingest(e,t){let n=0;for(let t=0;t<e.length;t++)n+=e[t]*e[t];let r=Math.sqrt(n/e.length);if(this.level=Math.max(r*6,this.level*.85),r>2e-5&&(this.lastSound=t),this.noise=r<this.noise?this.noise*.9+r*.1:this.noise*.999+r*.001,r>Math.max(.01,this.noise*3)?(this.streak++,this.streak===3?(t-this.lastVoice>1500&&this.onSpeechStart?.(t),this.lastVoice=t):this.streak>3&&(this.lastVoice=t)):this.streak=0,this.paused)return;let i=t-e.length/Fn*1e3,a=0;for(;a<e.length;){this.fill===0&&(this.bufT=i+a/Fn*1e3);let t=Math.min(In-this.fill,e.length-a);for(let n=0;n<t;n++){let t=Math.max(-1,Math.min(1,e[a+n]));this.buf[this.fill+n]=t<0?t*32768:t*32767}this.fill+=t,a+=t,this.fill===In&&this.flush()}}flush(){this.fill&&=(this.onChunk({t:Math.round(this.bufT),pcm:this.buf.slice(0,this.fill)}),0)}discard(){this.fill=0}setPaused(e){e&&this.flush(),this.paused=e}async stop(){this.flush(),this.node&&(this.node.port.onmessage=null),this.node?.disconnect(),this.node=null,this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null,await this.ctx?.close().catch(()=>void 0),this.ctx=null,this.level=0}},zn=1500;function Bn(){for(let e of[`video/webm;codecs=vp9`,`video/webm;codecs=vp8`,`video/webm`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(e))return e;return``}var Vn=class{onVideo;onShot;stream=null;track=null;recorder=null;video=null;canvas=null;lastShot=0;shotCount=0;stopped=null;mime=``;startedAt=0;onEnded=null;constructor(e,t){this.onVideo=e,this.onShot=t}get active(){return!!this.track&&this.track.readyState===`live`}async start(e){let t=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:12,max:24},width:{max:1920},height:{max:1200}},audio:!1,preferCurrentTab:!0,selfBrowserSurface:`include`,surfaceSwitching:`exclude`,monitorTypeSurfaces:`exclude`});this.stream=t;let n=t.getVideoTracks()[0];this.track=n,n.addEventListener(`ended`,()=>{this.stop(),this.onEnded?.()});let r=globalThis.CropTarget;if(e.crop&&r&&n.cropTo)try{await n.cropTo(await r.fromElement(e.crop))}catch{}let i=document.createElement(`video`);i.muted=!0,i.playsInline=!0,i.srcObject=t,this.video=i,await Promise.race([i.play().catch(()=>void 0),new Promise(e=>setTimeout(e,zn))])}record(e){let t=this.stream;if(t&&!this.recorder&&(this.startedAt=Date.now(),this.mime=Bn(),e&&this.mime)){let e=new MediaRecorder(t,{mimeType:this.mime,videoBitsPerSecond:12e5});e.ondataavailable=e=>{e.data.size&&this.onVideo(e.data,this.mime,this.startedAt)},this.stopped=new Promise(t=>e.addEventListener(`stop`,()=>t(),{once:!0})),e.start(1e3),this.recorder=e}}shoot(e,t=!1){let n=this.video;if(!n||!this.active)return;if(!n.videoWidth){t&&n.addEventListener(`loadeddata`,()=>this.video===n&&this.shoot(e,!0),{once:!0});return}let r=Date.now();if(!t&&(r-this.lastShot<2500||this.shotCount>=150))return;this.lastShot=r,this.shotCount++;let i=Math.min(1,1280/n.videoWidth),a=Math.round(n.videoWidth*i),o=Math.round(n.videoHeight*i),s=this.canvas??=document.createElement(`canvas`);s.width=a,s.height=o;let c=s.getContext(`2d`);c&&(c.drawImage(n,0,0,a,o),s.toBlob(t=>t&&this.onShot({t:r,reason:e,jpeg:t,w:a,h:o}),`image/jpeg`,.8))}async stop(){this.recorder&&this.recorder.state!==`inactive`&&(this.recorder.stop(),await this.stopped),this.recorder=null,this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null,this.track=null,this.video&&(this.video.srcObject=null),this.video=null}},Hn=`saywright.session.audio`;function Un(e){return new Promise(t=>setTimeout(()=>{if(typeof requestAnimationFrame!=`function`)return t();let e=setTimeout(t,100);requestAnimationFrame(()=>requestAnimationFrame(()=>{clearTimeout(e),t()}))},e))}var Wn=3e4;function Gn(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function Kn(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}var qn={events:0,clicks:0,errors:0,failedRequests:0,frustration:0,marks:0,speech:0,shots:0},Jn={id:null,status:`idle`,stage:``,startedAt:0,counts:qn,audioSeconds:0,mic:`off`,screen:`off`,paused:!1,captions:[],lastIssue:null,error:null,backlog:0},Yn=class{onChange;limit;queue=[];busy=!1;failures=0;bytes=0;dropped=0;constructor(e,t=1/0){this.onChange=e,this.limit=t}get size(){return this.queue.length}sizeOf(e){return e instanceof Blob?e.size:e.byteLength}add(e,t,n=!1){let r=this.sizeOf(t);!n&&this.bytes+r>this.limit?(this.dropped++,this.onChange()):(this.bytes+=r,n?this.queue.unshift({url:e,body:t}):this.queue.push({url:e,body:t}),this.onChange(),this.pump())}async pump(){if(!this.busy){for(this.busy=!0;this.queue.length;){let e=this.queue[0];try{let t=await fetch(e.url,{method:`POST`,body:e.body,headers:{"Content-Type":`text/plain`},credentials:`omit`});if(await t.arrayBuffer().catch(()=>void 0),!t.ok&&t.status!==409&&t.status!==404)throw Error(String(t.status));this.queue.splice(this.queue.indexOf(e),1),this.bytes-=this.sizeOf(e.body),this.failures=0,this.onChange()}catch{this.failures++,await new Promise(e=>setTimeout(e,Math.min(8e3,500*2**this.failures)))}}this.busy=!1}}async drain(e){let t=Date.now()+e;for(;this.queue.length&&Date.now()<t;)await new Promise(e=>setTimeout(e,100))}},Xn=class{state={...Jn};mic=null;screen=null;audio=new Yn(()=>this.backlog(),64e6);video=new Yn(()=>this.backlog(),96e6);es=null;endpoint=``;key=``;listeners=new Set;periodic=null;lastActivity=0;external=!1;useExternalEvents(){this.external=!0}subscribe(e){return this.listeners.add(e),e(this.state),()=>this.listeners.delete(e)}set(e){this.state={...this.state,...e};for(let e of this.listeners)e(this.state)}backlog(){let e=this.audio.size+this.video.size,t=this.audio.dropped+this.video.dropped;(e!==this.state.backlog||t!==(this.state.lost??0))&&this.set({backlog:e,lost:t})}url(e,t={}){let n=new URLSearchParams(Object.entries({...t,...this.key?{k:this.key}:{}}).map(([e,t])=>[e,String(t)])).toString();return`${this.endpoint}/api/sessions/${encodeURIComponent(this.state.id??``)}${e}${n?`?${n}`:``}`}attach(e,t,n,r=``){this.endpoint=e.replace(/\/$/,``),this.key=r,this.set({...Jn,id:t,status:`recording`,startedAt:n}),this.restorePending(),this.listen(),this.watchUnload()}async resumeMic(e){if(this.mic||this.state.status!==`recording`)return;let t=this.makeMic();this.set({mic:`starting`});try{await t.start(e),this.mic=t,this.set({mic:`on`})}catch(e){this.set({mic:e?.name===`NotAllowedError`?`denied`:`error`})}}async resumeScreen(e){if(this.screen||this.state.status!==`recording`)return;let t=this.makeScreen();try{await t.start({crop:e.crop}),t.record(e.video),t.onEnded=()=>this.set({screen:`off`}),this.screen=t,this.set({screen:`on`})}catch{this.set({screen:`denied`})}}makeMic(){return new Rn(e=>this.state.id&&this.audio.add(this.url(`/audio`,{t:e.t}),e.pcm.buffer.slice(e.pcm.byteOffset,e.pcm.byteOffset+e.pcm.byteLength)),()=>this.moment(`speech`))}videoChunks=0;makeScreen(){return new Vn((e,t,n)=>this.state.id&&this.video.add(this.url(`/video`,{mime:t,startedAt:n,n:this.videoChunks++}),e),e=>this.uploadShot(e.t,e.reason,e.jpeg,e.w,e.h))}unloadHooked=!1;watchUnload(){this.unloadHooked||(this.unloadHooked=!0,addEventListener(`pagehide`,()=>{if(this.state.status!==`recording`)return;this.mic?.flush();let e=[],t=3e6;for(let n of this.audio.queue){if(!e.length)try{if(navigator.sendBeacon(n.url,new Blob([n.body],{type:`text/plain`})))continue}catch{}n.body instanceof Blob||n.body.byteLength>t||(t-=n.body.byteLength,e.push({url:n.url,b64:Gn(n.body)}))}try{e.length&&sessionStorage.setItem(Hn,JSON.stringify({id:this.state.id,items:e}))}catch{}}))}restorePending(){let e=null;try{e=JSON.parse(sessionStorage.getItem(Hn)??`null`),sessionStorage.removeItem(Hn)}catch{return}if(e?.items&&e.id===this.state.id)for(let t of e.items.reverse())this.audio.add(t.url,Kn(t.b64),!0)}go=!1;cancelled=!1;wake=null;startNow(){this.state.status===`starting`&&(this.go=!0,this.wake?.())}cancelStart(){this.state.status!==`starting`||this.state.id||(this.cancelled=!0,this.wake?.())}stillStarting(e){return this.state.status===`starting`&&this.state.id===e}async waitFor(e,t){let n=e.then(()=>`done`,()=>`failed`),r=Date.now()+t;for(;;){if(this.cancelled)return`cancelled`;let e=r-Date.now();if(e<=0)return`timeout`;let t,i=await Promise.race([n,new Promise(n=>{t=setTimeout(()=>n(null),e),this.wake=()=>n(null)})]);if(clearTimeout(t),this.wake=null,i)return i}}async warmSpeech(e){try{return(await(await fetch(`${this.endpoint}/api/speech/warm?mode=${e}&wait=1`,{method:`POST`,credentials:`omit`,signal:AbortSignal.timeout(9e4)})).json()).narration===`live`?`ok`:`unavailable`}catch{return`unavailable`}}async notStarted(e){if(await this.release(),e===null)return this.set({...Jn}),null;throw this.set({status:`failed`,countdown:null,mic:`off`,error:e}),Error(e)}async release(){let e=this.mic,t=this.screen;this.mic=null,this.screen=null,await Promise.race([Promise.all([e?.stop(),t?.stop()].map(e=>e?.catch(()=>void 0))),new Promise(e=>setTimeout(e,4e3))])}async start(e){if(this.state.status===`recording`||this.state.status===`starting`||this.state.status===`stopping`)throw Error(`Already recording`);this.endpoint=e.endpoint.replace(/\/$/,``),this.go=!1,this.cancelled=!1;let t=Math.max(0,Math.round(e.countdown??0)),n={left:t,total:t,mic:e.mic?`opening`:`off`,screen:`off`,speech:e.mic?`loading`:`off`,app:`ok`,waiting:null,goLabel:`Start now`};this.set({...Jn,status:`starting`,countdown:t?n:null});let r=null;if(e.screen){if(!navigator.mediaDevices?.getDisplayMedia)r=`unsupported`;else{let t=this.makeScreen(),n=t.start({crop:e.crop}),i=await this.waitFor(n,Wn);if(i===`done`)t.onEnded=()=>this.set({screen:`off`}),this.screen=t;else if(n.then(()=>t.stop(),()=>t.stop()),i===`failed`)r=`denied`;else if(i===`cancelled`)return this.notStarted(null);else return this.notStarted(`Sharing the screen didn’t start within ${Wn/1e3} seconds. Start again, or turn off “Record the screen”.`)}}let i=null,a=!1,o=e.mic?this.makeMic():null;o&&(this.mic=o,this.set({mic:`starting`}),o.start(e.micDeviceId).then(()=>{a=!0,this.mic===o&&this.set({mic:`on`}),this.wake?.()},e=>{i=e?.name===`NotAllowedError`?`blocked`:`failed`,this.mic===o&&(this.mic=null,this.set({mic:i===`blocked`?`denied`:`error`})),this.wake?.()}));let s=e.mic?`loading`:`off`;if(e.mic&&t&&this.warmSpeech(e.lang).then(e=>{s=e,this.wake?.()}),t){let n=Date.now()+t*1e3,c=()=>{let c=o?i??(a?o.lastSound>o.startedAt?`ok`:Date.now()-o.startedAt>1500?`quiet`:`checking`:`opening`):`off`,l=!e.appReady||e.appReady()?`ok`:`waiting`,u=Math.max(0,Math.ceil((n-Date.now())/1e3)),d=u>0?null:c===`opening`?`Allow the microphone in your browser…`:c===`checking`?`Listening to the microphone…`:c===`quiet`?`No sound from the microphone: check it isn’t muted.`:c===`blocked`?`The microphone is blocked: allow it from the address bar, or record without your voice.`:c===`failed`?`The microphone couldn’t be opened: is one connected?`:l===`waiting`?`Waiting for your app to connect…`:s===`loading`?`Loading the speech model…`:null,f=c===`opening`||c===`blocked`||c===`failed`?`Record without voice`:d?`Start anyway`:`Start now`;return{left:u,total:t,mic:c,screen:e.screen?this.screen?`ok`:r??`denied`:`off`,speech:s,app:l,waiting:d,goLabel:f}};for(;;){let e=c();if(this.set({countdown:e}),this.cancelled)return this.notStarted(null);if(this.go||e.left===0&&!e.waiting)break;await new Promise(e=>{let t=setTimeout(e,200);this.wake=()=>{clearTimeout(t),e()}}),this.wake=null}}let c;try{c=await fetch(`${this.endpoint}/api/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e.name,appUrl:e.appUrl,source:e.source,lang:e.lang,replace:e.replace}),credentials:`omit`,signal:AbortSignal.timeout(2e4)})}catch{throw await this.release(),this.set({status:`failed`,countdown:null,mic:`off`,error:"The studio isn’t reachable. Is it still running? Start it again with `npx @saywright/studio`."}),Error(this.state.error)}let l=await c.json().catch(()=>({}));if(!c.ok||!l.session)throw await this.release(),this.set({status:`failed`,countdown:null,mic:`off`,error:l.error??`Couldn’t start (${c.status})`,busy:l.code===`busy`}),Error(this.state.error);let u=l.session.id;if(this.cancelled)return fetch(`${this.endpoint}/api/sessions/${encodeURIComponent(u)}/stop${l.key?`?k=${encodeURIComponent(l.key)}`:``}`,{method:`POST`,headers:{"Content-Type":`text/plain`},body:`{}`,credentials:`omit`}).catch(()=>void 0),this.notStarted(null);this.key=l.key??``,this.mic?.discard(),this.set({id:u,countdown:null}),this.screen&&e.countdown&&await Un(220),this.screen?.record(e.video);try{await e.onCreated?.(u,this.key)}catch(e){console.warn(`[saywright] starting the app’s recorder:`,e)}return this.stillStarting(u)&&(this.set({status:`recording`,startedAt:l.session.startedAt,screen:this.screen?`on`:r===`unsupported`?`unsupported`:r?`denied`:`off`}),this.listen(),this.watchUnload(),this.moment(`start`,!0),this.periodic=setInterval(()=>{Date.now()-this.lastActivity>2e4&&this.moment(`periodic`)},5e3)),u}moment(e,t=!1){this.lastActivity=Date.now(),this.screen&&this.state.status===`recording`&&!this.state.paused&&setTimeout(()=>this.screen?.shoot(e,t),e===`speech`||e===`start`?0:450)}uploadShot(e,t,n,r,i){this.state.id&&fetch(this.url(`/shots`,{t:e,reason:t,w:r,h:i}),{method:`POST`,body:n,headers:{"Content-Type":`text/plain`},credentials:`omit`}).then(e=>e.arrayBuffer()).catch(()=>void 0)}async mark(e=``,t=`button`){this.state.id&&this.state.status===`recording`&&(this.moment(`mark`,!0),await fetch(this.url(`/mark`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({note:e,via:t,t:Date.now()}),credentials:`omit`}).catch(()=>void 0))}setPaused(e){this.mic?.setPaused(e),this.set({paused:e})}get micLevel(){return this.mic?.level??0}voiceStatus(e=Date.now()){let t=this.state,n=this.mic;if(t.mic===`denied`)return{state:`blocked`,text:`Mic blocked`,hint:`The browser blocked the microphone: allow it from the icon in the address bar.`,tone:`bad`};if(t.mic===`error`)return{state:`unavailable`,text:`No microphone`,hint:`The microphone couldn’t be opened: none is connected, or another app is using it.`,tone:`bad`};if(t.mic===`starting`)return{state:`starting`,text:`Starting the mic…`,hint:`Opening the microphone.`,tone:`quiet`};if(t.mic!==`on`||!n)return{state:`off`,text:`Voice off`,hint:`Your voice isn’t being recorded in this session.`,tone:`quiet`};if(t.paused)return{state:`paused`,text:`Paused`,hint:`Your voice isn’t being recorded until you resume.`,tone:`quiet`};if(e-n.lastVoice<450)return{state:`speaking`,text:`Hearing you`,hint:`Your voice is coming through.`,tone:`ok`};let r=t.heardAt??0;if(r&&r>=n.lastVoice-500&&e-r<2500)return{state:`heard`,text:`Got it`,hint:`Your last sentence was transcribed: it shows next to this.`,tone:`ok`};if(e-Math.max(n.lastSound,n.startedAt)>3e3)return{state:`silent`,text:`No sound from the mic`,hint:`The microphone sends silence: check it isn’t muted (a switch or key on it), or pick another one in the studio’s Settings → Voice.`,tone:`warn`};let i=e-n.lastVoice;return t.narration===`off`?{state:`untranscribed`,text:`Recording, not transcribing`,hint:`Your voice is recorded, but the studio can’t transcribe it on this computer: install a speech model in Settings → Voice, then transcribe it from the report.`,tone:`warn`}:t.narration===`loading`&&n.lastVoice>n.startedAt?{state:`loading`,text:`Loading the speech model…`,hint:`What you say is kept and transcribed as soon as the model has loaded.`,tone:`quiet`}:n.lastVoice>r&&i<8e3?{state:`transcribing`,text:`Writing it down…`,hint:`Transcribing what you just said.`,tone:`quiet`}:{state:`listening`,text:`Listening`,hint:`Say what you notice; each sentence appears here once it is transcribed.`,tone:`quiet`}}async stop(){if(this.state.status===`starting`&&!this.state.id)return this.cancelStart();if(!this.state.id||this.state.status!==`recording`&&this.state.status!==`starting`)return;let e=Date.now();this.set({status:`stopping`}),this.periodic&&clearInterval(this.periodic),this.periodic=null,this.screen?.shoot(`end`,!0),await new Promise(e=>setTimeout(e,150));let t=e=>Promise.race([e?.catch(()=>void 0),new Promise(e=>setTimeout(e,4e3))]);await t(this.mic?.stop()),this.mic=null,await t(this.screen?.stop()),this.screen=null,await Promise.all([this.audio.drain(15e3),this.video.drain(15e3)]);for(let t=0;;t++)try{await fetch(this.url(`/stop`),{method:`POST`,headers:{"Content-Type":`text/plain`},body:JSON.stringify({endedAt:e}),credentials:`omit`,signal:AbortSignal.timeout(15e3)}),this.set({status:`processing`,stage:`Finishing the transcript`,mic:`off`,screen:`off`});return}catch{if(t<2)await new Promise(e=>setTimeout(e,1e3));else return this.set({status:`failed`,error:`Couldn’t reach the studio to stop the session.`,mic:`off`,screen:`off`})}}stoppedElsewhere(){this.periodic&&clearInterval(this.periodic),this.periodic=null,this.mic?.stop(),this.mic=null,this.screen?.stop(),this.screen=null}listen(){if(this.external)return;this.es?.close();let e=new EventSource(this.url(`/live`));this.es=e,e.addEventListener(`session`,e=>{try{this.handle(JSON.parse(e.data))}catch{}})}handle(e){if(e&&e.id===this.state.id){if(e.kind===`counts`)this.set({counts:{...qn,...e.counts},audioSeconds:Number(e.audioSeconds??0),...e.narration?{narration:e.narration}:{}});else if(e.kind===`speech`){let t=e.segment;this.set({captions:[...this.state.captions,{t:t.start,text:t.text}].slice(-3),heardAt:Date.now()})}else if(e.kind===`issue`)this.set({lastIssue:{t:Number(e.t),text:String(e.text)}}),this.moment(`issue`);else if(e.kind===`status`){let t=e.status;t===`processing`&&(this.state.status===`recording`||this.state.status===`stopping`)&&this.stoppedElsewhere(),(t===`processing`||t===`ready`||t===`failed`)&&this.set({status:t,stage:String(e.stage??``),error:e.error??null}),(t===`ready`||t===`failed`)&&this.es&&(this.es.close(),this.es=null)}}}reset(){this.es?.close(),this.es=null,this.set({...Jn})}},Zn=`saywright.session.prefs`,Qn=`saywright.report.lang`;function $n(){try{let e=localStorage.getItem(Qn);return e===`en`||e===`ar`?e:null}catch{return null}}function er(){let e={lang:navigator.language?.startsWith(`ar`)?`ar`:`auto`,mic:!0,screen:!0,video:!0,countdown:3};try{return{...e,...JSON.parse(localStorage.getItem(Zn)??`{}`)}}catch{return e}}var tr=_()(()=>({live:Jn,list:[],open:null,detail:null,detailError:null,reportLang:$n(),setup:!1,speech:null,prefs:er()})),O=tr.setState,k=tr.getState;function nr(e){return{src:e.src,name:e.name,tag:e.tag,role:e.role,label:e.label.replace(/^[^·]*·\s*/,``).slice(0,60),text:e.text,rect:[Math.round(e.rect.x),Math.round(e.rect.y),Math.round(e.rect.w),Math.round(e.rect.h)]}}var rr=500,A=new class{client=new Xn;host=null;outbox=[];flushTimer=null;pointing=null;lookups=new Set;restoreMode=null;seq=0;key;awaiting=new Map;poll=null;constructor(){this.client.useExternalEvents(),this.client.subscribe(e=>{let t=k().live;O({live:e}),t.status!==e.status&&(e.status===`ready`||e.status===`failed`)&&this.refreshList(),this.syncPoll()})}syncPoll(){k().live.status===`processing`||this.awaiting.size?this.poll??=setInterval(()=>void this.resync(),4e3):this.poll&&=(clearInterval(this.poll),null)}init(e){this.host=e,this.refreshList(),this.refreshSpeech();let t=/^\/report\/([\w-]+)/.exec(location.pathname);t&&this.openReport(t[1]),u.get(`/sessions/active`).then(({session:e,key:t})=>{e&&e.source===`studio`&&k().live.status===`idle`&&(this.key=t,this.client.attach(location.origin,e.id,e.startedAt),this.host?.bridgeSession(!0,e.id,location.origin,t),this.restoreMode=this.host?.enterUse()??null)})}serverEvent(e,t){if(e===`speech`)O({speech:t});else if(e===`session`){let e=t;this.client.handle(e),e.kind===`status`?(this.refreshList(),k().open===e.id&&this.loadDetail(e.id),(e.status===`ready`||e.status===`failed`)&&this.announce(e.id,e.status)):e.kind===`report`&&k().open===e.id&&this.loadDetail(e.id)}}async resync(){await this.refreshList();let e=k().live,t=e.id?k().list.find(t=>t.id===e.id):void 0;t&&e.status===`processing`&&t.status!==`processing`&&this.client.handle({kind:`status`,id:t.id,status:t.status,stage:t.stage,error:t.error});for(let e of this.awaiting.keys()){let t=k().list.find(t=>t.id===e);(!t||t.status===`ready`||t.status===`failed`)&&this.announce(e,t?.status??`failed`)}}announce(e,t){let n=this.awaiting.get(e);n!==void 0&&(this.awaiting.delete(e),this.syncPoll(),k().open!==e&&this.host?.notify(t===`ready`?`Report ready: ${n}`:`The report for “${n}” couldn’t be written`,[{label:`Open`,run:()=>this.openReport(e),primary:!0}]))}setPrefs(e){let t={...k().prefs,...e};localStorage.setItem(Zn,JSON.stringify(t)),O({prefs:t})}get recording(){let e=k().live.status;return e===`recording`||e===`starting`||e===`stopping`}async start(e,t=!1){if(!this.host||this.recording)return;let n=k().prefs;O({setup:!1});let r=k().live,i=r.status===`ready`||r.status===`failed`;r.id&&(r.status===`processing`||i)&&this.awaiting.set(r.id,k().list.find(e=>e.id===r.id)?.name||`the last session`),this.syncPoll();try{let r=this.host;await this.client.start({endpoint:location.origin,name:e,lang:n.lang,appUrl:r.appUrl(),source:`studio`,mic:n.mic,screen:n.screen,video:n.video&&n.screen,crop:r.frame(),replace:t,countdown:n.countdown,appReady:()=>r.appConnected(),onCreated:async(e,t)=>{this.seq=0,this.key=t,this.restoreMode=r.enterUse(),await r.bridgeSession(!0,e,location.origin,t)}})}catch{O({setup:!0})}r.id&&i&&this.announce(r.id,r.status)}startNow(){this.client.startNow()}cancelStart(){this.client.cancelStart()}async stop(){if(this.recording){if(k().live.status===`starting`&&!k().live.id)return this.cancelStart();this.flushPointing(),await this.flush(),this.host?.bridgeSession(!1),this.restoreMode?.(),this.restoreMode=null,await this.client.stop()}}mark(e=``,t=`key`){k().live.status===`recording`&&(this.host?.bridgeMark(e,t),this.client.moment(`mark`,!0))}moment(e){this.client.moment(e)}pointed(e,t){if(k().live.status!==`recording`)return;let n=Date.now();if(this.pointing&&e&&this.pointing.el.id===e.id||(this.flushPointing(n),!e))return;let r={el:e,since:n,via:t,timer:setTimeout(()=>r.locator=this.locate(e),rr)};this.pointing=r}locate(e){return this.host?this.host.locate(e.id).catch(()=>null):Promise.resolve(null)}flushPointing(e=Date.now()){let t=this.pointing;if(!t)return;this.pointing=null,clearTimeout(t.timer);let n=e-t.since;if(n<rr)return;let r=nr(t.el),i=(t.locator??this.locate(t.el)).then(e=>{e&&Object.assign(r,{locator:e.code,description:e.description,...e.within?{within:e.within}:{}})});this.lookups.add(i),i.finally(()=>this.lookups.delete(i)),this.queue({type:`point`,el:r,ms:n,via:t.via,t:t.since})}command(e,t,n){k().live.status===`recording`&&this.queue({type:`command`,text:e.slice(0,300),input:t,result:n.slice(0,120),t:Date.now()})}queue(e){this.outbox.push(e),this.flushTimer||=setTimeout(()=>void this.flush(),1500)}async flush(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null,this.lookups.size&&await Promise.race([Promise.all(this.lookups),new Promise(e=>setTimeout(e,1e3))]);let e=k().live.id;if(!e||!this.outbox.length)return;let t=this.outbox.splice(0).map(e=>({...e,seq:++this.seq}));await u.post(`/sessions/${e}/studio-events`,{events:t}).catch(()=>void 0)}async refreshList(){let{sessions:e}=await u.get(`/sessions`).catch(()=>({sessions:[]}));O({list:e})}async refreshSpeech(){let e=await u.get(`/speech/status`).catch(()=>null);e&&O({speech:e})}warmSpeech(e){u.post(`/speech/warm?mode=`+e,{}).catch(()=>void 0)}async installSpeech(e){let t=await u.post(`/speech/install`,{id:e}).catch(()=>null);t&&O({speech:t})}openReport(e){let t=k().live;t.id===e&&(t.status===`ready`||t.status===`failed`)&&this.client.reset(),this.awaiting.delete(e),this.syncPoll(),O({open:e,detail:null,detailError:null}),location.pathname!==`/report/${e}`&&history.pushState(null,``,`/report/${e}`),this.loadDetail(e)}closeReport(){O({open:null,detail:null,detailError:null}),location.pathname.startsWith(`/report/`)&&history.pushState(null,``,`/`)}async loadDetail(e){try{let t=await u.get(`/sessions/${e}`);k().open===e&&O({detail:t,detailError:null})}catch(t){k().open===e&&O({detailError:t instanceof Error?t.message:String(t)})}}setReportLang(e){try{localStorage.setItem(Qn,e)}catch{}O({reportLang:e})}async setSkipped(e,t){let n=k().detail;n?.meta.id===e&&O({detail:{...n,decisions:{...n.decisions,skipped:t}}}),await u.put(`/sessions/${e}/decisions`,{skipped:t})}async correctSentence(e,t,n){await u.put(`/sessions/${e}/transcript/${t}`,{text:n}),await this.loadDetail(e)}async retranslate(e){await u.post(`/sessions/${e}/translate`,{}),await this.loadDetail(e)}async regenerate(e,t=!0){await u.post(`/sessions/${e}/report`,{ai:t}),await this.loadDetail(e)}async retranscribe(e,t){await u.post(`/sessions/${e}/transcribe`,{lang:t}),await this.loadDetail(e)}async rename(e,t){await u.put(`/sessions/${e}`,{name:t}),await this.refreshList(),k().open===e&&await this.loadDetail(e)}async remove(e){await fetch(`/api/sessions/${e}`,{method:`DELETE`}),k().open===e&&this.closeReport(),await this.refreshList()}bridgeSaid(e){let t=k().live;t.status===`recording`&&t.id&&e!==t.id&&this.host?.bridgeSession(!0,t.id,location.origin,this.key)}};window.addEventListener(`popstate`,()=>{let e=/^\/report\/([\w-]+)/.exec(location.pathname);e?k().open!==e[1]&&A.openReport(e[1]):k().open&&O({open:null,detail:null})});function ir(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var ar=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return ar(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return ar(t)(e)}}}},or=(e,t)=>(n,r,i)=>{let a={storage:ir(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return ar(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},sr={theme:`system`,onboarded:!1,voice:{lang:navigator.language?.startsWith(`en`)?navigator.language:`en-US`,autoStopMs:1300,sounds:!0,engine:`auto`,review:!1},ui:{panelOpen:!0,panelTab:`changes`,device:`fill`,commitOnKeep:!1}},cr=_()(or(e=>({...sr,set:t=>e(t),setVoice:t=>e(e=>({voice:{...e.voice,...t}})),setUi:t=>e(e=>({ui:{...e.ui,...t}})),reset:()=>e({...sr,onboarded:!0})}),{name:`saywright.settings`,version:3,migrate:e=>{let t={...e??{}};for(let e of[`camera`,`engine`,`aimAssist`,`dwellSelect`,`labs`])delete t[e];return t},partialize:({set:e,setVoice:t,setUi:n,reset:r,...i})=>i,merge:(e,t)=>{let n=e??{};return{...t,...n,voice:{...t.voice,...n.voice},ui:{...t.ui,...n.ui}}}}));function lr(e){let t=e===`dark`||e===`system`&&matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}var ur=null,dr=!0;function fr(e){dr=e}function pr(e,t,n,r,i=`sine`,a){if(!ur)return;let o=ur.currentTime+t,s=ur.createOscillator(),c=ur.createGain();s.type=i,s.frequency.setValueAtTime(e,o),a&&s.frequency.exponentialRampToValueAtTime(a,o+n),c.gain.setValueAtTime(0,o),c.gain.linearRampToValueAtTime(r,o+.008),c.gain.exponentialRampToValueAtTime(1e-4,o+n),s.connect(c).connect(ur.destination),s.start(o),s.stop(o+n+.02)}function j(e){if(dr){try{ur??=new AudioContext,ur.state===`suspended`&&ur.resume()}catch{return}switch(e){case`listen`:pr(660,0,.09,.05,`sine`,990);break;case`send`:pr(990,0,.08,.04,`sine`,740);break;case`tap`:pr(1800,0,.03,.025,`triangle`);break;case`pick`:pr(1320,0,.04,.03,`triangle`),pr(1760,.05,.05,.03,`triangle`);break;case`keep`:pr(784,0,.12,.045),pr(1175,.07,.16,.04);break;case`undo`:pr(523,0,.14,.045,`sine`,392);break;case`error`:pr(220,0,.18,.05,`triangle`,180)}}}var mr={startUrl:null,steps:[],expectations:[],spec:null,run:null,running:!1,installing:!1,installLog:[],verifying:!1},hr=_()(()=>({mode:`edit`,status:null,statusError:null,app:{connected:!1,url:``,title:``,reloadKey:0},pointer:null,hover:null,snapped:!1,selection:null,pins:[],previewTargets:[],replay:null,autopilot:null,voice:{supported:!0,state:`idle`,trigger:null,words:[],bindings:[],error:null,last:null,model:`idle`,modelError:``},draft:null,island:{kind:`idle`},request:null,waiting:[],changes:[],inspect:null,inspectLoading:!1,recorder:mr,summary:null,overlay:null,settingsTab:`general`,history:[],focusInput:0,onboardingStep:0})),M=hr.setState,N=hr.getState,gr=e=>e.changes.filter(e=>e.status===`preview`);function _r(e,t){return e===t?!0:!e||!t?!1:e.id===t.id&&e.rect.x===t.rect.x&&e.rect.y===t.rect.y&&e.rect.w===t.rect.w&&e.rect.h===t.rect.h&&e.src===t.src&&e.text===t.text}var vr=new Set(`a an the this that these those it its to into as be is are was make makes made turn change set use using with please can you could would just look looks like more less bit little lot much way really so and also now then on in of for here there me my our your some kind sort`.split(` `)),yr=/\b(?:everywhere|wherever|throughout|all of (?:them|these|those)|(?:all|every|each) (?:the )?(?:one|ones|instances?|occurrences?|places?|pages?|screens?|buttons?|links?|labels?|copies)|across the (?:app|site|page|pages|project))\b/i,br=RegExp(`\\s+(?:${yr.source})(?:\\s+(?:it|they)\\s+(?:appears?|shows?|is|are)(?:\\s+used)?)?[.!]*$`,`i`),xr=/^(?:please|thanks|thank you|instead|now|for me)?[.!]*$/i,Sr=/\uE000(\d+)\uE000/g;function Cr(e){return e.replace(/^[\s"“'‘]+|[\s"”'’.]+$/g,``)}var wr=new Set(`on in at for when if unless until while after before and but or so then with without except only instead to into than border borders shadow shadows padding margin margins spacing space gap underline background bg color colour outline radius rounded rounding corner corners bold italic animation transition scrollbar placeholder tooltip focus hover opacity blur gradient style styles styling class classes wrap wrapping overflow limit validation confirmation delay duplicate duplicates uppercase lowercase`.split(` `));function Tr(e){let t=e.trim().replace(/^(?:(?:please|can you|could you|would you|just|now)\s+)+/,``),n=/^(?:remove|delete|get rid of|drop|hide)\b(.*)$/.exec(t);if(!n)return null;let r=n[1].replace(/\b(?:please|now|entirely|completely|altogether|for me)\b/g,` `).replace(/\bfrom (?:the |this )?(?:page|screen|view|app)\b/g,` `).trim(),i=r?r.split(/\s+/):[];return i.length<=4&&!i.some(e=>wr.has(e))?`element`:`other`}function Er(e){let t=[];return{masked:e.replace(/"([^"]*)"|“([^”]*)”|«([^»]*)»|(?<![\p{L}\p{N}])'([^']*)'(?![\p{L}\p{N}])|(?<![\p{L}\p{N}])‘([^’]*)’(?![\p{L}\p{N}])/gu,(...e)=>(t.push(String(e.slice(1,6).find(e=>e!==void 0)??``)),`\uE000${t.length-1}\uE000`)),values:t}}function Dr(e,t){let n=/^\s*\uE000(\d+)\uE000(.*)$/s.exec(e);if(n){let e=t[Number(n[1])].trim(),r=n[2].replace(Sr,(e,n)=>t[Number(n)]).trim();return yr.test(r)?{value:e,everywhere:!0,quoted:!0}:xr.test(r)?{value:e,everywhere:!1,quoted:!0}:null}let r=Cr(e.replace(Sr,(e,n)=>`"${t[Number(n)]}"`)),i=br.exec(r);return i&&(r=r.slice(0,i.index).trim()),{value:r,everywhere:!!i,quoted:!1}}function Or(e){let t=e.split(/\s/)[0];return/\p{Lu}|\d/u.test(t.slice(1))?e:e[0].toUpperCase()+e.slice(1)}var kr=e=>` `+e.toLowerCase().replace(/[“”"‘’']/g,``).replace(/[^a-z0-9\s-]/g,` `).replace(/\s+/g,` `).trim()+` `;function Ar(e){let t=e.trim(),{masked:n,values:r}=Er(t),i=kr(t),a=kr(n.replace(Sr,` `));if(/\b(look|looks|style|styled)\s+(just\s+|exactly\s+)?like\b|\bsame (style|look|size|styling) as\b|\bmatch(es)?\b/.test(a))return{kind:`copy`,adjust:/\b(smaller|tinier|less)\b/.test(a)?-1:+!!/\b(bigger|larger)\b/.test(a)};let o=/\b(?:rename|relabel|call)\b.*?\b(?:to|as)\b\s+(.+)$/is.exec(n)??/\b(?:change|set|update|make)\s+(?:the\s+)?(?:text|label|copy|title|wording|words?)\b.*?\b(?:to|into)\b\s+(.+)$/is.exec(n)??/\b(?:make\s+(?:this|that|it)\s+)?(?:say|read)s?\s+(.+)$/is.exec(n);if(o){let e=Dr(o[1],r);if(!e)return null;let t=e.everywhere||yr.test(n.slice(0,o.index+o[0].length-o[1].length).replace(Sr,` `));if(e.value)return{kind:`text`,value:e.quoted?e.value:Or(e.value),...t?{everywhere:!0}:{}}}if(/\b(?:and|then|also|plus)\b/.test(a))return null;let s=/\b(move|put|place|drag)\b.*\b(above|below|before|after|under|over|beneath|underneath)\b/.exec(a);if(s)return{kind:`move`,where:/^(below|after|under|beneath|underneath)$/.test(s[2])?`below`:`above`};let c=Tr(a);if(c===`element`)return{kind:`remove`};if(c===`other`)return null;let l=/\b(bigger|larger|huge|grow|taller|wider|increase)\b/.test(i),u=/\b(smaller|tiny|tinier|shrink|shorter|narrower|decrease|compact)\b/.test(i),d=/\b(padding|spacing|space|gap|gaps|room|airy|tighter|looser|roomier)\b/.test(i);if(l||u||/\b(more|less) (padding|spacing|space|room)\b/.test(i)||/\b(tighter|roomier|looser)\b/.test(i))return{kind:`step`,dir:l||/\b(more|looser|roomier)\b/.test(i)?1:-1,amount:/\b(much|a lot|way|lots|huge|tiny)\b/.test(i)?2:1,focus:d?`spacing`:`size`};if(/\b(make|turn|set|change|switch|use|give)\b/.test(i)||i.trim().split(` `).length<=3){let e=i.trim().split(` `).filter(e=>e&&!vr.has(e));if(e.length&&e.length<=4)return{kind:`set`,terms:e}}return null}var jr=[`Keep it.`,`Keep.`,`Looks good.`,`Undo.`,`Undo that.`,`Go back.`,`Cancel.`,`Stop.`,`Never mind.`,`Fix it.`,`Run the test.`,`Generate a test.`,`Scroll down.`,`Scroll up.`,`Select parent.`,`Clear.`,`Help.`,`Click this.`],Mr=e=>e.toLowerCase().replace(/[^a-z0-9$.' ]/g,` `).replace(/\.(?=\s|$)/g,` `).split(/\s+/).filter(Boolean),Nr=(e,t)=>Mr(e).join(` `)===Mr(t).join(` `),Pr=new Set([`you`,`thank you`,`thanks`,`thank you very much`,`thanks for watching`,`bye`,`bye bye`,`hmm`,`mm`,`mhm`,`uh`,`um`,`oh`,`ah`,`huh`,`the`,`a`,`i`]),Fr=-1.2,Ir=-.8,Lr=.8,Rr=-2.8,zr=-3.5,Br=.4;function Vr(e,t=0,n=!1){let r=Mr(e);return!r.length||Pr.has(r.join(` `))||r.length>=4&&new Set(r).size/r.length<.5?!1:t>=(n?Ir:Fr)}function Hr(e,t){let n=Mr(e).map(Gr),r=Mr(t).map(Gr);if(!n.length||r.length<=n.length)return!1;let i=n.join(` `);return r.slice(r.length-n.length).join(` `)===i||r.slice(0,n.length).join(` `)===i}var Ur=new Set(`red orange amber yellow lime green emerald teal cyan blue indigo violet purple pink rose gray grey black white dark light primary secondary tertiary ghost outline outlined solid subtle soft link danger destructive success warning error info neutral muted accent bold italic underline small medium large tiny huge sm md lg xl rounded round square pill full wide narrow centered center left right disabled hidden visible`.split(` `)),Wr=new Set([...Ur,...`bigger smaller larger wider taller shorter tighter looser more less rename remove delete hide move change make undo keep cancel stop scroll select parent reload help click padding spacing space gap text label title button above below test fix pin this that`.split(` `)]);function Gr(e){let t=e.toLowerCase().replace(/[^a-z]/g,``);t=t.replace(/^kn/,`n`).replace(/^wr/,`r`).replace(/ph/g,`f`).replace(/gh/g,``).replace(/ck/g,`k`).replace(/q/g,`k`).replace(/x/g,`ks`).replace(/c(?=[eiy])/g,`s`).replace(/c/g,`k`);let n=/^[aeiouy]/.test(t)?`a`:``;return t=t.replace(/[aeiouyhw]/g,``).replace(/b/g,`p`).replace(/d/g,`t`).replace(/[gj]/g,`k`).replace(/v/g,`f`).replace(/z/g,`s`).replace(/(.)\1+/g,`$1`),n+t}var Kr=new Map;for(let e of Wr)e.length>=3&&Kr.set(Gr(e),[...Kr.get(Gr(e))??[],e]);function qr(e){let t=e.trim().split(/\s+/);if(t.length>1&&!/^(make|turn|set|change)$/i.test(t[0]))return[];let n=/^([^A-Za-z']*)([A-Za-z']+)(.*)$/.exec(t[t.length-1]);return!n||n[2].length<3||Wr.has(n[2].toLowerCase())?[]:(Kr.get(Gr(n[2]))??[]).map(e=>{let r=n[2][0]===n[2][0].toUpperCase()?e[0].toUpperCase()+e.slice(1):e;return[...t.slice(0,-1),n[1]+r+n[3]].join(` `)})}function Jr(e){let t=e.trim();if(!t)return!1;if(It(t,{hasFailingTest:!0})||Lt(t)||/^(why|what|where|when|how|can|could|is|are|does|do|should|which|who)\b/i.test(t))return!0;let n=Ar(t);return n?n.kind!==`set`||n.terms.some(e=>Ur.has(e)):!1}var Yr=e=>{let t=It(e,{hasFailingTest:!0});return t?`${t.kind}${`dir`in t?t.dir:``}`:``};function Xr(e,t){let n=e=>Gr(Mr(e).join(``));return Mr(e).length<=3&&n(e).length>=2&&n(e)===n(t)}function Zr(e,t,n){let r=e.filter(e=>t[e.text]!==void 0).sort((e,n)=>t[n.text]-t[e.text]),i=r[0];if(!i)return null;let a=n.some(e=>Xr(e.text,i.text));if(t[i.text]<(a?zr:Rr))return null;let o=r.find(e=>Yr(e.text)!==Yr(i.text));return o&&t[i.text]-t[o.text]<Br?null:i}function Qr(e,t){let n=e.filter(e=>e.text.trim());if(!n.length)return null;let r=n.find(e=>e.source===`browser`&&e.rank===0)??null;if(!t){let e=n.filter(e=>e.source===`browser`);return e.find(e=>Jr(e.text))??e[0]??null}let i=Zr(n.filter(e=>e.source===`command`),t,n.filter(e=>e.source===`browser`||e.source===`device`));if(i)return i;let a=e=>e.source===`browser`?e.rank===0?1:.3:e.source===`device`&&r&&Hr(r.text,e.text)?1.2:0,o=null,s=-1/0;for(let e of n){let n=t[e.text];if(n===void 0||e.source===`command`)continue;let r=n;if(e.source===`variant`){let i=e.from?t[e.from.text]:void 0;if(!e.from||i===void 0||n<i-Lr||!Jr(e.text))continue;r+=a(e.from)}else r+=a(e);Jr(e.text)&&(r+=1),r>s&&(s=r,o=e)}return o??r}function $r(e,t,n){let r=e.trim().split(/\s+/).filter(Boolean);if(!r.length)return[];let i=r.reduce((e,t)=>e+t.length,0)+r.length-1,a=Math.max(1,n-t),o=0;return r.map(e=>{let n=(o+e.length/2)/Math.max(1,i);return o+=e.length+1,{text:e,t:t+n*a}})}function ei(e,t,n){let r=e.filter(e=>e.trim()),i=t.trim();if(!r.length&&!i)return null;if(!r.length)return{text:i,source:`device`};if(!i||n(r[0]))return{text:r[0],source:`browser`};if(n(i))return{text:i,source:`device`};let a=r.find(e=>n(e));if(a)return{text:a,source:`browser`};let o=ti(r[0]),s=ti(i);return s.length>=o.length+2&&o.length&&o.every((e,t)=>ni(e,s[s.length-o.length+t]))?{text:i,source:`device`}:{text:r[0],source:`browser`}}function ti(e){return e.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu,` `).split(/\s+/).filter(Boolean)}function ni(e,t){if(!t)return!1;if(e===t)return!0;let n=e=>e.replace(/[أإآٱ]/g,`ا`).replace(/ة/g,`ه`).replace(/ى/g,`ي`);return n(e)===n(t)}var ri=16e3,ii=45e3,ai=12e4,oi=3,si=220,ci=220,li=128,ui=class{ctx=null;stream=null;node=null;chunks=[];opening=null;closeTimer=null;noise=.004;lastT=0;streak=0;level=0;lastVoice=0;error=null;get open(){return!!this.node}start(){return this.touch(),this.node?Promise.resolve(!0):(this.opening??=this.openMic().finally(()=>this.opening=null),this.opening)}async openMic(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});let e=new AudioContext({sampleRate:ri,latencyHint:`interactive`});this.ctx=e,await e.audioWorklet.addModule(`/voice-capture-worklet.js`);let t=e.createMediaStreamSource(this.stream),n=new AudioWorkletNode(e,`saywright-capture`);n.port.onmessage=e=>this.ingest(e.data.data,this.toPerf(e.data.time));let r=e.createGain();return r.gain.value=0,t.connect(n).connect(r).connect(e.destination),e.state===`suspended`&&await e.resume().catch(()=>void 0),this.node=n,this.error=null,!0}catch(e){let t=e?.name;return this.error=t===`NotAllowedError`?`Microphone is blocked. Allow it in the address bar (and on macOS in System Settings → Privacy & Security → Microphone).`:t===`NotFoundError`?`No microphone found.`:`Microphone unavailable: ${e?.message??e}`,this.close(),!1}}toPerf(e){let t=this.ctx,n=performance.now();if(t?.getOutputTimestamp){let r=t.getOutputTimestamp();r.contextTime!==void 0&&r.performanceTime&&(n=r.performanceTime+(e-r.contextTime)*1e3)}return n=Math.max(n,this.lastT+1),this.lastT=n,n}ingest(e,t){let n=0;for(let t=0;t<e.length;t++)n+=e[t]*e[t];let r=Math.sqrt(n/e.length);for(this.chunks.push({t,data:e,rms:r});this.chunks.length&&this.chunks[0].t<t-ii;)this.chunks.shift();this.noise=r<this.noise?this.noise*.9+r*.1:this.noise*.998+r*.002,this.streak=r>this.threshold()?this.streak+1:0,this.streak>=oi&&(this.lastVoice=t);let i=Math.min(1,r*9);this.level=i>this.level?this.level*.35+i*.65:this.level*.75+i*.25}threshold(){return Math.max(.008,this.noise*3.2)}sample(){return this.node||(this.level*=.85),this.level}slice(e,t){let n=[];for(let r of this.chunks){let i=r.t-r.data.length/ri*1e3;if(r.t<=e||i>=t)continue;let a=Math.max(0,Math.round((e-i)/1e3*ri)),o=Math.min(r.data.length,Math.round((t-i)/1e3*ri));o>a&&n.push(r.data.subarray(a,o))}let r=new Float32Array(n.reduce((e,t)=>e+t.length,0)),i=0;for(let e of n)r.set(e,i),i+=e.length;return r}peak(e,t){let n=0;for(let r of this.chunks)r.t>=e&&r.t<=t+50&&r.rms>n&&(n=r.rms);return n}voiced(e,t,n=e){let r=this.threshold(),i=[],a=null,o=0;this.chunks.forEach((n,s)=>{if(n.t<e||n.t>t+50)return;if(n.rms<=r){o=0;return}o++;let c=n.t-n.data.length/ri*1e3;a&&c-a.end<=si?(a.end=n.t,a.last=s):(a={start:c,end:n.t,sustained:!1,first:s,last:s},i.push(a)),o>=oi&&(a.sustained=!0)});let s=i.filter(e=>e.sustained&&e.end>=n-ci);if(!s.length)return null;let c=s[0],l=s[s.length-1];return{start:this.edge(c.first,r,`start`)??c.start,end:this.edge(l.last,r,`end`)??l.end}}edge(e,t,n){let r=null;for(let i of n===`start`?[e-1,e]:[e,e+1]){let e=this.chunks[i];if(!e)continue;let a=e.t-e.data.length/ri*1e3;for(let i=0;i+li<=e.data.length;i+=li){let o=0;for(let t=i;t<i+li;t++)o+=e.data[t]*e.data[t];if(!(Math.sqrt(o/li)<=t)){if(n===`start`)return a+i/ri*1e3;r=a+(i+li)/ri*1e3}}}return r}touch(){this.closeTimer&&clearTimeout(this.closeTimer),this.closeTimer=setTimeout(()=>this.close(),ai)}close(){this.closeTimer&&clearTimeout(this.closeTimer),this.closeTimer=null,this.node?.port.close(),this.node=null,this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null,this.ctx?.close().catch(()=>void 0),this.ctx=null,this.chunks=[],this.level=0}},di=class{langs=new Set;async transcribe(e,t,n){let r=new Int16Array(e.length);for(let t=0;t<e.length;t++){let n=Math.max(-1,Math.min(1,e[t]));r[t]=n<0?n*32768:n*32767}try{let e=await fetch(`/api/speech/transcribe?lang=${t}`,{method:`POST`,body:r.buffer,headers:{"Content-Type":`application/octet-stream`},signal:n});return e.ok?await e.json():null}catch{return null}}};function fi(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var pi={"not-allowed":`Microphone is blocked. Allow it in the address bar (and on macOS in System Settings → Privacy & Security → Microphone).`,"service-not-allowed":`Speech recognition is turned off in this browser. Use Chrome, or type instead.`,"audio-capture":`No microphone found.`,network:`The browser’s speech service can’t be reached (it needs the internet).`,"language-not-supported":`That language isn’t supported for speech here.`},mi=e=>e.replace(/\s+/g,` `).trim(),hi=class{static supported(){return typeof window<`u`&&!!fi()}lang=`en-US`;onWords=null;onFinal=null;onError=null;onAudioStart=null;rec=null;words=[];finals=``;current=``;lastAlts=[];lastPrefix=``;want=!1;finishTimer=null;done=!0;state=`idle`;setState(e){this.state=e}start(){let e=fi();return e?(this.state!==`idle`&&this.cancel(),this.words=[],this.finals=``,this.current=``,this.lastAlts=[],this.lastPrefix=``,this.want=!0,this.done=!1,this.spawn(e),this.setState(`listening`),!0):(this.onError?.(`unsupported`,`This browser has no speech recognition. Use Chrome, or type your command.`),!1)}spawn(e){let t=new e;t.lang=this.lang,t.continuous=!0,t.interimResults=!0,t.maxAlternatives=5,t.onresult=e=>this.handleResult(e),t.onaudiostart=()=>this.onAudioStart?.(),t.onerror=e=>{e.error!==`aborted`&&e.error!==`no-speech`&&(this.want=!1,this.onError?.(e.error,pi[e.error]??`Speech recognition error: ${e.error}`))},t.onend=()=>{if(this.rec===t){if(this.want){this.finals=this.text(),this.current=``;try{this.spawn(e);return}catch{}}this.finish()}},this.rec=t;try{t.start()}catch{}}text(){return mi(`${this.finals} ${this.current}`)}handleResult(e){let t=``,n=-1;for(let r=0;r<e.results.length;r++)t+=` `+e.results[r][0].transcript,e.results[r].isFinal&&(n=r);if(this.current=t,n>=0){let t=this.finals;for(let r=0;r<n;r++)t+=` `+e.results[r][0].transcript;let r=e.results[n],i=[];for(let e=0;e<r.length;e++)r[e]?.transcript&&i.push(mi(r[e].transcript));this.lastPrefix=mi(t),this.lastAlts=i}let r=this.text(),i=performance.now(),a=r?r.split(` `):[];this.words=a.map((e,t)=>({text:e,t:this.words[t]?.t??i})),this.onWords?.(this.words)}stop(){if(this.state===`listening`){this.want=!1,this.setState(`finishing`);try{this.rec?.stop()}catch{}this.finishTimer=setTimeout(()=>this.finish(),1600)}}cancel(){this.want=!1,this.done=!0,this.finishTimer&&clearTimeout(this.finishTimer);try{this.rec?.abort()}catch{}this.rec=null,this.setState(`idle`)}finish(){if(this.finishTimer&&clearTimeout(this.finishTimer),this.finishTimer=null,this.rec=null,this.done)return;this.done=!0;let e=this.text(),t=[e];for(let e of this.lastAlts.slice(1)){let n=mi(`${this.lastPrefix} ${e}`);n&&!t.includes(n)&&t.push(n)}this.setState(`idle`),this.onFinal?.(e,this.words,e?t:[])}},gi=600,_i=350,vi=1700,yi=6e3,bi=2500,xi=`/models/moonshine/tiny`,Si=`The on-device speech model isn’t downloaded.`,Ci={text:``,words:[],alternatives:[]},wi=(e,t)=>Promise.race([e,new Promise(e=>setTimeout(()=>e(null),t))]),Ti=class{state=`idle`;reason=``;onChange=null;worker=null;loading=null;seq=0;waiting=new Map;busy=!1;load(){return this.state===`ready`?Promise.resolve(!0):this.state===`unavailable`?Promise.resolve(!1):(this.loading??=this.boot(),this.loading)}setState(e,t=``){this.state=e,this.reason=t,this.onChange?.(e,t)}async boot(){this.setState(`loading`);let e=``;try{let t=await fetch(`${xi}/encoder_model.onnx`,{method:`HEAD`});if(!t.ok||/text\/html/.test(t.headers.get(`content-type`)??``))throw Error(Si);let n=new Worker(new URL(`/assets/asr.worker-FcRNDSsJ.js`,``+import.meta.url),{type:`module`});if(this.worker=n,!await new Promise(t=>{let r=setTimeout(()=>t(!1),3e4);n.onmessage=n=>{let i=n.data;if(i.type===`loaded`)clearTimeout(r),t(!0);else if(i.type===`error`&&!i.id)e=i.message??``,clearTimeout(r),t(!1);else if(i.id){let e=this.waiting.get(i.id);this.waiting.delete(i.id),e?.(i)}},n.onerror=n=>{e=n.message,clearTimeout(r),t(!1)},n.postMessage({type:`load`,base:new URL(xi,location.origin).href,wasmPaths:void 0})}))throw Error(e||`The speech model didn’t start in time.`);return n.onerror=()=>this.fail(`The on-device speech model stopped working. Reload the studio to restart it.`),this.setState(`ready`),!0}catch(e){return this.fail(e instanceof Error?e.message:String(e)),!1}}fail(e){this.dispose();for(let e of this.waiting.values())e({type:`error`});this.waiting.clear(),this.setState(`unavailable`,e)}call(e,t,n=[]){if(!this.worker||this.state!==`ready`)return Promise.resolve(null);let r=++this.seq;return new Promise(i=>{let a=setTimeout(()=>{this.waiting.delete(r),i(null)},t);this.waiting.set(r,e=>{clearTimeout(a),i(e.type===`error`?null:e)}),this.worker.postMessage({...e,id:r},n)})}async partial(e){if(this.busy)return null;this.busy=!0;try{return(await this.call({type:`partial`,audio:e},4e3,[e.buffer]))?.text??null}finally{this.busy=!1}}final(e,t){return this.call({type:`final`,key:e,audio:t},1e4,[t.buffer])}async score(e,t,n=!1){return(await this.call({type:`score`,key:e,candidates:t,prune:n},5e3))?.scores??null}retry(){return this.state===`unavailable`&&(this.loading=null,this.state=`idle`),this.load()}dispose(){this.worker?.terminate(),this.worker=null}},Ei=class e{engine=`auto`;lang=`en-US`;autoStopMs=1300;onState=null;onWords=null;onFinal=null;onError=null;onNothing=null;capture=new ui;asr=new Ti;server=new di;debug=null;web=new hi;state=`idle`;seq=0;gen=0;current=null;lastReleased=null;pending=0;webOwner=null;webBrokenAt=-1/0;constructor(){this.web.onWords=e=>{let t=this.webOwner;t&&(t.webWords=e,t===this.current&&this.onWords?.(e,!1))},this.web.onAudioStart=()=>{this.webOwner&&this.webOwner===this.current&&this.goLive(this.webOwner)},this.web.onFinal=(e,t,n)=>{let r=this.webOwner;this.webOwner=null,r?.resolveWeb?.({text:e,words:t,alternatives:n}),setTimeout(()=>{let e=this.current;e&&e.useWeb&&!e.webStarted&&!this.webOwner&&this.runWeb(e)},0)},this.web.onError=(e,t)=>{(e===`network`||e===`service-not-allowed`)&&(this.webBrokenAt=performance.now());let n=this.webOwner;this.webOwner=null,n?.resolveWeb?.(Ci),n&&(n.useWeb=!1,n.webError=t,n.useDevice&&this.asr.state!==`unavailable`||n.useServer?n===this.current&&this.capture.open&&this.goLive(n):(this.onError?.(e,t),this.drop(n)))}}static browserSupported(){return hi.supported()}get deviceOn(){return!this.arabic&&(this.engine===`device`||this.engine===`auto`&&/^en\b/i.test(this.lang))}get arabic(){return/^ar\b/i.test(this.lang)}get serverOn(){return this.arabic&&this.engine!==`browser`&&this.server.langs.has(`ar`)}get supported(){let t=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia;return this.engine===`device`?t&&(!this.arabic||this.serverOn):e.browserSupported()||(this.deviceOn||this.serverOn)&&t}level(){return this.capture.sample()}warmUp(){this.deviceOn&&this.asr.load()}sync(){let e=this.current?this.current.live?`listening`:`starting`:this.pending?`finishing`:`idle`;e!==this.state&&(this.state=e,this.onState?.(e))}async start(t={}){if(this.current)return!0;let n=performance.now(),r={id:++this.seq,pressAt:n,liveAt:0,releasedAt:0,endCap:1/0,handsFree:!!t.handsFree,live:!1,useDevice:this.deviceOn,useServer:this.serverOn,useWeb:this.engine!==`device`&&e.browserSupported()&&!(this.engine===`auto`&&(this.deviceOn||this.serverOn)&&n-this.webBrokenAt<6e4),webStarted:!1,webStopped:!1,web:null,resolveWeb:null,webWords:[],webError:null,timers:[]},i=this.lastReleased;i&&n<i.releasedAt+_i&&(i.endCap=n,this.endWeb(i)),this.current=r,this.sync();let a=this.capture.start();r.useDevice&&this.asr.load(),r.useWeb&&(r.web=new Promise(e=>r.resolveWeb=e),this.webOwner||this.runWeb(r));let o=await a;return this.current===r?!o&&!r.useWeb?(this.onError?.(`audio-capture`,this.capture.error??`No microphone available.`),this.drop(r),!1):(o&&(r.useDevice||r.useServer)||!r.useWeb?this.goLive(r):r.timers.push(setTimeout(()=>this.goLive(r),1500)),r.useDevice&&!r.useWeb&&this.startPartials(r),this.watchSilence(r),!0):r.releasedAt>0}runWeb(e){this.web.lang=this.lang,this.webOwner=e,e.webStarted=!0,this.web.start()||(this.webOwner=null,e.useWeb=!1,e.resolveWeb?.(Ci),e===this.current&&(this.capture.open||e.useDevice)&&this.goLive(e))}endWeb(e){this.webOwner!==e||e.webStopped||(e.webStopped=!0,this.web.stop())}goLive(e){this.current!==e||e.live||(e.live=!0,e.liveAt=performance.now(),this.sync())}stop(){let e=this.current;if(!e)return;e.releasedAt=performance.now(),e.timers.forEach(clearTimeout),e.timers=[],this.current=null,this.lastReleased=e,this.pending++,this.sync();let t=this.gen;setTimeout(()=>void this.finish(e,t),_i)}setHandsFree(e){this.current&&(this.current.handsFree=e)}cancel(){this.gen++;let e=this.current;e&&this.drop(e),this.webOwner&&(this.webOwner.resolveWeb?.(Ci),this.webOwner=null,this.web.cancel()),this.pending=0,this.sync()}drop(e){e.timers.forEach(clearTimeout),e.timers=[],this.webOwner===e&&(this.webOwner=null,this.web.cancel()),e.resolveWeb?.(Ci),this.current===e&&(this.current=null),this.sync()}startPartials(e){e.timers.push(setInterval(async()=>{if(this.current!==e||!e.live||this.asr.state!==`ready`)return;let t=e.pressAt-gi,n=performance.now(),r=this.capture.voiced(t,n,e.pressAt);if(!r)return;let i=await this.asr.partial(this.capture.slice(Math.max(t,r.start-250),n));i&&this.current===e&&Vr(i)&&this.onWords?.($r(i,r.start,r.end),!0)},700))}watchSilence(e){e.timers.push(setInterval(()=>{if(this.current!==e||!e.live||!e.handsFree)return;let t=performance.now(),n=e.webWords.at(-1)?.t??0,r=this.capture.open?this.capture.lastVoice:0,i=Math.max(n,r),a=i>e.pressAt;a&&t-i>this.autoStopMs?this.stop():!a&&t-e.liveAt>8e3&&(this.drop(e),this.onNothing?.())},100))}modelReady(e){return this.asr.state===`ready`?Promise.resolve(!0):wi(this.asr.load(),e).then(e=>e===!0)}async finish(e,t){try{if(t!==this.gen)return;let n=e.pressAt-gi,r=Math.min(e.releasedAt+_i,e.endCap);this.endWeb(e),this.capture.touch();let i=this.capture.open?this.capture.voiced(n,r,e.pressAt):null;if(e.useServer)return await this.finishOnServer(e,t,n,r,i);let a=i?i.end-i.start:0,o=e.useDevice&&!!i&&this.asr.state!==`unavailable`,s=()=>{let t=this.capture.slice(Math.max(n,i.start-250),Math.min(r,i.end+300));return t.length<3200?Promise.resolve(null):this.modelReady(e.useWeb?4e3:3e4).then(n=>n?this.asr.final(e.id,t):null)},c=o&&(!e.useWeb||a<=yi)?s():null,l=e.web&&e.webStarted?await wi(e.web,bi)??Ci:Ci;!c&&o&&!l.alternatives.length&&(c=s());let u=c?await c:null;if(t!==this.gen)return;let d=l.alternatives.map((e,t)=>({text:e,source:`browser`,rank:t})),f=null,p=!!u&&d.length>0&&Nr(d[0].text,u.text);if(u&&!p){u.text&&Vr(u.text,u.score,!d.length&&e.webStarted)&&d.push({text:u.text,source:`device`,rank:0}),f={},d.some(e=>e.source===`device`)&&(f[u.text]=u.score);let n=[];for(let e of d)if(!Jr(e.text))for(let t of qr(e.text))!d.some(e=>e.text===t)&&!n.some(e=>e.text===t)&&n.push({text:t,source:`variant`,rank:0,from:e});let r=[...l.alternatives,...n.map(e=>e.text)],i=r.length?await this.asr.score(e.id,r):{};if(t!==this.gen)return;i?(Object.assign(f,i),d.push(...n)):f=null;let o=f&&Qr(d,f);if(f&&a<vi&&!(o&&Jr(o.text))){let n=await this.asr.score(e.id,jr,!0);if(t!==this.gen)return;for(let[e,t]of Object.entries(n??{}))d.some(t=>t.text===e)||(d.push({text:e,source:`command`,rank:0}),f[e]=t)}}let m=p?d[0]:Qr(d,f);this.debug={candidates:d.map(({from:e,...t})=>({...t,...e?{from:{...e,from:void 0}}:{}})),scores:f,chosen:m?.text??null};let h={start:i?.start??e.pressAt,end:i?.end??r},g={span:h,browser:l.alternatives,browserError:e.webError,device:u?.text??``,loudness:this.capture.peak(n,r),ms:Math.round(performance.now()-e.releasedAt)};if(!m){this.onFinal?.({text:``,words:[],aligned:!1,source:`browser`,...g});return}let _=!i&&m.source===`browser`&&m.rank===0&&l.words.length>0,v=_?l.words:$r(m.text,h.start,h.end);this.onFinal?.({text:m.text,words:v,aligned:!_,source:m.source,...g})}finally{t===this.gen&&(this.pending=Math.max(0,this.pending-1)),this.sync()}}async finishOnServer(e,t,n,r,i){let a=i?this.capture.slice(Math.max(n,i.start-250),Math.min(r,i.end+300)):null,o=a&&a.length>=3200?this.server.transcribe(a,`ar`):Promise.resolve(null),s=e.web&&e.webStarted?await wi(e.web,bi)??Ci:Ci,c=await wi(o,15e3)??null;if(t!==this.gen)return;let l=ei(s.alternatives,c?.text??``,e=>!!ut(e)||Jr(e));this.debug={candidates:[...s.alternatives.map((e,t)=>({text:e,source:`browser`,rank:t})),...c?.text?[{text:c.text,source:`device`,rank:0}]:[]],scores:null,chosen:l?.text??null};let u={start:i?.start??e.pressAt,end:i?.end??r},d={span:u,browser:s.alternatives,browserError:e.webError,device:c?.text??``,loudness:this.capture.peak(n,r),ms:Math.round(performance.now()-e.releasedAt)};l?this.onFinal?.({text:l.text,words:$r(l.text,u.start,u.end),aligned:!0,source:l.source,...d}):this.onFinal?.({text:``,words:[],aligned:!1,source:`browser`,...d})}},Di={anthropic:[{id:`claude-opus-5-5`,label:`Claude Opus 5.5`,tier:`top`,vision:!0,tools:!0,price:{input:4,output:20,cacheRead:.2,cacheWrite:5},note:`Best results`},{id:`claude-sonnet-5-5`,label:`Claude Sonnet 5.5`,tier:`balanced`,vision:!0,tools:!0,price:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},note:`Fast and capable`},{id:`claude-haiku-5-5`,label:`Claude Haiku 5.5`,tier:`fast`,vision:!0,tools:!0,price:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,longAbove:1e5,long:{input:.5,output:2.5,cacheRead:.05,cacheWrite:.625}},note:`Fastest, lightest`},{id:`claude-fable-5-1`,label:`Claude Fable 5.1`,tier:`top`,vision:!0,tools:!0,price:{input:10,output:50,cacheRead:.25,cacheWrite:12.5},note:`Most capable, priciest`}],openai:[{id:`gpt-6.1-sol`,label:`GPT-6.1 Sol`,tier:`top`,vision:!0,tools:!0,price:{input:2,output:10,cacheRead:.1},note:`Best value at the top`},{id:`gpt-6-astra`,label:`GPT-6 Astra`,tier:`top`,vision:!0,tools:!0,price:{input:10,output:50,cacheRead:1},note:`Most capable, priciest`},{id:`gpt-5.4-mini`,label:`GPT-5.4 mini`,tier:`balanced`,vision:!0,tools:!0,price:{input:.75,output:4.5,cacheRead:.075}},{id:`gpt-6-luna`,label:`GPT-6 Luna`,tier:`fast`,vision:!0,tools:!0,price:{input:.1,output:.5,cacheRead:.01},note:`Fastest, lightest`}],gemini:[{id:`gemini-4-argon`,label:`Gemini 4 Argon`,tier:`top`,vision:!0,tools:!0,price:{input:2,output:10,cacheRead:.1},note:`Best results`},{id:`gemini-3.8-flash`,label:`Gemini 3.8 Flash`,tier:`balanced`,vision:!0,tools:!0,price:{input:.75,output:3.75,cacheRead:.075}},{id:`gemini-3.5-flash-lite`,label:`Gemini 3.5 Flash-Lite`,tier:`fast`,vision:!0,tools:!0,price:{input:.3,output:2.5,cacheRead:.03}},{id:`gemini-3.1-flash-lite`,label:`Gemini 3.1 Flash-Lite`,tier:`fast`,vision:!0,tools:!0,price:{input:.25,output:1.5,cacheRead:.025},note:`Cheapest`}],"claude-code":[{id:`opus`,label:`Opus (latest)`,tier:`top`,vision:!0,tools:!0,price:{input:4,output:20,cacheRead:.2,cacheWrite:5}},{id:`sonnet`,label:`Sonnet (latest)`,tier:`balanced`,vision:!0,tools:!0,price:{input:2,output:10,cacheRead:.1,cacheWrite:2.5}},{id:`haiku`,label:`Haiku (latest)`,tier:`fast`,vision:!0,tools:!0,price:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125}}],codex:[{id:`gpt-6.1-sol`,label:`GPT-6.1 Sol`,tier:`top`,vision:!0,tools:!0,price:{input:2,output:10,cacheRead:.1}},{id:`gpt-5.4-mini`,label:`GPT-5.4 mini`,tier:`balanced`,vision:!0,tools:!0,price:{input:.75,output:4.5,cacheRead:.075}}],"gemini-cli":[{id:`gemini-4-argon`,label:`Gemini 4 Argon`,tier:`top`,vision:!0,tools:!0,price:{input:2,output:10,cacheRead:.1}},{id:`gemini-3.8-flash`,label:`Gemini 3.8 Flash`,tier:`balanced`,vision:!0,tools:!0,price:{input:.75,output:3.75,cacheRead:.075}}]},Oi={"deepseek-chat":{input:.28,output:.42,cacheRead:.028},"deepseek-v4-flash":{input:.3,output:1.2,cacheRead:.006},"deepseek-v4-pro":{input:1.32,output:3.96,cacheRead:.044},"openai/gpt-oss-120b":{input:.15,output:.6,cacheRead:.075},"qwen/qwen3.8-27b":{input:.8,output:4},"mistral-medium-latest":{input:1.5,output:7.5,cacheRead:.15},"mistral-large-latest":{input:.5,output:1.5,cacheRead:.05},"devstral-latest":{input:.4,output:2,cacheRead:.04},"codestral-latest":{input:.3,output:.9,cacheRead:.03},"grok-code-fast-1":{input:1,output:2,cacheRead:.2}},ki=[{id:`openrouter`,label:`OpenRouter`,baseUrl:`https://openrouter.ai/api/v1`,keyUrl:`https://openrouter.ai/keys`,note:`One key for hundreds of models from every major lab. Reports the exact cost of each call.`},{id:`ollama`,label:`Ollama`,baseUrl:`http://localhost:11434/v1`,keyUrl:null,local:!0,note:`Models running on this computer. Free and private; changes need a model that can call tools.`},{id:`lmstudio`,label:`LM Studio`,baseUrl:`http://localhost:1234/v1`,keyUrl:null,local:!0,note:`Models running on this computer through LM Studio’s local server.`},{id:`groq`,label:`Groq`,baseUrl:`https://api.groq.com/openai/v1`,keyUrl:`https://console.groq.com/keys`,models:[{id:`openai/gpt-oss-120b`,label:`gpt-oss-120b`,tier:`balanced`,tools:!0,price:Oi[`openai/gpt-oss-120b`]}],note:`Very fast open models.`},{id:`deepseek`,label:`DeepSeek`,baseUrl:`https://api.deepseek.com/v1`,keyUrl:`https://platform.deepseek.com/api_keys`,models:[{id:`deepseek-v4-pro`,label:`DeepSeek V4 Pro`,tier:`top`,tools:!0,price:Oi[`deepseek-v4-pro`]},{id:`deepseek-v4-flash`,label:`DeepSeek V4 Flash`,tier:`fast`,tools:!0,vision:!0,price:Oi[`deepseek-v4-flash`]}]},{id:`mistral`,label:`Mistral`,baseUrl:`https://api.mistral.ai/v1`,keyUrl:`https://console.mistral.ai/api-keys`,models:[{id:`devstral-latest`,label:`Devstral`,tier:`balanced`,tools:!0,price:Oi[`devstral-latest`]},{id:`mistral-medium-latest`,label:`Mistral Medium`,tier:`top`,tools:!0,vision:!0,price:Oi[`mistral-medium-latest`]}]},{id:`xai`,label:`xAI`,baseUrl:`https://api.x.ai/v1`,keyUrl:`https://console.x.ai`,models:[{id:`grok-code-fast-1`,label:`Grok Code Fast`,tier:`fast`,tools:!0,vision:!0,price:Oi[`grok-code-fast-1`]}]},{id:`custom`,label:`Other (OpenAI-compatible)`,baseUrl:``,keyUrl:null,note:`Any server that speaks the OpenAI Chat Completions API.`}];function Ai(e){if(!e)return`AI`;for(let t of Object.values(Di)){let n=t?.find(t=>t.id===e||e.startsWith(`${t.id}-`)||e.endsWith(`/${t.id}`));if(n&&!/latest|default/i.test(n.label))return n.label}let t=/claude-(\w+)-(\d+)-(\d+)/.exec(e);return t?`Claude ${t[1][0].toUpperCase()}${t[1].slice(1)} ${t[2]}.${t[3]}`:e}function ji(e){switch(e?.connection){case`anthropic`:case`claude-code`:return`Claude`;case`openai`:case`codex`:return`GPT`;case`gemini`:case`gemini-cli`:return`Gemini`;default:return`AI`}}function Mi(){return ji(hr(e=>e.status?.ai.who))}var P=()=>cr.getState(),Ni=e=>e instanceof HTMLElement&&!!e.closest(`button, select, [role="switch"], [role="tab"], [role="combobox"], [role="option"], [role="slider"], [role="radio"]`),Pi=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))&&!e.readOnly,Fi=50,Ii=380,Li=e=>[e.selection?.id,...e.pins.map(e=>e.id),...e.previewTargets.map(e=>e.el.id)].join(),Ri=class{bridge=new Le;voice=new Ei;track=new Bt;replayer=new vn({bridge:this.bridge,connected:()=>N().app.connected,connections:()=>this.appLoads,appUrl:()=>N().app.url||N().status?.target.url||``,enterUse:()=>this.useWhilePlaying(),show:e=>M({replay:e}),point:(e,t)=>this.guideTo(e,t),openReport:e=>A.openReport(e),notify:e=>this.notify(e,`warn`)});autopilot=new cn({bridge:this.bridge,connected:()=>N().app.connected,connections:()=>this.appLoads,appUrl:()=>N().app.url||N().status?.target.url||``,enterUse:()=>this.useWhilePlaying(),show:e=>M({autopilot:e}),point:(e,t)=>this.guideTo(e,t),openReport:e=>A.openReport(e),notify:e=>this.notify(e,`warn`)});guide=null;useWhilePlaying(){let e=N().mode;return e!==`use`&&this.setMode(`use`),()=>{N().mode===`use`&&e!==`use`&&this.setMode(e)}}guideTo(e,t){this.wake();let n=this.geom();if(!e||!n){this.guide=null;return}let r=n.left+(e.rect.x+e.rect.w/2)*n.scale,i=n.top+(e.rect.y+e.rect.h/2)*n.scale;t&&this.ripples.push({x:r,y:i,t:performance.now(),kind:`replay`}),this.guide={x:r,y:i,fromX:this.guide?.x??r-60,fromY:this.guide?.y??i+80,at:performance.now()}}appLoads=0;changesAsked=0;ripples=[];dryRun=null;started=!1;frame=null;canvas=null;scale=1;mouse=null;appMouse=null;raf=0;later=null;frames=0;clearedProbe=!1;lastProbe=null;trackedAt=0;painted=!1;spaceDownAt=0;spaceConsumed=!1;noticeTimer=null;drafted=null;lastMouseAt=0;resolving=new Set;colors={};cleanups=[];start(){if(this.started)return;this.started=!0;let e=P();lr(e.theme),fr(e.voice.sounds),this.readColors(),this.applyVoiceSettings();let t=setTimeout(()=>this.voice.warmUp(),2500);this.cleanups.push(()=>clearTimeout(t)),this.cleanups.push(cr.subscribe((e,t)=>{e.theme!==t.theme&&(lr(e.theme),requestAnimationFrame(()=>this.readColors())),e.voice.sounds!==t.voice.sounds&&fr(e.voice.sounds),e.voice!==t.voice&&(this.applyVoiceSettings(),(e.voice.engine!==t.voice.engine||e.voice.lang!==t.voice.lang)&&this.voice.warmUp())}));let n=matchMedia(`(prefers-color-scheme: dark)`),r=()=>{P().theme===`system`&&(lr(`system`),requestAnimationFrame(()=>this.readColors()))};n.addEventListener(`change`,r),this.cleanups.push(()=>n.removeEventListener(`change`,r)),this.wireVoice(),this.wireBridge(),this.cleanups.push(d({progress:e=>{let t=e,n=N().request;n&&n.id===t.requestId&&n.step!==`Stopping`&&M({request:{...n,step:t.step,detail:t.detail}})},install:e=>{let t=e.line,n=N().recorder;M({recorder:{...n,installLog:[...n.installLog,t].slice(-200)}})},speech:e=>A.serverEvent(`speech`,e),session:e=>A.serverEvent(`session`,e),apps:e=>T.serverEvent(e),usage:e=>{let t=N().status;t&&M({status:{...t,ai:{...t.ai,usage:e}}})},changes:()=>void this.refreshChanges().then(()=>{let e=new Set(N().changes.filter(e=>e.status!==`preview`).map(e=>e.id)),t=N().previewTargets.filter(t=>!e.has(t.changeId));t.length!==N().previewTargets.length&&M({previewTargets:t})}),change:e=>{let{change:t,via:n}=e;this.upsertChange(t),this.refreshAfterEdit(),j(`send`),this.notify(`${n} proposed a change: ${t.title}. Keep or undo it.`,`info`)}},e=>{e&&T.reconnected().then(()=>{A.resync(),this.refreshStatus(),this.refreshChanges()})}));let i=e=>{let t=this.voice.server.langs;t.clear(),e&&e.runtime!==`missing`&&e.runtime!==`failed`&&(e.active.ar&&t.add(`ar`),e.active.en&&t.add(`en`))};this.cleanups.push(tr.subscribe((e,t)=>e.speech!==t.speech&&i(e.speech))),A.init({frame:()=>this.frame,appConnected:()=>N().app.connected,appUrl:()=>N().app.url||N().status?.target.url||``,bridgeSession:(e,t,n,r)=>this.bridge.session(e,t,n,r),bridgeMark:(e,t)=>this.bridge.mark(e,t),enterUse:()=>{let e=N().mode;return e!==`use`&&this.setMode(`use`),()=>{N().mode===`use`&&e!==`use`&&this.setMode(e)}},notify:(e,t)=>this.notify(e,`ok`,t),locate:async e=>(await this.bridge.locator(e))?.locator??null}),this.cleanups.push(hr.subscribe((e,t)=>e.selection!==t.selection||e.pins!==t.pins||e.app.url!==t.app.url?this.pushContext():void 0));let a=e=>this.onKeyDown(e),o=e=>this.onKeyUp(e),s=()=>this.releaseTalk();window.addEventListener(`keydown`,a),window.addEventListener(`keyup`,o),window.addEventListener(`blur`,s),this.cleanups.push(()=>{window.removeEventListener(`keydown`,a),window.removeEventListener(`keyup`,o),window.removeEventListener(`blur`,s)}),T.init(e=>this.appSwitched(e)).then(()=>this.restoreRecorder()),this.cleanups.push(hr.subscribe((e,t)=>{e.recorder!==t.recorder&&this.keepRecorder()})),this.refreshStatus(),this.refreshChanges().then(()=>this.announceWaiting()),this.cleanups.push(hr.subscribe((e,t)=>{(e.selection!==t.selection||e.pins!==t.pins||e.previewTargets!==t.previewTargets)&&Li(e)!==Li(t)&&this.wake()})),this.wake()}dispose(){this.started=!1,this.rest();for(let e of this.cleanups.splice(0))e();this.bridge.detach()}readColors(){let e=getComputedStyle(document.documentElement);for(let t of[`human`,`ai`,`ok`,`bad`,`fg`,`fg-2`,`inverse`,`glass`])this.colors[t]=e.getPropertyValue(`--${t}`).trim()}attachFrame(e,t){!e||!t?(this.bridge.detach(),this.frame=null):(this.frame=e,this.bridge.attach(e,t))}frameLoaded(){M({app:{...N().app,connected:!1}}),this.bridge.sayHello()}attachCanvas(e){this.canvas=e,this.painted=!1,e&&(e.style.visibility=`hidden`),this.wake()}setScale(e){this.scale=e||1}geom(){if(!this.frame)return null;let e=this.frame.getBoundingClientRect();return e.width?{left:e.left,top:e.top,scale:this.scale,w:e.width,h:e.height}:null}toApp(e,t){let n=this.geom();return n?{x:(e-n.left)/n.scale,y:(t-n.top)/n.scale}:null}wireBridge(){let e=this.bridge;e.onReady=({url:t,title:n})=>{this.appLoads++,M({app:{...N().app,connected:!0,url:t,title:n,outdated:void 0}});let r=N().mode;e.trackMouse(r!==`edit`),e.record(r===`record`),e.forwardKeys(!0),this.reresolveAll()},e.onOutdated=e=>M({app:{...N().app,connected:!1,outdated:e}}),e.onNavigated=({url:e,title:t})=>{M({app:{...N().app,url:e,title:t}}),this.recordedPage(e)},e.onProbe=e=>{let t=N();(!_r(t.hover,e.hit)||t.snapped!==e.snapped)&&M({hover:e.hit,snapped:e.snapped}),t.hover?.id!==e.hit?.id&&A.pointed(e.hit,`mouse`),this.track.push(performance.now(),e.hit),this.applyTracked(e.tracked)},e.onMouse=e=>{this.appMouse=e,this.wake(),e&&(this.lastMouseAt=performance.now())},e.onRecorded=e=>{if(N().mode!==`record`)return;let t=N().recorder,[n]=Ie([{kind:e.kind,locator:e.locator,description:e.description,value:`value`in e?e.value:void 0,key:`key`in e?e.key:void 0,...e.kind===`fill`&&e.secret?{secret:e.secret}:{},...e.kind===`fill`&&e.select?{select:e.select,values:e.values}:{},...e.kind===`fill`&&e.checked!==void 0?{checked:e.checked}:{}}]);M({recorder:{...t,steps:[...t.steps,n]}})},e.onKey=(e,t)=>{e===`Space`?t?this.pressTalk():this.releaseTalk():e===`Escape`&&t?this.stop(`key`):e===`Mark`&&t&&A.mark(``,`shortcut`)},e.onSession=e=>A.bridgeSaid(e.id),e.onMoment=e=>A.moment(e)}trackedIds(){let e=N(),t=new Set;e.selection&&t.add(e.selection.id);for(let n of e.pins)t.add(n.id);for(let n of e.previewTargets)t.add(n.el.id);return[...t]}applyTracked(e){let t=N(),n=t=>{if(!(String(t.id)in e))return t;let n=e[t.id];return n?n.x===t.rect.x&&n.y===t.rect.y&&n.w===t.rect.w&&n.h===t.rect.h?t:{...t,rect:n}:`gone`},r=!1,i={};if(t.selection){let e=n(t.selection);e===`gone`?this.resolveLater(t.selection):e!==t.selection&&(i.selection=e,r=!0)}let a=t.pins.map(e=>{let t=n(e);return t===`gone`?(this.resolveLater(e),e):(t!==e&&(r=!0),t)});r&&(i.pins=a);let o=!1,s=t.previewTargets.map(e=>{let t=n(e.el);return t===`gone`?(this.resolveLater(e.el),e):(t!==e.el&&(o=!0),t===e.el?e:{...e,el:t})});o&&(i.previewTargets=s),(r||o)&&M(i)}resolveLater(e){this.resolving.has(e.id)||(this.resolving.add(e.id),setTimeout(async()=>{let t=e.src?await this.bridge.resolve(e.src,e.index):null;this.replaceEl(e.id,t),setTimeout(()=>this.resolving.delete(e.id),400)},120))}replaceEl(e,t){let n=N();M({selection:n.selection?.id===e?t:n.selection,pins:n.pins.flatMap(n=>n.id===e?t?[t]:[]:[n]),previewTargets:n.previewTargets.flatMap(n=>n.el.id===e?t?[{...n,el:t}]:[]:[n])}),n.selection?.id===e&&t?.src&&t.src!==n.selection.src&&this.loadInspect(t)}async reresolveAll(){let e=N(),t=async e=>e.src?await this.bridge.resolve(e.src,e.index):null;M({selection:e.selection?await t(e.selection):null,pins:(await Promise.all(e.pins.map(t))).filter(e=>!!e),previewTargets:(await Promise.all(e.previewTargets.map(async e=>({...e,el:await t(e.el)})))).filter(e=>!!e.el),hover:null})}refreshAfterEdit(){let e=N();e.status?.app?.framework===`static`&&e.app.url&&this.bridge.goto(e.app.url);for(let e of[300,900,2e3])setTimeout(()=>void this.refreshTargets(),e)}async refreshTargets(){let e=N(),t=async e=>await this.bridge.describe(e.id)??(e.src?await this.bridge.resolve(e.src,e.index):null),n=e.selection?await t(e.selection):null,r=(await Promise.all(e.pins.map(t))).filter(e=>!!e),i=(await Promise.all(e.previewTargets.map(async e=>({...e,el:await t(e.el)})))).filter(e=>!!e.el),a=N();M({selection:a.selection?.id===e.selection?.id?n:a.selection,pins:a.pins===e.pins?r:a.pins,previewTargets:a.previewTargets===e.previewTargets?i:a.previewTargets});let o=N().selection;o&&this.loadInspect(o,!0)}wake=()=>{!this.raf&&this.started&&(this.later&&clearTimeout(this.later),this.later=null,this.raf=requestAnimationFrame(this.loop))};rest(){cancelAnimationFrame(this.raf),this.raf=0,this.later&&clearTimeout(this.later),this.later=null}loop=e=>{this.raf=0,this.frames++;let t=this.pointer(),n=t?t.source:null;N().pointer!==n&&M({pointer:n});let r=this.trackedIds(),i=this.geom(),a=!1;if(t&&t.inApp&&i){let n=(t.x-i.left)/i.scale,o=(t.y-i.top)/i.scale,s=this.lastProbe;a=!!s&&!r.length&&Math.abs(n-s.x)<.75&&Math.abs(o-s.y)<.75&&e-s.t<200&&s.deep===t.deep,a||(this.bridge.probe(n,o,t.radius/i.scale,t.deep,r),this.lastProbe={x:n,y:o,t:e,deep:t.deep}),this.clearedProbe=!1}else(!this.clearedProbe||r.length&&e-this.trackedAt>=Fi)&&(this.lastProbe=null,this.bridge.probe(null,null,0,!1,r),this.clearedProbe=!0,this.trackedAt=e);this.draw(e),this.ripples.length>0||this.guide&&e-this.guide.at<Ii||t?.inApp&&!a?this.raf=requestAnimationFrame(this.loop):(t?.inApp||r.length)&&(this.later=setTimeout(this.wake,t?.inApp?200:Fi))};pointer(){let e=N().mode;if(e===`edit`&&this.mouse)return{...this.mouse,source:`mouse`,radius:0,deep:this.mouse.alt,inApp:!0};if(e!==`edit`&&this.appMouse){let e=this.geom();return e?{x:e.left+this.appMouse.x*e.scale,y:e.top+this.appMouse.y*e.scale,source:`mouse`,radius:0,deep:!1,inApp:!0}:null}return null}draw(e){let t=this.canvas;if(!t)return;if(!this.ripples.length&&!this.guide){this.painted&&=(t.getContext(`2d`)?.clearRect(0,0,t.width,t.height),t.style.visibility=`hidden`,!1);return}this.painted||(t.style.visibility=`visible`),this.painted=!0;let n=Math.min(2,window.devicePixelRatio||1),r=window.innerWidth,i=window.innerHeight;(t.width!==Math.round(r*n)||t.height!==Math.round(i*n))&&(t.width=Math.round(r*n),t.height=Math.round(i*n));let a=t.getContext(`2d`);if(!a)return;a.setTransform(n,0,0,n,0,0),a.clearRect(0,0,r,i);for(let t=this.ripples.length-1;t>=0;t--){let n=this.ripples[t],r=(e-n.t)/450;r>=1?this.ripples.splice(t,1):(a.globalAlpha=(1-r)*.9,a.strokeStyle=this.colors.ai||`#3dd6f5`,a.lineWidth=2,a.beginPath(),a.arc(n.x,n.y,10+r*24,0,Math.PI*2),a.stroke())}let o=this.guide;if(o){let t=1-(1-Math.min(1,(e-o.at)/Ii))**3,n=o.fromX+(o.x-o.fromX)*t,r=o.fromY+(o.y-o.fromY)*t,i=this.colors.ai||`#3dd6f5`;a.globalAlpha=1,a.fillStyle=i,a.strokeStyle=this.colors.inverse||`#000`,a.lineWidth=1.5,a.beginPath(),a.moveTo(n,r),a.lineTo(n+3.5,r+17),a.lineTo(n+7.5,r+12.5),a.lineTo(n+14,r+13),a.closePath(),a.fill(),a.stroke()}a.globalAlpha=1}mouseMove(e,t,n){this.mouse={x:e,y:t,alt:n},this.lastMouseAt=performance.now(),this.wake()}mouseLeave(){this.mouse=null,this.wake()}async mouseClick(e,t,n,r,i=1){if(i>1)return;let a=this.toApp(e,t),o=(async()=>{let e=(a?await this.bridge.probeAt(a.x,a.y,0,r):null)??N().hover,t={selection:N().selection,pins:N().pins};this.setPicked(n?Qt(t,e):Zt(t,e))})();this.picking=o;try{await o}finally{this.picking===o&&(this.picking=null)}}picking=null;wheel(e,t){let n=this.mouse;if(!n)return;let r=this.toApp(n.x,n.y);r&&this.bridge.scroll(r.x,r.y,e/this.scale,t/this.scale)}select(e){this.setPicked(Jt(e?[e]:[]))}setPicked(e){let t=N(),n=e.selection,r=n?.id===t.selection?.id,i=r||n?.src&&t.inspect?.file&&n.src.startsWith(t.inspect.file+`:`)?t.inspect:null;M({selection:n,pins:e.pins,inspect:n?i:null}),n&&(!r||!t.inspect)&&this.loadInspect(n)}toggleSelected(e){this.setPicked(Qt({selection:N().selection,pins:N().pins},e))}deselect(e){let t=N();this.setPicked(Jt(qt(t).filter(t=>t.id!==e),t.selection))}clearTargets(){M({selection:null,pins:[],inspect:null})}async step(e){let t=N().selection;if(!t)return this.notify(e===`parent`?`Select something first, then go up to what contains it.`:`Select something first.`,`info`);let n=await this.bridge.step(t.id,e);if(!n)return this.notify({parent:`That’s already the outermost element.`,child:`There’s nothing inside it to select.`,next:`That’s the last one.`,prev:`That’s the first one.`}[e],`info`);let r=N();r.selection?.id===t.id&&this.setPicked($t(r,t,n))}selectParent(){return this.step(`parent`)}async selectCalled(e,t,n){let r=await this.bridge.find(n?.id??null,e,t);if(!r){let r=n?t===`in`?`inside it`:t===`out`?`around it`:`around or inside it`:`on the page`;return this.notify(`Couldn’t find a “${e}” ${r}.`,`info`)}let i=N();i.selection&&n?.id===i.selection.id?this.setPicked($t(i,i.selection,r)):this.select(r)}traceEl(e){return u.post(`/inspect`,{ref:{src:e.src,frames:e.frames,hint:e.hint,tag:e.tag,text:e.text},pageUrl:N().app.url})}async loadInspect(e,t=!1){t||M({inspectLoading:!0});try{let{result:t}=await this.traceEl(e);N().selection?.id===e.id&&M({inspect:t})}catch{}finally{t||M({inspectLoading:!1})}}async setProp(e,t){let n=N().selection;if(n?.src)try{let r=await u.post(`/props`,{src:n.src,prop:e,value:t});this.applyResult(r,`${e}: ${t}`,[n])}catch(e){this.fail(e)}}async openInEditor(e){let t=e??N().selection??N().hover;if(!t)return this.notify(`Point at or select something from your app first.`,`info`);let n=N().inspect,r=n&&t.id===N().selection?.id?n:null;if(!r)try{r=(await this.traceEl(t)).result}catch{r=null}if(!r)return this.notify(`Couldn’t find that element’s source file.`,`warn`);await this.openFile(r.absPath,r.line,r.col)}async openFile(e,t=1,n=1){let r=`${e.split(`/`).slice(-2).join(`/`)}:${t}`,i=await fetch(`/__open-in-editor?file=${encodeURIComponent(`${e}:${t}:${n}`)}`,{method:`POST`}).catch(()=>null);if(i?.ok)return this.notify(`Opening ${r} in your editor…`,`info`);let a=(await i?.json().catch(()=>null))?.error;this.notify(a??`Couldn’t open ${r} in your editor.`,`warn`)}openRelative(e,t=1){let n=N().status?.target.root;n&&this.openFile(`${n.replace(/\/$/,``)}/${e}`,t,1)}async copyLocator(e){let t=await this.bridge.locator(e.id);if(!t)return this.notify(`Couldn’t build a locator for that element.`,`warn`);await navigator.clipboard?.writeText(t.locator.code).catch(()=>void 0),this.notify(`Copied ${t.locator.code}`,`ok`)}setMode(e){if(N().mode!==e&&(this.mouse=null,this.appMouse=null,this.wake(),M({mode:e,hover:null}),this.bridge.trackMouse(e!==`edit`),this.bridge.record(e===`record`),e===`record`)){let e=N().recorder;!e.steps.length&&!e.expectations.length&&M({recorder:{...mr,startUrl:N().app.url||N().status?.target.url||null}}),P().setUi({panelOpen:!0,panelTab:`test`})}}newRecording(e=!1){let t=N().status?.target.frameUrl||N().status?.target.url||null;e&&t?(M({recorder:{...mr,startUrl:t}}),this.bridge.goto(t)):M({recorder:{...mr,startUrl:N().app.url||null}})}awayFromStart(){let e=N().status?.target.frameUrl||N().status?.target.url,t=N().app.url;if(!e||!t)return!1;let n=e=>{try{let t=new URL(e);return`${t.pathname.replace(/\/+$/,``)}${t.hash.replace(/^#\/?$/,``)}`}catch{return e}};return n(e)!==n(t)}removeStep(e){let t=N().recorder,n=t.expectations.map(t=>t.after!==void 0&&t.after>e?{...t,after:t.after-1}:t);M({recorder:{...t,steps:t.steps.filter((t,n)=>n!==e),expectations:n,spec:null,run:null}})}recordedPage(e){let t=N().recorder;if(N().mode!==`record`||!t.startUrl)return;let n=e=>{try{let t=new URL(e);return t.hash.startsWith(`#/`)?t.hash.split(`?`)[0]:t.pathname}catch{return e}},r=[...t.steps].reverse().find(e=>e.kind===`url`||e.kind===`goto`)?.url??t.startUrl;n(e)!==n(r)&&t.steps.length&&M({recorder:{...t,steps:[...t.steps,{kind:`url`,url:e,description:`Wait for ${n(e)}`}]}})}async checkPlace(){return await this.bridge.flushRecorder(),N().recorder.steps.length}removeExpectation(e){let t=N().recorder;M({recorder:{...t,expectations:t.expectations.filter((t,n)=>n!==e)}})}async reloadApp(){M({hover:null});let{connected:e,url:t}=N().app;if(e&&t&&await this.bridge.reload(t))return M({app:{...N().app,connected:!1}});M({app:{...N().app,connected:!1,reloadKey:N().app.reloadKey+1}})}applyVoiceSettings(){let e=P().voice;this.voice.engine=e.engine,this.voice.lang=e.lang,this.voice.autoStopMs=e.autoStopMs,M({voice:{...N().voice,supported:this.voice.supported}})}wireVoice(){let e=this.voice;e.asr.onChange=(e,t)=>M({voice:{...N().voice,model:e,modelError:t}}),e.onState=e=>{let t=N().voice.state;M({voice:{...N().voice,state:e,...e===`idle`?{trigger:null,words:[],bindings:[]}:{}}}),e===`listening`&&t!==`listening`&&j(`listen`)},e.onWords=(e,t)=>{M({voice:{...N().voice,words:e.map(e=>e.text),bindings:this.bind(e,t)}})},e.onFinal=e=>{let t={text:e.text,source:e.source,browser:e.browser,browserError:e.browserError,device:e.device,loudness:e.loudness,ms:e.ms};M({voice:{...N().voice,last:t}});let n=this.talking();if(this.dryRun)return!n&&N().island.kind===`listening`&&M({island:{kind:`idle`}}),this.dryRun(e.text,e);if(!e.text.trim()){!n&&N().island.kind===`listening`&&M({island:{kind:`idle`}});return}j(`send`);let r={words:e.words,aligned:e.aligned,span:e.span};if(P().voice.review)return this.draftSpoken(e,r);this.handleUtterance(e.text,r,`voice`)},e.onError=(e,t)=>{M({voice:{...N().voice,error:t}}),j(`error`),this.notify(t,`error`)},e.onNothing=()=>this.notify(`Didn’t hear anything. Try again, a little closer to the mic.`,`info`)}bind(e,t=!1){let n=N(),r=t?0:Ut.lagMs;return Gt(e,this.track,{...Ut,lagMs:r,pins:n.pins,selection:n.selection}).map(e=>({index:e.index,word:e.word,el:e.el,via:e.via}))}draftSpoken(e,t){this.drafted=t;let n=[...new Set([...e.browser,e.device])].filter(t=>t&&t!==e.text).slice(0,3);N().island.kind===`listening`&&M({island:{kind:`idle`}}),M({draft:{text:e.text,alternatives:n,n:(N().draft?.n??0)+1}})}submitText(e){let t=e.trim(),n=this.drafted;if(this.clearDraft(),t){if(n)return void this.handleUtterance(t,{...n,words:$r(t,n.span.start,n.span.end),aligned:!0},`voice`);this.handleUtterance(t,null,`typed`)}}clearDraft(){this.drafted=null,N().draft&&M({draft:null})}startTalk(e){this.voice.supported?this.talking()||(this.noticeTimer&&clearTimeout(this.noticeTimer),this.applyVoiceSettings(),M({voice:{...N().voice,trigger:e,words:[],bindings:[],error:null},island:{kind:`listening`}}),this.voice.start({handsFree:e===`toggle`})):(this.notify(`Voice needs a microphone and Chrome, Edge or Safari. Type your request instead.`,`warn`),M({focusInput:N().focusInput+1}))}stopTalk(){this.voice.stop()}cancelTalk(e){this.voice.cancel(),M({voice:{...N().voice,state:`idle`,trigger:null,words:[],bindings:[]}}),e?this.notify(e,`info`):N().island.kind===`listening`&&M({island:{kind:`idle`}})}talking(){let e=N().voice.state;return e===`starting`||e===`listening`}toggleTalk(){this.talking()?this.stopTalk():this.startTalk(`toggle`)}pressTalk(){this.spaceDownAt=performance.now(),this.talking()&&N().voice.trigger===`toggle`?(this.spaceConsumed=!0,this.stopTalk()):(this.spaceConsumed=!1,this.startTalk(`hold`))}releaseTalk(){if(!this.spaceDownAt)return;let e=performance.now()-this.spaceDownAt;if(this.spaceDownAt=0,this.spaceConsumed){this.spaceConsumed=!1;return}let t=N().voice;this.talking()&&t.trigger===`hold`&&(e<280?(M({voice:{...t,trigger:`toggle`}}),this.voice.setHandsFree(!0)):this.stopTalk())}onKeyDown(e){if(e.defaultPrevented)return;let t=N(),n=e.metaKey||e.ctrlKey;if(n&&e.key.toLowerCase()===`k`)e.preventDefault(),M({overlay:t.overlay===`palette`?null:`palette`});else if((!t.overlay&&!On()||e.code===`Space`&&this.dryRun&&!Ni(e.target))&&!Pi(e.target)){if(e.code===`Space`&&!n&&!e.altKey)e.preventDefault(),e.repeat||this.pressTalk();else if(!e.repeat){if(e.key===`Escape`)return this.stop(`key`);if(e.key===`Enter`&&!n&&gr(t).length)e.preventDefault(),this.keep(`key`);else if(n&&e.key.toLowerCase()===`z`&&!e.shiftKey)gr(t).length&&(e.preventDefault(),this.undo(`key`));else if(!(n||e.altKey))switch(e.key){case`/`:e.preventDefault(),M({focusInput:t.focusInput+1});return;case`?`:M({overlay:`help`});return;case`e`:case`E`:return this.setMode(`edit`);case`u`:case`U`:return this.setMode(`use`);case`r`:case`R`:return this.setMode(`record`);case`m`:case`M`:A.recording&&A.mark(``,`key`);return;case`\\`:P().setUi({panelOpen:!P().ui.panelOpen});return;case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:t.selection&&!tr.getState().open&&(e.preventDefault(),this.step({ArrowUp:`parent`,ArrowDown:`child`,ArrowLeft:`prev`,ArrowRight:`next`}[e.key]));return;case`o`:case`O`:t.selection&&this.openInEditor(t.selection);return}}}}onKeyUp(e){e.code===`Space`&&this.spaceDownAt&&(e.preventDefault(),this.releaseTalk())}async handleUtterance(e,t,n){let r=e.trim();if(!r)return;if(this.picking&&await this.picking,this.dryRun)return N().island.kind===`listening`&&M({island:{kind:`idle`}}),this.dryRun(r);let i=N();M({history:[r,...i.history.filter(e=>e!==r)].slice(0,40)});let a=ut(r),o=a?.text??r;if(A.recording&&(a?.kind===`session`||/^(?:mark|flag|bookmark)(?: (?:this|that|it|here|the moment|this moment))?[.!]?$/i.test(r)))return N().island.kind===`listening`&&M({island:{kind:`idle`}}),A.mark(r,`voice`),this.notify(`Marked this moment.`,`ok`);let s=It(o,{hasFailingTest:i.recorder.run?.status===`failed`&&!!i.recorder.spec});if(A.command(r,n,s?s.kind:a?a.kind:`request`),s)return N().island.kind===`listening`&&M({island:{kind:`idle`}}),this.runCommand(s,t);if(i.mode===`record`){let e=Lt(o);if(e)return this.addExpectation(e,t)}return this.sendIntent(o,t,n)}pointedAt(e){if(e?.words.length){let t=e.aligned?0:Ut.lagMs,n=Gt(e.words,this.track,{...Ut,lagMs:t,pins:[],selection:null}).find(e=>e.el);if(n?.el)return n.el;let r=this.pointedWhile(e);if(r)return r}return N().hover}pointedWhile(e){return this.track.dwellWinner(e.span.start-300,e.span.end+150)}targetFrom(e){let t=N();if(e?.words.length){let t=this.bind(e.words,e.aligned).find(e=>e.el);if(t?.el)return t.el;let n=this.pointedWhile(e);if(n)return n}if(t.mode===`record`){if(t.hover)return t.hover;let e=this.track.dwellWinner(performance.now()-5e3,performance.now());if(e)return e}return t.selection?t.selection:t.hover?t.hover:t.pins[0]??null}async runCommand(e,t){switch(e.kind){case`keep`:return this.keep(`voice`);case`undo`:return this.undo(`voice`);case`cancel`:return this.stop(`voice`);case`parent`:return this.selectParent();case`nav`:return this.step(e.to);case`find`:{let n=N();return this.selectCalled(e.what,e.where,n.selection??(t?.words.length?this.pointedWhile(t):null)??n.hover)}case`clear`:return this.clearTargets(),this.notify(`Nothing selected.`,`info`);case`mode`:return this.setMode(e.mode),this.notify(e.mode===`record`?`Recording. Use the app, then point at what’s wrong and say what it should show.`:`${e.mode===`edit`?`Edit`:`Use`} mode.`,`info`);case`generate`:return this.generateTest();case`run`:return this.runTest();case`fix`:return this.fix(t?`voice`:`typed`);case`click`:{let e=this.targetFrom(t);if(!e)return this.notify(`Point at what to click while you say it.`,`info`);await this.bridge.click(e.rect.x+e.rect.w/2,e.rect.y+e.rect.h/2);return}case`type`:(await this.bridge.type(e.text,e.submit)).ok||this.notify(`Click a text field in the app first, then say “type …”.`,`info`);return;case`scroll`:{let t=this.geom();if(!t)return;let n=t.w/t.scale/2,r=t.h/t.scale/2,i=t.h/t.scale*.7,a=e.dir===`down`?i:e.dir===`up`?-i:e.dir===`top`?-1e6:1e6;this.bridge.scroll(n,r,0,a);return}case`reload`:return this.reloadApp();case`help`:M({overlay:`help`});return;case`open`:return this.openInEditor(this.targetFrom(t));case`select`:{let e=this.pointedAt(t);e?this.select(e):this.notify(`Point at what to select while you say it.`,`info`);return}case`add`:{let e=this.pointedAt(t);e?this.toggleSelected(e):this.notify(`Point at what to add while you say it.`,`info`);return}}}refsFor(e){let t=N(),n=[];if(e?.words.length&&(n=this.bind(e.words,e.aligned).filter(e=>e.el).map(e=>({el:e.el,role:e.via===`pin`?`pin:${e.word}`:e.word}))),!n.length){let r=e?.words.length?this.pointedWhile(e):t.hover;n=Kt(t.pins,t.selection,r).map((e,n)=>({el:e,role:t.pins.length?`pin ${n+1}`:t.selection?`selection`:`pointed`}))}let r=new Set,i=n.filter(e=>r.has(e.el.id)&&e.role===`it`?!1:(r.add(e.el.id),!0));return{refs:i.map(({el:e,role:t})=>Bi(e,t)),els:i.map(e=>e.el)}}async freshRefs(e){let{refs:t,els:n}=this.refsFor(e),r=await Promise.all(n.map(async e=>await this.bridge.describe(e.id).catch(()=>null)??e));return{refs:t.map((e,t)=>r[t]===n[t]?e:Bi(r[t],e.role)),els:r}}pointerKind(){return performance.now()-this.lastMouseAt<5e3?`mouse`:`none`}requests=new xn({started:(e,t)=>M({request:e,...t?{island:{kind:`thinking`}}:{}}),stopping:e=>{let t=N().request;t?.id===e&&M({request:{...t,step:`Stopping`,detail:void 0}})},ended:e=>{N().request?.id===e&&M({request:null})},waiting:e=>M({waiting:e}),cancel:e=>u.post(`/cancel`,{requestId:e}).catch(()=>void 0),fail:e=>this.fail(e)});appEpoch=0;ask(e){return this.requests.ask(e)||(this.notify(`3 requests are already waiting. Let them finish, or press Esc to stop them.`,`info`),Promise.resolve())}async sendIntent(e,t,n){let r=this.pointerKind(),{refs:i,els:a}=await this.freshRefs(t);return this.intent({text:e,refs:i,els:a,input:n,pointer:r,pageUrl:N().app.url})}intent(e){let t=this.appEpoch;return this.ask({text:e.text,kind:`intent`,step:`Working`,run:async(n,r)=>{try{let i=await u.post(`/intent`,{text:e.text,refs:e.refs,requestId:n,input:e.input,pointer:e.pointer,pageUrl:e.pageUrl,...e.ai?{ai:!0}:{}});this.settle(n,i,e.text,e.els,{stopped:r(),epoch:t,again:()=>void this.intent({...e,ai:!0})})}finally{this.refreshSummary()}}})}settle(e,t,n,r,i){return N().request?.id===e&&M({request:null}),i.epoch===this.appEpoch?t.kind===`change`?(this.applyResult(t,n,r),i.stopped&&this.notify(`It was done before it could stop: “${t.change.title}” is a preview now. Keep or undo it.`,`info`),!0):(i.stopped||this.applyResult(t,n,r,i.again),!1):!1}applyResult(e,t,n,r){switch(e.kind){case`change`:{this.upsertChange(e.change);let t=n.map(t=>({changeId:e.change.id,el:t}));M({previewTargets:[...N().previewTargets,...t].slice(-8),island:{kind:`idle`}}),this.refreshAfterEdit();return}case`answer`:M({island:{kind:`answer`,text:e.text,said:t,model:e.model,latencyMs:e.latencyMs}});return;case`message`:return e.tone===`error`&&j(`error`),this.notify(e.text,e.tone===`error`?`error`:e.tone===`warn`?`warn`:`info`,this.nextActions(e.next,r));case`needs-key`:M({island:{kind:`needs-key`,text:e.text,actions:this.nextActions(e.next,r)}});return}}nextActions(e,t){let n=(e??[]).flatMap(e=>{switch(e.kind){case`ask-ai`:{let e=ji(N().status?.ai.who);return t?[{label:e===`AI`?`Ask the AI anyway`:`Ask ${e} anyway`,primary:!0,run:()=>(this.dismissIsland(),t())}]:[]}case`connect-ai`:return[{label:`Connect an AI`,primary:!0,run:()=>M({overlay:`settings`,settingsTab:`ai`,island:{kind:`idle`}})}];case`link-folder`:return[{label:`Link its folder…`,primary:!0,run:()=>(this.dismissIsland(),T.show(`folder`,v.getState().active??void 0))}];case`open`:{let t=/^(.+?):(\d+)(?::\d+)?$/.exec(e.src);return!t||!N().status?.target.root?[]:[{label:t[2]===`1`?`Open ${oe(t[1])}`:`Open ${oe(t[1])}:${t[2]}`,run:()=>this.openRelative(t[1],Number(t[2]))}]}}});return n.length?n:void 0}upsertChange(e){M({changes:[e,...N().changes.filter(t=>t.id!==e.id)]})}async keep(e,t){if(!t&&!gr(N()).length)return this.notify(`Nothing is waiting to be kept.`,`info`);try{let n=await u.post(`/changes/keep`,{id:t,via:e,commit:P().ui.commitOnKeep});j(`keep`),await this.decided(n.kept);let r=n.kept.length===1?n.kept[0].title:`${n.kept.length} changes`;n.commitError?this.notify(`Kept: ${r}, but not committed. Git said: ${n.commitError}`,`warn`):this.notify(`Kept: ${r}${n.committed?` (committed)`:``}`,`ok`)}catch(e){this.fail(e)}}async undo(e,t=!1,n){if(!n&&!gr(N()).length)return this.notify(`Nothing to undo.`,`info`);try{let r=await u.post(`/changes/undo`,{id:n,via:e,force:t});j(`undo`),await this.decided(r.undone),this.notify(r.undone.length===1?`Undone: ${r.undone[0].title}`:`Undid ${r.undone.length} changes.`,`info`),this.refreshAfterEdit()}catch(t){if(t instanceof c&&t.code===`conflict`){j(`error`),M({island:{kind:`message`,tone:`warn`,text:t.message,sticky:!0,actions:[{label:`Undo anyway`,run:()=>void this.undo(e,!0,n)},{label:`Leave it`,run:()=>M({island:{kind:`idle`}})}]}});return}this.fail(t)}}async decided(e){let t=new Set(e.map(e=>e.id));M({previewTargets:N().previewTargets.filter(e=>!t.has(e.changeId)),recorder:{...N().recorder,verifying:!1}}),await this.refreshChanges(),this.refreshSummary()}undoChange(e){return this.undo(`panel`,!1,e)}keepChange(e){return this.keep(`panel`,e)}stop(e){let t=N();if(this.replayer.running)return this.replayer.stop();if(this.autopilot.running)return this.autopilot.stop();if(t.voice.state!==`idle`)return this.cancelTalk();if(t.request)return void this.cancelRequest();if(t.island.kind!==`idle`)return M({island:{kind:`idle`}});if(t.selection||t.pins.length)return this.clearTargets()}async cancelRequest(){let e=this.requests.stop();e!==null&&this.notify(e?`Stopped. ${e===1?`The request waiting after it wasn’t sent.`:`The ${e} requests waiting after it weren’t sent.`}`:`Stopped.`,`info`)}dismissIsland(){M({island:{kind:`idle`}})}notify(e,t=`info`,n){this.noticeTimer&&clearTimeout(this.noticeTimer);let r={kind:`message`,text:e,tone:t,actions:n};M({island:r}),n?.length||(this.noticeTimer=setTimeout(()=>{N().island===r&&M({island:{kind:`idle`}})},t===`error`?7e3:t===`warn`?6e3:3800))}fail(e){j(`error`),this.notify(e instanceof Error?e.message:String(e),`error`)}async addExpectation(e,t){let n=this.targetFrom(t);if(!n)return this.notify(`Point at the element that shows the wrong value while you say it.`,`warn`);let r=await this.checkOf(n,e.expected);if(!r)return this.notify(`Couldn’t build a locator for that element. Try pointing at it again.`,`warn`);let i=N().recorder;M({recorder:{...i,expectations:[...i.expectations,r],spec:null,run:null}}),j(`keep`);let a=r.field===`checked`?`, it is ${r.actual}`:r.actual?`, it shows “${ue(r.actual,r.expected)?.slice(0,40)}”`:``;this.notify(`Check added: ${r.description} ${fe(r)}${a}.`,`ok`,[{label:`Generate test`,primary:!0,run:()=>void this.generateTest()},{label:`Add another`,run:()=>this.dismissIsland()}])}async addExpectationFor(e,t){let n=await this.checkOf(e,t);if(!n)return this.notify(`Couldn’t build a locator for that element.`,`warn`);let r=N().recorder;M({recorder:{...r,expectations:[...r.expectations,n],spec:null,run:null}})}async checkOf(e,t){let n=de(t),r=await this.bridge.locator(e.id,{expected:t,...n?{state:!0}:{}});if(!r)return null;let i=await this.checkPlace(),a={locator:r.locator.code,description:r.locator.description,after:i};if(n&&r.checked!==void 0)return{...a,expected:n,actual:r.checked?`checked`:`not checked`,field:`checked`};if(n===`checked`&&r.option&&r.chosen)return{...a,expected:r.option,actual:r.chosen.join(`, `),field:`select`};let o=n?await this.bridge.locator(e.id,{expected:t}):r;return o?{locator:o.locator.code,description:o.locator.description,expected:t,actual:o.locator.text,after:i,...Vi(e)}:null}findingTargets(e,t){let n=[];for(let r of e){let e=r.kind===`speech`?t.transcript.find(e=>e.start===r.t):null,i=r.issue?t.issues.find(e=>e.id===r.issue):null,a=e?.el??i?.el;a&&!n.some(e=>e.src===a.src&&e.label===a.label)&&n.push(a)}return n.slice(0,4)}async fixFromReport(e,t,n){let r=this.findingTargets(t,n).map(e=>({role:`finding`,src:e.src,name:e.name,label:e.label,text:e.text,tag:e.tag,hint:e.hint})),i=[`Fix this problem found in a test session: ${e.title}.`,...zt(e,t)].join(`
3
+ `);P().setUi({panelOpen:!0,panelTab:`changes`});let a=this.appEpoch;await this.ask({text:`Fix: ${e.title}`,kind:`fix`,step:`Working`,run:async(t,n)=>{let o=await u.post(`/intent`,{text:i.slice(0,1990),refs:r,requestId:t,input:`typed`,pointer:`none`,pageUrl:N().app.url});this.settle(t,o,e.title,[],{stopped:n(),epoch:a})}})}async fixFindings(e,t){if(!e.length)return;let n=[],r=e.map(({f:e,items:r},i)=>{for(let e of this.findingTargets(r,t))n.length<8&&!n.some(t=>(t.src??t.label)===(e.src??e.label))&&n.push({role:`finding`,src:e.src,name:e.name,label:e.label,text:e.text,tag:e.tag,hint:e.hint});return[`${i+1}. [${e.severity}] ${e.title}`,...zt(e,r).map(e=>` ${e}`)].join(`
4
+ `)}).join(`
5
+
6
+ `),i=e.length;await this.reportTask(`Fix ${i===1?`this problem`:`these ${i} problems`} found in a test session.`,r,n,i===1?`Fix: ${e[0].f.title}`:`Fix ${i} findings`)}async implementSuggestions(e,t){if(!e.length)return;let n=[`The session: ${t.title}. ${t.summary}`,``,...e.map((e,t)=>`${t+1}. (${e.kind}, ${e.effort} effort) ${e.title}: ${e.why}`)].join(`
7
+ `),r=e.length;await this.reportTask(`Implement ${r===1?`this suggestion`:`these ${r} suggestions`} from a test session report.`,n,[],r===1?e[0].title:`${r} suggestions`)}async reveal(e){N().mode!==`edit`&&this.setMode(`edit`);let t=await this.bridge.reveal(e.id,e.src,e.index);return t&&this.select(t),t}async fixReview(e,t){if(!e.length)return;let n=[];for(let t of e)for(let e of t.els??[])n.length<8&&!n.some(t=>(t.src??t.label)===(e.src??e.label))&&n.push({role:`finding`,src:e.src,name:e.name,label:e.label,text:e.text,tag:e.tag,hint:e.hint,frames:e.frames});let r=e.map((e,t)=>`${t+1}. [${e.rule}] ${e.title}\n Found: ${e.what}\n Fix: ${e.fix}${e.rewrite?`\n Change the text “${e.rewrite.before}” to “${e.rewrite.after}”.`:``}`).join(`
8
+ `),i=e.length===1?`Fix: ${e[0].title}`:`Fix ${e.length} ${t} findings`;await this.reportTask(`Fix these ${t} findings from the studio's page review. Fix each at its root: when the elements share a design token, style or component (one colour, one size), change that once so every use is fixed; the elements named are examples. Otherwise make the smallest change that satisfies the rule.`,r,n,i)}async reportTask(e,t,n,r){P().setUi({panelOpen:!0,panelTab:`changes`});let i=this.appEpoch;await this.ask({text:r,kind:`fix`,step:`Working`,run:async(a,o)=>{let s=await u.post(`/intent`,{text:e,brief:t.slice(0,16e3),refs:n,requestId:a,input:`typed`,pointer:`none`,pageUrl:N().app.url});this.settle(a,s,r,[],{stopped:o(),epoch:i})}})}async startAutopilot(e){if(!(this.autopilot.running||this.replayer.running)){if(!N().app.connected)return this.notify(`Open your app first: Autopilot uses it here, in the studio.`,`info`);if(!N().status?.ai.ready)return this.notify(`Autopilot needs an AI to decide what to try.`,`info`,[{label:`Connect an AI`,primary:!0,run:()=>M({overlay:`settings`,settingsTab:`ai`,island:{kind:`idle`}})}]);A.closeReport(),A.recording&&await A.stop(),await this.autopilot.run(e)}}async verifySession(e){if(!this.replayer.running){if(!e.analysis?.steps.some(e=>e.kind!==`navigate`&&e.locator))return this.notify(`This session has no steps to replay.`,`info`);A.closeReport(),A.recording&&await A.stop(),await this.replayer.run(e)}}async testFromReport(e,t,n,r){let i=pn(e,n)??mn(e,n),a=Hi(n,i?i.t+1e3:t.length?t[t.length-1].t+1e3:1/0),o=n.steps.find(e=>e.kind===`navigate`)?.url??r,s=[];i&&s.push({locator:i.locator,description:i.el.description??i.el.label,expected:i.expected,actual:i.el.text,after:a.length,...Vi(i.el)}),M({recorder:{...mr,startUrl:o,steps:a,expectations:s}}),P().setUi({panelOpen:!0,panelTab:`test`}),s.length?await this.generateTest():this.notify(`Loaded ${a.length} steps from the session. Now point at the value that is wrong and say what it should show, or add a check in the Test tab.`,`info`)}checkSession(e,t){let n=Hi(e);M({recorder:{...mr,startUrl:e.steps.find(e=>e.kind===`navigate`)?.url??t,steps:n}}),this.setMode(`record`),P().setUi({panelOpen:!0,panelTab:`test`}),this.notify(`Loaded ${n.length} steps from the session. Point at a value that must be right, like a total, and say what it should show.`,`info`,[{label:`Got it`,run:()=>this.dismissIsland()}])}async generateTest(){let e=N().recorder;if(!e.expectations.length)return P().setUi({panelOpen:!0,panelTab:`test`}),this.notify(`First say what you expected: point at the wrong value and say “this should show …”.`,`info`);try{let t=await u.post(`/tests/generate`,{startUrl:e.startUrl??N().app.url,steps:e.steps,expectations:e.expectations,...e.spec||e.written?{replace:e.spec??e.written}:{}});M({recorder:{...N().recorder,spec:t,written:t,run:null,baseline:void 0}}),P().setUi({panelOpen:!0,panelTab:`test`}),this.notify(`Test saved to ${t.path}.`,`ok`,[{label:`Run it`,primary:!0,run:()=>void this.runTest()}])}catch(e){this.fail(e)}}async runTest(){let e=N().recorder.spec;if(!e){if(!N().recorder.expectations.length)return this.notify(`Record a bug first: switch to Record mode, use the app, then say what you expected.`,`info`);if(await this.generateTest(),e=N().recorder.spec,!e)return}if(N().recorder.running||this.requests.has(`test`))return;let t=e.path;await this.ask({text:`Run ${t}`,kind:`test`,step:`Running the test`,run:e=>this.testRun(e,t)})}async testRun(e,t){M({recorder:{...N().recorder,running:!0}});let{verifying:n,baseline:r}=N().recorder,i;try{i=await u.post(`/tests/run`,{path:t,...r?{baseline:r}:{}})}catch(e){i={status:`error`,durationMs:0,message:e instanceof Error?e.message:String(e)}}let a=!!r&&!!i.hash&&i.hash!==r;M({recorder:{...N().recorder,running:!1,run:{...i,at:Date.now()},...a&&i.status===`passed`?{baseline:void 0}:{}}}),N().request?.id===e&&M({request:null}),this.refreshSummary();let o={label:`Details`,run:()=>(P().setUi({panelOpen:!0,panelTab:`test`}),this.dismissIsland())},s=i.counts?`${se(i.counts.steps,`step`)} and ${se(i.counts.checks,`check`)}`:`its steps and checks`;switch(i.status){case`passed`:{let e=n&&gr(N()).length>0;if(M({recorder:{...N().recorder,verifying:!1}}),!i.verified){j(`error`),M({island:{kind:`message`,tone:`warn`,sticky:!0,text:e?`Couldn’t verify the fix. ${i.unverified??``}`:`Couldn’t verify. ${i.unverified??``}`,actions:e?[{label:`Keep anyway`,run:()=>void this.keep(`test`)},{label:`Undo fix`,primary:!0,run:()=>void this.undo(`test`)},o]:[o]}});return}j(`keep`),e?M({island:{kind:`message`,tone:`ok`,sticky:!0,text:`The test passes with this fix: all ${s} ran. Keep it?`,actions:[{label:`Keep fix`,primary:!0,run:()=>void this.keep(`test`)},{label:`Undo`,run:()=>void this.undo(`test`)}]}}):this.notify(`Test passed in ${(i.durationMs/1e3).toFixed(1)} s: all ${s} ran.`,`ok`);return}case`failed`:{j(`error`);let e=n&&gr(N()).length>0;M({recorder:{...N().recorder,verifying:!1,baseline:i.hash}});let t={label:`Fix with ${ji(N().status?.ai.who)}`,primary:!0,run:()=>void this.fix()};if(i.failedAt===`step`){let n=i.steps?.find(e=>!e.ok),r=(n?.error??i.message??``).split(`
9
+ `)[0].slice(0,160);M({island:{kind:`message`,tone:`warn`,sticky:!0,text:`${e?`With the fix, the test`:`The test`} didn’t reach its checks, so it doesn’t show the bug yet: ${n?n.title.replace(/^\[\d+\] /,``):`a step`} failed${r?` (${r})`:``}.`,actions:[o,{...t,primary:!1,label:`Fix with ${ji(N().status?.ai.who)} anyway`}]}});return}M({island:{kind:`message`,tone:`error`,sticky:!0,text:`${e?`Still failing with the fix: expected`:`Test failed: expected`} “${i.expected??`?`}”, got “${i.received??`?`}”.`,actions:[t,o]}});return}case`setup-needed`:M({recorder:{...N().recorder,verifying:!1}}),M({island:{kind:`message`,tone:`warn`,sticky:!0,text:i.message??`Playwright needs a one-time setup.`,actions:i.missingSecrets?.length?[{label:`Open the Test tab`,primary:!0,run:()=>(P().setUi({panelOpen:!0,panelTab:`test`}),this.dismissIsland())}]:/Chromium/.test(i.message??``)?[{label:`Install test browser`,primary:!0,run:()=>void this.installBrowser()}]:[o]}});return;default:j(`error`),M({recorder:{...N().recorder,verifying:!1}}),this.notify(i.message??`The test couldn’t run.`,`error`)}}async fix(e){let t=N().recorder;if(!t.spec||t.run?.status!==`failed`)return this.notify(`Run a failing test first, then ask for a fix.`,`info`);let n={path:t.spec.path,failure:t.run.message??``,input:e},r=t.run.hash,i=this.appEpoch;await this.ask({text:`Fix the bug this test shows`,kind:`fix`,step:`Reading the failing test`,run:async(e,t)=>{let a=await u.post(`/fix`,{...n,requestId:e});this.settle(e,a,`fix it`,[],{stopped:t(),epoch:i})&&!t()&&a.kind===`change`&&(M({recorder:{...N().recorder,verifying:!0,baseline:r}}),setTimeout(()=>void this.runTest(),500))}})}async installBrowser(){M({recorder:{...N().recorder,installing:!0,installLog:[]},island:{kind:`idle`}}),P().setUi({panelOpen:!0,panelTab:`test`});try{let{ok:e}=await u.post(`/tests/install`);this.notify(e?`Test browser installed. Run the test again.`:`The install failed. See the log in the Test tab.`,e?`ok`:`error`,e?[{label:`Run test`,primary:!0,run:()=>void this.runTest()}]:void 0)}catch(e){this.fail(e)}finally{M({recorder:{...N().recorder,installing:!1}})}}keepTimer=null;keepRecorder(){this.keepTimer&&clearTimeout(this.keepTimer),this.keepTimer=setTimeout(()=>{let e=v.getState().active;if(!e)return;let{startUrl:t,steps:n,expectations:r,spec:i,run:a,baseline:o,written:s}=N().recorder;try{sessionStorage.setItem(zi,JSON.stringify({app:e,recorder:{startUrl:t,steps:n,expectations:r,spec:i,run:a,baseline:o,written:s}}))}catch{}},300)}restoreRecorder(){try{let e=JSON.parse(sessionStorage.getItem(zi)??`null`),t=N().recorder;if(!e?.recorder||e.app!==v.getState().active||t.steps.length||t.expectations.length)return;M({recorder:{...mr,...e.recorder,running:!1,installing:!1,installLog:[],verifying:!1}})}catch{}}appSwitched(e=!0){e?(this.appEpoch++,this.requests.stop(),M({selection:null,pins:[],hover:null,previewTargets:[],inspect:null,recorder:mr,changes:[],replay:null}),this.refreshStatus(),this.refreshChanges().then(()=>this.announceWaiting()),A.refreshList()):(this.refreshStatus(),this.refreshChanges(),A.refreshList())}announceWaiting(){let e=N().changes.filter(e=>e.status===`preview`).length;e&&this.notify(e===1?`A change from before is still a preview in your code. Keep it or undo it.`:`${e} changes from before are still previews in your code. Keep or undo them.`,`info`)}async refreshStatus(){try{let e=await u.get(`/status`);return M({status:e,statusError:null}),e}catch(e){return M({statusError:e instanceof Error?e.message:String(e)}),setTimeout(()=>void this.refreshStatus(),2e3),null}}async refreshChanges(){let e=++this.changesAsked;try{let{changes:t}=await u.get(`/changes`);e===this.changesAsked&&M({changes:t})}catch{}}async refreshSummary(){try{M({summary:await u.get(`/metrics/summary`)})}catch{}}pushContext=(()=>{let e=null,t=``;return()=>{e&&clearTimeout(e),e=setTimeout(()=>{let e=N(),n=(e,t)=>({role:t,src:e.src,name:e.name,label:e.label,text:e.text,tag:e.tag,hint:e.hint,frames:e.frames}),r={pageUrl:e.app.url||null,selection:e.selection?[n(e.selection,`selection`)]:[],pins:e.pins.map(e=>n(e,`pin`))},i=JSON.stringify(r);i!==t&&(t=i,u.put(`/context`,r).catch(()=>void 0))},400)}})()},zi=`saywright.recorder`;function Bi(e,t){return{role:t,src:e.src,name:e.name,label:e.label,text:e.text,tag:e.tag,hint:e.hint,frames:e.frames,...e.same?{same:e.same}:{}}}function Vi(e){return e.tag===`input`||e.tag===`textarea`?{field:`value`}:e.tag===`select`?{field:`select`}:{}}function Hi(e,t=1/0){return e.steps.filter(e=>e.t<=t&&e.kind!==`navigate`&&e.locator).map(e=>({kind:e.kind===`fill`?`fill`:e.kind===`press`?`press`:`click`,locator:e.locator,value:e.value,checked:e.checked,key:e.key,description:e.description,...e.secret?{secret:e.secret}:{},...e.select?{select:e.select}:{}}))}var Ui=new Ri,F=r(),Wi=(0,s.createContext)({});function Gi(e){let t=(0,s.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Ki=typeof window<`u`?s.useLayoutEffect:s.useEffect,qi=(0,s.createContext)(null);function Ji(e,t){e.indexOf(t)===-1&&e.push(t)}function Yi(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Xi=(e,t,n)=>n>t?t:n<e?e:n,Zi={},Qi=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),$i=e=>typeof e==`object`&&!!e,ea=e=>/^0[^.\s]+$/u.test(e);function ta(e){let t;return()=>(t===void 0&&(t=e()),t)}var na=e=>e,ra=(...e)=>e.reduce((e,t)=>n=>t(e(n))),ia=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},aa=class{constructor(){this.subscriptions=[]}add(e){return Ji(this.subscriptions,e),()=>this.remove(e)}remove(e){Yi(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},oa=e=>e*1e3,sa=e=>e/1e3,ca=(e,t)=>t?1e3/t*e:0,la=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function ua(e,t,n,r){return e===t&&n===r?na:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=la(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(la(s+1e-7,e,n)-i-r)}return la(s,t,r)}}var da=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,fa=e=>t=>1-e(1-t),pa=ua(.33,1.53,.69,.99),ma=fa(pa),ha=da(ma),ga=e=>e>=1?1:(e*=2)<1?.5*ma(e):.5*(2-2**(-10*(e-1))),_a=e=>1-Math.sin(Math.acos(e)),va=fa(_a),ya=da(_a),ba=ua(.42,0,1,1),xa=ua(0,0,.58,1),Sa=ua(.42,0,.58,1),Ca=e=>Array.isArray(e)&&typeof e[0]!=`number`,wa=e=>Array.isArray(e)&&typeof e[0]==`number`,Ta={linear:na,easeIn:ba,easeInOut:Sa,easeOut:xa,circIn:_a,circInOut:ya,circOut:va,backIn:ma,backInOut:ha,backOut:pa,anticipate:ga},Ea=e=>typeof e==`string`,Da=e=>{if(wa(e)){e.length;let[t,n,r,i]=e;return ua(t,n,r,i)}return Ea(e)?(Ta[e],`${e}`,Ta[e]):e},I={delta:0,timestamp:0,isProcessing:!1},Oa;function ka(){Oa=void 0}var L={now:()=>(Oa===void 0&&L.set(I.isProcessing||Zi.useManualTiming?I.timestamp:performance.now()),Oa),set:e=>{Oa=e,queueMicrotask(ka)}},Aa=e=>Math.round(e*1e5)/1e5,ja=e=>t=>typeof t==`string`&&t.startsWith(e),Ma=ja(`--`),Na=ja(`var(--`),Pa=e=>Na(e)?Fa.test(e.split(`/*`)[0].trim()):!1,Fa=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ia(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var La={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Ra={...La,transform:e=>Xi(0,1,e)},za={...La,default:1},Ba=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Va(e){return e==null}var Ha=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ua=(e,t)=>n=>!!(typeof n==`string`&&Ha.test(n)&&n.startsWith(e)||t&&!Va(n)&&Object.prototype.hasOwnProperty.call(n,t)),Wa=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ba);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Ga=e=>Xi(0,255,e),Ka={...La,transform:e=>Math.round(Ga(e))},qa={test:Ua(`rgb`,`red`),parse:Wa(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Ka.transform(e)+`, `+Ka.transform(t)+`, `+Ka.transform(n)+`, `+Aa(Ra.transform(r))+`)`};function Ja(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var Ya={test:Ua(`#`),parse:Ja,transform:qa.transform},Xa=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Za=Xa(`deg`),Qa=Xa(`%`),R=Xa(`px`),$a=Xa(`vh`),eo=Xa(`vw`),to={...Qa,parse:e=>Qa.parse(e)/100,transform:e=>Qa.transform(e*100)},no={test:Ua(`hsl`,`hue`),parse:Wa(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Qa.transform(Aa(t))+`, `+Qa.transform(Aa(n))+`, `+Aa(Ra.transform(r))+`)`},z={test:e=>qa.test(e)||Ya.test(e)||no.test(e),parse:e=>qa.test(e)?qa.parse(e):no.test(e)?no.parse(e):Ya.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?qa.transform(e):no.transform(e),getAnimatableNone:e=>{let t=z.parse(e);return t.alpha=0,z.transform(t)}},ro=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,io=new RegExp(Ba.source),ao=new RegExp(ro.source,`i`);function oo(e){return isNaN(e)&&typeof e==`string`&&(io.test(e)||ao.test(e))}var so=`number`,co=`color`,lo=`var`,uo=`var(`,fo="${}",po=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function mo(e){let t=e.toString();return io.test(t)||ao.test(t)}function ho(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(po,e=>(z.test(e)?(r.color.push(a),i.push(co),n.push(z.parse(e))):e.startsWith(uo)?(r.var.push(a),i.push(lo),n.push(e)):(r.number.push(a),i.push(so),n.push(parseFloat(e))),++a,fo)).split(fo),indexes:r,types:i}}function go(e){return ho(e).values}function _o({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===so?Aa(r[a]):e===co?z.transform(r[a]):r[a]}return i}}function vo(e){return _o(ho(e))}var yo=e=>typeof e==`number`?0:z.test(e)?z.getAnimatableNone(e):e,bo=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:yo(e);function xo(e){let t=ho(e);return _o(t)(t.values.map((e,n)=>bo(e,t.split[n])))}var B={test:oo,parse:go,createTransformer:vo,getAnimatableNone:xo};function So(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Co({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=So(s,r,e+1/3),a=So(s,r,e),o=So(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function wo(e,t){return n=>n>0?t:e}var V=(e,t,n)=>e+(t-e)*n,To=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Eo=[Ya,qa,no],Do=e=>Eo.find(t=>t.test(e));function Oo(e){let t=Do(e);if(!t)return`${e}`,!1;let n=t.parse(e);return t===no&&(n=Co(n)),n}var ko=(e,t)=>{let n=Oo(e),r=Oo(t);if(!n||!r)return wo(e,t);let i={...n};return e=>(i.red=To(n.red,r.red,e),i.green=To(n.green,r.green,e),i.blue=To(n.blue,r.blue,e),i.alpha=V(n.alpha,r.alpha,e),qa.transform(i))},Ao=new Set([`none`,`hidden`]);function jo(e,t){return Ao.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Mo(e,t){return n=>V(e,t,n)}function No(e){return typeof e==`number`?Mo:typeof e==`string`?Pa(e)?wo:z.test(e)?ko:Lo:Array.isArray(e)?Po:typeof e==`object`?z.test(e)?ko:Fo:wo}function Po(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>No(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Fo(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=No(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Io(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var Lo=(e,t)=>{let n=B.createTransformer(t),r=ho(e),i=ho(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Ao.has(e)&&!i.values.length||Ao.has(t)&&!r.values.length?jo(e,t):ra(Po(Io(r,i),i.values),n):(`${e}${t}`,wo(e,t))},Ro=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function zo(e,t){let n=Ro.exec(e);if(!n)return;let r=Ro.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>Aa(V(a,o,e))+i}function Bo(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return V(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=zo(e,t);if(n)return n}return No(e)(e,t)}var Vo=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Ho(e){let t=new Set,n=new Set,r=!1,i=!1,a=new Set,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(n.add(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var Uo=40;function Wo(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=Vo.reduce((e,t)=>(e[t]=Ho(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Zi.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,Uo),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:Vo.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Vo.length;t++)o[Vo[t]].cancel(e)},state:n,steps:o}}var{schedule:H,cancel:Go,steps:Ko}=Wo(typeof requestAnimationFrame<`u`?requestAnimationFrame:na,!0,I),qo=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>H.update(t,e),stop:()=>Go(t),now:()=>I.isProcessing?I.timestamp:L.now()}},Jo=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Yo=2e4;function Xo(e,t=50,n=Yo,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function Zo(e,t=100,n){let{keyframes:r,velocity:i}=e,a=r&&r[r.length-1]-r[0],o=n({...e,velocity:i&&a?i*t/a:i,keyframes:[0,t]}),s=Math.min(Xo(o),Yo);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:sa(s)}}var U={stiffness:100,damping:10,mass:1,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05},Qo=e=>e<0?1/Math.max(1+e,U.minDamping):Math.max(1-e,U.minDamping);function $o(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return ns(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function es(e,t){return e*Math.sqrt(1-t*t)}var ts=12;function ns(e,t,n){let r=n;for(let n=1;n<ts;n++)r-=e(r)/t(r);return r}var rs=.001;function is({duration:e=U.duration,bounce:t=U.bounce}){let n,r;U.maxDuration;let i=Qo(t);e=Xi(U.minDuration,U.maxDuration,sa(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=es(t,i),o=Math.exp(-r);return rs-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=es(t*t,i);return(-n(t)+rs>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=ns(n,r,a),s=o*$o(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:oa(e)}}var as=(e,t)=>(t?e>=0:e>0)&&e<1/0;function os(e,t){if(as(e,t))return e}function ss(e){let t=os(e.stiffness),n=os(e.damping,!0),r=os(e.mass),i={...e,stiffness:t??U.stiffness,damping:n??U.damping,mass:r??U.mass,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=Qo(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*$o(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,is(i)),i.isResolvedFromDuration=!0;(!as(i.stiffness)||!as(i.damping,!0))&&(i.stiffness=U.stiffness,i.damping=U.damping)}return i}function cs(e=U.visualDuration,t=U.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=ss({...n}),f=e=>d?0:-sa(e),p=s/(2*Math.sqrt(o*c)),m=sa(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?U.restSpeed.granular:U.restSpeed.default),g.restDelta=n.restDelta||(e?U.restDelta.granular:U.restDelta.default)};_();let v,y,b;if(p<1){let e=es(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=d?1/0:300/e,i=(e,t)=>Math.exp(t>r?-e*r-h*(t-r):-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>oa(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=oa(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(Xo(S),Yo),t=Jo(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}cs.applyToOptions=e=>{let t=Zo(e,100,cs);return e.ease=t.ease,e.duration=oa(t.duration),e.type=`keyframes`,e};function ls({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=cs({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function us(e,t,n){let r=[],i=n||Zi.mix||Bo,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=ra(Array.isArray(t)?t[n]||na:t,a)),r.push(a)}return r}function ds(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=us(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=ia(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Xi(e[0],e[a-1],t)):l}function fs(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ia(0,t,r);e.push(V(n,1,i))}}function ps(e){let t=[0];return fs(t,e.length-1),t}function ms(e,t){return e.map(e=>e*t)}function hs(e,t){return e.map(()=>t||Sa).splice(0,e.length-1)}function gs({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=Ca(r)?r.map(Da):Da(r)||Sa,a={done:!1,value:t[0]};if(t.length===2&&!Array.isArray(i)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,o=n===r?void 0:(Zi.mix||Bo)(n,r);return{calculatedDuration:e,next:t=>(a.value=o?o(i(e>0?Xi(0,1,t/e):1)):r,a.done=t>=e,a)}}let o=ds(ms(n&&n.length===t.length?n:ps(t),e),t,{ease:Array.isArray(i)?i:hs(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var _s=5;function vs(e,t,n){let r=Math.max(t-_s,0);return ca(n-e(r),t-r)}function ys(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):vs(t=>e.next(t).value,t,e.next(t).value)}var bs=e=>e!==null;function xs(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(bs),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Ss={decay:ls,inertia:ls,tween:gs,keyframes:gs,spring:cs};function Cs(e){typeof e.type==`string`&&(e.type=Ss[e.type])}var ws=40,Ts=(e,t)=>t-e>ws&&!Zi.useManualTiming?t:e;function Es(e,t){return{kind:e,animation:t,timestamp:L.now(),frameTimestamp:I.timestamp,frameIsProcessing:I.isProcessing}}function Ds(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...Es(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function Os(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...Es(`layout-animation-start`,e),node:t})}catch{}}var ks=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},As=e=>e/100,js=class extends ks{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==L.now()&&this.tick(L.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),Ds(this,this.options)}initAnimation(){let{options:e}=this;Cs(e);let{type:t=gs,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||gs;s!==gs&&typeof o[0]!=`number`&&(this.mixKeyframes=ra(As,Bo(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Xo(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.startTime===this.pendingStartTime&&(this.startTime=Ts(this.startTime,e)),this.pendingStartTime=void 0,this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Xi(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==ls&&(b.value=xs(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return sa(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+sa(e)}get time(){return sa(this.currentTime)}set time(e){e=oa(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return ys(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(L.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=sa(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=qo,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??(this.pendingStartTime=n):this.startTime=n-this.holdTime/(this.playbackSpeed||1),this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(L.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},Ms=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Ns(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ba)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Ms.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var Ps=/\b([a-z-]*)\(.*?\)/gu,Fs={...B,getAnimatableNone:e=>{let t=e.match(Ps);return t?t.map(Ns).join(` `):e}},Is={...B,getAnimatableNone:e=>{let t=B.parse(e);return B.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},Ls={...La,transform:Math.round},Rs={borderWidth:R,borderTopWidth:R,borderRightWidth:R,borderBottomWidth:R,borderLeftWidth:R,borderRadius:R,borderTopLeftRadius:R,borderTopRightRadius:R,borderBottomRightRadius:R,borderBottomLeftRadius:R,width:R,maxWidth:R,height:R,maxHeight:R,top:R,right:R,bottom:R,left:R,inset:R,insetBlock:R,insetBlockStart:R,insetBlockEnd:R,insetInline:R,insetInlineStart:R,insetInlineEnd:R,padding:R,paddingTop:R,paddingRight:R,paddingBottom:R,paddingLeft:R,paddingBlock:R,paddingBlockStart:R,paddingBlockEnd:R,paddingInline:R,paddingInlineStart:R,paddingInlineEnd:R,margin:R,marginTop:R,marginRight:R,marginBottom:R,marginLeft:R,marginBlock:R,marginBlockStart:R,marginBlockEnd:R,marginInline:R,marginInlineStart:R,marginInlineEnd:R,fontSize:R,backgroundPositionX:R,backgroundPositionY:R,rotate:Za,pathRotation:Za,rotateX:Za,rotateY:Za,rotateZ:Za,scale:za,scaleX:za,scaleY:za,scaleZ:za,skew:Za,skewX:Za,skewY:Za,distance:R,translateX:R,translateY:R,translateZ:R,x:R,y:R,z:R,perspective:R,transformPerspective:R,opacity:Ra,originX:to,originY:to,originZ:R,zIndex:Ls,fillOpacity:Ra,strokeOpacity:Ra,numOctaves:Ls},zs={...Rs,color:z,backgroundColor:z,outlineColor:z,fill:z,stroke:z,borderColor:z,borderTopColor:z,borderRightColor:z,borderBottomColor:z,borderLeftColor:z,filter:Fs,WebkitFilter:Fs,mask:Is,WebkitMask:Is},Bs=e=>zs[e],Vs=new Set([Fs,Is]);function Hs(e,t){let n=Bs(e);return Vs.has(n)||(n=B),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function Us(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Ws=e=>e*180/Math.PI,Gs=e=>qs(Ws(Math.atan2(e[1],e[0]))),Ks={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Gs,rotateZ:Gs,skewX:e=>Ws(Math.atan(e[1])),skewY:e=>Ws(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},qs=e=>(e%=360,e<0&&(e+=360),e),Js=Gs,Ys=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Xs=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Zs={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ys,scaleY:Xs,scale:e=>(Ys(e)+Xs(e))/2,rotateX:e=>qs(Ws(Math.atan2(e[6],e[5]))),rotateY:e=>qs(Ws(Math.atan2(-e[2],e[0]))),rotateZ:Js,rotate:Js,skewX:e=>Ws(Math.atan(e[4])),skewY:e=>Ws(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Qs(e){return+!!e.includes(`scale`)}function $s(e,t){if(!e||e===`none`)return Qs(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=Zs,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Ks,i=t}if(!i)return Qs(t);let a=r[t],o=i[1].split(`,`).map(tc);return typeof a==`function`?a(o):o[a]}var ec=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return $s(n,t)};function tc(e){return parseFloat(e.trim())}var nc=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],rc=new Set([...nc,`pathRotation`]),ic=e=>e===La||e===R,ac=new Set([`x`,`y`,`z`]),oc=nc.filter(e=>!ac.has(e));function sc(e){let t=[];return oc.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var cc=new Set([`bottom`,`right`]);function lc(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var uc={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>lc(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>lc(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:({transform:e})=>$s(e,`x`),y:({transform:e})=>$s(e,`y`)};uc.translateX=uc.x,uc.translateY=uc.y;var dc=new Set,fc=!1,pc=!1,mc=!1;function hc(){if(pc){let e=[],t=new Set,n=new Set;dc.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),cc.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=sc(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}pc=!1,fc=!1,dc.forEach(e=>e.complete(mc)),dc.clear()}function gc(){dc.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(pc=!0)})}function _c(){mc=!0,gc(),hc(),mc=!1}function vc(e,t,n){if(typeof e==`string`){if(Qi(e)||ea(e))return parseFloat(e);if(!B.test(e)&&B.test(n))return Hs(t,n)}return e??void 0}var yc=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(dc.add(this),fc||(fc=!0,H.read(gc),H.resolveKeyframes(hc))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=vc(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Us(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),dc.delete(this)}cancel(){this.state===`scheduled`&&(dc.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},bc=e=>e.startsWith(`--`);function xc(e,t,n){bc(t)?e.style.setProperty(t,n):e.style[t]=n}var Sc={};function Cc(e,t){let n=ta(e);return()=>Sc[t]??n()}var wc=Cc(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Tc=Cc(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Ec=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Dc={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Ec([0,.65,.55,1]),circOut:Ec([.55,0,1,.45]),backIn:Ec([.31,.01,.66,-.59]),backOut:Ec([.33,1.53,.69,.99])};function Oc(e,t){if(e)return typeof e==`function`?Tc()?Jo(e,t):`ease-out`:wa(e)?Ec(e):Array.isArray(e)?e.map(e=>Oc(e,t)||Dc.easeOut):Dc[e]}function kc(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Oc(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Ac(e){return typeof e==`function`&&`applyToOptions`in e}function jc({type:e,...t}){return Ac(e)&&Tc()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Mc=class extends ks{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=jc(e);this.animation=kc(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=xs(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),xc(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},Ds(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return sa(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+sa(e)}get time(){return sa(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=oa(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&wc()?(this.animation.timeline=e,t?.(this.animation),na):n(this)}},Nc={anticipate:ga,backInOut:ha,circInOut:ya};function Pc(e){return e in Nc}function Fc(e){typeof e.ease==`string`&&Pc(e.ease)&&(e.ease=Nc[e.ease])}var Ic=10,Lc=class extends Mc{constructor(e){Fc(e),Cs(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new js({...a,autoplay:!1}),s=Math.max(Ic,L.now()-this.startTime),c=Xi(0,Ic,s-Ic),l=o.sample(s).value,{name:u}=this.options;i&&u&&xc(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},Rc=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(B.test(e)||e===`0`)&&!e.startsWith(`url(`));function zc(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function Bc(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=Rc(i,t),s=Rc(a,t);return!o||!s?(o!==s&&`${t}${i}${a}${o?a:i}`,!1):zc(e)||(n===`spring`||Ac(n))&&r}function Vc(e){e.duration=0,e.type=`keyframes`}var Hc=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),Uc=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Wc(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Uc.test(e[t]))return!0;return!1}var Gc=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Kc=ta(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function qc(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(Hc.has(n)||Gc.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return Kc()&&(Hc.has(n)||Gc.has(n)&&Wc(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Jc=class extends ks{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=L.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||yc;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=L.now();let u=!0;Bc(e,i,a,o)||(u=!1,(Zi.instantAnimations||!s)&&l?.(xs(e,n,t)),e[0]=e[e.length-1],Vc(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&qc(n);r&&(f||this.resolvedAt!==this.createdAt)&&(n.startTime??=Ts(this.createdAt,this.resolvedAt));let p;if(f){n.element=n.motionValue?.owner?.current;try{p=new Lc(n)}catch{p=new js(n)}}else p=new js(n);this.pendingTimeline&&=(this.stopTimeline=p.attachTimeline(this.pendingTimeline),void 0),this._animation=p}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),_c()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Yc(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Xc=30,Zc=e=>!isNaN(parseFloat(e)),Qc={current:void 0},$c=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=L.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.notifyChange(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=L.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Zc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new aa)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new aa,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){H.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.notifyChange()}notifyChange(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Qc.current&&Qc.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=L.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Xc)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Xc);return ca(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&this.clearAnimation(),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){this.animation=void 0}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function el(e,t){return new $c(e,t)}function tl(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function nl(e,t){let n=e?.[t]??e?.default??e;return n===e?n:tl(n,e)}var rl={type:`spring`,stiffness:500,damping:25,restSpeed:10},il=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),al={type:`keyframes`,duration:.8},ol={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},sl=(e,{keyframes:t})=>t.length>2?al:rc.has(e)?e.startsWith(`scale`)?il(t[1]):rl:ol,cl=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function ll(e){for(let t in e)if(!cl.has(t))return!0;return!1}var ul=(e,t,n,r={},i,a)=>o=>{let s=nl(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=oa(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};ll(s)||Object.assign(u,sl(e,u)),u.duration&&=oa(u.duration),u.repeatDelay&&=oa(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Vc(u),u.delay===0&&(d=!0)),(Zi.instantAnimations||Zi.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,Vc(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=xs(u.keyframes,s);if(e!==void 0){H.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new js(u):new Jc(u)},dl=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function fl(e){let t=dl.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function pl(e,t,n=1){`${e}`;let[r,i]=fl(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Qi(e)?parseFloat(e):e}return Pa(i)?pl(i,t,n+1):i}function ml(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function hl(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...ml(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function gl(e,t,n){return hl(e.getProps(),t,n,e)}var _l=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,vl=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...nc]),yl=e=>Array.isArray(e);function bl(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,el(n))}function xl(e){return yl(e)?e[e.length-1]||0:e}function Sl(e,t){let{transitionEnd:n={},transition:r={},...i}=gl(e,t)||{};i={...i,...n};for(let t in i)bl(e,t,xl(i[t]))}var W=e=>!!(e&&e.getVelocity);function Cl(e){return!!(W(e)&&e.add)}function wl(e,t){let n=e.getValue(`willChange`);if(Cl(n))return n.add(t);if(!n&&Zi.WillChange){let n=new Zi.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Tl(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var El=`data-`+Tl(`framerAppearId`);function Dl(e){return e.props[El]}var Ol=typeof window<`u`;function kl({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Al(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?tl(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&kl(f,t))continue;let o={delay:n,...nl(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){H.update(()=>r.set(i));continue}let p=!1;if(Ol&&window.MotionHandoffAnimation){let n=Dl(e);if(n){let e=window.MotionHandoffAnimation(n,t,H);e!==null&&(o.startTime=e,p=!0)}}wl(e,t);let m=l??e.shouldReduceMotion;r.start(ul(t,r,i,m&&vl.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>H.update(()=>{o&&Sl(e,o)});d.length?Promise.all(d).then(t):t()}return d}function jl(e,t,n={}){let r=gl(e,t,_l(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Al(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(jl(e,t,{...n,delay:r+(typeof o==`function`?0:o)+Yc(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Ml(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>jl(e,t,n))):typeof t==`string`?jl(e,t,n):Promise.all(Al(e,gl(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var Nl={test:e=>e===`auto`,parse:e=>e},Pl=e=>t=>t.test(e),Fl=[La,R,Qa,Za,eo,$a,Nl],Il=e=>Fl.find(Pl(e));function Ll(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||ea(e)}var Rl=new Set([`auto`,`none`,`0`]);function zl(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Rl.has(t)&&mo(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=Hs(n,i))}var Bl=class extends yc{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Pa(r))){let i=pl(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!vl.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=Il(r),o=Il(i);if(Ia(r)!==Ia(i)&&uc[n])this.needsMeasurement=!0;else if(a!==o){if(ic(a)&&ic(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else uc[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||Ll(e[t]))&&n.push(t);n.length&&zl(e,n,t)}measure(){let{element:e,name:t}=this;return uc[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e||!e.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},Vl=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function Hl(e){return $i(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function Ul(e){return $i(e)&&`ownerSVGElement`in e}var Wl=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Gl(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var Kl={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},ql=nc.length;function Jl(e,t,n){let r=``,i=!0;for(let a=0;a<ql;a++){let o=nc[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=Wl(s,Rs[o]);if(!c){i=!1;let t=Kl[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${Wl(a,Rs.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Yl(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(rc.has(e))o=!0;else if(Ma(e))i[e]=n;else{let t=Wl(n,Rs[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Jl(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var Xl={offset:`stroke-dashoffset`,array:`stroke-dasharray`},Zl={offset:`strokeDashoffset`,array:`strokeDasharray`};function Ql(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Xl:Zl;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var $l=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function eu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Yl(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of $l)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&Ql(d,i,a,o,!1)}function tu({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function nu({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function ru(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function iu(e){return e===void 0||e===1}function au({scale:e,scaleX:t,scaleY:n}){return!iu(e)||!iu(t)||!iu(n)}function ou(e){return au(e)||su(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function su(e){return cu(e.x)||cu(e.y)}function cu(e){return e&&e!==`0%`}function lu(e,t,n){return n+t*(e-n)}function uu(e,t,n,r,i){return i!==void 0&&(e=lu(e,i,r)),lu(e,n,r)+t}function du(e,t=0,n=1,r,i){e.min=uu(e.min,t,n,r,i),e.max=uu(e.max,t,n,r,i)}function fu(e,{x:t,y:n}){du(e.x,t.translate,t.scale,t.originPoint),du(e.y,n.translate,n.scale,n.originPoint)}var pu=.999999999999,mu=1.0000000000001;function hu(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(gu(e.x,-a.scroll.offset.x),gu(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,fu(e,o)),r&&ou(a.latestValues)&&yu(e,a.latestValues,a.layout?.layoutBox))}t.x<mu&&t.x>pu&&(t.x=1),t.y<mu&&t.y>pu&&(t.y=1)}function gu(e,t){e.min+=t,e.max+=t}function _u(e,t,n,r,i=.5){du(e,t,n,V(e.min,e.max,i),r)}function vu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function yu(e,t,n){let r=n??e;_u(e.x,vu(t.x,r.x),t.scaleX,t.scale,t.originX),_u(e.y,vu(t.y,r.y),t.scaleY,t.scale,t.originY)}function bu(e,t){return tu(ru(e.getBoundingClientRect(),t))}function xu(e,t,n){let r=bu(e,n),{scroll:i}=t;return i&&(gu(r.x,i.offset.x),gu(r.y,i.offset.y)),r}var{schedule:Su,cancel:Cu}=Wo(queueMicrotask,!1),wu={x:!1,y:!1};function Tu(){return wu.x||wu.y}function Eu(e){return e===`x`||e===`y`?wu[e]?null:(wu[e]=!0,()=>{wu[e]=!1}):wu.x||wu.y?null:(wu.x=wu.y=!0,()=>{wu.x=wu.y=!1})}function Du(e,t){let n=Gl(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Ou(e){return!(e.pointerType===`touch`||Tu())}function ku(e,t,n={}){let[r,i,a]=Du(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{e.pointerType!==`touch`&&(n?r=!0:s(e))};e.addEventListener(`pointerenter`,n=>{if(!Ou(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Au=(e,t)=>t?e===t||Au(e,t.parentElement):!1,ju=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Mu=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Nu(e){return Mu.has(e.tagName)||e.isContentEditable===!0}var Pu=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Fu(e){return Pu.has(e.tagName)||e.isContentEditable===!0}var Iu=new WeakSet;function Lu(e){return t=>{t.key===`Enter`&&e(t)}}function Ru(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var zu=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Lu(()=>{if(Iu.has(n))return;Ru(n,`down`);let e=Lu(()=>{Ru(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Ru(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Bu(e){return ju(e)&&!Tu()}var Vu=new WeakSet;function Hu(e,t,n={}){let[r,i,a]=Du(e,n),o=e=>{let r=e.currentTarget;if(!Bu(e)||Vu.has(e))return;Iu.add(r),n.stopPropagation&&Vu.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),Iu.has(r)&&Iu.delete(r),Bu(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Au(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),Hl(e)&&(e.addEventListener(`focus`,e=>zu(e,i)),!Nu(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}var Uu=new WeakMap,Wu,Gu=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Ul(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Ku=Gu(`inline`,`width`,`offsetWidth`),qu=Gu(`block`,`height`,`offsetHeight`);function Ju({target:e,borderBoxSize:t}){Uu.get(e)?.forEach(n=>{n(e,{get width(){return Ku(e,t)},get height(){return qu(e,t)}})})}function Yu(e){e.forEach(Ju)}function Xu(){typeof ResizeObserver<`u`&&(Wu=new ResizeObserver(Yu))}function Zu(e,t){Wu||Xu();let n=Gl(e);return n.forEach(e=>{let n=Uu.get(e);n||(n=new Set,Uu.set(e,n)),n.add(t),Wu?.observe(e)}),()=>{n.forEach(e=>{let n=Uu.get(e);n?.delete(t),n?.size||Wu?.unobserve(e)})}}var Qu=new Set,$u;function ed(){$u=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Qu.forEach(t=>t(e))},window.addEventListener(`resize`,$u)}function td(e){return Qu.add(e),$u||ed(),()=>{Qu.delete(e),!Qu.size&&typeof $u==`function`&&(window.removeEventListener(`resize`,$u),$u=void 0)}}function nd(e,t){return typeof e==`function`?td(e):Zu(e,t)}var rd={value:null,addProjectionMetrics:null};function id(e){return Ul(e)&&e.tagName===`svg`}var ad=e=>typeof e==`number`?e:parseFloat(e),od=()=>({translate:0,scale:1,origin:0,originPoint:0}),sd=()=>({x:od(),y:od()}),cd=()=>({min:0,max:0}),G=()=>({x:cd(),y:cd()}),ld=new WeakMap;function ud(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function dd(e){return typeof e==`string`||Array.isArray(e)}var fd=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],pd=[`initial`,...fd];function md(e){if(ud(e.animate))return!0;for(let t=0;t<pd.length;t++)if(dd(e[pd[t]]))return!0;return!1}function hd(e){return!!(md(e)||e.variants)}function gd(e,t,n){for(let r in t){let i=t[r],a=n[r];if(W(i))e.addValue(r,i);else if(W(a))e.addValue(r,el(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,el(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var _d={current:null},vd={current:!1},yd=typeof window<`u`;function bd(){if(vd.current=!0,yd){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>_d.current=e.matches;e.addEventListener(`change`,t),t()}else _d.current=!1}}var xd=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Sd={};function Cd(e){Sd=e}function wd(){return Sd}var Td=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=yc,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=L.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,H.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=md(t),this.isVariantNode=hd(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&W(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,ld.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(vd.current||bd(),this.shouldReduceMotion=_d.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Go(this.notifyUpdate),Go(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&Hc.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Mc({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:oa(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=rc.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&H.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Sd){let t=Sd[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):G()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<xd.length;t++){let n=xd[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=gd(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=el(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Qi(n)||ea(n))?n=parseFloat(n):typeof n!=`number`&&!B.test(n)&&B.test(t)&&(n=Hs(e,t)),this.setBaseTarget(e,W(n)?n.get():n)),W(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return this.events[e]||(this.events[e]=new aa),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Su.render(this.render)}},Ed=class extends Td{constructor(){super(...arguments),this.KeyframeResolver=Bl}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;W(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Dd=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Od(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}var kd={};function Ad(e,{layout:t,layoutId:n}){return rc.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!kd[e]||e===`opacity`)}function jd(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(W(r[t])||i&&W(i[t])||Ad(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Md(e){return window.getComputedStyle(e)}var Nd=class extends Ed{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Od}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(rc.has(t))return this.projection?.isProjecting?Qs(t):ec(e,t);{let n=Md(e),r=(Ma(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return bu(e,t)}build(e,t,n){Yl(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return jd(e,t,n)}},Pd=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),Fd=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Id(e,t,n,r){Od(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Pd.has(n)?n:Tl(n),t.attrs[n])}function Ld(e,t,n){let r=jd(e,t,n);for(let n in e)if(W(e[n])||W(t[n])){let t=nc.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Rd=class extends Ed{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=G}getBaseTargetFromProps(e,t){return rc.has(t)?super.getBaseTargetFromProps(e,t)??Qs(t):e[t]}getDefaultValue(e){return rc.has(e)?this.latestValues[e]??Qs(e):void 0}readValueFromInstance(e,t){if(rc.has(t)){let e=Bs(t);return e&&e.default||0}if($l.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=Pd.has(t)?t:Tl(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Ld(e,t,n)}build(e,t,n){eu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){Id(e,t,n,r)}mount(e){this.isSVGTag=Fd(e.tagName),super.mount(e)}};function zd(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Bd=[...fd].reverse();function Vd(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Ml(e,t,n))),n=Ud(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,l=r||i,u=[],d=new Set,f={},p=1/0,m=e;do m=m.props.inherit!==!1&&m.parent;while(m&&!m.isControllingVariants);if(Bd.forEach((t,r)=>{let i=n[t],h=o[t],g=m&&m.props[t],_=h===void 0?dd(g)||g===!1?g:void 0:h,v=dd(_),y=t===a?i.isActive:null;y===!1&&(p=r);let b=v&&h===void 0&&!(l&&c);if(i.protectedKeys={...f},!i.isActive&&y===null||!_&&!i.prevProp||ud(_)||typeof _==`boolean`)return;if(t===`exit`&&i.isActive&&y!==!0){f={...f,...i.prevResolvedValues};return}let x=Hd(i.prevProp,_),S=x||v&&(y&&!b||r>p),C=!1,w=Array.isArray(_)?_:[_],T={};if(y!==!1)for(let n of w){let{transition:r,transitionEnd:i,...a}=gl(e,n,_l(e,t))||{};T={...T,...a,...i}}let{prevResolvedValues:E}=i;for(let t in{...E,...T}){if(t in f)continue;let n=T[t],r=E[t],a=Array.isArray(n)&&Array.isArray(r)?!zd(n,r)||x:n!==r;if(a&&n==null)d.add(t);else if(a||n!==void 0&&d.has(t)){S=!0,d.delete(t)&&(C=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0}if(i.prevProp=_,i.prevResolvedValues=T,i.isActive&&(f={...f,...T}),S&&(!(b&&x)||C))for(let n of w){let r={type:t};if(typeof n==`string`&&l&&c&&s?.enteringChildren){let t=gl(s,n)?.transition?.delayChildren;r.delay=Yc(s.enteringChildren,e,t)}u.push({animation:n,options:r})}}),d.size){let{initial:t}=o,n={},r=typeof t!=`boolean`&&gl(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom);r&&r.transition&&(n.transition=r.transition),d.forEach(i=>{let a=e.getValue(i);a&&(a.liveStyle=!0);let s=r&&!Array.isArray(t)?r[i]:void 0,c=e.getBaseTargetFromProps(o,i);n[i]=(s===void 0?c!==void 0&&!W(c)?c:e.initialValues[i]===void 0?e.baseTarget[i]:void 0:s)??null}),u.push({animation:n})}let h=l&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!h&&u.length?t(u):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=Ud(),i=!0}}}function Hd(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!zd(t,e):!1}function Ud(){let e={};for(let t of fd)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}};return e}function Wd(e,t){e.min=t.min,e.max=t.max}function Gd(e,t){Wd(e.x,t.x),Wd(e.y,t.y)}function Kd(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var qd=.9999,Jd=1.0001,Yd=-.01,Xd=.01;function K(e){return e.max-e.min}function Zd(e,t,n){return Math.abs(e-t)<=n}function Qd(e,t,n,r=.5){e.origin=r,e.originPoint=V(t.min,t.max,e.origin),e.scale=K(n)/K(t),e.translate=V(n.min,n.max,e.origin)-e.originPoint,(e.scale>=qd&&e.scale<=Jd||isNaN(e.scale))&&(e.scale=1),(e.translate>=Yd&&e.translate<=Xd||isNaN(e.translate))&&(e.translate=0)}function $d(e,t,n,r){Qd(e.x,t.x,n.x,r?r.originX:void 0),Qd(e.y,t.y,n.y,r?r.originY:void 0)}function ef(e,t,n,r=0){e.min=(r?V(n.min,n.max,r):n.min)+t.min,e.max=e.min+K(t)}function tf(e,t,n,r){ef(e.x,t.x,n.x,r?.x),ef(e.y,t.y,n.y,r?.y)}function nf(e,t,n,r=0){let i=r?V(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+K(t)}function rf(e,t,n,r){nf(e.x,t.x,n.x,r?.x),nf(e.y,t.y,n.y,r?.y)}function af(e,t,n,r,i){return e-=t,e=lu(e,1/n,r),i!==void 0&&(e=lu(e,1/i,r)),e}function of(e,t=0,n=1,r=.5,i,a=e,o=e){if(Qa.test(t)&&(t=parseFloat(t),t=V(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=V(a.min,a.max,r);e===a&&(s-=t),e.min=af(e.min,t,n,s,i),e.max=af(e.max,t,n,s,i)}function sf(e,t,[n,r,i],a,o){of(e,t[n],t[r],t[i],t.scale,a,o)}var cf=[`x`,`scaleX`,`originX`],lf=[`y`,`scaleY`,`originY`];function uf(e,t,n,r){sf(e.x,t,cf,n?n.x:void 0,r?r.x:void 0),sf(e.y,t,lf,n?n.y:void 0,r?r.y:void 0)}function df(e){return e.translate===0&&e.scale===1}function ff(e){return df(e.x)&&df(e.y)}function pf(e,t){return e.min===t.min&&e.max===t.max}function mf(e,t){return pf(e.x,t.x)&&pf(e.y,t.y)}function hf(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function gf(e,t){return hf(e.x,t.x)&&hf(e.y,t.y)}function _f(e){return K(e.x)/K(e.y)}function vf(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function yf(e){return[e(`x`),e(`y`)]}function bf(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var xf={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(R.test(e))e=parseFloat(e);else return e}return`${bf(e,t.target.x)}% ${bf(e,t.target.y)}%`}},Sf={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=B.parse(e);if(i.length>5)return r;let a=B.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=V(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}};function Cf(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var wf=Vl.length,Tf=e=>typeof e==`number`||R.test(e);function Ef(e,t,n,r,i,a){i?(e.opacity=V(0,n.opacity??1,Of(r)),e.opacityExit=V(t.opacity??1,0,kf(r))):a&&(e.opacity=V(t.opacity??1,n.opacity??1,r));for(let i=0;i<wf;i++){let a=Vl[i],o=Df(t,a),s=Df(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||Tf(o)===Tf(s)?(e[a]=Math.max(V(ad(o),ad(s),r),0),(Qa.test(s)||Qa.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=V(t.rotate||0,n.rotate||0,r))}function Df(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Of=Af(0,.5,va),kf=Af(.5,.95,na);function Af(e,t,n){return r=>r<e?0:r>t?1:n(ia(e,t,r))}function jf(e,t,n){let r=W(e)?e:el(e);return r.start(ul(``,r,t,n)),r.animation}function Mf(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Nf=(e,t)=>e.depth-t.depth,Pf=class{constructor(){this.children=[],this.isDirty=!1}add(e){Ji(this.children,e),this.isDirty=!0}remove(e){Yi(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Nf),this.isDirty=!1,this.children.forEach(e)}};function Ff(e,t){let n=L.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Go(r),e(a-t))};return H.setup(r,!0),()=>Go(r)}function If(e){return W(e)?e.get():e}var Lf=class{constructor(){this.members=[]}add(e){Ji(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Yi(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Yi(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Rf={borderRadius:{...xf,applyTo:[...Vl]},borderTopLeftRadius:xf,borderTopRightRadius:xf,borderBottomLeftRadius:xf,borderBottomRightRadius:xf,boxShadow:Sf},zf={hasAnimatedSinceResize:!0,hasEverUpdated:!1};Object.assign(kd,{...Rf,...kd});var Bf={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Vf=[``,`X`,`Y`,`Z`],Hf=1e3,Uf=0;function Wf(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Gf(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Dl(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,H,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Gf(r)}function Kf({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Uf++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,rd.value&&(Bf.nodes=Bf.calculatedTargetDeltas=Bf.calculatedProjections=0),this.nodes.forEach(Yf),this.nodes.forEach(op),this.nodes.forEach(sp),this.nodes.forEach(Xf),rd.addProjectionMetrics&&rd.addProjectionMetrics(Bf)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new Pf)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new aa),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=Ul(t)&&!id(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;H.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Ff(i,250),zf.hasAnimatedSinceResize&&(zf.hasAnimatedSinceResize=!1,this.nodes.forEach(ap)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||mp,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!gf(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...nl(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||ap(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Go(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(cp),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Gf(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1),t.isAnimationBlocked&&(t.dragSnapshot||=t.measure(),this.dragAncestor=t)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach($f),this.nodes.forEach(Qf);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(ep);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(np),this.nodes.forEach(rp),this.nodes.forEach(ip),this.nodes.forEach(qf),this.nodes.forEach(Jf)):this.nodes.forEach(ep),this.clearAllSnapshots();let e=L.now();I.delta=Xi(0,1e3/60,e-I.timestamp),I.timestamp=e,I.isProcessing=!0,Ko.update.process(I),Ko.preRender.process(I),Ko.render.process(I),I.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Su.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Zf),this.sharedNodes.forEach(lp)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,H.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){H.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!K(this.snapshot.measuredBox.x)&&!K(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=G(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!ff(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||ou(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),vp(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return G();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(bp))){let{scroll:e}=this.root;e&&(gu(t.x,e.offset.x),gu(t.y,e.offset.y))}return t}removeElementScroll(e){let t=G();if(Gd(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Gd(t,e),gu(t.x,i.offset.x),gu(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||G();Gd(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(gu(r.x,-n.scroll.offset.x),gu(r.y,-n.scroll.offset.y)),ou(n.latestValues)&&yu(r,n.latestValues,n.layout?.layoutBox)}return ou(this.latestValues)&&yu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=G();Gd(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!ou(n.latestValues))continue;let r;n.instance&&(au(n.latestValues)&&n.updateSnapshot(),r=G(),Gd(r,n.measurePageBox())),uf(t,n.latestValues,n.snapshot?.layoutBox,r)}return ou(this.latestValues)&&uf(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==I.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=I.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=G(),this.targetWithTransforms=G()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),tf(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Gd(this.target,this.layout.layoutBox),fu(this.target,this.targetDelta)):Gd(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),rd.value&&Bf.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||au(this.parent.latestValues)||su(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=G(),this.relativeTargetOrigin=G(),rf(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Gd(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===I.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Gd(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;hu(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=G());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Kd(this.prevProjectionDelta.x,this.projectionDelta.x),Kd(this.prevProjectionDelta.y,this.projectionDelta.y)),$d(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!vf(this.projectionDelta.x,this.prevProjectionDelta.x)||!vf(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),rd.value&&Bf.calculatedProjections++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=sd(),this.projectionDelta=sd(),this.projectionDeltaWithTransform=sd()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=sd();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=G(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(pp));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=V(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=V(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(up(o.x,e.x,n),up(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(rf(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),fp(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&mf(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=G(),Gd(f,this.relativeTarget)),c&&(this.animationValues=a,Ef(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Go(this.pendingAnimation),void 0),this.pendingAnimation=H.update(()=>{zf.hasAnimatedSinceResize=!0,this.motionValue||=el(0),this.motionValue.jump(0,!1),this.currentAnimation=jf(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),Os(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Hf),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&yp(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||G();let t=K(this.layout.layoutBox.x);i.x.min=e.target.x.min,i.x.max=i.x.min+t;let n=K(this.layout.layoutBox.y);i.y.min=e.target.y.min,i.y.max=i.y.min+n}Gd(t,i),yu(t,r),$d(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Lf),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Wf(`z`,e,r,this.animationValues);for(let t=0;t<Vf.length;t++)Wf(`rotate${Vf[t]}`,e,r,this.animationValues),Wf(`skew${Vf[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=If(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=If(t?.pointerEvents)||``),this.hasProjected&&!ou(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Cf(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in kd){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=kd[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?If(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=this.dragSnapshot=this.dragAncestor=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Qf),this.root.sharedNodes.clear()}}}function qf(e){e.updateLayout(),tp(e)}function Jf(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)yf(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=K(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Wd(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else yp(i,t.layoutBox,n)&&yf(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=K(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=sd();$d(o,n,t.layoutBox);let s=sd();a?$d(s,e.applyTransform(r,!0),t.measuredBox):$d(s,n,t.layoutBox);let c=!ff(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=G();rf(s,t.layoutBox,i.layoutBox,o);let c=G();rf(c,n,a.layoutBox,o),gf(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Yf(e){rd.value&&Bf.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Xf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Zf(e){e.clearSnapshot()}function Qf(e){e.clearMeasurements()}function $f(e){e.isLayoutDirty=!0,e.updateLayout()}function ep(e){e.isLayoutDirty=!1}function tp(e){let{snapshot:t,dragAncestor:n}=e,r=n?.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;yf(e=>gu(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function np(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function rp(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function ip(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function ap(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function op(e){e.resolveTargetDelta()}function sp(e){e.calcProjection()}function cp(e){e.resetSkewAndRotation()}function lp(e){e.removeLeadSnapshot()}function up(e,t,n){e.translate=V(t.translate,0,n),e.scale=V(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function dp(e,t,n,r){e.min=V(t.min,n.min,r),e.max=V(t.max,n.max,r)}function fp(e,t,n,r){dp(e.x,t.x,n.x,r),dp(e.y,t.y,n.y,r)}function pp(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var mp={duration:.45,ease:[.4,0,.1,1]},hp=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),gp=hp(`applewebkit/`)&&!hp(`chrome/`)?Math.round:na;function _p(e){e.min=gp(e.min),e.max=gp(e.max)}function vp(e){_p(e.x),_p(e.y)}function yp(e,t,n){return e===`position`||e===`preserve-aspect`&&!Zd(_f(t),_f(n),.2)}function bp(e){return e!==e.root&&e.scroll?.wasRoot}var xp=Kf({attachResizeListener:(e,t)=>Mf(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Sp={current:void 0},Cp=Kf({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Sp.current){let e=new xp({});e.mount(window),e.setOptions({layoutScroll:!0}),Sp.current=e}return Sp.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),wp=(0,s.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Tp(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ep(...e){return t=>{let n=!1,r=e.map(e=>{let r=Tp(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Tp(e[t],null)}}}}function Dp(...e){return s.useCallback(Ep(...e),e)}var Op=class extends s.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(Hl(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=Hl(e)&&e.offsetWidth||0,r=Hl(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function kp({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,s.useId)(),c=(0,s.useRef)(null),l=(0,s.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:u}=(0,s.useContext)(wp),d=Dp(c,a===!1?void 0:e.props?.ref??e?.ref);return(0,s.useInsertionEffect)(()=>{let{width:e,height:s,top:d,left:f,right:p,bottom:m,direction:h}=l.current;if(t||a===!1||!c.current||!e||!s)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`,y=c.current;y.dataset.motionPopId=o;let b=y.ownerDocument,x=b.createElement(`style`);u&&(x.nonce=u);let S=i??b.head;return S.appendChild(x),x.sheet&&x.sheet.insertRule(`
10
+ [data-motion-pop-id="${o}"] {
11
+ position: absolute !important;
12
+ width: ${e}px !important;
13
+ height: ${s}px !important;
14
+ ${_}px !important;
15
+ ${v}px !important;
16
+ }
17
+ `),()=>{c.current?.removeAttribute(`data-motion-pop-id`),S.contains(x)&&S.removeChild(x)}},[t]),(0,F.jsx)(Op,{isPresent:t,childRef:c,sizeRef:l,pop:a,children:a===!1?e:s.cloneElement(e,{ref:d})})}var Ap=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:c,anchorY:l,root:u})=>{let d=Gi(jp),f=(0,s.useId)(),p=(0,s.useRef)(n),m=(0,s.useRef)(r);Ki(()=>{p.current=n,m.current=r});let h=!0,g=(0,s.useMemo)(()=>(h=!1,{id:f,initial:t,isPresent:n,custom:i,onExitComplete:e=>{d.set(e,!0);for(let e of d.values())if(!e)return;r&&r()},register:e=>(d.set(e,!1),()=>{d.delete(e),!p.current&&!d.size&&m.current?.()})}),[n,d,r]);return a&&h&&(g={...g}),(0,s.useMemo)(()=>{d.forEach((e,t)=>d.set(t,!1))},[n]),s.useEffect(()=>{!n&&!d.size&&r&&r()},[n]),e=(0,F.jsx)(kp,{pop:o===`popLayout`,isPresent:n,anchorX:c,anchorY:l,root:u,children:e}),(0,F.jsx)(qi.Provider,{value:g,children:e})};function jp(){return new Map}function Mp(e=!0){let t=(0,s.useContext)(qi);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,s.useId)();(0,s.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,s.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Np=e=>e.key||``;function Pp(e){let t=[];return s.Children.forEach(e,e=>{(0,s.isValidElement)(e)&&t.push(e)}),t}var Fp=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:c=`left`,anchorY:l=`top`,root:u})=>{let[d,f]=Mp(o),p=(0,s.useMemo)(()=>Pp(e),[e]),m=o&&!d?[]:p.map(Np),h=(0,s.useRef)(!0),g=Gi(()=>new Map),_=(0,s.useRef)(new Set),[v,y]=(0,s.useState)(p),[b,x]=(0,s.useState)(p);Ki(()=>{o&&!d&&!b.length&&f?.()},[d,o,b.length,f]),Ki(()=>{h.current=!1;for(let e=0;e<b.length;e++){let t=Np(b[e]);m.includes(t)?(g.delete(t),_.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[b,m.length,m.join(`-`)]);let S=[];if(p!==v){let e=[...p],t=0;for(let n of b){let r=m.indexOf(Np(n));r===-1?(e.splice(t++,0,n),S.push(n)):t=r+S.length+1}return S.every(e=>g.get(Np(e)))?e=p:a===`wait`&&(e=S),x(Pp(e)),y(p),null}let{forceRender:C}=(0,s.useContext)(Wi);return(0,F.jsx)(F.Fragment,{children:b.map(e=>{let s=Np(e),v=o&&!d?!1:p===b||m.includes(s);return(0,F.jsx)(Ap,{isPresent:v,initial:!h.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:u,onExitComplete:v?void 0:()=>{if(_.current.has(s))return;if(g.has(s))_.current.add(s),g.set(s,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(C?.(),y([]),o&&f?.(),r&&r())},anchorX:c,anchorY:l,children:e},s)})})},Ip=(0,s.createContext)({strict:!1}),Lp={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},Rp=!1;function zp(){if(Rp)return;let e={};for(let t in Lp)e[t]={isEnabled:e=>Lp[t].some(t=>!!e[t])};Cd(e),Rp=!0}function Bp(){return zp(),wd()}function Vp(e){let t=Bp();for(let n in e)t[n]={...t[n],...e[n]};Cd(t)}var Hp=(0,s.createContext)({});function Up(e,t){if(md(e)){let{initial:t,animate:n}=e;return{initial:t===!1||dd(t)?t:void 0,animate:dd(n)?n:void 0}}return e.inherit===!1?{}:t}function Wp(e){let{initial:t,animate:n}=Up(e,(0,s.useContext)(Hp));return(0,s.useMemo)(()=>({initial:t,animate:n}),[Gp(t),Gp(n)])}function Gp(e){return Array.isArray(e)?e.join(` `):e}var Kp=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function qp(e,t,n){for(let r in t)!W(t[r])&&!Ad(r,n)&&(e[r]=t[r])}function Jp({transformTemplate:e},t){return(0,s.useMemo)(()=>{let n=Kp();return Yl(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Yp(e,t){let n=e.style||{},r={};return qp(r,n,e),Object.assign(r,Jp(e,t)),r}function Xp(e,t){let n={},r=Yp(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var Zp=()=>({...Kp(),attrs:{}});function Qp(e,t,n,r){let i=(0,s.useMemo)(()=>{let n=Zp();return eu(n,t,Fd(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};qp(t,e.style,e),i.style={...t,...i.style}}return i}var $p=new Set(`animate.exit.variants.initial.style.values.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function em(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||$p.has(e)}function tm(e,t){return e.startsWith(`on`)?!em(e):t?.(e)??!em(e)}function nm(e,t,n,r){let i={};for(let a in e)(a!==`values`||typeof e.values!=`object`)&&(W(e[a])||(tm(a,r)||n===!0&&em(a)||!t&&!em(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]));return i}var rm=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function im(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(rm.indexOf(e)>-1||/[A-Z]/u.test(e))}function am(e,t,n,{latestValues:r},i,a=!1,o,c){let l=(o??im(e)?Qp:Xp)(t,r,i,e),u=nm(t,typeof e==`string`,a,c),d=e===s.Fragment?{}:{...u,...l,ref:n},{children:f}=t,p=(0,s.useMemo)(()=>W(f)?f.get():f,[f]);return(0,s.createElement)(e,{...d,children:p})}function om({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:sm(n,r,i,e),renderState:t()}}function sm(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=If(a[e]);let{initial:o,animate:s}=e,c=md(e),l=hd(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!ud(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=hl(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var cm=e=>(t,n)=>{let r=(0,s.useContext)(Hp),i=(0,s.useContext)(qi),a=()=>om(e,t,r,i);return n?a():Gi(a)},lm=cm({scrapeMotionValuesFromProps:jd,createRenderState:Kp}),um=cm({scrapeMotionValuesFromProps:Ld,createRenderState:Zp}),dm=Symbol.for(`motionComponentSymbol`);function fm(e,t,n){let r=(0,s.useRef)(n);(0,s.useInsertionEffect)(()=>{r.current=n});let i=(0,s.useRef)(null);return(0,s.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var pm=(0,s.createContext)({});function mm(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function hm(e,t,n,r,i,a){let{visualElement:o}=(0,s.useContext)(Hp),c=(0,s.useContext)(Ip),l=(0,s.useContext)(qi),u=(0,s.useContext)(wp),d=u.reducedMotion,f=u.skipAnimations,p=(0,s.useRef)(null),m=(0,s.useRef)(!1);r||=c.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:d,skipAnimations:f,isSVG:a}),m.current&&p.current&&(p.current.manuallyAnimateOnMount=!0));let h=p.current,g=(0,s.useContext)(pm);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&gm(p.current,n,i,g);let _=(0,s.useRef)(!1);(0,s.useInsertionEffect)(()=>{h&&_.current&&h.update(n,l)});let v=n[El],y=(0,s.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return Ki(()=>{m.current&&h&&(h.animationState?.animateChanges(),h.enteringChildren=void 0)},[]),Ki(()=>{m.current=!0,h&&(_.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),y.current&&h.animationState&&h.animationState.animateChanges())}),(0,s.useEffect)(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),h.enteringChildren=void 0)}),h}function gm(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:_m(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&mm(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function _m(e){if(e)return e.options.allowProjection===!1?_m(e.parent):e.projection}function vm(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Vp(r);let a=n?n===`svg`:im(e),o=a?um:lm;function c(n,c){let l,u={...(0,s.useContext)(wp),...n,layoutId:ym(n)},{isStatic:d,isValidProp:f}=u,p=Wp(n),m=o(n,d);if(!d&&typeof window<`u`){bm(u,r);let t=xm(u);l=t.MeasureLayout,p.visualElement=hm(e,m,u,i,t.ProjectionNode,a)}return(0,F.jsxs)(Hp.Provider,{value:p,children:[l&&p.visualElement?(0,F.jsx)(l,{visualElement:p.visualElement,...u}):null,am(e,n,fm(m,p.visualElement,c),m,d,t,a,f)]})}c.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let l=(0,s.forwardRef)(c);return l[dm]=e,l}function ym({layoutId:e}){let t=(0,s.useContext)(Wi).id;return t&&e!==void 0?t+`-`+e:e}function bm(e,t){(0,s.useContext)(Ip).strict}function xm(e){let{drag:t,layout:n}=Bp();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Sm(e,t){if(typeof Proxy>`u`)return vm;let n=new Map,r=(n,r)=>vm(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,vm(a,void 0,e,t)),n.get(a))})}var Cm=(e,t)=>t.isSVG??im(e)?new Rd(t):new Nd(t,{allowProjection:e!==s.Fragment}),wm=class extends Dd{constructor(e){super(e),e.animationState||=Vd(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();ud(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},Tm=0,Em={animation:{Feature:wm},exit:{Feature:class extends Dd{constructor(){super(...arguments),this.id=Tm++}update(){let{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;let{isPresent:r,onExitComplete:i}=e,a=t?.isPresent;if(r===a)return;if(r&&a===!1){if(this.exit===!0){let{initial:e}=this.node.getProps();if(e&&!Array.isArray(e)){let{transition:t,transitionEnd:n,...r}=gl(this.node,e)||{};for(let e in r)this.node.getValue(e)?.jump(r[e])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive(`exit`,!1);this.exit=void 0;return}let o=this.exit=n.setActive(`exit`,!r);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Dm(e){return{point:{x:e.pageX,y:e.pageY}}}var Om=e=>t=>ju(t)&&e(t,Dm(t));function km(e,t,n,r){return Mf(e,t,Om(n),r)}var Am=({current:e})=>e?e.ownerDocument.defaultView:null,jm=(e,t)=>Math.abs(e-t);function Mm(e,t){let n=jm(e.x,t.x),r=jm(e.y,t.y);return Math.sqrt(n**2+r**2)}var Nm=new Set([`auto`,`scroll`]),Pm=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Fm(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Lm(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Mm(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:L.now()});let{onStart:i,onMove:a}=this.handlers;t||(i&&i(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a&&a(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Fm(t,this.transformPagePoint),this.hasPendingMove=!0,H.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.hasPendingMove&&this.updatePoint(),this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Lm(e.type===`pointercancel`?this.lastMoveEventInfo:Fm(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!ju(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Fm(Dm(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=I;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Lm(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=ra(km(this.contextWindow,`pointermove`,this.handlePointerMove,d),km(this.contextWindow,`pointerup`,this.handlePointerUp,d),km(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Nm.has(e.overflowX)||Nm.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),H.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Go(this.updatePoint)}};function Fm(e,t){return t?{point:t(e.point)}:e}function Im(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Lm({point:e},t){return{point:e,delta:Im(e,zm(t)),offset:Im(e,Rm(t)),velocity:Bm(t,.1)}}function Rm(e){return e[0]}function zm(e){return e[e.length-1]}function Bm(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=zm(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>oa(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>oa(t)*2&&(r=e[1]);let a=sa(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Vm(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?V(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?V(n,e,r.max):Math.min(e,n)),e}function Hm(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Um(e,{top:t,left:n,bottom:r,right:i}){return{x:Hm(e.x,n,i),y:Hm(e.y,t,r)}}function Wm(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Gm(e,t){return{x:Wm(e.x,t.x),y:Wm(e.y,t.y)}}function Km(e,t){let n=.5,r=K(e),i=K(t);return i>r?n=ia(t.min,t.max-r,e.min):r>i&&(n=ia(e.min,e.max-i,t.min)),Xi(0,1,n)}function qm(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Jm=.35;function Ym(e=Jm){return e===!1?e=0:e===!0&&(e=Jm),{x:Xm(e,`left`,`right`),y:Xm(e,`top`,`bottom`)}}function Xm(e,t,n){return{min:Zm(e,t),max:Zm(e,n)}}function Zm(e,t){return typeof e==`number`?e:e[t]||0}var Qm=new WeakMap,$m=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=G(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(e),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Eu(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),yf(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Qa.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=K(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&H.update(()=>i(e,t),!1,!0),wl(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;r&&this.currentDirection===null?(this.currentDirection=rh(o),this.currentDirection!==null&&i&&i(this.currentDirection)):(this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&H.update(()=>a(e,t),!1,!0))},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Pm(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Am(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&H.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!nh(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Vm(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&mm(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?Um(n.layoutBox,e):!1,this.elastic=Ym(t),r!==this.constraints&&!mm(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&yf(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=qm(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!mm(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=xu(n,r.root,this.visualElement.getTransformPagePoint()),a=Gm(r.layout.layoutBox,i);if(t){let e=t(nu(a));this.hasMutatedConstraints=!!e,e&&(a=tu(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=yf(o=>{if(!nh(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return wl(this.visualElement,e),n.start(ul(e,n,0,t,this.visualElement,!1))}stopAnimation(){yf(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){let{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,a=this.visualElement.measureViewportBox();yf(e=>{if(!nh(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-V(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!mm(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};yf(e=>{let t=this.getAxisMotionValue(e).get();i[e]=Km({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),yf(t=>{let n=this.getAxisMotionValue(t);if(!nh(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(V(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Qm.set(this.visualElement,this);let e=this.visualElement.current,t=km(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Fu(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();mm(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=th(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),H.read(r);let o=Mf(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(yf(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Jm,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function eh(e){let t=!0;return()=>{t?t=!1:e()}}function th(e,t,n){let r=nd(e,eh(n)),i=nd(t,eh(n));return()=>{r(),i()}}function nh(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function rh(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var ih=class extends Dd{constructor(e){super(e),this.removeGroupControls=na,this.removeListeners=na,this.controls=new $m(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||na}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},ah=e=>(t,n)=>{e&&H.update(()=>e(t,n),!1,!0)},oh=class extends Dd{constructor(){super(...arguments),this.removePointerDownListener=na}onPointerDown(e){this.session=new Pm(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Am(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:ah(e),onStart:ah(t),onMove:ah(n),onEnd:(e,t)=>{delete this.session,r&&H.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=km(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},sh=!1,ch=class extends s.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),sh&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),zf.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),sh=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||H.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Su.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;sh=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function lh(e){let[t,n]=Mp(),r=(0,s.useContext)(Wi);return(0,F.jsx)(ch,{...e,layoutGroup:r,switchLayoutGroup:(0,s.useContext)(pm),isPresent:t,safeToRemove:n})}var uh={pan:{Feature:oh},drag:{Feature:ih,ProjectionNode:Cp,MeasureLayout:lh}};function dh(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&H.postRender(()=>i(t,Dm(t)))}var fh=class extends Dd{mount(){let{current:e}=this.node;e&&(this.unmount=ku(e,(e,t)=>(dh(this.node,t,`Start`),e=>dh(this.node,e,`End`))))}unmount(){}},ph=class extends Dd{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=ra(Mf(this.node.current,`focus`,()=>this.onFocus()),Mf(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function mh(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&H.postRender(()=>i(t,Dm(t)))}var hh=class extends Dd{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Hu(e,(e,t)=>(mh(this.node,t,`Start`),(e,{success:t})=>mh(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},gh=new WeakMap,_h=new WeakMap,vh=e=>{let t=gh.get(e.target);t&&t(e)},yh=e=>{e.forEach(vh)};function bh({root:e,...t}){let n=e||document;_h.has(n)||_h.set(n,{});let r=_h.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(yh,{root:e,...t})),r[i]}function xh(e,t,n){let r=bh(t);return gh.set(e,n),r.observe(e),()=>{gh.delete(e),r.unobserve(e)}}var Sh={some:0,all:1},Ch=class extends Dd{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:Sh[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=xh(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(wh(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function wh({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Th={inView:{Feature:Ch},tap:{Feature:hh},focus:{Feature:ph},hover:{Feature:fh}},Eh={layout:{ProjectionNode:Cp,MeasureLayout:lh}},Dh=Sm({...Em,...Th,...uh,...Eh},Cm),Oh=n(o(),1),kh=Dh,Ah=Object.defineProperty,jh=(e,t)=>Ah(e,`name`,{value:t,configurable:!0});function Mh(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}jh(Mh,`setRef`);function Nh(...e){return t=>{let n=!1,r=e.map(e=>{let r=Mh(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Mh(e[t],null)}}}}jh(Nh,`composeRefs`);function q(...e){return s.useCallback(Nh(...e),e)}jh(q,`useComposedRefs`);var Ph=Object.defineProperty,Fh=(e,t)=>Ph(e,`name`,{value:t,configurable:!0});function Ih(e){let t=s.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,c=[];r=Kh(r),s.Children.forEach(r,e=>{if(Hh(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;Wh(n)&&typeof Xh==`function`;)n=Xh(n._payload);a=zh(t,n),c.push(a?.props?.children)}else c.push(e)}),a?a=s.cloneElement(a,void 0,c):!o&&s.Children.count(r)===1&&s.isValidElement(r)&&(a=r);let l=a?Vh(a):void 0,u=q(n,l);if(!a){if(r||r===0)throw Error(o?Yh(e):Jh(e));return r}let d=Bh(i,a.props??{});return a.type!==s.Fragment&&(d.ref=n?u:l),s.cloneElement(a,d)});return t.displayName=`${e}.Slot`,t}Fh(Ih,`createSlot`);var Lh=Symbol.for(`radix.slottable`);function Rh(e){let t=Fh(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=Lh,t}Fh(Rh,`createSlottable`);var zh=Fh((e,t)=>`child`in e.props?s.isValidElement(t)?s.cloneElement(t,void 0,e.props.children(t.props.children)):null:s.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function Bh(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=qh(a,i))}return{...e,...n}}Fh(Bh,`mergeProps`);function Vh(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)}Fh(Vh,`getElementRef`);function Hh(e){return s.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Lh}Fh(Hh,`isSlottable`);var Uh=Symbol.for(`react.lazy`);function Wh(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Uh&&`_payload`in e&&Gh(e._payload)}Fh(Wh,`isLazyComponent`);function Gh(e){return typeof e==`object`&&!!e&&`then`in e}Fh(Gh,`isPromiseLike`);function Kh(e){let t=e;for(;Wh(t)&&typeof Xh==`function`;)t=Xh(t._payload);return t}Fh(Kh,`useUnwrappedLazy`);function qh(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Fh(qh,`concatAriaDescribedby`);var Jh=Fh(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Yh=Fh(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Xh=s.use,Zh=Object.defineProperty,Qh=(e,t)=>Zh(e,`name`,{value:t,configurable:!0}),$h=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Ih(`Primitive.${t}`),r=s.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,F.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function eg(e,t){e&&Oh.flushSync(()=>e.dispatchEvent(t))}Qh(eg,`dispatchDiscreteCustomEvent`);var tg=Object.defineProperty,ng=(e,t)=>tg(e,`name`,{value:t,configurable:!0});function rg(e,t){let n=s.createContext(t);n.displayName=e+`Context`;let r=ng(e=>{let{children:t,...r}=e,i=s.useMemo(()=>r,Object.values(r));return(0,F.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=s.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return ng(i,`useContext`),[r,i]}ng(rg,`createContext`);function ig(e,t=[]){let n=[];function r(t,r){let i=s.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=ng(t=>{let{scope:n,children:r,...o}=t,c=n?.[e]?.[a]||i,l=s.useMemo(()=>o,Object.values(o));return(0,F.jsx)(c.Provider,{value:l,children:r})},`Provider`);o.displayName=t+`Provider`;function c(n,o,c={}){let{optional:l=!1}=c,u=o?.[e]?.[a]||i,d=s.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return ng(c,`useContext`),[o,c]}ng(r,`createContext`);let i=ng(()=>{let t=n.map(e=>s.createContext(e));return ng(function(n){let r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,ag(i,...t)]}ng(ig,`createContextScope`);function ag(...e){let t=e[0];if(e.length===1)return t;let n=ng(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return ng(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}ng(ag,`composeContextScopes`);var J=globalThis?.document?s.useLayoutEffect:()=>{},og=Object.defineProperty,Y=(e,t)=>og(e,`name`,{value:t,configurable:!0});function sg(e){let t=e+`CollectionProvider`,[n,r]=ig(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Y(e=>{let{scope:t,children:n}=e,r=s.useRef(null),a=s.useRef(new Map).current;return(0,F.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let c=e+`CollectionSlot`,l=Ih(c),u=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=q(t,a(c,n).collectionRef);return(0,F.jsx)(l,{ref:i,children:r})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=Ih(d),m=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),c=q(t,o),l=a(d,n);return s.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,F.jsx)(p,{[f]:``,ref:c,children:r})});m.displayName=d;function h(t){let n=a(e+`CollectionConsumer`,t);return s.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return Y(h,`useCollection`),[{Provider:o,Slot:u,ItemSlot:m},h,r]}Y(sg,`createCollection`);var cg=new WeakMap,lg=class e extends Map{static{Y(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],cg.set(this,!0)}set(e,t){return cg.get(this)&&!this.has(e)&&this.#e.push(e),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=r?this.size:this.size+1,a=fg(e),o=a>=0?Math.min(a,i-1):Math.max(i+a,0);if(r?this.#e.indexOf(t)===o:o===this.size)return this.set(t,n),this;let s=this.#e.filter(e=>e!==t);s.splice(o,0,t);let c=s.map(e=>[e,e===t?n:this.get(e)]);this.clear();for(let[e,t]of c)this.set(e,t);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);if(r===-1)return this;let i=this.#e.indexOf(t),a=i!==-1&&i<r?r-1:r;return this.insert(a,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);if(r===-1)return this;let i=this.#e.indexOf(t),a=i!==-1&&i<=r?r:r+1;return this.insert(a,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=ug(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=ug(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return ug(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=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=0,a=n;for(let e of this)a=i===0&&!r?e:Reflect.apply(t,this,[a,e,i,this]),i++;return a}reduceRight(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=n;for(let e=this.size-1;e>=0;e--){let n=this.entryAt(e);i=e===this.size-1&&!r?n:Reflect.apply(t,this,[i,n,e,this])}return i}sort(e){if(typeof e!=`function`)throw TypeError(`OrderedDict.sort requires a compare function`);let t=[...this.entries()].sort(e);this.clear();for(let[e,n]of t)this.set(e,n);return this}toSorted(t){if(typeof t!=`function`)throw TypeError(`OrderedDict.toSorted requires a compare function`);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;for(let e of this.#e.slice(t,n))r.set(e,this.get(e));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 ug(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=dg(e,t);return n===-1?void 0:e[n]}Y(ug,`at`);function dg(e,t){let n=e.length,r=fg(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Y(dg,`toSafeIndex`);function fg(e){return e!==e||e===0?0:Math.trunc(e)}Y(fg,`toSafeInteger`);function pg(e){let t=e+`CollectionProvider`,[n,r]=ig(t),[i,a]=n(t);i.displayName=e+`CollectionStableContextProvider`;let[o,c]=n(t);o.displayName=e+`CollectionStatefulContextProvider`;let l=Y(({state:e,...t})=>e?(0,F.jsx)(d,{...t,state:e}):(0,F.jsx)(u,{...t}),`CollectionProvider`);l.displayName=t;let u=Y(e=>{let t=v();return(0,F.jsx)(d,{...e,state:t})},`CollectionInit`);u.displayName=e+`CollectionInit`;let d=Y(e=>{let{scope:t,children:n,state:r}=e,a=s.useRef(null),[c,l]=s.useState(null),u=q(a,l),[d,f]=r,p=s.useRef(new lg),m=s.useCallback(()=>{let e=p.current;return gg(e)||e.sort(_g),e},[]);return s.useEffect(()=>{if(!c)return;let e=vg(()=>{f(e=>{let t=e.toSorted(_g);return t.some(([t],n)=>e.keyAt(n)!==t)?t:e})});return e.observe(c,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[c,f]),(0,F.jsx)(i,{scope:t,collectionElementRef:u,collectionElementRefObject:a,getCollection:m,setCollection:f,registryRef:p,children:(0,F.jsx)(o,{scope:t,collectionElement:c,collection:d,children:n})})},`CollectionProviderImpl`);d.displayName=e+`CollectionProviderImpl`;let f=e+`CollectionSlot`,p=Ih(f),m=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=q(t,a(f,n).collectionElementRef);return(0,F.jsx)(p,{ref:i,children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=Ih(h),_=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),{setCollection:c,registryRef:l}=a(h,n),u=s.useRef(i);mg(u.current,i)||(u.current=i);let d=u.current,f=q(t,s.useCallback(e=>{let t=l.current;e?t.set(e,{...u.current,element:e}):o.current&&t.delete(o.current)},[l]),o);J(()=>{let e=o.current,t=l.current;e&&t.has(e)&&t.set(e,{...d,element:e})},[d,l]);let p=s.useRef(null);return s.useEffect(()=>{let e=o.current,t=p.current;((t?.element??null)!==e||e&&t?.itemData!==d)&&(p.current=e?{element:e,itemData:d}:null,c(n=>{let r=new lg(n);return t&&t.element!==e&&r.delete(t.element),e&&r.set(e,{...d,element:e}),r.sort(_g)}))}),s.useEffect(()=>()=>{let e=p.current;p.current=null,e&&c(t=>{if(!t.has(e.element))return t;let n=new lg(t);return n.delete(e.element),n})},[c]),(0,F.jsx)(g,{"data-radix-collection-item":``,ref:f,children:r})});_.displayName=h;function v(){return s.useState(new lg)}Y(v,`useInitCollection`);function y(t){let{collection:n}=c(e+`CollectionConsumer`,t);return n}Y(y,`useCollection`);function b(t){let{getCollection:n}=a(e+`CollectionConsumer`,t);return n}return Y(b,`useGetCollection`),[{Provider:l,Slot:m,ItemSlot:_},{createCollectionScope:r,useCollection:y,useGetCollection:b,useInitCollection:v}]}Y(pg,`createCollection`);function mg(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}Y(mg,`shallowEqual`);function hg(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Y(hg,`isElementPreceding`);function gg(e){let t;for(let n of e.keys()){if(t){let e=t.compareDocumentPosition(n);if(!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&e&Node.DOCUMENT_POSITION_PRECEDING)return!1}t=n}return!0}Y(gg,`isInDocumentOrder`);function _g(e,t){return!e[1].element||!t[1].element?0:hg(e[1].element,t[1].element)?-1:1}Y(_g,`sortByDocumentPosition`);function vg(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Y(vg,`getChildListObserver`);var yg=Object.defineProperty,bg=(e,t)=>yg(e,`name`,{value:t,configurable:!0}),xg=!!(typeof window<`u`&&window.document&&window.document.createElement);function X(e,t,{checkForDefaultPrevented:n=!0}={}){return bg(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}bg(X,`composeEventHandlers`);function Sg(e){if(!xg)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}bg(Sg,`getOwnerWindow`);function Cg(e){if(!xg)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}bg(Cg,`getOwnerDocument`);function wg(e,t=!1){let{activeElement:n}=Cg(e);if(!n?.nodeName)return null;if(Tg(n)&&n.contentDocument)return wg(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Cg(n).getElementById(e);if(t)return t}}return n}bg(wg,`getActiveElement`);function Tg(e){return e.tagName===`IFRAME`}bg(Tg,`isFrame`);var Eg=Object.defineProperty,Dg=(e,t)=>Eg(e,`name`,{value:t,configurable:!0}),Og=s.useEffectEvent,kg=s.useInsertionEffect;function Ag(e){if(typeof Og==`function`)return Og(e);let t=s.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof kg==`function`?kg(()=>{t.current=e}):J(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}Dg(Ag,`useEffectEvent`);var jg=Object.defineProperty,Mg=(e,t)=>jg(e,`name`,{value:t,configurable:!0}),Ng=s.useInsertionEffect||J;function Pg({prop:e,defaultProp:t,onChange:n=Mg(()=>{},`onChange`),caller:r}){let[i,a,o]=Fg({defaultProp:t,onChange:n}),c=e!==void 0;return[c?e:i,s.useCallback(t=>{if(c){let n=Ig(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[c,e,a,o])]}Mg(Pg,`useControllableState`);function Fg({defaultProp:e,onChange:t}){let[n,r]=s.useState(e),i=s.useRef(n),a=s.useRef(t);return Ng(()=>{a.current=t},[t]),s.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Mg(Fg,`useUncontrolledState`);function Ig(e){return typeof e==`function`}Mg(Ig,`isFunction`);var Lg=Symbol(`RADIX:SYNC_STATE`);function Rg(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:c}=t,l=i!==void 0,u=Ag(o),d=[{...n,state:a}];r&&d.push(r);let[f,p]=s.useReducer((t,n)=>{if(n.type===Lg)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&u(r.state),r},...d),m=f.state,h=s.useRef(m);s.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=s.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return s.useEffect(()=>{l&&!Object.is(i,f.state)&&p({type:Lg,state:i})},[i,f.state,l]),[g,p]}Mg(Rg,`useControllableStateReducer`);var zg=Object.defineProperty,Bg=(e,t)=>zg(e,`name`,{value:t,configurable:!0});function Vg(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}Bg(Vg,`useStateMachine`);var Hg=Bg(e=>{let{present:t,children:n}=e,r=Ug(t),i=typeof n==`function`?n({present:r.isPresent}):s.Children.only(n),a=Gg(r.ref,qg(i));return typeof n==`function`||r.isPresent?s.cloneElement(i,{ref:a}):null},`Presence`);function Ug(e){let[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),a=s.useRef(`none`),o=s.useRef(void 0),[c,l]=Vg(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return s.useEffect(()=>{c===`mounted`?(a.current=o.current??Kg(r.current),o.current=void 0):a.current=`none`},[c]),J(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Kg(t);e?(o.current=s,l(`MOUNT`)):s===`none`||t?.display===`none`?l(`UNMOUNT`):l(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,l]),J(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Bg(a=>{let o=Kg(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(l(`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=Bg(e=>{e.target===t&&(a.current=Kg(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)}}l(`ANIMATION_END`)},[t,l]),{isPresent:[`mounted`,`unmountSuspended`].includes(c),ref:s.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Kg(t)}else r.current=null;n(e)},[])}}Bg(Ug,`usePresence`);function Wg(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Bg(Wg,`setRef`);function Gg(...e){let t=s.useRef(e);return t.current=e,s.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Wg(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():Wg(n[e],null)}}},[])}Bg(Gg,`useStableComposedRefs`);function Kg(e){return e?.animationName||`none`}Bg(Kg,`getAnimationName`);function qg(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)}Bg(qg,`getElementRef`);var Jg=Object.defineProperty,Yg=(e,t)=>Jg(e,`name`,{value:t,configurable:!0}),Xg=s.useId||(()=>void 0),Zg=0;function Qg(e){let[t,n]=s.useState(Xg());return J(()=>{e||n(e=>e??String(Zg++))},[e]),e||(t?`radix-${t}`:``)}Yg(Qg,`useId`);var $g=Object.defineProperty,e_=(e,t)=>$g(e,`name`,{value:t,configurable:!0}),t_={LTR:`ltr`,RTL:`rtl`},n_=s.createContext(void 0);function r_(e){let t=s.useContext(n_);return e||t||t_.LTR}e_(r_,`useDirection`);var i_=Object.defineProperty,a_=(e,t)=>i_(e,`name`,{value:t,configurable:!0}),o_=s.useInsertionEffect;function s_(e){let t=s.useRef(e);return typeof o_==`function`?o_(()=>{t.current=e}):J(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}a_(s_,`useCallbackRef`);var c_=Object.defineProperty,Z=(e,t)=>c_(e,`name`,{value:t,configurable:!0}),l_=`dismissableLayer.update`,u_=`dismissableLayer.pointerDownOutside`,d_=`dismissableLayer.focusOutside`,f_,p_=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),m_=s.forwardRef(Z(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,d=s.useContext(p_),[f,p]=s.useState(null),m=f?.ownerDocument??globalThis?.document,[,h]=s.useState({}),g=q(t,p),_=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=v?_.indexOf(v):-1,b=f?_.indexOf(f):-1,x=d.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=s.useRef(!1),w=__(e=>{a?.(e),c?.(e),e.defaultPrevented||l?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:s.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...d.branches].some(t=>t.contains(e));return S&&!t},[d.branches,S])}),T=v_(e=>{if(r&&C.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},m),E=f?b===_.length-1:!1,ee=s_(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))});return s.useEffect(()=>{if(E)return m.addEventListener(`keydown`,ee,{capture:!0}),()=>m.removeEventListener(`keydown`,ee,{capture:!0})},[m,E,ee]),s.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(f_=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),y_(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=f_))}},[f,m,n,d]),s.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),y_())},[f,d]),s.useEffect(()=>{let e=Z(()=>h({}),`handleUpdate`);return document.addEventListener(l_,e),()=>document.removeEventListener(l_,e)},[]),(0,F.jsx)($h.div,{...u,ref:g,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:X(e.onFocusCapture,T.onFocusCapture),onBlurCapture:X(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:X(e.onPointerDownCapture,w.onPointerDownCapture)})},`DismissableLayer`));function h_(){let e=s.useContext(p_),[t,n]=s.useState(null);return s.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Z(h_,`useDismissableLayerSurface`);var g_=Z(()=>!0,`IS_TRUE`);function __(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=g_}=t,c=s_(e),l=s.useRef(!1),u=s.useRef(!1),d=s.useRef(new Map),f=s.useRef(()=>{});return s.useEffect(()=>{function e(){u.current=!1,i.current=!1,d.current.clear()}Z(e,`resetOutsideInteraction`);function t(){return Array.from(d.current.values()).some(Boolean)}Z(t,`isOutsideInteractionIntercepted`);function s(e){if(!u.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||d.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{u.current&&f.current()},0)}Z(s,`handleInteractionCapture`);function p(e){u.current&&d.current.set(e.type,!1)}Z(p,`handleInteractionBubble`);let m=Z(a=>{if(a.target&&!l.current){let s=function(){n.removeEventListener(`click`,f.current);let r=t();e(),r||b_(u_,c,p,{discrete:!0})};if(Z(s,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,f.current),e(),l.current=!1;return}let p={originalEvent:a};u.current=!0,i.current=r&&a.button===0,d.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,f.current),f.current=s,n.addEventListener(`click`,f.current,{once:!0}))}else n.removeEventListener(`click`,f.current),e();l.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,s,!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`,f.current);for(let e of h)n.removeEventListener(e,s,!0),n.removeEventListener(e,p)}},[n,c,r,i,a,o]),{onPointerDownCapture:Z(()=>l.current=!0,`onPointerDownCapture`)}}Z(__,`usePointerDownOutside`);function v_(e,t=globalThis?.document){let n=s_(e),r=s.useRef(!1);return s.useEffect(()=>{let e=Z(e=>{e.target&&!r.current&&b_(d_,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:Z(()=>r.current=!0,`onFocusCapture`),onBlurCapture:Z(()=>r.current=!1,`onBlurCapture`)}}Z(v_,`useFocusOutside`);function y_(){let e=new CustomEvent(l_);document.dispatchEvent(e)}Z(y_,`dispatchUpdate`);function b_(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?eg(i,a):i.dispatchEvent(a)}Z(b_,`handleAndDispatchCustomEvent`);var x_=Object.defineProperty,Q=(e,t)=>x_(e,`name`,{value:t,configurable:!0}),S_=`focusScope.autoFocusOnMount`,C_=`focusScope.autoFocusOnUnmount`,w_={bubbles:!1,cancelable:!0},T_=s.forwardRef(Q(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o,...c}=e,[l,u]=s.useState(null),d=s_(a),f=s_(o),p=s.useRef(null),m=q(t,u),h=s.useRef(i);s.useEffect(()=>{h.current=i});let g=s.useCallback(e=>e?l?.contains(e)?!0:!!h.current?.some(t=>t.contains(e)):!1,[l]),_=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let e=function(e){if(_.paused||!l)return;let t=e.target;g(t)?p.current=t:I_(p.current,{select:!0})},t=function(e){if(_.paused||!l)return;let t=e.relatedTarget;t!==null&&(g(t)||I_(p.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&I_(l)};Q(e,`handleFocusIn`),Q(t,`handleFocusOut`),Q(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,l,_.paused,g]),s.useEffect(()=>{if(l){L_.add(_);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(S_,w_);l.addEventListener(S_,d),l.dispatchEvent(t),t.defaultPrevented||(A_(B_(M_(l)),{select:!0}),document.activeElement===e&&I_(l))}return()=>{l.removeEventListener(S_,d);let t=l.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(C_,w_);l.addEventListener(C_,f),l.dispatchEvent(r),r.defaultPrevented||I_(e??t.body,{select:!0}),l.removeEventListener(C_,f),L_.remove(_)},0)}}},[l,d,f,_]);let v=s.useCallback(e=>{if(!n&&!r||_.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]=j_(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&I_(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&I_(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,_.paused]);return(0,F.jsx)($h.div,{tabIndex:-1,...c,ref:m,onKeyDown:v})},`FocusScope`)),E_=s.createContext(null);function D_({registry:e,children:t}){return e?(0,F.jsx)(E_.Provider,{value:e,children:t}):t}Q(D_,`FocusScopeBranchProvider`);function O_(){let[e,t]=s.useState([]);return{nodes:e,registry:s.useMemo(()=>({add:Q(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:Q(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}Q(O_,`useFocusScopeBranchRegistry`);function k_(e){let t=s.useContext(E_);s.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}Q(k_,`useFocusScopeBranch`);function A_(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(I_(r,{select:t}),document.activeElement!==n)return}Q(A_,`focusFirst`);function j_(e){let t=M_(e);return[N_(t,e),N_(t.reverse(),e)]}Q(j_,`getTabbableEdges`);function M_(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Q(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}Q(M_,`getTabbableCandidates`);function N_(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):P_(r,{upTo:t})))return r}Q(N_,`findVisible`);function P_(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}Q(P_,`isHidden`);function F_(e){return e.tagName===`INPUT`&&typeof e.select==`function`}Q(F_,`isSelectableInput`);function I_(e,{select:t=!1}={}){if(e&&e.focus){let n=(e.ownerDocument??document).activeElement;e.focus({preventScroll:!0}),e!==n&&F_(e)&&t&&e.select()}}Q(I_,`focus`);var L_=R_();function R_(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=z_(e,t),e.unshift(t)},remove(t){e=z_(e,t),e[0]?.resume()}}}Q(R_,`createFocusScopesStack`);function z_(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Q(z_,`arrayRemove`);function B_(e){return e.filter(e=>e.tagName!==`A`)}Q(B_,`removeLinks`);var V_=Object.defineProperty,H_=s.forwardRef(((e,t)=>V_(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=s.useState(!1);J(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Oh.createPortal((0,F.jsx)($h.div,{...r,ref:t}),o):null},`Portal`)),U_=Object.defineProperty,W_=(e,t)=>U_(e,`name`,{value:t,configurable:!0}),G_=0,K_=null;function q_(e){return J_(),e.children}W_(q_,`FocusGuards`);function J_(){s.useEffect(()=>{K_||={start:Y_(),end:Y_()};let{start:e,end:t}=K_;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),G_++,()=>{G_===1&&(K_?.start.remove(),K_?.end.remove(),K_=null),G_=Math.max(0,G_-1)}},[])}W_(J_,`useFocusGuards`);function Y_(){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}W_(Y_,`createFocusGuard`);var X_=function(){return X_=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},X_.apply(this,arguments)};function Z_(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 Q_(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 $_=`right-scroll-bar-position`,ev=`width-before-scroll-bar`,tv=`with-scroll-bars-hidden`,nv=`--removed-body-scroll-bar-size`;function rv(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function iv(e,t){var n=(0,s.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 av=typeof window<`u`?s.useLayoutEffect:s.useEffect,ov=new WeakMap;function sv(e,t){var n=iv(t||null,function(t){return e.forEach(function(e){return rv(e,t)})});return av(function(){var t=ov.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||rv(e,null)}),i.forEach(function(e){r.has(e)||rv(e,a)})}ov.set(n,e)},[e]),n}function cv(e){return e}function lv(e,t){t===void 0&&(t=cv);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 uv(e){e===void 0&&(e={});var t=lv(null);return t.options=X_({async:!0,ssr:!1},e),t}var dv=function(e){var t=e.sideCar,n=Z_(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 s.createElement(r,X_({},n))};dv.isSideCarExport=!0;function fv(e,t){return e.useMedium(t),dv}var pv=uv(),mv=function(){},hv=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:mv,onWheelCapture:mv,onTouchMoveCapture:mv}),i=r[0],a=r[1],o=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Z_(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=sv([n,t]),w=X_(X_({},x),i);return s.createElement(s.Fragment,null,d&&s.createElement(S,{sideCar:pv,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?s.cloneElement(s.Children.only(c),X_(X_({},w),{ref:C})):s.createElement(y,X_({},w,{className:l,ref:C}),c))});hv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hv.classNames={fullWidth:ev,zeroRight:$_};var gv=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function _v(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=gv();return t&&e.setAttribute(`nonce`,t),e}function vv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function yv(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var bv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=_v())&&(vv(t,n),yv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xv=function(){var e=bv();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Sv=function(){var e=xv();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Cv={left:0,top:0,right:0,gap:0},wv=function(e){return parseInt(e||``,10)||0},Tv=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[wv(n),wv(r),wv(i)]},Ev=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Cv;var t=Tv(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])}},Dv=Sv(),Ov=`data-scroll-locked`,kv=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
18
+ .${tv} {
19
+ overflow: hidden ${r};
20
+ padding-right: ${s}px ${r};
21
+ }
22
+ body[${Ov}] {
23
+ overflow: hidden ${r};
24
+ overscroll-behavior: contain;
25
+ ${[t&&`position: relative ${r};`,n===`margin`&&`
26
+ padding-left: ${i}px;
27
+ padding-top: ${a}px;
28
+ padding-right: ${o}px;
29
+ margin-left:0;
30
+ margin-top:0;
31
+ margin-right: ${s}px ${r};
32
+ `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
33
+ }
34
+
35
+ .${$_} {
36
+ right: ${s}px ${r};
37
+ }
38
+
39
+ .${ev} {
40
+ margin-right: ${s}px ${r};
41
+ }
42
+
43
+ .${$_} .${$_} {
44
+ right: 0 ${r};
45
+ }
46
+
47
+ .${ev} .${ev} {
48
+ margin-right: 0 ${r};
49
+ }
50
+
51
+ body[${Ov}] {
52
+ ${nv}: ${s}px;
53
+ }
54
+ `},Av=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},jv=function(){s.useEffect(function(){return document.body.setAttribute(Ov,(Av()+1).toString()),function(){var e=Av()-1;e<=0?document.body.removeAttribute(Ov):document.body.setAttribute(Ov,e.toString())}},[])},Mv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;jv();var a=s.useMemo(function(){return Ev(i)},[i]);return s.createElement(Dv,{styles:kv(a,!t,i,n?``:`!important`)})},Nv=!1;if(typeof window<`u`)try{var Pv=Object.defineProperty({},"passive",{get:function(){return Nv=!0,!0}});window.addEventListener(`test`,Pv,Pv),window.removeEventListener(`test`,Pv,Pv)}catch{Nv=!1}var Fv=Nv?{passive:!1}:!1,Iv=function(e){return e.tagName===`TEXTAREA`},Lv=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Iv(e)&&n[t]===`visible`)},Rv=function(e){return Lv(e,`overflowY`)},zv=function(e){return Lv(e,`overflowX`)},Bv=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Uv(e,r)){var i=Wv(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Vv=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Hv=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Uv=function(e,t){return e===`v`?Rv(t):zv(t)},Wv=function(e,t){return e===`v`?Vv(t):Hv(t)},Gv=function(e,t){return e===`h`&&t===`rtl`?-1:1},Kv=function(e,t,n,r,i){var a=Gv(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=Wv(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Uv(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},qv=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Jv=function(e){return[e.deltaX,e.deltaY]},Yv=function(e){return e&&`current`in e?e.current:e},Xv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Zv=function(e){return`
55
+ .block-interactivity-${e} {pointer-events: none;}
56
+ .allow-interactivity-${e} {pointer-events: all;}
57
+ `},Qv=0,$v=[];function ey(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),i=s.useState(Qv++)[0],a=s.useState(Sv)[0],o=s.useRef(e);s.useEffect(function(){o.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Q_([e.lockRef.current],(e.shards||[]).map(Yv),!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 c=s.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=qv(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=Bv(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Bv(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 Kv(h,t,e,h===`h`?s:c,!0)},[]),l=s.useCallback(function(e){var n=e;if($v.length&&$v[$v.length-1]===a){var r=`deltaY`in n?Jv(n):qv(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Xv(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var s=(o.current.shards||[]).map(Yv).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?c(n,s[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=s.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ty(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=s.useCallback(function(e){n.current=qv(e),r.current=void 0},[]),f=s.useCallback(function(t){u(t.type,Jv(t),t.target,c(t,e.lockRef.current))},[]),p=s.useCallback(function(t){u(t.type,qv(t),t.target,c(t,e.lockRef.current))},[]);s.useEffect(function(){return $v.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,l,Fv),document.addEventListener(`touchmove`,l,Fv),document.addEventListener(`touchstart`,d,Fv),function(){$v=$v.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,l,Fv),document.removeEventListener(`touchmove`,l,Fv),document.removeEventListener(`touchstart`,d,Fv)}},[]);var m=e.removeScrollBar,h=e.inert;return s.createElement(s.Fragment,null,h?s.createElement(a,{styles:Zv(i)}):null,m?s.createElement(Mv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ty(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ny=fv(pv,ey),ry=s.forwardRef(function(e,t){return s.createElement(hv,X_({},e,{ref:t,sideCar:ny}))});ry.classNames=hv.classNames;var iy=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},ay=new WeakMap,oy=new WeakMap,sy={},cy=0,ly=function(e){return e&&(e.host||ly(e.parentNode))},uy=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ly(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})},dy=function(e,t,n,r){var i=uy(t,Array.isArray(e)?e:[e]);sy[n]||(sy[n]=new WeakMap);var a=sy[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=(ay.get(e)||0)+1,l=(a.get(e)||0)+1;ay.set(e,c),a.set(e,l),o.push(e),c===1&&i&&oy.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(),cy++,function(){o.forEach(function(e){var t=ay.get(e)-1,i=a.get(e)-1;ay.set(e,t),a.set(e,i),t||(oy.has(e)||e.removeAttribute(r),oy.delete(e)),i||e.removeAttribute(n)}),cy--,cy||(ay=new WeakMap,ay=new WeakMap,oy=new WeakMap,sy={})}},fy=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||iy(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),dy(r,i,n,`aria-hidden`)):function(){return null}},py=Object.defineProperty,my=(e,t)=>py(e,`name`,{value:t,configurable:!0}),hy=`Dialog`,[gy,_y]=ig(hy),[vy,yy]=gy(hy),by=my(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,c=s.useRef(null),l=s.useRef(null),{nodes:u,registry:d}=O_(),[f,p]=Pg({prop:r,defaultProp:i??!1,onChange:a,caller:hy}),[m,h]=s.useState(0),[g,_]=s.useState(0);return(0,F.jsx)(vy,{scope:t,triggerRef:c,contentRef:l,contentId:Qg(),titleId:Qg(),descriptionId:Qg(),titlePresent:m>0,descriptionPresent:g>0,setTitleCount:h,setDescriptionCount:_,open:f,onOpenChange:p,onOpenToggle:s.useCallback(()=>p(e=>!e),[p]),modal:o,branchNodes:u,branchRegistry:d,children:n})},`Dialog`),xy=`DialogPortal`,[Sy,Cy]=gy(xy,{forceMount:void 0}),wy=my(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=yy(xy,t);return(0,F.jsx)(Sy,{scope:t,forceMount:n,children:s.Children.map(r,e=>(0,F.jsx)(Hg,{present:n||a.open,children:(0,F.jsx)(H_,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Ty=`DialogOverlay`,Ey=s.forwardRef(my(function(e,t){let n=Cy(Ty,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yy(Ty,e.__scopeDialog);return a.modal?(0,F.jsx)(Hg,{present:r||a.open,children:(0,F.jsx)(Oy,{...i,ref:t})}):null},`DialogOverlay`)),Dy=Ih(`DialogOverlay.RemoveScroll`),Oy=s.forwardRef(my(function(e,t){let{__scopeDialog:n,...r}=e,i=yy(Ty,n),a=q(t,h_());return(0,F.jsx)(ry,{as:Dy,allowPinchZoom:!0,shards:s.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,F.jsx)($h.div,{"data-state":zy(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),ky=`DialogContent`,Ay=s.forwardRef(my(function(e,t){let n=Cy(ky,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yy(ky,e.__scopeDialog);return(0,F.jsx)(Hg,{present:r||a.open,children:a.modal?(0,F.jsx)(jy,{...i,ref:t}):(0,F.jsx)(My,{...i,ref:t})})},`DialogContent`)),jy=s.forwardRef(my(function(e,t){let n=yy(ky,e.__scopeDialog),r=s.useRef(null),i=q(t,n.contentRef,r);return s.useEffect(()=>{let e=r.current;if(e)return fy(e)},[]),(0,F.jsx)(Ny,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:X(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:X(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:X(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),My=s.forwardRef(my(function(e,t){let n=yy(ky,e.__scopeDialog),r=s.useRef(!1),i=s.useRef(!1);return(0,F.jsx)(Ny,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ny=s.forwardRef(my(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=yy(ky,n);return J_(),(0,F.jsx)(D_,{registry:l.branchRegistry,children:(0,F.jsx)(T_,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,F.jsx)(m_,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?Ry(o,l.descriptionId):o,"data-state":zy(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`)),Py=s.forwardRef(my(function(e,t){let{__scopeDialog:n,...r}=e,i=yy(`DialogTitle`,n),{setTitleCount:a}=i;return J(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,F.jsx)($h.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Fy=s.forwardRef(my(function(e,t){let{__scopeDialog:n,...r}=e,i=yy(`DialogDescription`,n),{setDescriptionCount:a}=i;return J(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,F.jsx)($h.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Iy=`DialogClose`,Ly=s.forwardRef(my(function(e,t){let{__scopeDialog:n,...r}=e,i=yy(Iy,n);return(0,F.jsx)($h.button,{type:`button`,...r,ref:t,onClick:X(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Ry(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}my(Ry,`concatAriaDescribedby`);function zy(e){return e?`open`:`closed`}my(zy,`getState`);var By=Object.defineProperty,Vy=(e,t)=>By(e,`name`,{value:t,configurable:!0});function Hy(e){let[t,n]=s.useState(void 0);return J(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=0,r=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let i=r[0];window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{let t,r;if(`borderBoxSize`in i){let e=i.borderBoxSize,n=Array.isArray(e)?e[0]:e;t=n.inlineSize,r=n.blockSize}else t=e.offsetWidth,r=e.offsetHeight;n({width:t,height:r})})});return r.observe(e,{box:`border-box`}),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}n(void 0)},[e]),t}Vy(Hy,`useSize`);var Uy=[`top`,`right`,`bottom`,`left`],Wy=Math.min,Gy=Math.max,Ky=Math.round,qy=Math.floor,Jy=e=>({x:e,y:e}),Yy={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Xy(e,t,n){return Gy(e,Wy(t,n))}function Zy(e,t){return typeof e==`function`?e(t):e}function Qy(e){return e.split(`-`)[0]}function $y(e){return e.split(`-`)[1]}function eb(e){return e===`x`?`y`:`x`}function tb(e){return e===`y`?`height`:`width`}function nb(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function rb(e){return eb(nb(e))}function ib(e,t,n){n===void 0&&(n=!1);let r=$y(e),i=rb(e),a=tb(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=pb(o)),[o,pb(o)]}function ab(e){let t=pb(e);return[ob(e),t,ob(t)]}function ob(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var sb=[`left`,`right`],cb=[`right`,`left`],lb=[`top`,`bottom`],ub=[`bottom`,`top`];function db(e,t,n){switch(e){case`top`:case`bottom`:return n?t?cb:sb:t?sb:cb;case`left`:case`right`:return t?lb:ub;default:return[]}}function fb(e,t,n,r){let i=$y(e),a=db(Qy(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ob)))),a}function pb(e){let t=Qy(e);return Yy[t]+e.slice(t.length)}function mb(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function hb(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:mb(e)}function gb(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 _b(e,t,n){let{reference:r,floating:i}=e,a=nb(t),o=rb(t),s=tb(o),c=Qy(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=$y(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function vb(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}=Zy(t,e),p=hb(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=gb(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=gb(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 yb=50,bb=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:vb},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=_b(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<yb&&(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}=_b(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},xb=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}=Zy(e,t)||{};if(l==null)return{};let d=hb(u),f={x:n,y:r},p=rb(i),m=tb(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=Wy(d[_],T),ee=Wy(d[v],T),te=C-h[m]-ee,ne=C/2-h[m]/2+w,D=Xy(E,ne,te),re=!c.arrow&&$y(i)!=null&&ne!==D&&a.reference[m]/2-(ne<E?E:ee)-h[m]/2<0,ie=re?ne<E?ne-E:ne-te:0;return{[p]:f[p]+ie,data:{[p]:D,centerOffset:ne-D-ie,...re&&{alignmentOffset:ie}},reset:re}}}),Sb=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}=Zy(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Qy(r),_=nb(o),v=Qy(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[pb(o)]:ab(o)),x=p!==`none`;!d&&x&&b.push(...fb(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=ib(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`||_===nb(t)||T.every(e=>nb(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=nb(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}if(r!==n)return{reset:{placement:n}}}return{}}}};function Cb(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wb(e){return Uy.some(t=>e[t]>=0)}var Tb=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Zy(e,t);switch(i){case`referenceHidden`:{let e=Cb(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:wb(e)}}}case`escaped`:{let e=Cb(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:wb(e)}}}default:return{}}}}},Eb=new Set([`left`,`top`]);async function Db(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Qy(n),s=$y(n),c=nb(n)===`y`,l=Eb.has(o)?-1:1,u=a&&c?-1:1,d=Zy(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 Ob=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 Db(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}}}}},kb=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}=Zy(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=nb(i),p=eb(f),m=u[p],h=u[f],g=(e,t)=>Xy(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}}}}}},Ab=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}=Zy(e,t),u={x:n,y:r},d=nb(i),f=eb(d),p=u[f],m=u[d],h=Zy(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=Eb.has(Qy(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}}}},jb=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}=Zy(e,t),c=await i.detectOverflow(t,s),l=Qy(n),u=$y(n),d=nb(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=Wy(p-c[m],g),y=Wy(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*Gy(c.left,c.right):S=p-2*Gy(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 Mb(){return typeof window<`u`}function Nb(e){return Fb(e)?(e.nodeName||``).toLowerCase():`#document`}function $(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Pb(e){return((Fb(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Fb(e){return Mb()?e instanceof Node||e instanceof $(e).Node:!1}function Ib(e){return Mb()?e instanceof Element||e instanceof $(e).Element:!1}function Lb(e){return Mb()?e instanceof HTMLElement||e instanceof $(e).HTMLElement:!1}function Rb(e){return!Mb()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof $(e).ShadowRoot}function zb(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Xb(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Bb(e){return/^(table|td|th)$/.test(Nb(e))}function Vb(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Hb=/transform|translate|scale|rotate|perspective|filter/,Ub=/paint|layout|strict|content/,Wb=e=>!!e&&e!==`none`,Gb;function Kb(e){let t=Ib(e)?Xb(e):e;return Wb(t.transform)||Wb(t.translate)||Wb(t.scale)||Wb(t.rotate)||Wb(t.perspective)||!Jb()&&(Wb(t.backdropFilter)||Wb(t.filter))||Hb.test(t.willChange||``)||Ub.test(t.contain||``)}function qb(e){let t=Qb(e);for(;Lb(t)&&!Yb(t);){if(Kb(t))return t;if(Vb(t))return null;t=Qb(t)}return null}function Jb(){return Gb??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Gb}function Yb(e){return/^(html|body|#document)$/.test(Nb(e))}function Xb(e){return $(e).getComputedStyle(e)}function Zb(e){return Ib(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qb(e){if(Nb(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Rb(e)&&e.host||Pb(e);return Rb(t)?t.host:t}function $b(e){let t=Qb(e);return Yb(t)?(e.ownerDocument||e).body:Lb(t)&&zb(t)?t:$b(t)}function ex(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=$b(e),i=r===e.ownerDocument?.body,a=$(r);if(i){let e=tx(a);return t.concat(a,a.visualViewport||[],zb(r)?r:[],e&&n?ex(e):[])}return t.concat(r,ex(r,[],n))}function tx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nx(e){let t=Xb(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Lb(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Ky(n)!==a||Ky(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function rx(e){return Ib(e)?e:e.contextElement}function ix(e){let t=rx(e);if(!Lb(t))return Jy(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=nx(t),o=(a?Ky(n.width):n.width)/r,s=(a?Ky(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ax=Jy(0);function ox(e){let t=$(e);return!Jb()||!t.visualViewport?ax:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sx(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===$(e)}function cx(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=rx(e),o=Jy(1);t&&(r?Ib(r)&&(o=ix(r)):o=ix(e));let s=sx(a,n,r)?ox(a):Jy(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=$(a),t=Ib(r)?$(r):r,n=e,i=tx(n);for(;i&&t!==n;){let e=ix(i),t=i.getBoundingClientRect(),r=Xb(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=$(i),i=tx(n)}}return gb({width:u,height:d,x:c,y:l})}function lx(e,t){let n=Zb(e).scrollLeft;return t?t.left+n:cx(Pb(e)).left+n}function ux(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-lx(e,n),y:n.top+t.scrollTop}}function dx(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Pb(r),s=t?Vb(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Jy(1),u=Jy(0),d=Lb(r);if((d||!a)&&((Nb(r)!==`body`||zb(o))&&(c=Zb(r)),d)){let e=cx(r);l=ix(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ux(o,c):Jy(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 fx(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function px(e){let t=Zb(e),n=e.ownerDocument.body,r=Gy(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Gy(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+lx(e),o=-t.scrollTop;return Xb(n).direction===`rtl`&&(a+=Gy(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var mx=25;function hx(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=$(e),a=Pb(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Jb()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(lx(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<=mx&&(s-=o)}return{width:s,height:c,x:l,y:u}}function gx(e,t){let n=cx(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ix(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _x(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=hx(e,n,t);else if(t===`document`)r=px(Pb(e));else if(Ib(t))r=gx(t,n);else{let n=ox(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return gb(r)}function vx(e,t){let n=t.get(e);if(n)return n;let r=ex(e,[],!1).filter(e=>Ib(e)&&Nb(e)!==`body`),i=null,a=Xb(e).position===`fixed`,o=a?Qb(e):e;for(;Ib(o)&&!Yb(o);){let e=Xb(o),t=Kb(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Qb(o)}return t.set(e,r),r}function yx(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Vb(t)?[]:vx(t,this._c):[].concat(n),r],o=_x(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=_x(t,a[e],i);s=Gy(n.top,s),c=Wy(n.right,c),l=Wy(n.bottom,l),u=Gy(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function bx(e){let{width:t,height:n}=nx(e);return{width:t,height:n}}function xx(e,t,n){let r=Lb(t),i=Pb(t),a=n===`fixed`,o=cx(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Jy(0);if((r||!a)&&((Nb(t)!==`body`||zb(i))&&(s=Zb(t)),r)){let e=cx(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=lx(i));let l=i&&!r&&!a?ux(i,s):Jy(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 Sx(e){return Xb(e).position===`static`}function Cx(e,t){if(!Lb(e)||Xb(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Pb(e)===n&&(n=n.ownerDocument.body),n}function wx(e,t){let n=$(e);if(Vb(e))return n;if(!Lb(e)){let t=Qb(e);for(;t&&!Yb(t);){if(Ib(t)&&!Sx(t))return t;t=Qb(t)}return n}let r=Cx(e,t);for(;r&&Bb(r)&&Sx(r);)r=Cx(r,t);return r&&Yb(r)&&Sx(r)&&!Kb(r)?n:r||qb(e)||n}var Tx=async function(e){let t=this.getOffsetParent||wx,n=this.getDimensions,r=await n(e.floating);return{reference:xx(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ex(e){return Xb(e).direction===`rtl`}var Dx={convertOffsetParentRelativeRectToViewportRelativeRect:dx,getDocumentElement:Pb,getClippingRect:yx,getOffsetParent:wx,getElementRects:Tx,getClientRects:fx,getDimensions:bx,getScale:ix,isElement:Ib,isRTL:Ex};function Ox(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function kx(e,t,n){let r=null,i,a=Pb(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=qy(d),h=qy(a.clientWidth-(u+f)),g=qy(a.clientHeight-(d+p)),_=qy(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Gy(0,Wy(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Ox(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=$(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ax(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=rx(e),u=i||a?[...l?ex(l):[],...t?ex(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?kx(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?cx(e):null;c&&g();function g(){let t=cx(e);h&&!Ox(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 jx=Ob,Mx=kb,Nx=Sb,Px=jb,Fx=Tb,Ix=xb,Lx=Ab,Rx=(e,t,n)=>{let r=new Map,i=n??{},a={...Dx,...i.platform,_c:r};return bb(e,t,{...i,platform:a})},zx=typeof document<`u`?s.useLayoutEffect:function(){};function Bx(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(!Bx(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)&&!Bx(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vx(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hx(e,t){let n=Vx(e);return Math.round(t*n)/n}function Ux(e){let t=s.useRef(e);return zx(()=>{t.current=e}),t}function Wx(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[d,f]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=s.useState(r);Bx(p,r)||m(r);let[h,g]=s.useState(null),[_,v]=s.useState(null),y=s.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=s.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=s.useRef(null),w=s.useRef(null),T=s.useRef(d),E=l!=null,ee=Ux(l),te=Ux(i),ne=Ux(u),D=s.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};te.current&&(e.platform=te.current),Rx(C.current,w.current,e).then(e=>{let t={...e,isPositioned:ne.current!==!1};re.current&&!Bx(T.current,t)&&(T.current=t,Oh.flushSync(()=>{f(t)}))})},[p,t,n,te,ne]);zx(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let re=s.useRef(!1);zx(()=>(re.current=!0,()=>{re.current=!1}),[]),zx(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(ee.current)return ee.current(x,S,D);D()}},[x,S,D,ee,E]);let ie=s.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),ae=s.useMemo(()=>({reference:x,floating:S}),[x,S]),oe=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!ae.floating)return e;let t=Hx(ae.floating,d.x),r=Hx(ae.floating,d.y);return c?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vx(ae.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,c,ae.floating,d.x,d.y]);return s.useMemo(()=>({...d,update:D,refs:ie,elements:ae,floatingStyles:oe}),[d,D,ie,ae,oe])}var Gx=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?{}:Ix({element:r.current,padding:i}).fn(n):r?Ix({element:r,padding:i}).fn(n):{}}}},Kx=(e,t)=>{let n=jx(e);return{name:n.name,fn:n.fn,options:[e,t]}},qx=(e,t)=>{let n=Mx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jx=(e,t)=>({fn:Lx(e).fn,options:[e,t]}),Yx=(e,t)=>{let n=Nx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xx=(e,t)=>{let n=Px(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zx=(e,t)=>{let n=Fx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qx=(e,t)=>{let n=Gx(e);return{name:n.name,fn:n.fn,options:[e,t]}},$x=Object.defineProperty,eS=(e,t)=>$x(e,`name`,{value:t,configurable:!0}),tS={Partial:`partial`,Always:`always`},nS={Optimized:`optimized`,Always:`always`},rS=`Popper`,[iS,aS]=ig(rS),[oS,sS]=iS(rS),cS=eS(e=>{let{__scopePopper:t,children:n}=e,[r,i]=s.useState(null),[a,o]=s.useState(void 0);return(0,F.jsx)(oS,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),lS=`PopperAnchor`,uS=s.forwardRef(eS(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=sS(lS,n),o=s.useRef(null),c=a.onAnchorChange,l=q(t,s.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=s.useRef(null);s.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let d=a.placementState&&_S(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,F.jsx)($h.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:l})},`PopperAnchor`)),dS=`PopperContent`,[fS,pS]=iS(dS),mS=s.forwardRef(eS(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=tS.Partial,hideWhenDetached:p=!1,updatePositionStrategy:m=nS.Optimized,onPlaced:h,...g}=e,_=sS(dS,n),[v,y]=s.useState(null),b=q(t,y),[x,S]=s.useState(null),C=Hy(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),ee=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},te=Array.isArray(u)?u:[u],ne=te.length>0,D={padding:ee,boundary:te.filter(hS),altBoundary:ne},{refs:re,floatingStyles:ie,placement:ae,isPositioned:oe,middlewareData:se}=Wx({strategy:`fixed`,placement:E,whileElementsMounted:eS((...e)=>Ax(...e,{animationFrame:m===nS.Always}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[Kx({mainAxis:i+T,alignmentAxis:o}),l&&qx({mainAxis:!0,crossAxis:!1,...f===tS.Partial?{limiter:Jx()}:{},...D}),l&&Yx({...D}),Xx({...D,apply:eS(({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`)}),x&&Qx({element:x,padding:c}),gS({arrowWidth:w,arrowHeight:T}),p&&Zx(ne?{strategy:`referenceHidden`,...D}:{strategy:`referenceHidden`,padding:D.padding,altBoundary:D.altBoundary})]}),ce=_.setPlacementState;J(()=>(ce(ae),()=>{ce(void 0)}),[ae,ce]);let[le,ue]=_S(ae),de=s_(h);J(()=>{oe&&de?.()},[oe,de]);let fe=se.arrow?.x,pe=se.arrow?.y,me=se.arrow?.centerOffset!==0,[he,ge]=s.useState();return J(()=>{v&&ge(window.getComputedStyle(v).zIndex)},[v]),(0,F.jsx)(`div`,{ref:re.setFloating,"data-radix-popper-content-wrapper":``,style:{...ie,transform:oe?ie.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:he,"--radix-popper-transform-origin":[se.transformOrigin?.x,se.transformOrigin?.y].join(` `),...se.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,F.jsx)(fS,{scope:n,placedSide:le,placedAlign:ue,onArrowChange:S,arrowX:fe,arrowY:pe,shouldHideArrow:me,children:(0,F.jsx)($h.div,{"data-side":le,"data-align":ue,...g,ref:b,style:{...g.style,animation:oe?g.style?.animation:`none`}})})})},`PopperContent`));function hS(e){return e!==null}eS(hS,`isNotNull`);var gS=eS(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]=_S(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 _S(e){let[t,n=`center`]=e.split(`-`);return[t,n]}eS(_S,`getSideAndAlignFromPlacement`);var vS=Object.defineProperty,yS=(e,t)=>vS(e,`name`,{value:t,configurable:!0}),bS=!1;function xS(){let[e,t]=s.useState(bS);return s.useEffect(()=>{bS||(bS=!0,t(!0))},[]),e}yS(xS,`useIsHydrated`);var SS=s.useSyncExternalStore;function CS(){return()=>{}}yS(CS,`subscribe`);function wS(){return SS(CS,()=>!0,()=>!1)}yS(wS,`useIsHydratedModern`);var TS=typeof SS==`function`?wS:xS,ES=Object.defineProperty,DS=(e,t)=>ES(e,`name`,{value:t,configurable:!0}),OS=`rovingFocusGroup.onEntryFocus`,kS={bubbles:!1,cancelable:!0},AS=`RovingFocusGroup`,[jS,MS,NS]=sg(AS),[PS,FS]=ig(AS,[NS]),IS={Vertical:`vertical`,Horizontal:`horizontal`},LS={LTR:`ltr`,RTL:`rtl`},[RS,zS]=PS(AS),BS=s.forwardRef(DS(function(e,t){return(0,F.jsx)(jS.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(jS.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(VS,{...e,ref:t})})})},`RovingFocusGroup`)),VS=s.forwardRef(DS(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=s.useRef(null),m=q(t,p),h=r_(a),[g,_]=Pg({prop:o,defaultProp:c??null,onChange:l,caller:AS}),[v,y]=s.useState(!1),b=s_(u),x=MS(n),S=s.useRef(!1),[C,w]=s.useState(0);return s.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(OS,b),()=>e.removeEventListener(OS,b)},[b]),(0,F.jsx)(RS,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:s.useCallback(e=>_(e),[_]),onItemShiftTab:s.useCallback(()=>y(!0),[]),onFocusableItemAdd:s.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:s.useCallback(()=>w(e=>e-1),[]),children:(0,F.jsx)($h.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:X(e.onMouseDown,()=>{S.current=!0}),onFocus:X(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(OS,kS);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);qS([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:X(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),HS=`RovingFocusGroupItem`,US=s.forwardRef(DS(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...c}=e,l=Qg(),u=a||l,d=zS(HS,n),f=d.currentTabStopId===u,p=MS(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=d,_=TS();return J(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),s.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,F.jsx)(jS.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,F.jsx)($h.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...c,ref:t,onMouseDown:X(e.onMouseDown,e=>{r?d.onItemFocus(u):e.preventDefault()}),onFocus:X(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:X(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=KS(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?JS(n,r+1):n.slice(r+1)}setTimeout(()=>qS(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),WS={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function GS(e,t){return t===LS.RTL?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}DS(GS,`getDirectionAwareKey`);function KS(e,t,n){let r=GS(e.key,n);if(!(t===IS.Vertical&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===IS.Horizontal&&[`ArrowUp`,`ArrowDown`].includes(r)))return WS[r]}DS(KS,`getFocusIntent`);function qS(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}DS(qS,`focusFirst`);function JS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}DS(JS,`wrapArray`);var YS=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function XS(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:YS(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var ZS=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},QS=e=>{let t=ZS(e);return t.charAt(0).toUpperCase()+t.slice(1)},$S=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),eC={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function tC(e){return e!=null}function nC(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??eC.width,a=e.size??e.height??eC.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?$S(...c):$S(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??eC[`stroke-width`])*Number(e.size??e.width??eC.width)/Number(t.size??t.width??eC.width):t.strokeWidth??eC[`stroke-width`];return[`svg`,{...Object.entries(eC).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&tC(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&tC(t.width)&&{[r(`width`)]:t.width},...`height`in t&&tC(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function rC(e,t={}){return nC(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var iC=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},aC=(0,s.createContext)({}),oC=()=>(0,s.useContext)(aC),sC=(0,s.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:c=``,children:l,iconNode:u=[],icon:d={node:u,aliases:[],size:24},...f},p)=>{let{size:m=24,strokeWidth:h=2,absoluteStrokeWidth:g=!1,nonScalingStroke:_=!1,color:v=`currentColor`,className:y=``}=oC()??{},b=!!l||iC(f),[x,S,C=[]]=rC(d,{color:e??v,width:n??t??m,height:r??t??m,strokeWidth:i??h,absoluteStrokeWidth:a??g,nonScalingStroke:o??_,className:$S(y,c),hasA11yProp:b,attributes:f});return(0,s.createElement)(x,{ref:p,...S},[...C.map(([e,t])=>(0,s.createElement)(e,t)),...Array.isArray(l)?l:[l]])});function cC(e,t=[],n=[]){let r=typeof e==`string`?XS(e,t,n):e,i=(0,s.forwardRef)(({className:e,...t},n)=>(0,s.createElement)(sC,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=QS(r.name)),i}var lC={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};lC.node;var uC=cC(lC),dC={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};dC.node;var fC=cC(dC),pC={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};pC.node;var mC=cC(pC),hC={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};hC.node;var gC=cC(hC),_C={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};_C.node;var vC=cC(_C),yC={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};yC.node;var bC=cC(yC),xC={primary:`bg-fg text-inverse hover:bg-fg/90 shadow-[inset_0_1px_0_rgba(255,255,255,.12)]`,secondary:`bg-raised text-fg ring-1 ring-inset ring-line-strong hover:bg-hover hover:ring-line-strong`,ghost:`text-fg-2 hover:text-fg hover:bg-hover`,human:`bg-human text-[#1b1203] hover:brightness-105`,ai:`bg-ai-soft text-ai-fg ring-1 ring-inset ring-ai-line/40 hover:bg-ai-soft/80`,danger:`text-bad hover:bg-bad-soft`,ok:`bg-ok text-inverse hover:brightness-105`},SC={xs:`h-6 px-2 text-[11.5px] gap-1 rounded-[6px]`,sm:`h-7 px-2.5 text-[12.5px] gap-1.5 rounded-[7px]`,md:`h-8 px-3 text-[13px] gap-2 rounded-[8px]`},CC=(0,s.forwardRef)(function({variant:e=`secondary`,size:t=`sm`,icon:n,kbd:r,className:a,children:o,...s},c){return(0,F.jsxs)(`button`,{ref:c,className:i(`inline-flex shrink-0 select-none items-center justify-center whitespace-nowrap font-medium transition-[background-color,color,box-shadow,filter] duration-150 disabled:pointer-events-none disabled:opacity-45 [&_svg]:size-[14px] [&_svg]:shrink-0`,xC[e],SC[t],a),...s,children:[n,o,r]})}),wC=(0,s.forwardRef)(function({className:e,active:t,size:n=`md`,...r},a){return(0,F.jsx)(`button`,{ref:a,className:i(`inline-flex shrink-0 select-none items-center justify-center rounded-[7px] text-fg-2 transition-colors duration-150 hover:bg-hover hover:text-fg disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-[15px]`,n===`md`?`size-8`:`size-7 [&_svg]:size-[14px]`,t&&`bg-active text-fg`,e),...r})}),TC={neutral:`bg-active text-fg-2`,human:`bg-human-soft text-human-fg`,ai:`bg-ai-soft text-ai-fg`,ok:`bg-ok-soft text-ok`,bad:`bg-bad-soft text-bad`,warn:`bg-warn-soft text-warn`};function EC({tone:e=`neutral`,children:t,className:n}){return(0,F.jsx)(`span`,{className:i(`inline-flex h-[18px] items-center gap-1 rounded-[5px] px-1.5 text-[11px] font-medium leading-none`,TC[e],n),children:t})}function DC({tone:e=`neutral`,pulse:t,className:n}){let r={neutral:`bg-fg-3`,off:`bg-fg-3/60`,human:`bg-human`,ai:`bg-ai`,ok:`bg-ok`,bad:`bg-bad`,warn:`bg-warn`}[e];return(0,F.jsxs)(`span`,{className:i(`relative inline-flex size-[7px] shrink-0`,n),children:[t&&(0,F.jsx)(`span`,{className:i(`absolute inset-0 animate-ping rounded-full opacity-60`,r)}),(0,F.jsx)(`span`,{className:i(`relative inline-flex size-[7px] rounded-full`,r)})]})}function OC({className:e}){return(0,F.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:i(`size-[14px] animate-[spin_0.8s_linear_infinite]`,e),fill:`none`,children:[(0,F.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,stroke:`currentColor`,strokeOpacity:`.2`,strokeWidth:`2`}),(0,F.jsx)(`path`,{d:`M14 8a6 6 0 0 0-6-6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}function kC({children:e,action:t}){return(0,F.jsxs)(`div`,{className:`flex h-7 items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`shrink-0 whitespace-nowrap text-[12px] font-medium text-fg-3`,children:e}),t]})}function AC({icon:e,title:t,children:n}){return(0,F.jsxs)(`div`,{className:`flex flex-col items-center px-6 py-10 text-center`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex size-10 items-center justify-center rounded-[10px] bg-sunken text-fg-3 ring-1 ring-inset ring-line [&_svg]:size-[18px]`,children:e}),(0,F.jsx)(`div`,{className:`text-[13px] font-medium text-fg`,children:t}),n&&(0,F.jsx)(`div`,{className:`mt-1 max-w-[260px] text-[12.5px] leading-relaxed text-fg-3`,children:n})]})}function jC(e){let[t,n]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(e&&t)return An(t)},[e,t]),n}function MC(e,t={}){let[n,r]=(0,s.useState)(null),i=(0,s.useRef)(t);return i.current=t,(0,s.useEffect)(()=>{if(!e||!n)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=An(n);n.contains(document.activeElement)||(i.current.initialFocus?.()??Nn(n)[0]??n).focus({preventScroll:!0});let a=e=>{Dn(e)||kn()!==n||(e.key===`Escape`&&i.current.onEscape?(e.preventDefault(),i.current.onEscape()):e.key===`Tab`&&Pn(e,n))};return document.addEventListener(`keydown`,a),()=>{document.removeEventListener(`keydown`,a),r();let e=document.activeElement;if(e&&e!==document.body&&!n.contains(e))return;let o=e=>!!e&&e!==document.body&&e.isConnected&&!e.closest(`[inert]`),s=o(t)?t:i.current.returnFocus?.();o(s)&&s.focus({preventScroll:!0})}},[e,n]),r}function NC({open:e,onOpenChange:t,title:n,description:r,children:a,className:o,position:c=`center`,focusFirst:l=!1,showTitle:u=!1,ownTitle:d=!1,role:f}){let p=jC(e),m=(0,s.useRef)(null),h=(0,s.useRef)(e);return h.current=e,(0,F.jsx)(by,{open:e,onOpenChange:t,children:(0,F.jsx)(Fp,{children:e&&(0,F.jsxs)(wy,{forceMount:!0,children:[(0,F.jsx)(Ey,{asChild:!0,forceMount:!0,children:(0,F.jsx)(kh.div,{"data-layer-backdrop":!0,className:`fixed inset-0 z-50 bg-black/45 backdrop-blur-[2px]`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16}})}),(0,F.jsx)(Ay,{asChild:!0,forceMount:!0,ref:p,...f?{role:f}:{},"aria-modal":`true`,...d?{"aria-describedby":void 0}:{},onEscapeKeyDown:e=>!h.current&&En(e),onOpenAutoFocus:e=>{m.current=document.activeElement instanceof HTMLElement?document.activeElement:null,!l&&(e.preventDefault(),e.currentTarget?.focus())},onCloseAutoFocus:e=>{e.preventDefault();let t=m.current,n=document.activeElement;n&&n!==document.body||t&&t!==document.body&&t.isConnected&&!t.closest(`[inert]`)&&t.focus({preventScroll:!0})},children:(0,F.jsxs)(kh.div,{className:i(`fixed left-1/2 z-50 flex max-h-[86vh] w-[min(720px,calc(100vw-32px))] flex-col overflow-hidden rounded-[14px] bg-panel shadow-pop outline-none`,c===`center`?`top-1/2`:`top-[14vh] max-h-[80vh]`,o),initial:{opacity:0,scale:.97,x:`-50%`,y:c===`center`?`-48%`:6},animate:{opacity:1,scale:1,x:`-50%`,y:c===`center`?`-50%`:0},exit:{opacity:0,scale:.98,x:`-50%`,y:c===`center`?`-49%`:4},transition:{type:`spring`,stiffness:520,damping:38,mass:.8},children:[u?(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-line py-2.5 pe-2.5 ps-5`,children:[(0,F.jsx)(Py,{className:`text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:n}),(0,F.jsx)(Ly,{asChild:!0,children:(0,F.jsx)(wC,{"aria-label":`Close`,children:(0,F.jsx)(bC,{})})})]}):!d&&(0,F.jsx)(Py,{className:`sr-only`,children:n}),!d&&(0,F.jsx)(Fy,{className:`sr-only`,children:r??n}),a]})})]},`dialog`)})})}var PC=Py,FC=Fy,IC=_(()=>({ask:null}));function LC(e){return new Promise(t=>{IC.getState().ask?.resolve(!1),IC.setState({ask:{...e,resolve:t}})})}function RC(){let e=IC(e=>e.ask),t=(0,s.useRef)(e);e&&(t.current=e);let n=e??t.current,r=e=>{IC.getState().ask?.resolve(e),IC.setState({ask:null})};return(0,F.jsx)(NC,{open:!!e,onOpenChange:e=>!e&&r(!1),title:n?.title??``,ownTitle:!0,focusFirst:!0,role:`alertdialog`,className:`w-[min(440px,calc(100vw-32px))]`,children:(0,F.jsxs)(`div`,{className:`p-5`,"data-confirm":!0,children:[(0,F.jsx)(PC,{className:`text-[14.5px] font-semibold text-fg`,children:n?.title}),n?.body&&(0,F.jsx)(FC,{className:`mt-1.5 text-[12.5px] leading-relaxed text-fg-2`,children:n.body}),(0,F.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,F.jsx)(CC,{variant:`ghost`,size:`md`,onClick:()=>r(!1),children:`Cancel`}),(0,F.jsx)(CC,{variant:`primary`,size:`md`,className:n?.danger?`bg-bad text-inverse hover:bg-bad/90`:void 0,onClick:()=>r(!0),children:n?.action})]})]})})}var zC={name:`Saywright`,tagline:`Point at your app. Say what to change.`,taglineAr:`أشِر إلى تطبيقك وقل ما تريد تغييره.`,slug:`saywright`};export{Rh as $,Ey as A,ae as At,m_ as B,cS as C,ie as Ct,Hy as D,ne as Dt,aS as E,E as Et,H_ as F,_ as Ft,Pg as G,r_ as H,T_ as I,u as It,J,X as K,D_ as L,o as Lt,fy as M,ce as Mt,ry as N,T as Nt,by as O,re as Ot,J_ as P,v as Pt,Ih as Q,k_ as R,FS as S,fe as St,mS as T,oe as Tt,Qg as U,s_ as V,Hg as W,$h as X,ig as Y,eg as Z,fC as _,qt as _t,MC as a,Mi as at,BS as b,pe as bt,AC as c,Si as ct,CC as d,hr as dt,Nh as et,wC as f,cr as ft,mC as g,On as gt,gC as h,Dn as ht,NC as i,Ui as it,wy as j,D as jt,Ay as k,se as kt,kC as l,N as lt,vC as m,tr as mt,RC as n,kh as nt,EC as o,ki as ot,bC as p,A as pt,sg as q,LC as r,Fp as rt,DC as s,Ai as st,zC as t,q as tt,OC as u,M as ut,uC as v,Rt as vt,uS as w,le as wt,US as x,ue as xt,cC as y,Ve as yt,O_ as z};