@openloaf/openspeech-frontend 0.2.49-beta.0 → 0.2.49-beta.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.
@@ -801,7 +801,7 @@ Target language: ${h}`;let y="";try{const x=await Ni({mode:a.mode,systemPrompt:g
801
801
  `).slice(2,6).join(" | ");console.info(`[recording] stopMic called, caller=${e}`),Tl()};let au=!1;const k8=()=>{!lt||au||(au=!0,H("esc_capture_start").catch(e=>{au=!1,console.warn("[recording] esc_capture_start failed:",e)}))},S8=()=>{!lt||!au||(au=!1,H("esc_capture_stop").catch(e=>{console.warn("[recording] esc_capture_stop failed:",e)}))},Ct=(e,t,n={})=>{lt&&Dt("overlay","openspeech://overlay-toast",{kind:e,title:t,description:n.description,action:n.action,durationMs:n.durationMs})},bl=e=>{if(!lt){Oe("[overlay] showOverlayResult skipped: not main window");return}if(!e){Oe("[overlay] showOverlayResult skipped: empty text");return}Oe(`[overlay] showOverlayResult emit → text.len=${e.length} preview=${JSON.stringify(e.slice(0,32))}`),Dt("overlay","openspeech://overlay-show-result",{text:e}).then(()=>{Oe("[overlay] showOverlayResult emit ok")},t=>{nn(`[overlay] showOverlayResult emit failed: ${String(t)}`)})},E8=e=>{if(!lt)return;const t=Y.getState().ui;if(!ju(t,e)){Oe(`[overlay] hint ${e} skip: already learned or dismissed`);return}Oe(`[overlay] hint ${e} emit → overlay-show-hint-confirm`),Dt("overlay","openspeech://overlay-show-hint-confirm",{id:e,text:te.t(`overlay:hints.${e}.text`),confirmLabel:te.t(`overlay:hints.${e}.action_confirm`),ariaLabelClose:te.t("overlay:hints.aria.dismiss")})},Ck=()=>{if(!lt)return;const e=Y.getState().ui;if(ju(e,"firstResultConfirm")){E8("firstResultConfirm");return}const t=Vt;if(!t)return;const n=bt??t;if(!kW(e,"appFirstInject",t)){Oe(`[overlay] hint appFirstInject skip: app ${t} already shown or disabled`);return}const r=_s.appFirstInject;Oe(`[overlay] hint appFirstInject emit → overlay-show-hint-confirm app=${n}`),Dt("overlay","openspeech://overlay-show-hint-confirm",{id:"appFirstInject",text:te.t("overlay:hints.appFirstInject.text",{app:n}),confirmLabel:"",ariaLabelClose:te.t("overlay:hints.aria.dismiss"),autoHideMs:r.autoHideMs??2e3,hideActions:!0}),Y.getState().markHintSeenForApp("appFirstInject",t)},C8=async()=>{if(!bt)return!1;const e=await N0();return e?e.name!==bt:!1},qd=(e,t)=>{lt&&Dt("overlay","openspeech://translate-active",{active:e,lang:t})},j8=(e,t)=>{if(!lt)return;const n=mn.getState().bindings[t],r=n?C4(n,sn()):null;Dt("overlay","openspeech://mode-switch-hint",{kind:e,hotkeyLabel:r})},jk=e=>e==="dictate_ptt"||e==="translate",Nk=()=>{const e=Y.getState().general.translateTargetLang,t=`overlay:translate.lang.${e}`,n=te.t(t);return n===t?e.toUpperCase():n},N8=(e,t)=>{const n=`${e} ${t}`.toLowerCase();return n.includes("model repeat output happened")||n.includes("repeat output happened")||n.includes("repetition")};let wr=!1,is=!1,ou=null,su=null;const P8=()=>{su===null&&(su=window.setInterval(()=>{const e=.3+Math.random()*.5;Ma("openspeech://audio-level",e)},50))},cx=()=>{su!==null&&(window.clearInterval(su),su=null)},Xf=e=>{Ma("openspeech://debug-recording",e)},Pk=()=>{if(!is)return;is=!1,cx(),Xf({active:!1});const e=ou;ou=null,e?.(new Error("debug-cancelled"))},T8=e=>new Promise((t,n)=>{const r=window.setTimeout(()=>{ou=null,t()},e);ou=i=>{window.clearTimeout(r),ou=null,n(i)}});let gs=null,Zf=!1,Qi=null,bt=null,Fr=null,Vt=null,Ol=null,lu=!1,cu=null,as=null,Qf=!1,Sc=0;const _r=e=>{const t=String(e??"");if(t==="byok_not_implemented_yet"||t.includes("byok_not_implemented_yet"))return te.t("overlay:error.byok_not_implemented");if(t==="byok_missing_credentials"||t.includes("byok_missing_credentials"))return te.t("overlay:error.byok_missing_credentials");if(t.startsWith("byok_keyring_error")||t.includes("byok_keyring_error"))return te.t("overlay:error.byok_keyring_error");if(t==="unauthenticated_byok"||t.includes("unauthenticated_byok"))return te.t("overlay:error.unauthenticated_byok");if(t==="insufficient_funds"||t.includes("insufficient_funds"))return te.t("overlay:error.insufficient_funds");if(t==="idle_timeout"||t.includes("idle_timeout"))return te.t("overlay:error.idle_timeout");if(t==="rate_limited"||t.includes("rate_limited"))return te.t("overlay:error.rate_limited");if(t.includes("aliyun_invalid_audio_format"))return te.t("overlay:error.aliyun_invalid_audio_format");if(t.includes("aliyun_quota_exceeded"))return te.t("overlay:error.aliyun_quota_exceeded");if(t.includes("aliyun_oss_upload_failed"))return te.t("transcribe.aliyun_oss_upload_failed",{ns:"pages"});if(t.includes("aliyun_file_too_large"))return te.t("overlay:error.aliyun_file_too_large");if(t.includes("aliyun_filetrans_timeout"))return te.t("overlay:error.aliyun_filetrans_timeout");if(t.includes("aliyun_filetrans_failed")){const r=t.split("aliyun_filetrans_failed:").pop()?.trim()||"";return te.t("overlay:error.aliyun_filetrans_failed",{msg:r})}if(t.includes("aliyun_upload_failed")){const r=t.split("aliyun_upload_failed:").pop()?.trim()||"";return te.t("overlay:error.aliyun_upload_failed",{msg:r})}if(t.includes("aliyun_unauthenticated"))return te.t("overlay:error.aliyun_unauthenticated");if(t.includes("aliyun_rate_limited"))return te.t("overlay:error.aliyun_rate_limited");if(t.includes("aliyun_network_error"))return te.t("overlay:error.stt_network");if(t.includes("file_too_large_for_tencent_byok"))return te.t("overlay:error.file_too_large_for_tencent_byok");if(t.includes("tencent_task_timeout"))return te.t("overlay:error.tencent_task_timeout");if(t.includes("transcribe_timeout"))return te.t("overlay:error.transcribe_timeout");if(t.includes("tencent_task_failed")){const r=t.split("tencent_task_failed:").pop()?.trim()||"";return te.t("overlay:error.tencent_task_failed",{msg:r})}if(t.includes("tencent_unauthenticated"))return te.t("overlay:error.tencent_unauthenticated");if(t.includes("tencent_rate_limited"))return te.t("overlay:error.tencent_rate_limited");if(t.includes("tencent_network_error"))return te.t("overlay:error.stt_network");if(t.includes("tencent_cos_bucket_required"))return te.t("transcribe.tencent_cos_bucket_required",{ns:"pages"});if(t.includes("tencent_cos_upload_failed"))return te.t("transcribe.tencent_cos_upload_failed",{ns:"pages"});if(t.includes("tencent_cos_unauthenticated"))return te.t("overlay:error.tencent_cos_unauthenticated");if(t.includes("tencent_cos_forbidden"))return te.t("overlay:error.tencent_cos_forbidden");if(t.includes("tencent_cos_network"))return te.t("overlay:error.tencent_cos_network");if(t.includes("tencent_cos_unknown"))return te.t("overlay:error.tencent_cos_unknown");if(t.includes("network_unavailable"))return te.t("overlay:error.stt_network");if(t.includes("not authenticated"))return te.t("overlay:error.stt_not_authenticated");if(t.includes("HTTP error: 5"))return te.t("overlay:error.stt_5xx");if(t.includes("HTTP error: 4"))return te.t("overlay:error.stt_4xx");if(t.includes("audio stream not running"))return te.t("overlay:error.stt_mic_not_ready");if(t.includes("network error"))return te.t("overlay:error.stt_network");const n=t.split(":").pop()?.trim()||t;return n.length>60?n.slice(0,60)+"…":n},Tk="saas_unauthorized",os=e=>e==="unauthorized"||e==="not authenticated"||e.startsWith(`${Tk}:`)||e.startsWith(`${Tk} `)||e.startsWith("unauthorized:")||e.startsWith("not authenticated:"),hl=()=>{lt&&(console.warn("[stt] saas auth lost (401) → opening login (recording/history preserved)"),lu=!0,Ke.getState().openLogin())},A8=()=>{lt&&(console.warn("[stt] auth lost (401) before recording → discarding session + opening login"),kl(te.t("overlay:error.stt_not_authenticated")),qi(),Pn(),We.setState({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""}),Ke.getState().openLogin())},Ak=(e,t,n)=>{lt&&(kl(t||e),qi(),Pn(),We.setState({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""}),Ct("error",e,{description:t,...n??{}}))},wl=e=>{const t=String(e??"");return t.includes("byok_missing_credentials")||t.includes("byok_keyring_error")},_l=()=>({label:te.t("overlay:toast.byok_switch_to_saas.action"),key:"switch_to_saas"}),O8=e=>{lt&&(gs=null,Qi=null,lu=!1,bt=null,Fr=null,Vt=null,Ol=null,Promise.all([N0(),B2()]).then(([t,n])=>{t&&(bt=t.name,Fr=t.title||null,Vt=t.appId);const r=H2(n);Ol=r,Oe(`[session] start id=${e} app=${t?.name??"null"} appId=${t?.appId??"null"} title=${t?.title?JSON.stringify(t.title.slice(0,60)):"null"} ime=${n??"null"} imeBlocked=${r}`)}),IW(e).then(()=>{Zi()==="REALTIME"&&LW({mode:"auto",provider:ms(),lang:ru()}).catch(n=>{const r=String(n??"");if(os(r)){A8();return}console.warn("[stt] start failed → aborting recording:",n);const i=wl(n);Ak(te.t("overlay:toast.stt_start_failed.title"),te.t("overlay:toast.stt_start_failed.description",{reason:_r(n)}),i?{action:_l(),durationMs:0}:void 0)})}).catch(t=>{console.error("[recording] start recording failed → aborting:",t),Ak(te.t("overlay:toast.recording_start_failed.title"),_r(t))}))},P0=()=>te.t("overlay:transcript.placeholder"),kl=e=>{if(!lt)return;const t=We.getState().activeId==="translate";it.getState().add({type:t?"translate":"dictation",text:P0(),status:"failed",error:e,duration_ms:0,target_app:bt,target_app_id:Vt,target_lang:t?Y.getState().general.translateTargetLang:null}).catch(n=>console.warn("[recording] recordAbortFailureHistory failed:",n))},Ok=async()=>{if(!lt)return{rec:null,text:""};cu=null,as=null,Qf=!1;const e=Zi();console.info(`[recording] finalizeAndWriteHistory entering, mode=${e}`);const t=performance.now();let n=null,r=null,i=null,a=null,o=null,s=null;const l=await Promise.allSettled([CA()]).then(A=>A[0]);if(l.status==="fulfilled"&&l.value.voiced===!1){const A=l.value;return console.info(`[recording] silent recording (no voice) raw=${A.raw_duration_ms}ms → skip stt + history`),Nu(),ai(),{rec:null,text:"",silent:!0}}e!=="REALTIME"?wr=!0:!Zf&&!wr&&(console.info("[stt] ws never ready during recording → degrade to file transcribe"),wr=!0,Nu());const c=wr?{status:"fulfilled",value:{text:"",creditsConsumed:0}}:(await Promise.allSettled([$W()]))[0],d=l.status==="fulfilled"?l.value:null;cu=d;let u=c.status==="fulfilled"&&c.value.text?c.value.text:"";u&&(as=u),c.status==="fulfilled"&&!wr&&(i=c.value.creditsConsumed),console.info(`[finalize] mode=${e} sttStatus=${c.status} textLen=${u.length} recDurMs=${d?.duration_ms??"n/a"} degraded=${wr}`);const p=We.getState().activeId==="translate",h=e!=="REALTIME"&&!p&&iu();let g=!1,y=null,x=null,v="";if(wr)if(d)if(e!=="REALTIME"&&d.duration_ms>3e5){console.warn(`[stt] utterance recording too long (${d.duration_ms}ms) → skip transcribe`);const R=te.t("transcribe.too_long_for_utterance",{ns:"pages"});Ct("error",R,{durationMs:6e3}),o=R,u=""}else{const R=xo({corePrompt:j0[Ln(Y.getState().dictation.lang,Y.getState().general.interfaceLang)],items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:d.duration_ms,expandDomainKeywords:!0,includeUserCorrections:!0});if(h){ai();const P=Y.getState().aiRefine,D=Y.getState().general,O=Y.getState().dictation,M=Ln(O.lang,D.interfaceLang),I=Tu(Vt,P),$=Eo(bt,Vt),U=Pu($),F=Da({lang:M,customRules:I.customRules,customExamples:I.customExamples,targetApp:U});let T=null;P.mode==="custom"&&(T=P.customProviders.find(N=>N.id===P.activeCustomProviderId)??null),x=P.mode==="custom"&&T?`${T.name} · ${T.model}`:P.mode==="saas"?"OpenLoaf SaaS":null;const Q=xo({corePrompt:F,items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:d.duration_ms,enrichHotwords:!0,appTypeAddon:bp($,M)}),J=N=>{v+=N,lt&&We.getState().state==="transcribing"&&We.setState({state:"injecting",pillEarlyHide:!1}),We.setState({liveTranscript:v}),uu(v)};try{if(P.mode==="custom"&&!T){const L=await _k({audioPath:d.audio_path,durationMs:d.duration_ms,lang:ru(),provider:ms(),asrSystemPrompt:R,refine:null,clipboardFallback:!0},J);throw u=L.rawText,u&&(as=u),Qi=L.providerKind,i=L.creditsAsr??0,g=!0,L.asrError?new Error(L.asrError):new Error("no_active_custom_provider")}const N=performance.now(),z=await _k({audioPath:d.audio_path,durationMs:d.duration_ms,lang:ru(),provider:ms(),asrSystemPrompt:R,refine:{mode:P.mode,systemPrompt:Q,userText:"",customBaseUrl:T?.baseUrl,customModel:T?.model,customKeyringId:T?`ai_provider_${T.id}`:void 0,taskId:gs??void 0},clipboardFallback:!0},J);if(u=z.rawText,u&&(as=u),Qi=z.providerKind,i=z.creditsAsr??0,g=!0,console.info(`[stt] merged transcribe+refine → raw=${z.rawText.length} refined=${z.refinedText?.length??"null"} kind=${z.providerKind} creditsAsr=${z.creditsAsr} creditsRefine=${z.creditsRefine}`),z.asrError){const L=z.asrError;if(os(L))hl(),o=te.t("overlay:error.stt_not_authenticated");else{console.warn("[stt] merged ASR failed:",L);const B=_r(L),ee=wl(L);Ct("error",te.t("overlay:toast.transcribe_failed.title"),{description:B,...ee?{action:_l(),durationMs:0}:{}}),o=B}u=""}else if(a=(a??0)+(z.creditsRefine??0),z.refineError){const L=z.refineError,B=`${te.t("errors:phase.refine")}: `;if(P.mode==="custom"){console.warn(`[refine] merged custom failed: ${L}`);const ee=_r(L);await Ei(L)||Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:ee}),s=`${B}${ee}`}else if(os(L))console.warn(`[refine] merged saas auth lost: ${L}`),hl(),s=`${B}${te.t("overlay:error.stt_not_authenticated")}`;else{console.warn("[refine] merged stream failed → raw fallback:",L);const ee=_r(L);Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:ee}),s=`${B}${ee}`}}else y=z.refinedText,r=Math.round(performance.now()-N)}catch(N){const z=String(N??"");if(z.includes("no_active_custom_provider"))s=`${te.t("errors:phase.refine")}: ${te.t("overlay:toast.transcribe_failed.title")}`;else if(os(z))hl(),o=te.t("overlay:error.stt_not_authenticated"),u="";else{console.warn("[stt] merged transcribe+refine failed:",N);const L=_r(N),B=wl(N);Ct("error",te.t("overlay:toast.transcribe_failed.title"),{description:L,...B?{action:_l(),durationMs:0}:{}}),o=L,u=""}}}else try{console.info("[stt] file transcribe, audio=",d.audio_path,"duration=",d.duration_ms),console.info(`[stt] file transcribe system_prompt: len=${R.length} chars`);const P=await E0({audioPath:d.audio_path,durationMs:d.duration_ms,lang:ru(),provider:ms(),systemPrompt:R});u=P.text,u&&(as=u),Qi=P.providerKind,i=P.creditsConsumed??0,console.info(`[stt] file transcribe → got ${P.text.length} chars (variant=${P.variant} kind=${P.providerKind} credits=${P.creditsConsumed})`)}catch(P){const D=String(P??"");if(os(D))hl(),o=te.t("overlay:error.stt_not_authenticated"),u="";else{console.warn("[stt] file transcribe failed:",P);const O=_r(P),M=wl(P);Ct("error",te.t("overlay:toast.transcribe_failed.title"),{description:O,...M?{action:_l(),durationMs:0}:{}}),o=O,u=""}}}else console.warn("[stt] degraded but no rec; can't file transcribe");else if(c.status==="rejected")if(console.warn("[stt] finalize failed:",c.reason),String(c.reason??"").includes("no active stt session"))o=te.t("overlay:error.stt_mic_not_ready");else{const R=_r(c.reason),P=wl(c.reason);Ct("error",te.t("overlay:toast.transcribe_failed.title"),{description:R,...P?{action:_l(),durationMs:0}:{}}),o=R}else if(c.status==="fulfilled"&&!c.value){console.warn("[stt] no final transcript (silent or timeout)");const A=te.t("overlay:toast.transcribe_failed.no_transcript");Ct("error",te.t("overlay:toast.transcribe_failed.title"),{description:A,durationMs:5e3}),o=A}n=Math.round(performance.now()-t);const _=Zi(),b=We.getState().activeId==="translate",k=b||iu();if(Qf&&u){Qf=!1;const A=b,R=Qi??(_==="REALTIME"?"saas-realtime":"saas-file");We.setState({state:"idle",activeId:null,recordingId:null,liveTranscript:"",pillEarlyHide:!1}),Pn();try{await gn(u)}catch(P){console.warn("[skip-refine] writeClipboard failed:",P)}if(bl(u),d)try{await it.getState().add({type:A?"translate":"dictation",text:u,refined_text:null,status:"success",duration_ms:d.duration_ms,audio_path:d.audio_path,target_app:bt,target_app_id:Vt,asr_source:wr?"saas-rest":"saas-realtime",segment_mode:_,provider_kind:R,focus_title:Fr,asr_ms:n,credits_asr:i})}catch(P){console.warn("[skip-refine] history.add failed:",P)}return{rec:d,text:u}}if(u&&lt&&We.getState().state==="transcribing"&&!k&&We.setState({state:"injecting",pillEarlyHide:!1}),l.status==="rejected"){console.error("[recording] stop failed:",l.reason);const A=String(l.reason);Ct("error",te.t("overlay:toast.recording_save_failed.title"),{description:A}),o=`${te.t("overlay:toast.recording_save_failed.title")}: ${A}`}let S=null,w=null,E=null;const j=[];if(g){S=y,E=x,lt&&We.setState({pillEarlyHide:!0});try{await ys}catch{}if(Ji()&&Y.getState().dictation.clipboardCopy&&(S??u))try{await gn(S??u)}catch(A){console.warn("[clipboard] merged post-refine writeText failed:",A)}lt&&We.getState().state==="transcribing"&&We.setState({state:"injecting",pillEarlyHide:!1})}if(console.info(`[refine] gate textLen=${u.length} segmentMode=${_} refineEnabled=${k} merged=${g} willCallRefine=${!!u&&k&&!g}`),u&&k&&!g){const A=C0();ai();let R="";const P=performance.now(),D=Y.getState().aiRefine,O=Y.getState().general,M=Y.getState().dictation,I=Ln(M.lang,O.interfaceLang),$=O.translateTargetLang,U=v8[$]??$,F=Tu(Vt,D),T=Eo(bt,Vt),Q=Pu(T),J=Da({lang:I,customRules:F.customRules,customExamples:F.customExamples,targetApp:Q}),N=b?`${b0(D.customTranslationSystemPrompt,I)}
802
802
 
803
803
  Target language: ${U}`:null,z=b&&O.translateOutputMode==="bilingual";let L=null;D.mode==="custom"&&(L=D.customProviders.find(ee=>ee.id===D.activeCustomProviderId)??null),E=D.mode==="custom"&&L?`${L.name} · ${L.model}`:D.mode==="saas"?"OpenLoaf SaaS":null,console.info(`[ai-refine] stream start mode=${D.mode} textLen=${u.length} hotwordsLen=${A.length} provider=${L?.id??"saas"}`);let B=!1;try{if(D.mode==="custom"&&!L)throw new Error("no_active_custom_provider");const ee={customBaseUrl:L?.baseUrl,customModel:L?.model,customKeyringId:L?`ai_provider_${L.id}`:void 0},X=Ne=>{R+=Ne,lt&&We.getState().state==="transcribing"&&We.setState({state:"injecting",pillEarlyHide:!1}),We.setState({liveTranscript:R}),uu(R)},ne=b&&!z?Ne=>{}:X,fe=Eo(bt,Vt),V=xo({corePrompt:J,items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:d?.duration_ms,enrichHotwords:!0,appTypeAddon:bp(fe,I)});console.info(`[ai-refine] phase1 system_prompt: len=${V.length} chars`);const oe=await Ni({mode:D.mode,systemPrompt:V,userText:u,...ee,taskId:gs??void 0},ne);a=(a??0)+(oe.creditsConsumed??0);const me=oe.refinedText;if(B=!0,b){if(lt&&We.setState({state:"translating",pillEarlyHide:!1}),z){const ge=/\n*$/.exec(R)?.[0].length??0,de=Math.max(0,1-ge);de>0&&(R+=`
804
- `.repeat(de),uu(R))}let Ne=z;const xe=ge=>{if(Ne){if(ge=ge.replace(/^\s+/,""),!ge)return;Ne=!1}X(ge)},be=xo({corePrompt:N,items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:d?.duration_ms,skipHistory:!0,enrichHotwords:!0});console.info(`[ai-refine] phase2 system_prompt: len=${be.length} chars`);const je=await Ni({mode:D.mode,systemPrompt:be,userText:me,...ee,taskId:gs??void 0},xe);a=(a??0)+(je.creditsConsumed??0),S=z?R:je.refinedText,w=je.refinedText}else S=me;r=Math.round(performance.now()-P),console.info(`[ai-refine] stream done refinedLen=${S.length} elapsedMs=${r}`),M8(),lt&&We.setState({pillEarlyHide:!0});try{await ys}catch{}if(Ji()&&Y.getState().dictation.clipboardCopy)try{await gn(S)}catch(Ne){console.warn("[clipboard] post-refine writeText failed:",Ne)}}catch(ee){const X=String(ee??""),Z=b?B?`${te.t("errors:phase.translate")}: `:`${te.t("errors:phase.refine")}: `:`${te.t("errors:phase.refine")}: `;if(D.mode==="custom"){console.warn(`[refine] custom failed after ${Math.round(performance.now()-P)}ms: ${X}`);const ne=_r(ee);await Ei(ee)||Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:ne}),s=`${Z}${ne}`}else if(os(X))console.warn(`[refine] saas auth lost after ${Math.round(performance.now()-P)}ms: ${X}`),hl(),s=`${Z}${te.t("overlay:error.stt_not_authenticated")}`;else{console.warn(`[refine] stream failed after ${Math.round(performance.now()-P)}ms, falling back to raw transcript:`,ee);const ne=_r(ee);Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:ne}),s=`${Z}${ne}`}}lt&&(We.getState().state==="transcribing"||We.getState().state==="translating")&&We.setState({state:"injecting",pillEarlyHide:!1})}else u&&!k&&console.info(`[refine] skipped, segmentMode=${_} refineEnabled=${k}`);const C=S??u;if(d&&Ji()){const A=wr?"saas-rest":"saas-realtime",R=Qi??(_==="REALTIME"?"saas-realtime":"saas-file"),P=b&&s!==null;let D,O;u?P?(D="failed",O=s):s!==null?(D="success",O=s):(D="success",O=void 0):(D="failed",O=o??"no final transcript");const I=await it.getState().add({type:b?"translate":"dictation",text:u||P0(),refined_text:b?w:S,status:D,error:O,duration_ms:d.duration_ms,audio_path:d.audio_path,target_app:bt,target_app_id:Vt,asr_source:A,ai_model:E,segment_mode:_,provider_kind:R,target_lang:b?Y.getState().general.translateTargetLang:null,asr_ms:n,refine_ms:r,debug_payload:null,focus_title:Fr,credits_asr:i,credits_refine:a});if(Ea.getState().setFromHistory(I),lt&&D==="failed"&&I.audio_path&&!lu){const $=O??te.t("overlay:toast.transcribe_failed.title");Oe(`[overlay] emit show-transcribe-error historyId=${I.id} message="${$.slice(0,80)}"`),Dt("overlay","openspeech://overlay-show-transcribe-error",{historyId:I.id,message:$})}lu&&D==="failed"&&!u&&I.audio_path&&(console.info(`[recording] saas auth lost during finalize → pending recovery historyId=${I.id}`),Ke.getState().setPendingAuthRecoveryHistoryId(I.id)),lu=!1}if(C&&Ji()){try{await ys}catch{}if(!Ji())return console.log("[inject] tail skipped: flow no longer active (esc / cancel)"),ai(),{rec:d,text:C};const A=await h8(),R=A===!1,P=await C8(),D=await MA(),O=OA(Vt,bt);if(Oe(`[inject] tail gate check focusEditable=${A} focusNotEditable=${R} appChanged=${P} imeBlocked=${D} axUnreliable=${O} recordedApp=${bt??"null"}`),R&&!(O&&!P)||P){nn(`[inject] tail → result panel focusEditable=${A} appChanged=${P} typedLen=${Kn.length}`);try{await gn(C)}catch(I){console.warn("[clipboard] fallback write failed:",I)}return bl(C),ai(),{rec:d,text:C}}console.log("[inject] tail enter",{finalLen:C.length,injectedLen:Kn.length,prefixMatch:C.startsWith(Kn)});const M=C.startsWith(Kn)?C.slice(Kn.length):null;if(M===null){console.warn("[inject] tail prefix mismatch → clipboard-only fallback",{finalLen:C.length,injectedLen:Kn.length,finalHead:C.slice(0,24),injectedHead:Kn.slice(0,24)});try{await gn(C),console.log("[inject] clipboard-only write ok")}catch(I){console.error("[clipboard] writeText failed:",I)}bl(C)}else if(!M)console.log("[inject] tail no-op: remaining is empty (stream covered all)"),Ck();else{if(Oe(`[inject] tail → paste-all imeBlocked=${D} axUnreliable=${O} typedLen=${Kn.length} remainingLen=${M.length}`),D)try{await H("inject_commit_ime")}catch(I){console.warn("[inject] commit_ime before paste-all failed:",I)}try{await R8(M),console.log("[inject] tail paste-all ok"),Ck()}catch(I){console.error("[inject] tail paste-all failed:",I);try{await gn(C)}catch{}bl(C)}}ai()}else C||console.log("[inject] tail skipped: empty finalText");return{rec:d,text:C}};let Kn="",ys=Promise.resolve();const Ji=()=>{const e=We.getState().state;return e==="transcribing"||e==="injecting"||e==="translating"},M8=()=>{},ai=()=>{Kn=""},MA=async()=>{if(Ol!==null)return Ol;const e=await B2(),t=H2(e);return Ol=t,Oe(`[ime] session probe id=${e??"null"} blocks_unicode_keydown=${t}`),t},uu=e=>{if(lt&&Ji()&&Y.getState().dictation.streamingInject){if(Ol===!0){const t=e.slice(Kn.length);t&&Oe(`[inject] incremental skip (ime blocked) delta=${t.length} cumulativeFull=${e.length}`);return}if(OA(Vt,bt)){const t=e.slice(Kn.length);t&&Oe(`[inject] incremental skip (ax/cg unreliable app=${bt??"null"}) delta=${t.length} cumulativeFull=${e.length}`);return}ys=ys.then(async()=>{if(!Ji())return;if(await MA()){Oe(`[inject] incremental skip in chain (ime blocked) cumulativeFull=${e.length}`);return}if(!e.startsWith(Kn))return;const t=e.slice(Kn.length);if(t){if(Vt||bt){const n=await N0();if(n){const r=!!Vt&&!!n.appId&&n.appId!==Vt,i=!n.appId&&!!bt&&n.name!==bt;if(r||i){Oe(`[inject] incremental skip (app changed: recordedApp=${bt??"null"}/${Vt??"null"} → cur=${n.name}/${n.appId??"null"}) delta=${t.length}`);return}}}try{await H("inject_type",{text:t}),Kn=e}catch(n){console.warn("[inject] incremental type failed",{deltaLen:t.length,cumulativeLen:Kn.length,err:String(n)})}}})}},R8=async e=>{if(!e)return;const t=Y.getState().dictation.clipboardCopy;let n=null;if(!t)try{n=await Su()}catch(o){console.warn("[inject] read clipboard for backup failed:",o)}let r=!1;try{await gn(e),r=!0}catch(o){console.error("[inject] paste-all writeClipboard failed:",o)}let i=-1,a=!1;try{const o=await Su();i=o?.length??0,a=o===e}catch(o){console.warn("[inject] paste-all readback failed:",o)}if(Oe(`[inject] paste-all clipboard write_ok=${r} expected_len=${e.length} readback_len=${i} match=${a}`),await H("inject_paste"),!t){await new Promise(o=>setTimeout(o,80));try{await gn(n??"")}catch(o){console.warn("[inject] restore clipboard failed:",o)}}},qi=()=>{if(!lt)return;const e=new Error().stack?.split(`
804
+ `.repeat(de),uu(R))}let Ne=z;const xe=ge=>{if(Ne){if(ge=ge.replace(/^\s+/,""),!ge)return;Ne=!1}X(ge)},be=xo({corePrompt:N,items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:d?.duration_ms,skipHistory:!0,enrichHotwords:!0});console.info(`[ai-refine] phase2 system_prompt: len=${be.length} chars`);const je=await Ni({mode:D.mode,systemPrompt:be,userText:me,...ee,taskId:gs??void 0},xe);a=(a??0)+(je.creditsConsumed??0),S=z?R:je.refinedText,w=je.refinedText}else S=me;r=Math.round(performance.now()-P),console.info(`[ai-refine] stream done refinedLen=${S.length} elapsedMs=${r}`),M8(),lt&&We.setState({pillEarlyHide:!0});try{await ys}catch{}if(Ji()&&Y.getState().dictation.clipboardCopy)try{await gn(S)}catch(Ne){console.warn("[clipboard] post-refine writeText failed:",Ne)}}catch(ee){const X=String(ee??""),Z=b?B?`${te.t("errors:phase.translate")}: `:`${te.t("errors:phase.refine")}: `:`${te.t("errors:phase.refine")}: `;if(D.mode==="custom"){console.warn(`[refine] custom failed after ${Math.round(performance.now()-P)}ms: ${X}`);const ne=_r(ee);await Ei(ee)||Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:ne}),s=`${Z}${ne}`}else if(os(X))console.warn(`[refine] saas auth lost after ${Math.round(performance.now()-P)}ms: ${X}`),hl(),s=`${Z}${te.t("overlay:error.stt_not_authenticated")}`;else{console.warn(`[refine] stream failed after ${Math.round(performance.now()-P)}ms, falling back to raw transcript:`,ee);const ne=_r(ee);Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:ne}),s=`${Z}${ne}`}}lt&&(We.getState().state==="transcribing"||We.getState().state==="translating")&&We.setState({state:"injecting",pillEarlyHide:!1})}else u&&!k&&console.info(`[refine] skipped, segmentMode=${_} refineEnabled=${k}`);const C=S??u;if(d&&Ji()){const A=wr?"saas-rest":"saas-realtime",R=Qi??(_==="REALTIME"?"saas-realtime":"saas-file"),P=b&&s!==null;let D,O;u?P?(D="failed",O=s):s!==null?(D="success",O=s):(D="success",O=void 0):(D="failed",O=o??"no final transcript");const I=await it.getState().add({type:b?"translate":"dictation",text:u||P0(),refined_text:b?w:S,status:D,error:O,duration_ms:d.duration_ms,audio_path:d.audio_path,target_app:bt,target_app_id:Vt,asr_source:A,ai_model:E,segment_mode:_,provider_kind:R,target_lang:b?Y.getState().general.translateTargetLang:null,asr_ms:n,refine_ms:r,debug_payload:null,focus_title:Fr,credits_asr:i,credits_refine:a});if(Ea.getState().setFromHistory(I),lt&&D==="failed"&&I.audio_path&&!lu){const $=O??te.t("overlay:toast.transcribe_failed.title");Oe(`[overlay] emit show-transcribe-error historyId=${I.id} message="${$.slice(0,80)}"`),Dt("overlay","openspeech://overlay-show-transcribe-error",{historyId:I.id,message:$})}lu&&D==="failed"&&!u&&I.audio_path&&(console.info(`[recording] saas auth lost during finalize → pending recovery historyId=${I.id}`),Ke.getState().setPendingAuthRecoveryHistoryId(I.id)),lu=!1}if(C&&Ji()){try{await ys}catch{}if(!Ji())return console.log("[inject] tail skipped: flow no longer active (esc / cancel)"),ai(),{rec:d,text:C};const A=await h8(),R=A===!1,P=await C8(),D=await MA(),O=OA(Vt,bt);if(Oe(`[inject] tail gate check focusEditable=${A} focusNotEditable=${R} appChanged=${P} imeBlocked=${D} axUnreliable=${O} recordedApp=${bt??"null"}`),R&&!O){nn(`[inject] tail → result panel focusEditable=${A} appChanged=${P} typedLen=${Kn.length}`);try{await gn(C)}catch(I){console.warn("[clipboard] fallback write failed:",I)}return bl(C),ai(),{rec:d,text:C}}console.log("[inject] tail enter",{finalLen:C.length,injectedLen:Kn.length,prefixMatch:C.startsWith(Kn)});const M=C.startsWith(Kn)?C.slice(Kn.length):null;if(M===null){console.warn("[inject] tail prefix mismatch → clipboard-only fallback",{finalLen:C.length,injectedLen:Kn.length,finalHead:C.slice(0,24),injectedHead:Kn.slice(0,24)});try{await gn(C),console.log("[inject] clipboard-only write ok")}catch(I){console.error("[clipboard] writeText failed:",I)}bl(C)}else if(!M)console.log("[inject] tail no-op: remaining is empty (stream covered all)"),Ck();else{if(Oe(`[inject] tail → paste-all imeBlocked=${D} axUnreliable=${O} typedLen=${Kn.length} remainingLen=${M.length}`),D)try{await H("inject_commit_ime")}catch(I){console.warn("[inject] commit_ime before paste-all failed:",I)}try{await R8(M),console.log("[inject] tail paste-all ok"),Ck()}catch(I){console.error("[inject] tail paste-all failed:",I);try{await gn(C)}catch{}bl(C)}}ai()}else C||console.log("[inject] tail skipped: empty finalText");return{rec:d,text:C}};let Kn="",ys=Promise.resolve();const Ji=()=>{const e=We.getState().state;return e==="transcribing"||e==="injecting"||e==="translating"},M8=()=>{},ai=()=>{Kn=""},MA=async()=>{if(Ol!==null)return Ol;const e=await B2(),t=H2(e);return Ol=t,Oe(`[ime] session probe id=${e??"null"} blocks_unicode_keydown=${t}`),t},uu=e=>{if(lt&&Ji()&&Y.getState().dictation.streamingInject){if(Ol===!0){const t=e.slice(Kn.length);t&&Oe(`[inject] incremental skip (ime blocked) delta=${t.length} cumulativeFull=${e.length}`);return}if(OA(Vt,bt)){const t=e.slice(Kn.length);t&&Oe(`[inject] incremental skip (ax/cg unreliable app=${bt??"null"}) delta=${t.length} cumulativeFull=${e.length}`);return}ys=ys.then(async()=>{if(!Ji())return;if(await MA()){Oe(`[inject] incremental skip in chain (ime blocked) cumulativeFull=${e.length}`);return}if(!e.startsWith(Kn))return;const t=e.slice(Kn.length);if(t){if(Vt||bt){const n=await N0();if(n){const r=!!Vt&&!!n.appId&&n.appId!==Vt,i=!n.appId&&!!bt&&n.name!==bt;if(r||i){Oe(`[inject] incremental skip (app changed: recordedApp=${bt??"null"}/${Vt??"null"} → cur=${n.name}/${n.appId??"null"}) delta=${t.length}`);return}}}try{await H("inject_type",{text:t}),Kn=e}catch(n){console.warn("[inject] incremental type failed",{deltaLen:t.length,cumulativeLen:Kn.length,err:String(n)})}}})}},R8=async e=>{if(!e)return;const t=Y.getState().dictation.clipboardCopy;let n=null;if(!t)try{n=await Su()}catch(o){console.warn("[inject] read clipboard for backup failed:",o)}let r=!1;try{await gn(e),r=!0}catch(o){console.error("[inject] paste-all writeClipboard failed:",o)}let i=-1,a=!1;try{const o=await Su();i=o?.length??0,a=o===e}catch(o){console.warn("[inject] paste-all readback failed:",o)}if(Oe(`[inject] paste-all clipboard write_ok=${r} expected_len=${e.length} readback_len=${i} match=${a}`),await H("inject_paste"),!t){await new Promise(o=>setTimeout(o,80));try{await gn(n??"")}catch(o){console.warn("[inject] restore clipboard failed:",o)}}},qi=()=>{if(!lt)return;const e=new Error().stack?.split(`
805
805
  `).slice(2,6).join(" | ");console.info(`[recording] discardRecording called, caller=${e}`),jA(),Nu(),ai()},I8=async()=>{try{if(await H("permission_check_microphone")!=="granted")return{ok:!1,reason:te.t("overlay:error.preflight_permission_denied")}}catch(e){console.warn("[recording] preflight: permission check threw, assume granted",e)}try{const e=await H("audio_list_input_devices");if(!e||e.length===0)return{ok:!1,reason:te.t("overlay:error.preflight_no_device")}}catch(e){return console.warn("[recording] preflight: device list threw",e),{ok:!1,reason:te.t("overlay:error.preflight_no_device")}}return{ok:!0}},Mk=async()=>{if(!lt)return;const e=new Error().stack?.split(`
806
806
  `).slice(2,6).join(" | ");console.info(`[recording] abortAndSaveHistory called, caller=${e}`),console.log("[recording] abort: saving audio without transcription");const t=We.getState().activeId==="translate";Nu(),ai();let n=null;try{n=await CA()}catch(i){console.warn("[recording] abort: stopRecordingAndSave failed:",i)}if(n&&!n.voiced)return;if(n&&n.duration_ms<1e3){n.audio_path&&xl(n.audio_path).catch(i=>console.warn("[recording] abort: discard short clip file failed:",i));return}if(n){const i=Zi(),a=Qi??(i==="REALTIME"?"saas-realtime":"saas-file");try{await it.getState().add({type:t?"translate":"dictation",text:te.t("overlay:transcript.aborted_placeholder"),status:"cancelled",duration_ms:n.duration_ms,audio_path:n.audio_path,target_app:bt,target_app_id:Vt,segment_mode:i,provider_kind:a,focus_title:Fr})}catch(o){console.warn("[recording] abort: history.add failed:",o)}}ye.info(te.t("overlay:toast.aborted_saved.title"),{description:n?te.t("overlay:toast.aborted_saved.description"):void 0})},We=yi((e,t)=>{let n=Promise.resolve();return{state:"idle",activeId:null,errorMessage:null,recordingStartedAt:0,startedListening:!1,audioLevels:tn(),recordingId:null,liveTranscript:"",pillEarlyHide:!1,segmentModeOverride:null,setSegmentModeOverride:r=>e({segmentModeOverride:r}),initListeners:async()=>{if(t().startedListening){console.log("[recording] initListeners: already started, skip");return}if(e({startedListening:!0}),console.log("[recording] initListeners: attaching listeners"),!lt){console.log("[recording] non-main window: skip initListeners");return}let r="",i=t().state,a=null,o=t().state==="error",s=t().errorMessage;We.subscribe(c=>{const d=i!=="idle"&&i!=="error",u=c.state!=="idle"&&c.state!=="error";d!==u&&j6(u),i==="recording"&&c.state==="transcribing"?(yg("stop"),Y.getState().markHintSuccess("recordingControls")):(i==="preparing"||i==="recording")&&c.state==="idle"&&yg("cancel");const p=i==="preparing"||i==="recording",h=c.state==="preparing"||c.state==="recording";p&&!h&&qd(!1);const g=i==="preparing"||i==="recording"||i==="transcribing",y=c.state==="preparing"||c.state==="recording"||c.state==="transcribing";!g&&y?k8():g&&!y&&S8(),i=c.state;const x=c.state==="error";x&&(!o||c.errorMessage!==s)?(a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{a=null,We.getState().state==="error"&&We.getState().dismissError()},w8)):!x&&a!==null&&(window.clearTimeout(a),a=null),o=x,s=c.errorMessage;const v=(c.state==="preparing"||c.state==="recording")&&c.recordingStartedAt>0?Math.round(Date.now()-(performance.now()-c.recordingStartedAt)):null,_=JSON.stringify({state:c.state,activeId:c.activeId,errorMessage:c.errorMessage,recordingId:c.recordingId,liveTranscript:c.liveTranscript,pillEarlyHide:c.pillEarlyHide,recordingStartedAtUnixMs:v});_!==r&&(r=_,Ma("openspeech://recording-phase",{state:c.state,activeId:c.activeId,errorMessage:c.errorMessage,recordingId:c.recordingId,liveTranscript:c.liveTranscript,pillEarlyHide:c.pillEarlyHide,recordingStartedAtUnixMs:v,refineActive:c.activeId==="translate"||iu()}))}),await Le("openspeech://overlay-action",c=>{const d=c.payload;console.log("[recording] overlay-action:",d),d==="cancel"?t().simulateCancel():d==="finalize"?t().simulateFinalize():d==="cancel-keep"?t().simulateCancelKeep():d==="skip-refine"&&t().simulateSkipRefine()}),await Le("openspeech://overlay-ready",()=>{const c=t(),d=(c.state==="preparing"||c.state==="recording")&&c.recordingStartedAt>0?Math.round(Date.now()-(performance.now()-c.recordingStartedAt)):null;Ma("openspeech://recording-phase",{state:c.state,activeId:c.activeId,errorMessage:c.errorMessage,recordingId:c.recordingId,liveTranscript:c.liveTranscript,pillEarlyHide:c.pillEarlyHide,recordingStartedAtUnixMs:d,refineActive:c.activeId==="translate"||iu()}),console.log("[recording] overlay-ready → resent recording-phase snapshot")}),await Le("openspeech://hotkey",c=>{const d=c.payload.phase==="pressed"?++Sc:0;n=n.then(async()=>{Oe(`[recording] event received: id=${c.payload.id} phase=${c.payload.phase} state=${t().state} activeId=${t().activeId??"null"}`);try{const{id:u,phase:p}=c.payload,h=performance.now(),g=t();if(p==="released")return;if(p==="pressed"){if(g.activeId===u&&(g.state==="recording"||g.state==="preparing")){const w=h-g.recordingStartedAt;if(g.state==="preparing"){console.log("[recording] toggle in preparing → silent abort (mic not ready)",{duration:w}),qi(),Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""});return}const E=100;if(u==="translate"&&w<E){console.log("[recording] toggle (translate): ignored (likely OS/webview-injected duplicate press)",{duration:w,threshold:E});return}if(w<Vd){console.log("[recording] toggle: too short → discard (no save / no transcribe)",{duration:w,threshold:Vd}),qi(),Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""});return}console.log("[recording] toggle: stopping → transcribing",{duration:w}),Pn(),e({state:"transcribing",audioLevels:tn()}),Ok().then(j=>{if(j.silent){e({state:"error",activeId:null,recordingId:null,liveTranscript:"",errorMessage:te.t("overlay:toast.silent_recording.title")});return}if(!j.text){e({state:"error",activeId:null,recordingId:null,liveTranscript:"",errorMessage:te.t("overlay:toast.transcribe_failed.title")});return}window.setTimeout(()=>{const C=t().state;C!=="transcribing"&&C!=="injecting"||e({state:"idle",activeId:null,recordingId:null,liveTranscript:""})},300)});return}if(g.activeId!==u&&jk(g.activeId)&&jk(u)&&(g.state==="recording"||g.state==="preparing")&&Zi()==="UTTERANCE"){console.log("[recording] mode switch:",g.activeId,"→",u),e({activeId:u}),u==="translate"?qd(!0,Nk()):qd(!1),j8(u==="translate"?"translate":"dictation",u),yg("start");return}if(g.state==="error")console.log("[recording] press on error → dismiss & start new",{id:u}),t().dismissError();else if(g.state!=="idle"){console.warn("[recording] press IGNORED: state not idle and activeId mismatch",{pressed_id:u,cur_state:g.state,cur_activeId:g.activeId});return}const x=Y.getState().dictation.mode==="custom";let v=ct.getState(),_=v.isAuthenticated;if(!_&&!x){Oe("[recording] gate: try_recover enter");const w=await Promise.race([H("openloaf_try_recover").catch(()=>!1),new Promise(E=>setTimeout(()=>E(!1),1500))]);Oe(`[recording] gate: try_recover exit recovered=${w}`),w&&(v=ct.getState(),_=v.isAuthenticated)}if(!_&&!x){console.log("[recording] gate blocked: no STT backend available");let w=!1;if(lt){const E=hi(),[j,C,A]=await Promise.all([E.isFocused().catch(()=>!1),E.isVisible().catch(()=>!1),E.isMinimized().catch(()=>!1)]);w=j||C&&!A}w?Ke.getState().openLogin():Ct("error",te.t("overlay:toast.not_logged_in.title"),{description:te.t("overlay:toast.not_logged_in.description"),action:{label:te.t("overlay:toast.not_logged_in.action"),key:"open_login"},durationMs:0});return}!x&&_&&lt&&H("openloaf_health_check").then(w=>{w||console.warn("[recording] health check failed (logged for debug only)")}).catch(w=>{console.warn("[recording] health check invoke failed:",w)}),Oe("[recording] preflight enter");const k=await I8();if(Oe(`[recording] preflight exit ok=${k.ok}`),d!==Sc){Oe(`[recording] press stale (myEpoch=${d} latest=${Sc}) — abort`);return}if(!k.ok){console.warn("[recording] preflight failed:",k.reason),Ct("error",te.t("overlay:toast.preflight_failed.title"),{description:k.reason});const w=u==="translate";it.getState().add({type:w?"translate":"dictation",text:P0(),status:"failed",error:k.reason,duration_ms:0,target_lang:w?Y.getState().general.translateTargetLang:null}).catch(E=>console.warn("[recording] preflight: history.add failed:",E));return}const S=So();ai(),wr=!1,Zf=!1,e({state:"preparing",activeId:u,errorMessage:null,recordingStartedAt:h,audioLevels:tn(),recordingId:S,pillEarlyHide:!1,liveTranscript:""}),u==="translate"&&qd(!0,Nk()),Oe(`[recording] startMic enter id=${u} recordingId=${S}`),_8().then(w=>{if(Oe(`[recording] startMic exit ok=${w} state=${t().state} activeId=${t().activeId??"null"}`),d!==Sc){Oe(`[recording] startMic stale (myEpoch=${d} latest=${Sc}) — balance only`),w&&Pn();return}const E=t();if(E.state!=="preparing"||E.activeId!==u){w&&(console.warn("[recording] startMic resolved after state changed → balancing stopMic",{resolvedFor:u,curState:E.state,curActiveId:E.activeId}),Pn());return}if(!w){const j=te.t("overlay:error.stt_mic_not_ready");kl(j),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""}),Ct("error",te.t("overlay:toast.recording_start_failed.title"),{description:j});return}O8(S),e({state:"recording"})});return}}catch(u){nn(`[recording] hotkey handler threw: ${String(u)}`);try{Pn()}catch{}try{jA()}catch{}try{Nu()}catch{}We.setState({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""})}}).catch(()=>{})}),await Le("openspeech://audio-level",c=>{const d=Math.max(0,Math.min(1,Number(c.payload)||0));e(u=>({audioLevels:[d,...u.audioLevels.slice(0,-1)]}))}),await Le("openspeech://mic-start-failed",c=>{const d=String(c.payload?.reason??"generic"),u=String(c.payload?.detail??"");console.warn(`[audio] mic-start-failed reason=${d} detail=${u}`);const h=["no-input-device","permission-denied","device-busy","device-config-unsupported","device-removed","generic"].includes(d)?d:"generic",g=te.t("overlay:toast.mic_start_failed.title"),y=te.t(`overlay:toast.mic_start_failed.reasons.${h}`);Ct("error",g,{description:y})}),await Le("openspeech://mic-silence",c=>{const d=Number(c.payload??0),u=Math.round(d/1e3);console.warn(`[audio] mic-silence triggered after ${d}ms`),Ct("warning",te.t("overlay:toast.mic_silence.title"),{description:te.t("overlay:toast.mic_silence.description",{seconds:u})})}),await Le("openspeech://audio-stream-error",c=>{const d=String(c.payload??"");console.warn("[audio] stream-error:",d);const u=t();if(u.state==="preparing"||u.state==="recording"||u.state==="transcribing"){const p=te.t("overlay:error.stt_mic_not_ready");kl(p),qi(),Pn(),e({state:"error",activeId:null,errorMessage:p,audioLevels:tn(),recordingId:null,liveTranscript:""}),Ct("error",te.t("overlay:toast.recording_start_failed.title"),{description:p})}else Pn()}),await Le("openspeech://asr-partial",c=>{e({liveTranscript:String(c.payload??"")})}),await Le("openspeech://asr-final",c=>{const d=String(c.payload??"");e({liveTranscript:d});const u=Zi(),p=t().activeId==="translate";u==="REALTIME"&&!p&&uu(d)}),await Le("openspeech://asr-error",c=>{console.warn("[stt] asr-error:",c.payload);const{code:d,message:u}=c.payload??{code:"",message:""};if(N8(d,u)){Zi()==="REALTIME"?Ct("warning",te.t("overlay:toast.realtime_degraded.title"),{description:te.t("overlay:toast.realtime_degraded.realtime_mode")}):(wr=!0,Ct("info",te.t("overlay:toast.realtime_degraded.title"),{description:te.t("overlay:toast.realtime_degraded.description")}));return}Ct("error",te.t("overlay:toast.asr_error.title"),{description:d?`${d}: ${u}`:u||te.t("overlay:toast.asr_error.unknown")})}),await Le("openspeech://asr-closed",c=>{const{reason:d}=c.payload??{reason:"unknown"};d==="insufficient_credits"?(kl(te.t("overlay:toast.insufficient_credits.error_message")),qi(),Pn(),Ct("error",te.t("overlay:toast.insufficient_credits.title"),{description:te.t("overlay:toast.insufficient_credits.description")}),e({state:"error",errorMessage:te.t("overlay:toast.insufficient_credits.error_message"),audioLevels:tn(),recordingId:null,liveTranscript:""})):d==="worker_dead"?(console.warn("[stt] worker_dead, aborting recording",c.payload),kl(te.t("overlay:toast.worker_dead.error_message")),qi(),Pn(),Ct("error",te.t("overlay:toast.worker_dead.title"),{description:te.t("overlay:toast.worker_dead.description")}),e({state:"error",errorMessage:te.t("overlay:toast.worker_dead.error_message"),audioLevels:tn(),recordingId:null,liveTranscript:""})):d==="max_duration"?(Ct("warning",te.t("overlay:toast.session_timeout.title"),{description:te.t("overlay:toast.session_timeout.description")}),console.warn("[stt] session closed by server:",d)):d==="idle_timeout"&&console.warn("[stt] session closed by server:",d)}),await Le("openspeech://stt-ready",c=>{const d=c.payload?.sessionId??"";Zf=!0,d&&(gs=d,console.info(`[stt] session ready, id=${d}`))}),await Le("openspeech://stt-provider-resolved",c=>{const d=c.payload;(d==="saas-realtime"||d==="saas-file"||d==="tencent-realtime"||d==="tencent-file"||d==="aliyun-realtime"||d==="aliyun-file")&&(Qi=d,console.info(`[stt] provider resolved: ${d}`))}),await Le("openspeech://dictation-fallback",()=>{Ct("warning",te.t("overlay:toast.dictation_fallback.title"),{description:te.t("overlay:toast.dictation_fallback.description")})});const l=c=>{if(console.log("[recording] Esc → cancelling",{state:c}),is){Pk(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""});return}c==="preparing"||c==="recording"?Mk():qi(),Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""})};await Le("openspeech://key-preview",c=>{if(c.payload.phase!=="pressed"||c.payload.code!=="Escape"||c.payload.isRepeat)return;const d=t().state;if(d==="error"){console.log("[recording] Esc on error → dismiss"),t().dismissError();return}d!=="idle"&&l(d)}),await Le("openspeech://overlay-hint-confirm-action",c=>{const d=Y.getState(),u=c.payload.id;c.payload.action==="confirm"?d.markHintSuccess(u):d.dismissHint(u)}),await Le("openspeech://overlay-retry-history",async c=>{const d=c.payload.historyId;Oe(`[overlay] retry-history received id=${d}`),Dt("overlay","openspeech://overlay-transcribe-error-retry-status",{retrying:!0});try{await it.getState().retry(d);const u=it.getState().items.find(p=>p.id===d);if(u&&u.status==="success"){const p=u.refined_text??u.text??"";if(p){try{await gn(p)}catch(h){nn(`[overlay] retry-history clipboard write failed: ${String(h)}`)}bl(p)}Dt("overlay","openspeech://overlay-dismiss-transcribe-error",{})}else{const p=u?.error??te.t("overlay:toast.transcribe_failed.title");Dt("overlay","openspeech://overlay-show-transcribe-error",{historyId:d,message:p})}}catch(u){const p=_r(u);nn(`[overlay] retry-history failed: ${u instanceof Error?u.message:String(u)}`),Dt("overlay","openspeech://overlay-show-transcribe-error",{historyId:d,message:p})}finally{Dt("overlay","openspeech://overlay-transcribe-error-retry-status",{retrying:!1})}}),console.log("[recording] listeners attached (hotkey + audio-level + asr-* + stream-error)"),Ma("openspeech://overlay-ready")},syncBindings:async r=>{console.log("[recording] syncBindings → invoking apply_hotkey_config",r);try{await H("apply_hotkey_config",{payload:{bindings:r}}),console.log("[recording] syncBindings OK")}catch(i){console.error("[recording] syncBindings FAILED:",i),e({state:"error",errorMessage:te.t("overlay:error.sync_hotkey_failed",{error:String(i)})})}},dismissError:()=>{e({state:"idle",activeId:null,errorMessage:null,audioLevels:tn(),recordingId:null,liveTranscript:""})},simulateCancel:()=>{if(is){Pk(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""});return}const r=t();r.state==="preparing"||r.state==="recording"?Mk():qi(),Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""})},simulateCancelKeep:async()=>{if(!lt)return;const r=t();if(r.state!=="transcribing"){t().simulateCancel();return}const i=r.activeId==="translate";Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:"",pillEarlyHide:!1});const a=Date.now();for(;!cu&&Date.now()-a<1500;)await new Promise(d=>setTimeout(d,50));const o=cu,s=as;if(!o||!o.voiced)return;const l=Zi(),c=Qi??(l==="REALTIME"?"saas-realtime":"saas-file");try{await it.getState().add({type:i?"translate":"dictation",text:s&&s.length>0?s:te.t("overlay:transcript.aborted_placeholder"),refined_text:null,status:"cancelled",duration_ms:o.duration_ms,audio_path:o.audio_path,target_app:bt,target_app_id:Vt,asr_source:wr?"saas-rest":"saas-realtime",segment_mode:l,provider_kind:c,focus_title:Fr})}catch(d){console.warn("[cancel-keep] history.add failed:",d)}},simulateSkipRefine:async()=>{if(!lt)return;const r=t();if(r.state!=="transcribing")return;const i=as;if(!i){Qf=!0;return}const a=r.activeId==="translate",o=cu;Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:"",pillEarlyHide:!1});try{await gn(i)}catch(s){console.warn("[skip-refine] writeClipboard failed:",s)}if(bl(i),o){const s=Zi(),l=Qi??(s==="REALTIME"?"saas-realtime":"saas-file");try{await it.getState().add({type:a?"translate":"dictation",text:i,refined_text:null,status:"success",duration_ms:o.duration_ms,audio_path:o.audio_path,target_app:bt,target_app_id:Vt,asr_source:wr?"saas-rest":"saas-realtime",segment_mode:s,provider_kind:l,focus_title:Fr})}catch(c){console.warn("[skip-refine] history.add failed:",c)}}},simulateDictationFromAudio:async(r,i)=>{if(!lt)return;if(t().state!=="idle"){ye.warning("[DEBUG] 当前正在录音/转写,先结束再试");return}if(i>300*1e3){ye.error("[DEBUG] 录音超过 5 分钟,REST ASR 不支持");return}ai(),wr=!1,Zf=!1,gs=`debug-${So()}`,is=!0;const o=Date.now()+i;H("overlay_show").catch(s=>console.warn("[debug] overlay_show failed:",s)),Xf({active:!0,totalMs:i,endAtUnixMs:o}),P8(),e({state:"recording",liveTranscript:"",pillEarlyHide:!1,audioLevels:tn(),recordingStartedAt:performance.now()});try{await T8(i)}catch{return}if(cx(),Xf({active:!1}),!!is){e({state:"transcribing",liveTranscript:"",pillEarlyHide:!1});try{let s="";try{const u=xo({corePrompt:j0[Ln(Y.getState().dictation.lang,Y.getState().general.interfaceLang)],items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:i,expandDomainKeywords:!0,includeUserCorrections:!0});console.info(`[debug] file transcribe system_prompt: len=${u.length} chars`),s=(await E0({audioPath:r,durationMs:i,lang:ru(),provider:ms(),systemPrompt:u})).text??""}catch(u){console.warn("[debug] transcribe failed:",u);const p=wl(u);Ct("error",te.t("overlay:toast.transcribe_failed.title"),{description:_r(u),...p?{action:_l(),durationMs:0}:{}}),e({state:"idle",liveTranscript:""});return}if(!s){Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:te.t("overlay:toast.transcribe_failed.no_transcript")}),e({state:"idle",liveTranscript:""});return}const l=iu();l||e({state:"injecting",pillEarlyHide:!1});let c=null;if(l){let u="";const p=Y.getState().aiRefine,h=Y.getState(),g=Ln(h.dictation.lang,h.general.interfaceLang),y=Tu(Vt,p),x=Eo(bt,Vt),v=Pu(x),_=Da({lang:g,customRules:y.customRules,customExamples:y.customExamples,targetApp:v});let b=null;p.mode==="custom"&&(b=p.customProviders.find(k=>k.id===p.activeCustomProviderId)??null);try{if(p.mode==="custom"&&!b)throw new Error("no_active_custom_provider");const k=Eo(bt,Vt),S=xo({corePrompt:_,items:it.getState().items,targetApp:bt,focusTitle:Fr,audioDurationMs:i,enrichHotwords:!0,appTypeAddon:bp(k,g)});console.info(`[debug-refine] system_prompt: len=${S.length} chars`),c=(await Ni({mode:p.mode,systemPrompt:S,userText:s,customBaseUrl:b?.baseUrl,customModel:b?.model,customKeyringId:b?`ai_provider_${b.id}`:void 0,taskId:gs??void 0},E=>{u+=E,t().state==="transcribing"&&e({state:"injecting",pillEarlyHide:!1}),uu(u)})).refinedText,e({pillEarlyHide:!0});try{await ys}catch{}if(Ji())try{await gn(c)}catch(E){console.warn("[debug] clipboard write failed:",E)}}catch(k){const S=String(k??"");p.mode==="custom"?(console.warn("[debug] refine custom failed:",k),await Ei(k)||Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:_r(k)})):os(S)?hl():(console.warn("[debug] refine failed:",k),Ct("warning",te.t("overlay:toast.transcribe_failed.title"),{description:_r(k)}))}t().state==="transcribing"&&e({state:"injecting",pillEarlyHide:!1})}const d=c??s;if(d&&Ji()){try{await ys}catch{}if(!Ji()){ai(),e({state:"idle",liveTranscript:""});return}if(d.startsWith(Kn)){const u=d.slice(Kn.length);if(u)try{await H("inject_type",{text:u})}catch(p){console.warn("[debug] tail type failed:",p);try{await gn(u),await H("inject_paste")}catch(h){console.warn("[debug] tail paste fallback failed:",h)}}}else try{await gn(d)}catch{}ai()}e({state:"idle",liveTranscript:""}),ye.success("[DEBUG] 模拟完成",{description:`text=${d.length} chars`})}finally{is=!1,cx(),Xf({active:!1})}}},debugRefineOnly:async r=>{if(!lt)throw new Error("not main window");const i=r.trim();if(!i)throw new Error("empty text");const a=Y.getState().aiRefine,o=Y.getState(),s=Ln(o.dictation.lang,o.general.interfaceLang),l=Eo(bt,Vt),c=Pu(l),d=Da({lang:s,customRules:a.customRules,customExamples:a.customExamples,targetApp:c}),u=C0(),p=`${new Date().toISOString()} (UTC)`;let h=null;if(a.mode==="custom"&&(h=a.customProviders.find(x=>x.id===a.activeCustomProviderId)??null,!h))throw new Error("no_active_custom_provider");const g=RH(a.selectedDomains,a.customDomains);return(await Ni({mode:a.mode,systemPrompt:d,userText:i,hotwords:u.length>0?u:void 0,requestTime:p,domains:g.length>0?g:void 0,customBaseUrl:h?.baseUrl,customModel:h?.model,customKeyringId:h?`ai_provider_${h.id}`:void 0,taskId:`debug-refine-${So()}`},()=>{})).refinedText},debugReinject:async r=>{if(!lt)throw new Error("not main window");const i=r;if(!i)throw new Error("empty text");try{await H("inject_type",{text:i})}catch(a){console.warn("[debug] inject_type failed, fallback paste:",a),await gn(i),await H("inject_paste")}},simulateFinalize:()=>{const r=t();if(r.state!=="recording"&&r.state!=="preparing")return;const i=performance.now()-r.recordingStartedAt;if(i<Vd){console.log("[recording] finalize: too short → discard (no save / no transcribe)",{duration:i,threshold:Vd}),qi(),Pn(),e({state:"idle",activeId:null,audioLevels:tn(),recordingId:null,liveTranscript:""});return}Pn(),e({state:"transcribing",audioLevels:tn()}),Ok().then(a=>{if(a.silent){e({state:"idle",activeId:null,recordingId:null,liveTranscript:""});return}if(!a.text){e({state:"error",activeId:null,recordingId:null,liveTranscript:"",errorMessage:te.t("overlay:toast.transcribe_failed.title")});return}window.setTimeout(()=>{t().state==="transcribing"&&e({state:"idle",activeId:null,recordingId:null,liveTranscript:""})},800)})}}}),D8=300*1e3,L8=3e4,Sg=300,$8=6e4,Rk=3e4,z8=1e4,jt={policyListenerStarted:!1,homeActivated:!1,checkTimer:null,inFlight:!1,pendingAutoInstall:null,autoIdleTimer:null,lastRecordingActivityMs:0,recordingSubscribed:!1};function F8(){jt.recordingSubscribed||(jt.recordingSubscribed=!0,We.getState().state!=="idle"&&(jt.lastRecordingActivityMs=Date.now()),We.subscribe((e,t)=>{e.state!==t.state&&(jt.lastRecordingActivityMs=Date.now())}))}function T0(){jt.checkTimer&&(clearTimeout(jt.checkTimer),jt.checkTimer=null)}function Jf(){jt.autoIdleTimer&&(clearInterval(jt.autoIdleTimer),jt.autoIdleTimer=null)}function Xs(e=D8){T0(),jt.checkTimer=setTimeout(()=>{A0()},e);const t=e/6e4;Oe(t>=1?`[updater] next check scheduled in ${t.toFixed(0)} min`:`[updater] next check scheduled in ${(e/1e3).toFixed(0)}s`)}function B8(e){const t=We.getState().state;if(t!=="idle")return Oe(`[updater] tick=${e} deferred: recording state=${t}`),!0;const n=Date.now()-jt.lastRecordingActivityMs;return jt.lastRecordingActivityMs>0&&n<Rk?(Oe(`[updater] tick=${e} deferred: PTT quiet window ${n}ms < ${Rk}ms`),!0):!1}async function A0(){if(jt.inFlight){Oe("[updater] tick skipped: another check still in flight");return}const{updatePolicy:e,skippedUpdateVersion:t}=Y.getState().general,n=new Date().toISOString();if(e==="DISABLED"){Oe(`[updater] tick=${n} skipped: policy=DISABLED`);return}if(B8(n)){Xs(z8);return}const r=Ke.getState().pendingUpdate?.version??jt.pendingAutoInstall?.version??null;Oe(`[updater] tick=${n} START policy=${e} skipped=${t||"none"} queued=${r??"none"}`),jt.inFlight=!0;const i=Date.now();let a=null;try{a=await Promise.race([a0(),new Promise((s,l)=>setTimeout(()=>l(new Error("updater check timeout")),L8))])}catch(s){const l=Date.now()-i;nn(`[updater] tick=${n} FAIL after ${l}ms: ${String(s?.message??s)}`),jt.inFlight=!1,Xs();return}jt.inFlight=!1;const o=Date.now()-i;if(!a){Oe(`[updater] tick=${n} DONE no-update (${o}ms)`),Xs();return}if(Oe(`[updater] tick=${n} HIT version=${a.version} current=${a.currentVersion} (${o}ms)`),t&&t===a.version){Oe(`[updater] tick=${n} suppressed: ${a.version} matches skippedUpdateVersion`),Xs();return}if(r&&r===a.version){Oe(`[updater] tick=${n} no-op: ${a.version} already queued`),Xs();return}e==="AUTO"?(Oe(`[updater] tick=${n} → AUTO queue ${a.version}, will install on next idle window`),jt.pendingAutoInstall={version:a.version,update:a},H8()):(Oe(`[updater] tick=${n} → PROMPT toast for ${a.version}`),Ke.getState().setPendingUpdate({version:a.version,update:a})),Xs()}function H8(){jt.autoIdleTimer||(Ik(),jt.autoIdleTimer=setInterval(()=>{Ik()},$8))}async function Ik(){const e=jt.pendingAutoInstall;if(!e){Jf();return}const t=Y.getState().general.updatePolicy;if(t!=="AUTO"){Oe(`[updater] auto-install: policy changed to ${t}, hand off ${e.version}`),t==="PROMPT"&&Ke.getState().setPendingUpdate({version:e.version,update:e.update}),jt.pendingAutoInstall=null,Jf();return}const n=We.getState().state;if(n!=="idle"){Oe(`[updater] auto-install: waiting (recording state=${n}, version=${e.version})`);return}let r;try{r=await H("system_idle_seconds")}catch(i){nn(`[updater] auto-install: idle probe failed (${String(i?.message??i)}), skipping tick`);return}if(r<Sg){Oe(`[updater] auto-install: idle ${r}s < threshold ${Sg}s, waiting (version=${e.version})`);return}Oe(`[updater] auto-install FIRING version=${e.version} idleSec=${r} threshold=${Sg}s`),jt.pendingAutoInstall=null,Jf();try{await W8(e.update,e.version)}catch(i){Pl(`[updater] auto-install failed: ${String(i?.message??i)}`),Ke.getState().setPendingUpdate({version:e.version,update:e.update}),ye.error(te.t("settings:about.install_failed"),{description:String(i?.message??i)})}}async function W8(e,t){Oe(`[updater] silentInstall start → ${t}`),await e.downloadAndInstall(void 0,{timeout:300*1e3}),Oe("[updater] silentInstall returned, requesting relaunch"),await H("relaunch_app")}function U8(){if(jt.policyListenerStarted)return;jt.policyListenerStarted=!0,F8(),Oe("[updater] policy listener attached, awaiting home activation");let e=Y.getState().general.updatePolicy;Y.subscribe(t=>{const n=t.general.updatePolicy;if(n!==e){if(Oe(`[updater] policy changed ${e} → ${n}`),e=n,n==="DISABLED"){T0(),Jf(),jt.pendingAutoInstall=null;return}jt.homeActivated&&A0()}})}function V8(){jt.homeActivated=!0,Oe("[updater] home activated → running immediate check"),T0(),A0()}function RA(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=RA(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function kt(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=RA(e))&&(r&&(r+=" "),r+=t);return r}const q8=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},K8=(e,t)=>({classGroupId:e,validator:t}),IA=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),kp="-",Dk=[],G8="arbitrary..",Y8=e=>{const t=Z8(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return X8(o);const s=o.split(kp),l=s[0]===""&&s.length>1?1:0;return DA(s,l,t)},getConflictingClassGroupIds:(o,s)=>{if(s){const l=r[o],c=n[o];return l?c?q8(c,l):l:c||Dk}return n[o]||Dk}}},DA=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],a=n.nextPart.get(i);if(a){const c=DA(e,t+1,a);if(c)return c}const o=n.validators;if(o===null)return;const s=t===0?e.join(kp):e.slice(t).join(kp),l=o.length;for(let c=0;c<l;c++){const d=o[c];if(d.validator(s))return d.classGroupId}},X8=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?G8+r:void 0})(),Z8=e=>{const{theme:t,classGroups:n}=e;return Q8(n,t)},Q8=(e,t)=>{const n=IA();for(const r in e){const i=e[r];O0(i,n,r,t)}return n},O0=(e,t,n,r)=>{const i=e.length;for(let a=0;a<i;a++){const o=e[a];J8(o,t,n,r)}},J8=(e,t,n,r)=>{if(typeof e=="string"){eU(e,t,n);return}if(typeof e=="function"){tU(e,t,n,r);return}nU(e,t,n,r)},eU=(e,t,n)=>{const r=e===""?t:LA(t,e);r.classGroupId=n},tU=(e,t,n,r)=>{if(rU(e)){O0(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(K8(n,e))},nU=(e,t,n,r)=>{const i=Object.entries(e),a=i.length;for(let o=0;o<a;o++){const[s,l]=i[o];O0(l,LA(t,s),n,r)}},LA=(e,t)=>{let n=e;const r=t.split(kp),i=r.length;for(let a=0;a<i;a++){const o=r[a];let s=n.nextPart.get(o);s||(s=IA(),n.nextPart.set(o,s)),n=s}return n},rU=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,iU=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(a,o)=>{n[a]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let o=n[a];if(o!==void 0)return o;if((o=r[a])!==void 0)return i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},ux="!",Lk=":",aU=[],$k=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),oU=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const a=[];let o=0,s=0,l=0,c;const d=i.length;for(let y=0;y<d;y++){const x=i[y];if(o===0&&s===0){if(x===Lk){a.push(i.slice(l,y)),l=y+1;continue}if(x==="/"){c=y;continue}}x==="["?o++:x==="]"?o--:x==="("?s++:x===")"&&s--}const u=a.length===0?i:i.slice(l);let p=u,h=!1;u.endsWith(ux)?(p=u.slice(0,-1),h=!0):u.startsWith(ux)&&(p=u.slice(1),h=!0);const g=c&&c>l?c-l:void 0;return $k(a,h,p,g)};if(t){const i=t+Lk,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):$k(aU,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},sU=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a<n.length;a++){const o=n[a],s=o[0]==="[",l=t.has(o);s||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},lU=e=>({cache:iU(e.cacheSize),parseClassName:oU(e),sortModifiers:sU(e),postfixLookupClassGroupIds:cU(e),...Y8(e)}),cU=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},uU=/\s+/,dU=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],l=e.trim().split(uU);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:h,hasImportantModifier:g,baseClassName:y,maybePostfixModifierPosition:x}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let v=!!x,_;if(v){const E=y.substring(0,x);_=r(E);const j=_&&o[_]?r(y):void 0;j&&j!==_&&(_=j,v=!1)}else _=r(y);if(!_){if(!v){c=u+(c.length>0?" "+c:c);continue}if(_=r(y),!_){c=u+(c.length>0?" "+c:c);continue}v=!1}const b=h.length===0?"":h.length===1?h[0]:a(h).join(":"),k=g?b+ux:b,S=k+_;if(s.indexOf(S)>-1)continue;s.push(S);const w=i(_,v);for(let E=0;E<w.length;++E){const j=w[E];s.push(k+j)}c=u+(c.length>0?" "+c:c)}return c},fU=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=$A(n))&&(i&&(i+=" "),i+=r);return i},$A=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=$A(e[r]))&&(n&&(n+=" "),n+=t);return n},pU=(e,...t)=>{let n,r,i,a;const o=l=>{const c=t.reduce((d,u)=>u(d),e());return n=lU(c),r=n.cache.get,i=n.cache.set,a=s,s(l)},s=l=>{const c=r(l);if(c)return c;const d=dU(l,n);return i(l,d),d};return a=o,(...l)=>a(fU(...l))},hU=[],Cn=e=>{const t=n=>n[e]||hU;return t.isThemeGetter=!0,t},zA=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,FA=/^\((?:(\w[\w-]*):)?(.+)\)$/i,mU=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gU=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yU=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,vU=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,xU=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bU=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ro=e=>mU.test(e),at=e=>!!e&&!Number.isNaN(Number(e)),Bi=e=>!!e&&Number.isInteger(Number(e)),Eg=e=>e.endsWith("%")&&at(e.slice(0,-1)),_a=e=>gU.test(e),BA=()=>!0,wU=e=>yU.test(e)&&!vU.test(e),M0=()=>!1,_U=e=>xU.test(e),kU=e=>bU.test(e),SU=e=>!Me(e)&&!Ie(e),EU=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),CU=e=>Do(e,UA,M0),Me=e=>zA.test(e),Go=e=>Do(e,VA,wU),zk=e=>Do(e,RU,at),jU=e=>Do(e,KA,BA),NU=e=>Do(e,qA,M0),Fk=e=>Do(e,HA,M0),PU=e=>Do(e,WA,kU),Kd=e=>Do(e,GA,_U),Ie=e=>FA.test(e),Ec=e=>Is(e,VA),TU=e=>Is(e,qA),Bk=e=>Is(e,HA),AU=e=>Is(e,UA),OU=e=>Is(e,WA),Gd=e=>Is(e,GA,!0),MU=e=>Is(e,KA,!0),Do=(e,t,n)=>{const r=zA.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Is=(e,t,n=!1)=>{const r=FA.exec(e);return r?r[1]?t(r[1]):n:!1},HA=e=>e==="position"||e==="percentage",WA=e=>e==="image"||e==="url",UA=e=>e==="length"||e==="size"||e==="bg-size",VA=e=>e==="length",RU=e=>e==="number",qA=e=>e==="family-name",KA=e=>e==="number"||e==="weight",GA=e=>e==="shadow",IU=()=>{const e=Cn("color"),t=Cn("font"),n=Cn("text"),r=Cn("font-weight"),i=Cn("tracking"),a=Cn("leading"),o=Cn("breakpoint"),s=Cn("container"),l=Cn("spacing"),c=Cn("radius"),d=Cn("shadow"),u=Cn("inset-shadow"),p=Cn("text-shadow"),h=Cn("drop-shadow"),g=Cn("blur"),y=Cn("perspective"),x=Cn("aspect"),v=Cn("ease"),_=Cn("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...k(),Ie,Me],w=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],j=()=>[Ie,Me,l],C=()=>[ro,"full","auto",...j()],A=()=>[Bi,"none","subgrid",Ie,Me],R=()=>["auto",{span:["full",Bi,Ie,Me]},Bi,Ie,Me],P=()=>[Bi,"auto",Ie,Me],D=()=>["auto","min","max","fr",Ie,Me],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],M=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...j()],$=()=>[ro,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],U=()=>[ro,"screen","full","dvw","lvw","svw","min","max","fit",...j()],F=()=>[ro,"screen","full","lh","dvh","lvh","svh","min","max","fit",...j()],T=()=>[e,Ie,Me],Q=()=>[...k(),Bk,Fk,{position:[Ie,Me]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",AU,CU,{size:[Ie,Me]}],z=()=>[Eg,Ec,Go],L=()=>["","none","full",c,Ie,Me],B=()=>["",at,Ec,Go],ee=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Z=()=>[at,Eg,Bk,Fk],ne=()=>["","none",g,Ie,Me],fe=()=>["none",at,Ie,Me],V=()=>["none",at,Ie,Me],oe=()=>[at,Ie,Me],me=()=>[ro,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[_a],breakpoint:[_a],color:[BA],container:[_a],"drop-shadow":[_a],ease:["in","out","in-out"],font:[SU],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[_a],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[_a],shadow:[_a],spacing:["px",at],text:[_a],"text-shadow":[_a],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ro,Me,Ie,x]}],container:["container"],"container-type":[{"@container":["","normal","size",Ie,Me]}],"container-named":[EU],columns:[{columns:[at,Me,Ie,s]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{"inset-s":C(),start:C()}],end:[{"inset-e":C(),end:C()}],"inset-bs":[{"inset-bs":C()}],"inset-be":[{"inset-be":C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:["visible","invisible","collapse"],z:[{z:[Bi,"auto",Ie,Me]}],basis:[{basis:[ro,"full","auto",s,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,ro,"auto","initial","none",Me]}],grow:[{grow:["",at,Ie,Me]}],shrink:[{shrink:["",at,Ie,Me]}],order:[{order:[Bi,"first","last","none",Ie,Me]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...M(),"normal"]}],"justify-self":[{"justify-self":["auto",...M()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...M(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...M(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...M(),"baseline"]}],"place-self":[{"place-self":["auto",...M()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pbs:[{pbs:j()}],pbe:[{pbe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mbs:[{mbs:I()}],mbe:[{mbe:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],"inline-size":[{inline:["auto",...U()]}],"min-inline-size":[{"min-inline":["auto",...U()]}],"max-inline-size":[{"max-inline":["none",...U()]}],"block-size":[{block:["auto",...F()]}],"min-block-size":[{"min-block":["auto",...F()]}],"max-block-size":[{"max-block":["none",...F()]}],w:[{w:[s,"screen",...$()]}],"min-w":[{"min-w":[s,"screen","none",...$()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[o]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",n,Ec,Go]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,MU,jU]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Eg,Me]}],"font-family":[{font:[TU,NU,t]}],"font-features":[{"font-features":[Me]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Ie,Me]}],"line-clamp":[{"line-clamp":[at,"none",Ie,zk]}],leading:[{leading:[a,...j()]}],"list-image":[{"list-image":["none",Ie,Me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ie,Me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",Ie,Go]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[at,"auto",Ie,Me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"tab-size":[{tab:[Bi,Ie,Me]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ie,Me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ie,Me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Q()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Bi,Ie,Me],radial:["",Ie,Me],conic:[Bi,Ie,Me]},OU,PU]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-bs":[{"border-bs":B()}],"border-w-be":[{"border-be":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,Ie,Me]}],"outline-w":[{outline:["",at,Ec,Go]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","none",d,Gd,Kd]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",u,Gd,Kd]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[at,Go]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",p,Gd,Kd]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[at,Ie,Me]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":Z()}],"mask-image-linear-to-pos":[{"mask-linear-to":Z()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":Z()}],"mask-image-t-to-pos":[{"mask-t-to":Z()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":Z()}],"mask-image-r-to-pos":[{"mask-r-to":Z()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":Z()}],"mask-image-b-to-pos":[{"mask-b-to":Z()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":Z()}],"mask-image-l-to-pos":[{"mask-l-to":Z()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":Z()}],"mask-image-x-to-pos":[{"mask-x-to":Z()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":Z()}],"mask-image-y-to-pos":[{"mask-y-to":Z()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[Ie,Me]}],"mask-image-radial-from-pos":[{"mask-radial-from":Z()}],"mask-image-radial-to-pos":[{"mask-radial-to":Z()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":Z()}],"mask-image-conic-to-pos":[{"mask-conic-to":Z()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Q()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ie,Me]}],filter:[{filter:["","none",Ie,Me]}],blur:[{blur:ne()}],brightness:[{brightness:[at,Ie,Me]}],contrast:[{contrast:[at,Ie,Me]}],"drop-shadow":[{"drop-shadow":["","none",h,Gd,Kd]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",at,Ie,Me]}],"hue-rotate":[{"hue-rotate":[at,Ie,Me]}],invert:[{invert:["",at,Ie,Me]}],saturate:[{saturate:[at,Ie,Me]}],sepia:[{sepia:["",at,Ie,Me]}],"backdrop-filter":[{"backdrop-filter":["","none",Ie,Me]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[at,Ie,Me]}],"backdrop-contrast":[{"backdrop-contrast":[at,Ie,Me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,Ie,Me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,Ie,Me]}],"backdrop-invert":[{"backdrop-invert":["",at,Ie,Me]}],"backdrop-opacity":[{"backdrop-opacity":[at,Ie,Me]}],"backdrop-saturate":[{"backdrop-saturate":[at,Ie,Me]}],"backdrop-sepia":[{"backdrop-sepia":["",at,Ie,Me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ie,Me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",Ie,Me]}],ease:[{ease:["linear","initial",v,Ie,Me]}],delay:[{delay:[at,Ie,Me]}],animate:[{animate:["none",_,Ie,Me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[y,Ie,Me]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:oe()}],"skew-x":[{"skew-x":oe()}],"skew-y":[{"skew-y":oe()}],transform:[{transform:[Ie,Me,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:me()}],"translate-x":[{"translate-x":me()}],"translate-y":[{"translate-y":me()}],"translate-z":[{"translate-z":me()}],"translate-none":["translate-none"],zoom:[{zoom:[Bi,Ie,Me]}],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ie,Me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":T()}],"scrollbar-track-color":[{"scrollbar-track":T()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mbs":[{"scroll-mbs":j()}],"scroll-mbe":[{"scroll-mbe":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pbs":[{"scroll-pbs":j()}],"scroll-pbe":[{"scroll-pbe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ie,Me]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[at,Ec,Go,zk]}],stroke:[{stroke:["none",...T()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},DU=pU(IU);function se(...e){return DU(kt(e))}function Hk({version:e,onInstall:t,onSkip:n,duration:r}){const i=te.t("pages:layout.tray.update_found_title"),a=te.t("settings:about.install_now"),o=te.t("settings:about.skip_version");return ye.custom(s=>f.jsxs("div",{className:"flex w-[340px] flex-col gap-3 border border-te-gray bg-te-bg p-4 font-mono text-xs text-te-fg shadow-2xl",children:[f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.15em] text-te-fg",children:i}),f.jsx("span",{className:"text-te-light-gray",children:e})]}),f.jsxs("div",{className:"flex items-stretch justify-end gap-2",children:[n?f.jsx("button",{type:"button",onClick:()=>{ye.dismiss(s),n()},className:se("border border-te-gray px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.15em] text-te-light-gray transition-colors","hover:bg-te-surface-hover hover:text-te-fg"),children:o}):null,f.jsx("button",{type:"button",onClick:()=>{ye.dismiss(s),t()},className:se("border border-te-accent bg-te-accent px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.15em] text-te-accent-fg transition-colors","hover:bg-te-accent/90"),children:a})]})]}),{duration:r??1/0,unstyled:!0})}function LU(e,t){return function(r,...i){const a=new URL(e);return a.searchParams.set("code",r.toString()),i.forEach(o=>a.searchParams.append("args[]",o)),`${t} error #${r}; visit ${a} for the full message.`}}const ba=LU("https://base-ui.com/production-error","Base UI"),YA=m.createContext(void 0);function Lo(e){const t=m.useContext(YA);if(e===!1&&t===void 0)throw new Error(ba(27));return t}const Wk={};function hr(e,t){const n=m.useRef(Wk);return n.current===Wk&&(n.current=e(t)),n}function ql(e,t,n,r){const i=hr(XA).current;return zU(i,e,t,n,r)&&ZA(i,[e,t,n,r]),i.callback}function $U(e){const t=hr(XA).current;return FU(t,e)&&ZA(t,e),t.callback}function XA(){return{callback:null,cleanup:null,refs:[]}}function zU(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function FU(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function ZA(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const o=a(n);typeof o=="function"&&(r[i]=o);break}case"object":{a.current=n;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const o=r[i];typeof o=="function"?o():a(null);break}case"object":{a.current=null;break}}}}}}}const BU=parseInt(m.version,10);function R0(e){return BU>=e}function Uk(e){if(!m.isValidElement(e))return null;const t=e,n=t.props;return(R0(19)?n?.ref:t.ref)??null}function dx(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function I0(){}const fx=Object.freeze([]),Yn=Object.freeze({});function HU(e,t){const n={};for(const r in e){const i=e[r];if(t?.hasOwnProperty(r)){const a=t[r](i);a!=null&&Object.assign(n,a);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function WU(e,t){return typeof e=="function"?e(t):e}function UU(e,t){return typeof e=="function"?e(t):e}const D0={};function Kl(e,t,n,r,i){if(!n&&!r&&!e)return Sp(t);let a=Sp(e);return t&&(a=ep(a,t)),n&&(a=ep(a,n)),r&&(a=ep(a,r)),a}function VU(e){if(e.length===0)return D0;if(e.length===1)return Sp(e[0]);let t=Sp(e[0]);for(let n=1;n<e.length;n+=1)t=ep(t,e[n]);return t}function Sp(e){return L0(e)?{...JA(e,D0)}:qU(e)}function ep(e,t){return L0(t)?JA(t,e):KU(e,t)}function qU(e){const t={...e};for(const n in t){const r=t[n];QA(n,r)&&(t[n]=eO(r))}return t}function KU(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":{e[n]=dx(e.style,r);break}case"className":{e[n]=tO(e.className,r);break}default:QA(n,r)?e[n]=GU(e[n],r):e[n]=r}}return e}function QA(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function L0(e){return typeof e=="function"}function JA(e,t){return L0(e)?e(t):e??D0}function GU(e,t){return t?e?(...n)=>{const r=n[0];if(nO(r)){const a=r;Ep(a);const o=t(...n);return a.baseUIHandlerPrevented||e?.(...n),o}const i=t(...n);return e?.(...n),i}:eO(t):e}function eO(e){return e&&((...t)=>{const n=t[0];return nO(n)&&Ep(n),e(...t)})}function Ep(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function tO(e,t){return t?e?t+" "+e:t:e}function nO(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function Zr(e,t,n={}){const r=t.render,i=YU(t,n);if(n.enabled===!1)return null;const a=n.state??Yn;return QU(e,r,i,a)}function YU(e,t={}){const{className:n,style:r,render:i}=e,{state:a=Yn,ref:o,props:s,stateAttributesMapping:l,enabled:c=!0}=t,d=c?WU(n,a):void 0,u=c?UU(r,a):void 0,p=c?HU(a,l):Yn,h=c&&s?XU(s):void 0,g=c?dx(p,h)??{}:Yn;return typeof document<"u"&&(c?Array.isArray(o)?g.ref=$U([g.ref,Uk(i),...o]):g.ref=ql(g.ref,Uk(i),o):ql(null,null)),c?(d!==void 0&&(g.className=tO(g.className,d)),u!==void 0&&(g.style=dx(g.style,u)),g):Yn}function XU(e){return Array.isArray(e)?VU(e):Kl(void 0,e)}const ZU=Symbol.for("react.lazy");function QU(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=Kl(n,t.props);i.ref=n.ref;let a=t;return a?.$$typeof===ZU&&(a=m.Children.toArray(t)[0]),m.cloneElement(a,i)}if(e&&typeof e=="string")return JU(e,n);throw new Error(ba(8))}function JU(e,t){return e==="button"?m.createElement("button",{type:"button",...t,key:t.key}):e==="img"?m.createElement("img",{alt:"",...t,key:t.key}):m.createElement(e,t)}let Au=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const e9={[Au.startingStyle]:""},t9={[Au.endingStyle]:""},Gh={transitionStatus(e){return e==="starting"?e9:e==="ending"?t9:null}};let Ci=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Au.startingStyle]="startingStyle",e[e.endingStyle=Au.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),Vk=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const n9={[Vk.popupOpen]:"",[Vk.pressed]:""},r9={[Ci.open]:""},i9={[Ci.closed]:""},a9={[Ci.anchorHidden]:""},qk={open(e){return e?n9:null}},cd={open(e){return e?r9:i9},anchorHidden(e){return e?a9:null}},o9={...cd,...Gh},s9=m.forwardRef(function(t,n){const{render:r,className:i,style:a,forceRender:o=!1,...s}=t,{store:l}=Lo(),c=l.useState("open"),d=l.useState("nested"),u=l.useState("mounted"),p=l.useState("transitionStatus");return Zr("div",t,{state:{open:c,transitionStatus:p},ref:[l.context.backdropRef,n],stateAttributesMapping:o9,props:[{role:"presentation",hidden:!u,style:{userSelect:"none",WebkitUserSelect:"none"}},s],enabled:o||!d})});function Yh(){return typeof window<"u"}function or(e){return $0(e)?(e.nodeName||"").toLowerCase():"#document"}function yn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wa(e){var t;return(t=($0(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $0(e){return Yh()?e instanceof Node||e instanceof yn(e).Node:!1}function ut(e){return Yh()?e instanceof Element||e instanceof yn(e).Element:!1}function Lt(e){return Yh()?e instanceof HTMLElement||e instanceof yn(e).HTMLElement:!1}function Gl(e){return!Yh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yn(e).ShadowRoot}function $o(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Or(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function l9(e){return/^(table|td|th)$/.test(or(e))}function Xh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const c9=/transform|translate|scale|rotate|perspective|filter/,u9=/paint|layout|strict|content/,Yo=e=>!!e&&e!=="none";let Cg;function z0(e){const t=ut(e)?Or(e):e;return Yo(t.transform)||Yo(t.translate)||Yo(t.scale)||Yo(t.rotate)||Yo(t.perspective)||!Zh()&&(Yo(t.backdropFilter)||Yo(t.filter))||c9.test(t.willChange||"")||u9.test(t.contain||"")}function d9(e){let t=ua(e);for(;Lt(t)&&!ra(t);){if(z0(t))return t;if(Xh(t))return null;t=ua(t)}return null}function Zh(){return Cg==null&&(Cg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cg}function ra(e){return/^(html|body|#document)$/.test(or(e))}function Or(e){return yn(e).getComputedStyle(e)}function Qh(e){return ut(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ua(e){if(or(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gl(e)&&e.host||wa(e);return Gl(t)?t.host:t}function rO(e){const t=ua(e);return ra(t)?e.ownerDocument?e.ownerDocument.body:e.body:Lt(t)&&$o(t)?t:rO(t)}function Ou(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=rO(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),o=yn(i);if(a){const s=px(o);return t.concat(o,o.visualViewport||[],$o(i)?i:[],s&&n?Ou(s):[])}else return t.concat(i,Ou(i,[],n))}function px(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const jg=Ih[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],f9=jg&&jg!==m.useLayoutEffect?jg:e=>e();function et(e){const t=hr(p9).current;return t.next=e,f9(t.effect),t.trampoline}function p9(){const e={next:void 0,callback:h9,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function h9(){}const m9={...Ih},g9=()=>{},Ye=typeof document<"u"?m.useLayoutEffect:g9,y9=m.createContext(void 0);function F0(e=!1){const t=m.useContext(y9);if(t===void 0&&!e)throw new Error(ba(16));return t}function v9(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:m.useMemo(()=>{const c={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(c.tabIndex=i,!a&&n&&(c.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(c["aria-disabled"]=n),a&&(!t||s)&&(c.disabled=n),c},[r,n,t,o,s,a,i])}}function Jh(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=m.useRef(null),s=F0(!0),l=a??s!==void 0,{props:c}=v9({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:r,isNativeButton:i}),d=m.useCallback(()=>{const h=o.current;Ng(h)&&l&&t&&c.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,c.disabled,l]);Ye(d,[d]);const u=m.useCallback((h={})=>{const{onClick:g,onMouseDown:y,onKeyUp:x,onKeyDown:v,onPointerDown:_,...b}=h;return Kl({type:i?"button":void 0,onClick(S){if(t){S.preventDefault();return}g?.(S)},onMouseDown(S){t||y?.(S)},onKeyDown(S){if(t||(Ep(S),v?.(S),S.baseUIHandlerPrevented))return;const w=S.target===S.currentTarget,E=S.currentTarget,j=Ng(E),C=!i&&x9(E),A=w&&(i?j:!C),R=S.key==="Enter",P=S.key===" ",D=E.getAttribute("role"),O=D?.startsWith("menuitem")||D==="option"||D==="gridcell";if(w&&l&&P){if(S.defaultPrevented&&O)return;S.preventDefault(),C||i&&j?(E.click(),S.preventBaseUIHandler()):A&&(g?.(S),S.preventBaseUIHandler());return}A&&(!i&&(P||R)&&S.preventDefault(),!i&&R&&g?.(S))},onKeyUp(S){if(!t){if(Ep(S),x?.(S),S.target===S.currentTarget&&i&&l&&Ng(S.currentTarget)&&S.key===" "){S.preventDefault();return}S.baseUIHandlerPrevented||S.target===S.currentTarget&&!i&&!l&&S.key===" "&&g?.(S)}},onPointerDown(S){if(t){S.preventDefault();return}_?.(S)}},i?void 0:{role:"button"},c,b)},[t,c,l,i]),p=et(h=>{o.current=h,d()});return{getButtonProps:u,buttonRef:p}}function Ng(e){return Lt(e)&&e.tagName==="BUTTON"}function x9(e){return!!(e?.tagName==="A"&&e?.href)}const Mu="trigger-press",kr="trigger-hover",du="trigger-focus",B0="outside-press",iO="item-press",b9="close-press",Yl="focus-out",H0="escape-key",tp="list-navigation",w9="cancel-open",Gc="sibling-open",aO="imperative-action";function ht(e,t,n,r){let i=!1,a=!1;const o=Yn;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}const oO=m.forwardRef(function(t,n){const{render:r,className:i,disabled:a=!1,nativeButton:o=!0,style:s,...l}=t,{store:c}=Lo(),d=c.useState("open");function u(y){d&&c.setOpen(!1,ht(b9,y.nativeEvent))}const{getButtonProps:p,buttonRef:h}=Jh({disabled:a,native:o});return Zr("button",t,{state:{disabled:a},ref:[n,h],props:[{onClick:u},l,p]})});let Kk=0;function _9(e,t="mui"){const[n,r]=m.useState(e),i=e||n;return m.useEffect(()=>{n==null&&(Kk+=1,r(`${t}-${Kk}`))},[n,t]),i}const Gk=m9.useId;function Ds(e,t){if(Gk!==void 0){const n=Gk();return e??(t?`${t}-${n}`:n)}return _9(e,t)}function em(e){return Ds(e,"base-ui")}const k9=m.forwardRef(function(t,n){const{render:r,className:i,style:a,id:o,...s}=t,{store:l}=Lo(),c=em(o);return l.useSyncedValueWithCleanup("descriptionElementId",c),Zr("p",t,{ref:n,props:[{id:c},s]})}),S9=[];function W0(e){m.useEffect(e,S9)}const Cc=0;class da{static create(){return new da}currentId=Cc;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Cc,n()},t)}isStarted(){return this.currentId!==Cc}clear=()=>{this.currentId!==Cc&&(clearTimeout(this.currentId),this.currentId=Cc)};disposeEffect=()=>this.clear}function Kr(){const e=hr(da.create).current;return W0(e.disposeEffect),e}const sc=typeof navigator<"u",Pg=E9(),sO=j9(),lO=C9(),cO=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),uO=Pg.platform==="MacIntel"&&Pg.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Pg.platform),dO=sc&&/apple/i.test(navigator.vendor),hx=sc&&/android/i.test(sO)||/android/i.test(lO),fO=sc&&sO.toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints,pO=lO.includes("jsdom/");function E9(){if(!sc)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function C9(){if(!sc)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function j9(){if(!sc)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}function zr(e){e.preventDefault(),e.stopPropagation()}function N9(e){return"nativeEvent"in e}function hO(e){return e.pointerType===""&&e.isTrusted?!0:hx&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function mO(e){return pO?!1:!hx&&e.width===0&&e.height===0||hx&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function Ru(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function gO(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}function P9(e,t){return t!=null&&!Ru(t)?0:typeof e=="function"?e():e}function mx(e,t,n){const r=P9(e,n);return typeof r=="number"?r:r?.[t]}function Yk(e){return typeof e=="function"?e():e}function yO(e,t){return t||e==="click"||e==="mousedown"}function st(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function ia(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}function Gn(e){const t=hr(T9,e).current;return t.next=e,Ye(t.effect),t}function T9(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}const Yd=null;class A9{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let i=0;i<n.length;i+=1)n[i]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Xd=new A9;class Gi{static create(){return new Gi}static request(t){return Xd.request(t)}static cancel(t){return Xd.cancel(t)}currentId=Yd;request(t){this.cancel(),this.currentId=Xd.request(()=>{this.currentId=Yd,t()})}cancel=()=>{this.currentId!==Yd&&(Xd.cancel(this.currentId),this.currentId=Yd)};disposeEffect=()=>this.cancel}function U0(){const e=hr(Gi.create).current;return W0(e.disposeEffect),e}function pt(e){return e?.ownerDocument||document}const O9={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},M9={...O9,position:"fixed",top:0,left:0},Xl=m.forwardRef(function(t,n){const[r,i]=m.useState();Ye(()=>{dO&&i("button")},[]);const a={tabIndex:0,role:r};return f.jsx("span",{...t,ref:n,style:M9,"aria-hidden":r?void 0:!0,...a,"data-base-ui-focus-guard":""})}),gx="data-base-ui-focusable",vO="active",xO="selected",bO="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Co="ArrowLeft",jo="ArrowRight",V0="ArrowUp",ud="ArrowDown";function oi(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Qe(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Gl(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Nr(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Cp(e,t){if(!ut(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute("data-trigger-disabled");for(const[,r]of t.entries())if(Qe(r,n))return!r.hasAttribute("data-trigger-disabled");return!1}function bi(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function R9(e){return e.matches("html,body")}function tm(e){return Lt(e)&&e.matches(bO)}function I9(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${bO}`)!=null}function yx(e){return e?e.getAttribute("role")==="combobox"&&tm(e):!1}function D9(e){if(!e||pO)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function jp(e){return e?e.hasAttribute(gx)?e:e.querySelector(`[${gx}]`)||e:null}const L9=["top","right","bottom","left"],Zl=Math.min,Br=Math.max,Np=Math.round,us=Math.floor,aa=e=>({x:e,y:e}),$9={left:"right",right:"left",bottom:"top",top:"bottom"};function vx(e,t,n){return Br(e,Zl(t,n))}function Ba(e,t){return typeof e=="function"?e(t):e}function Pr(e){return e.split("-")[0]}function zo(e){return e.split("-")[1]}function q0(e){return e==="x"?"y":"x"}function K0(e){return e==="y"?"height":"width"}function li(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function G0(e){return q0(li(e))}function z9(e,t,n){n===void 0&&(n=!1);const r=zo(e),i=G0(e),a=K0(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=Pp(o)),[o,Pp(o)]}function F9(e){const t=Pp(e);return[xx(e),t,xx(t)]}function xx(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Xk=["left","right"],Zk=["right","left"],B9=["top","bottom"],H9=["bottom","top"];function W9(e,t,n){switch(e){case"top":case"bottom":return n?t?Zk:Xk:t?Xk:Zk;case"left":case"right":return t?B9:H9;default:return[]}}function U9(e,t,n,r){const i=zo(e);let a=W9(Pr(e),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),t&&(a=a.concat(a.map(xx)))),a}function Pp(e){const t=Pr(e);return $9[t]+e.slice(t.length)}function V9(e){return{top:0,right:0,bottom:0,left:0,...e}}function wO(e){return typeof e!="number"?V9(e):{top:e,right:e,bottom:e,left:e}}function Tp(e){const{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 Zd(e,t,n){return Math.floor(e/t)!==n}function Ap(e,t){return t<0||t>=e.length}function Tg(e,t){return ur(e.current,{disabledIndices:t})}function Qk(e,t){return ur(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function ur(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Ml(e,a,r));return a}function q9(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:l,maxIndex:c,prevIndex:d,stopEvent:u=!1}){let p=d,h;if(t.key===V0?h="up":t.key===ud&&(h="down"),h){const g=[],y=[];let x=!1,v=0;{let C=null,A=-1;e.forEach((R,P)=>{if(R==null)return;v+=1;const D=R.closest('[role="row"]');D&&(x=!0),(D!==C||A===-1)&&(C=D,A+=1,g[A]=[]),g[A].push(P),y[P]=A})}let _=!1,b=0;if(x)for(const C of g){const A=C.length;A>b&&(b=A),A!==o&&(_=!0)}const k=_&&v<e.length,S=b||o,w=C=>{if(!_||d===-1)return;const A=y[d];if(A==null)return;const R=g[A].indexOf(d),P=C==="up"?-1:1;for(let D=A+P,O=0;O<g.length;O+=1,D+=P){if(D<0||D>=g.length){if(!r||k)return;if(D=D<0?g.length-1:0,i){const I=Math.min(R,g[D].length-1),$=g[D][I]??g[D][0],U=i(t,d,$);D=y[U]??D}}const M=g[D];for(let I=Math.min(R,M.length-1);I>=0;I-=1){const $=M[I];if(!Ml(e,$,s))return $}}},E=C=>{if(!k||d===-1)return;const A=d%S,R=C==="up"?-S:S,P=c-c%S,D=us(c/S)+1;for(let O=d-A+R,M=0;M<D;M+=1,O+=R){if(O<0||O>c){if(!r)return;O=O<0?P:0}const I=Math.min(O+S-1,c);for(let $=Math.min(O+A,I);$>=O;$-=1)if(!Ml(e,$,s))return $}};u&&zr(t);const j=w(h)??E(h);if(j!==void 0)p=j;else if(d===-1)p=h==="up"?c:l;else if(p=ur(e,{startingIndex:d,amount:S,decrement:h==="up",disabledIndices:s}),r){if(h==="up"&&(d-S<l||p<0)){const C=d%S,A=c%S,R=c-(A-C);A===C?p=c:p=A>C?R:R-S,i&&(p=i(t,d,p))}h==="down"&&d+S>c&&(p=ur(e,{startingIndex:d%S-S,amount:S,disabledIndices:s}),i&&(p=i(t,d,p)))}Ap(e,p)&&(p=d)}if(n==="both"){const g=us(d/o);t.key===(a?Co:jo)&&(u&&zr(t),d%o!==o-1?(p=ur(e,{startingIndex:d,disabledIndices:s}),r&&Zd(p,o,g)&&(p=ur(e,{startingIndex:d-d%o-1,disabledIndices:s}),i&&(p=i(t,d,p)))):r&&(p=ur(e,{startingIndex:d-d%o-1,disabledIndices:s}),i&&(p=i(t,d,p))),Zd(p,o,g)&&(p=d)),t.key===(a?jo:Co)&&(u&&zr(t),d%o!==0?(p=ur(e,{startingIndex:d,decrement:!0,disabledIndices:s}),r&&Zd(p,o,g)&&(p=ur(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:s}),i&&(p=i(t,d,p)))):r&&(p=ur(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:s}),i&&(p=i(t,d,p))),Zd(p,o,g)&&(p=d));const y=us(c/o)===g;Ap(e,p)&&(r&&y?(p=t.key===(a?jo:Co)?c:ur(e,{startingIndex:d-d%o-1,disabledIndices:s}),i&&(p=i(t,d,p))):p=d)}return p}function K9(e,t,n){const r=[];let i=0;return e.forEach(({width:a,height:o},s)=>{let l=!1;for(;!l;){const c=[];for(let d=0;d<a;d+=1)for(let u=0;u<o;u+=1)c.push(i+d+u*t);i%t+a<=t&&c.every(d=>r[d]==null)?(c.forEach(d=>{r[d]=s}),l=!0):i+=1}}),[...r]}function G9(e,t,n,r,i){if(e===-1)return-1;const a=n.indexOf(e),o=t[e];switch(i){case"tl":return a;case"tr":return o?a+o.width-1:a;case"bl":return o?a+(o.height-1)*r:a;case"br":return n.lastIndexOf(e);default:return-1}}function Y9(e,t){return t.flatMap((n,r)=>e.includes(n)?[r]:[])}function Ml(e,t,n){if(typeof n=="function"?n(t):n?.includes(t)??!1)return!0;const i=e[t];return i?nm(i)?!n&&(i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true"):!0:!1}function X9(e){return e.visibility==="hidden"||e.visibility==="collapse"}function nm(e,t=e?Or(e):null){return!e||!e.isConnected||!t||X9(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const Z9='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function Q9(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return Gl(n)?n.host:null}function bx(e){for(const t of Array.from(e.children))if(or(t)==="summary")return t;return null}function J9(e,t){const n=bx(t);return!!n&&(e===n||Qe(n,e))}function _O(e){const t=e?or(e):"";return e!=null&&e.matches(Z9)&&(t!=="summary"||e.parentElement!=null&&or(e.parentElement)==="details"&&bx(e.parentElement)===e)&&(t!=="details"||bx(e)==null)&&(t!=="input"||e.type!=="hidden")}function kO(e){if(!_O(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=Q9(t)){const n=t!==e,r=or(t)==="slot";if(t.hasAttribute("inert")||n&&or(t)==="details"&&!t.open&&!J9(e,t)||t.hasAttribute("hidden")||!r&&!e7(t,n))return!1}return!0}function e7(e,t){const n=Or(e);return t?n.display!=="none":nm(e,n)}function SO(e){const t=e.tabIndex;if(t<0){const n=or(e);if(n==="details"||n==="audio"||n==="video"||Lt(e)&&e.isContentEditable)return 0}return t}function Ag(e){if(or(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function t7(e,t){const n=Ag(e);if(!n)return!0;const r=t.find(i=>{const a=Ag(i);return a?.name===n.name&&a.form===n.form&&a.checked});return r?r===n:t.find(i=>{const a=Ag(i);return a?.name===n.name&&a.form===n.form})===n}function EO(e){if(Lt(e)&&or(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return Lt(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function CO(e,t){EO(e).forEach(n=>{_O(n)&&t.push(n),CO(n,t)})}function jO(e,t,n){EO(e).forEach(r=>{Lt(r)&&r.matches(t)&&n.push(r),jO(r,t,n)})}function Y0(e){return kO(e)&&SO(e)>=0}function NO(e){const t=[];return CO(e,t),t.filter(kO)}function dd(e){const t=NO(e);return t.filter(n=>SO(n)>=0&&t7(n,t))}function PO(e,t){const n=dd(e),r=n.length;if(r===0)return;const i=oi(pt(e)),a=n.indexOf(i),o=a===-1?t===1?0:r-1:a+t;return n[o]}function X0(e){return PO(pt(e).body,1)||e}function TO(e){return PO(pt(e).body,-1)||e}function AO(e,t){if(!e)return null;const n=dd(pt(e).body),r=n.length;if(r===0)return null;const i=n.indexOf(e);if(i===-1)return null;const a=(i+t+r)%r;return n[a]}function n7(e){return AO(e,1)}function r7(e){return AO(e,-1)}function Rl(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Qe(n,r)}function i7(e){dd(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Jk(e){const t=[];jO(e,"[data-tabindex]",t),t.forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function oa(e,t,n=!0){return e.filter(i=>i.parentId===t).flatMap(i=>[...!n||i.context?.open?[i]:[],...oa(e,i.id,n)])}function eS(e,t){let n=[],r=e.find(i=>i.id===t)?.parentId;for(;r;){const i=e.find(a=>a.id===r);r=i?.parentId,i&&(n=n.concat(i))}return n}function Iu(e){return`data-base-ui-${e}`}let Qd=0;function np(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(Qd);const a=()=>e?.focus({preventScroll:n});if(i)return a(),I0;const o=requestAnimationFrame(a);return Qd=o,()=>{Qd===o&&(cancelAnimationFrame(o),Qd=0)}}const Og={inert:new WeakMap,"aria-hidden":new WeakMap},tS="data-base-ui-inert",wx={inert:new WeakSet,"aria-hidden":new WeakSet};let jc=new WeakMap,Mg=0;function a7(e){return wx[e]}function OO(e){return e?Gl(e)?e.host:OO(e.parentNode):null}const Rg=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=OO(n);return e.contains(r)?r:null}).filter(n=>n!=null),nS=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},rS=(e,t,n)=>{const r=[],i=a=>{!a||n.has(a)||Array.from(a.children).forEach(o=>{or(o)!=="script"&&(t.has(o)?i(o):r.push(o))})};return i(e),r};function o7(e,t,n,r,{mark:i=!0,markerIgnoreElements:a=[]}){const o=r?"inert":n?"aria-hidden":null;let s=null,l=null;const c=Rg(t,e),d=i?Rg(t,a):[],u=new Set(d),p=i?rS(t,nS(c),new Set(c)).filter(y=>!u.has(y)):[],h=[],g=[];if(o){const y=Og[o],x=a7(o);l=x,s=y;const v=Rg(t,Array.from(t.querySelectorAll("[aria-live]"))),_=c.concat(v);rS(t,nS(_),new Set(_)).forEach(k=>{const S=k.getAttribute(o),w=S!==null&&S!=="false",E=(y.get(k)||0)+1;y.set(k,E),h.push(k),E===1&&w&&x.add(k),w||k.setAttribute(o,o==="inert"?"":"true")})}return i&&p.forEach(y=>{const x=(jc.get(y)||0)+1;jc.set(y,x),g.push(y),x===1&&y.setAttribute(tS,"")}),Mg+=1,()=>{s&&h.forEach(y=>{const v=(s.get(y)||0)-1;s.set(y,v),v||(!l?.has(y)&&o&&y.removeAttribute(o),l?.delete(y))}),i&&g.forEach(y=>{const x=(jc.get(y)||0)-1;jc.set(y,x),x||y.removeAttribute(tS)}),Mg-=1,Mg||(Og.inert=new WeakMap,Og["aria-hidden"]=new WeakMap,wx.inert=new WeakSet,wx["aria-hidden"]=new WeakSet,jc=new WeakMap)}}function iS(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:i=!0,markerIgnoreElements:a=[]}=t,o=pt(e[0]).body;return o7(e,o,n,r,{mark:i,markerIgnoreElements:a})}const s7=500,l7=500,c7={style:{transition:"none"}},u7="data-base-ui-click-trigger",d7={fallbackAxisSide:"none"},f7={fallbackAxisSide:"end"},p7={clipPath:"inset(50%)",position:"fixed",top:0,left:0},MO=m.createContext(null),RO=()=>m.useContext(MO),h7=Iu("portal");function m7(e={}){const{ref:t,container:n,componentProps:r=Yn,elementProps:i}=e,a=Ds(),s=RO()?.portalNode,[l,c]=m.useState(null),[d,u]=m.useState(null),p=et(x=>{x!==null&&u(x)}),h=m.useRef(null);Ye(()=>{if(n===null){h.current&&(h.current=null,u(null),c(null));return}if(a==null)return;const x=(n&&($0(n)?n:n.current))??s??document.body;if(x==null){h.current&&(h.current=null,u(null),c(null));return}h.current!==x&&(h.current=x,u(null),c(x))},[n,s,a]);const g=Zr("div",r,{ref:[t,p],props:[{id:a,[h7]:""},i]});return{portalNode:d,portalSubtree:l&&g?qr.createPortal(g,l):null}}const IO=m.forwardRef(function(t,n){const{children:r,container:i,className:a,render:o,renderGuards:s,style:l,...c}=t,{portalNode:d,portalSubtree:u}=m7({container:i,ref:n,componentProps:t,elementProps:c}),p=m.useRef(null),h=m.useRef(null),g=m.useRef(null),y=m.useRef(null),[x,v]=m.useState(null),_=m.useRef(!1),b=x?.modal,k=x?.open,S=typeof s=="boolean"?s:!!x&&!x.modal&&x.open&&!!d;m.useEffect(()=>{if(!d||b)return;function E(j){d&&j.relatedTarget&&Rl(j)&&(j.type==="focusin"?_.current&&(Jk(d),_.current=!1):(i7(d),_.current=!0))}return ia(st(d,"focusin",E,!0),st(d,"focusout",E,!0))},[d,b]),m.useEffect(()=>{!d||k!==!1||(Jk(d),_.current=!1)},[k,d]);const w=m.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:h,beforeInsideRef:g,afterInsideRef:y,portalNode:d,setFocusManagerState:v}),[d]);return f.jsxs(m.Fragment,{children:[u,f.jsxs(MO.Provider,{value:w,children:[S&&d&&f.jsx(Xl,{"data-type":"outside",ref:p,onFocus:E=>{if(Rl(E,d))g.current?.focus();else{const j=x?x.domReference:null;TO(j)?.focus()}}}),S&&d&&f.jsx("span",{"aria-owns":d.id,style:p7}),d&&qr.createPortal(r,d),S&&d&&f.jsx(Xl,{"data-type":"outside",ref:h,onFocus:E=>{if(Rl(E,d))y.current?.focus();else{const j=x?x.domReference:null;X0(j)?.focus(),x?.closeOnFocusOut&&x?.onOpenChange(!1,ht(Yl,E.nativeEvent))}}})]})]})});function DO(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class Z0{nodesRef={current:[]};events=DO();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const LO=m.createContext(null),$O=m.createContext(null),qa=()=>m.useContext(LO)?.id||null,Fo=e=>{const t=m.useContext($O);return e??t};function zO(e){const t=Ds(),n=Fo(e),r=qa();return Ye(()=>{if(!t)return;const i={id:t,parentId:r};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,r]),t}function g7(e){const{children:t,id:n}=e,r=qa();return f.jsx(LO.Provider,{value:m.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function y7(e){const{children:t,externalTree:n}=e,r=hr(()=>n??new Z0).current;return f.jsx($O.Provider,{value:r,children:t})}function Sa(e){return e==null?e:"current"in e?e.current:e}function v7(e,t){const n=yn(Nr(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const aS=20;let bo=[];function Q0(){bo=bo.filter(e=>e.deref()?.isConnected)}function x7(e){Q0(),e&&or(e)!=="body"&&(bo.push(new WeakRef(e)),bo.length>aS&&(bo=bo.slice(-aS)))}function Ig(){return Q0(),bo[bo.length-1]?.deref()}function b7(e){return e?Y0(e)?e:dd(e)[0]||e:null}function oS(e,t){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const r=NO(e).filter(a=>{const o=a.getAttribute("data-tabindex")||"";return Y0(a)||a.hasAttribute("data-tabindex")&&!o.startsWith("-")}),i=e.getAttribute("tabindex");t.current.includes("floating")||r.length===0?i!=="0"&&e.setAttribute("tabindex","0"):(i!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function FO(e){const{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:l=!0,openInteractionType:c="",nextFocusableElement:d,previousFocusableElement:u,beforeContentFocusGuardRef:p,externalTree:h,getInsideElements:g}=e,y="rootStore"in t?t.rootStore:t,x=y.useState("open"),v=y.useState("domReferenceElement"),_=y.useState("floatingElement"),{events:b,dataRef:k}=y.context,S=et(()=>k.current.floatingContext?.nodeId),w=i===!1,E=yx(v)&&w,j=m.useRef(["content"]),C=Gn(i),A=Gn(a),R=Gn(c),P=Fo(h),D=RO(),O=m.useRef(!1),M=m.useRef(!1),I=m.useRef(!1),$=m.useRef(null),U=m.useRef(""),F=m.useRef(""),T=m.useRef(null),Q=m.useRef(null),J=ql(T,p,D?.beforeInsideRef),N=ql(Q,D?.afterInsideRef),z=Kr(),L=Kr(),B=U0(),ee=D!=null,X=jp(_),Z=et((V=X)=>V?dd(V):[]),ne=et(()=>g?.().filter(V=>V!=null)??[]);m.useEffect(()=>{if(r||!s)return;function V(me){me.key==="Tab"&&Qe(X,oi(pt(X)))&&Z().length===0&&!E&&zr(me)}const oe=pt(X);return st(oe,"keydown",V)},[r,v,X,s,j,E,Z]),m.useEffect(()=>{if(r||!x)return;const V=pt(X);function oe(){I.current=!1}function me(xe){const be=Nr(xe),je=ne(),ge=Qe(_,be)||Qe(v,be)||Qe(D?.portalNode,be)||je.some(de=>de===be||Qe(de,be));I.current=!ge,F.current=xe.pointerType||"keyboard",be?.closest(`[${u7}]`)&&(M.current=!0)}function Ne(){F.current="keyboard"}return ia(st(V,"pointerdown",me,!0),st(V,"pointerup",oe,!0),st(V,"pointercancel",oe,!0),st(V,"keydown",Ne,!0))},[r,_,v,X,x,D,ne]),m.useEffect(()=>{if(r||!l)return;const V=pt(X);function oe(){M.current=!0,L.start(0,()=>{M.current=!1})}function me(je){const ge=Nr(je);Y0(ge)&&($.current=ge)}function Ne(je){const ge=je.relatedTarget,de=je.currentTarget,ce=Nr(je);queueMicrotask(()=>{const ve=S(),q=y.context.triggerElements,ue=ne(),Te=ge?.hasAttribute(Iu("focus-guard"))&&[T.current,Q.current,D?.beforeInsideRef.current,D?.afterInsideRef.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,Sa(u),Sa(d)].includes(ge),G=!(Qe(v,ge)||Qe(_,ge)||Qe(ge,_)||Qe(D?.portalNode,ge)||ue.some(le=>le===ge||Qe(le,ge))||ge!=null&&q.hasElement(ge)||q.hasMatchingElement(le=>Qe(le,ge))||Te||P&&(oa(P.nodesRef.current,ve).find(le=>Qe(le.context?.elements.floating,ge)||Qe(le.context?.elements.domReference,ge))||eS(P.nodesRef.current,ve).find(le=>[le.context?.elements.floating,jp(le.context?.elements.floating)].includes(ge)||le.context?.elements.domReference===ge)));if(de===v&&X&&oS(X,j),o&&de!==v&&!nm(ce)&&oi(V)===V.body){if(Lt(X)&&(X.focus(),o==="popup")){B.request(()=>{X.focus()});return}const le=Z(),Ce=$.current,Ee=(Ce&&le.includes(Ce)?Ce:null)||le[le.length-1]||X;Lt(Ee)&&Ee.focus()}if(k.current.insideReactTree){k.current.insideReactTree=!1;return}(E||!s)&&ge&&G&&!M.current&&(E||ge!==Ig())&&(O.current=!0,y.setOpen(!1,ht(Yl,je)))})}function xe(){I.current||(k.current.insideReactTree=!0,z.start(0,()=>{k.current.insideReactTree=!1}))}const be=Lt(v)?v:null;if(!(!_&&!be))return ia(be&&st(be,"focusout",Ne),be&&st(be,"pointerdown",oe),_&&st(_,"focusin",me),_&&st(_,"focusout",Ne),_&&D&&st(_,"focusout",xe,!0))},[r,v,_,X,s,P,D,y,l,o,Z,E,S,j,k,z,L,B,d,u,ne]),m.useEffect(()=>{if(r||!_||!x)return;const V=Array.from(D?.portalNode?.querySelectorAll(`[${Iu("portal")}]`)||[]),me=(P?eS(P.nodesRef.current,S()):[]).find(de=>yx(de.context?.elements.domReference||null))?.context?.elements.domReference,xe=[...[_,...V,T.current,Q.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,...ne()],me,Sa(u),Sa(d),E?v:null].filter(de=>de!=null),be=iS(xe,{ariaHidden:s||E,mark:!1}),je=[_,...V].filter(de=>de!=null),ge=iS(je);return()=>{ge(),be()}},[x,r,v,_,s,j,D,E,P,S,d,u,ne]),Ye(()=>{if(!x||r||!Lt(X))return;const V=pt(X),oe=oi(V);queueMicrotask(()=>{const me=C.current,Ne=typeof me=="function"?me(R.current||""):me;if(Ne===void 0||Ne===!1||Qe(X,oe))return;let be=null;const je=()=>(be==null&&(be=Z(X)),be[0]||X);let ge;Ne===!0||Ne===null?ge=je():ge=Sa(Ne),ge=ge||je(),np(ge,{preventScroll:ge===X})})},[r,x,X,w,Z,C,R]),Ye(()=>{if(r||!X)return;const V=pt(X),oe=oi(V);x7(oe);function me(xe){if(xe.open||(U.current=v7(xe.nativeEvent,F.current)),xe.reason===kr&&xe.nativeEvent.type==="mouseleave"&&(O.current=!0),xe.reason===B0)if(xe.nested)O.current=!1;else if(hO(xe.nativeEvent)||mO(xe.nativeEvent))O.current=!1;else{let be=!1;pt(X).createElement("div").focus({get preventScroll(){return be=!0,!1}}),be?O.current=!1:O.current=!0}}b.on("openchange",me);function Ne(){const xe=A.current;let be=typeof xe=="function"?xe(U.current):xe;if(be===void 0||be===!1)return null;if(be===null&&(be=!0),typeof be=="boolean"){const ge=v||Ig();return ge&&ge.isConnected?ge:null}const je=v||Ig();return Sa(be)||je||null}return()=>{b.off("openchange",me);const xe=oi(V),be=ne(),je=Qe(_,xe)||be.some(ce=>ce===xe||Qe(ce,xe))||P&&oa(P.nodesRef.current,S(),!1).some(ce=>Qe(ce.context?.elements.floating,xe)),ge=A.current,de=Ne();queueMicrotask(()=>{const ce=b7(de),ve=typeof ge!="boolean";ge&&!O.current&&Lt(ce)&&(!(!ve&&ce!==xe&&xe!==V.body)||je)&&ce.focus({preventScroll:!0}),O.current=!1})}},[r,_,X,A,k,b,P,v,S,ne]),Ye(()=>{if(!cO||x||!_)return;const V=oi(pt(_));!Lt(V)||!tm(V)||Qe(_,V)&&V.blur()},[x,_]),Ye(()=>{if(!(r||!D))return D.setFocusManagerState({modal:s,closeOnFocusOut:l,open:x,onOpenChange:y.setOpen,domReference:v}),()=>{D.setFocusManagerState(null)}},[r,D,s,x,y,l,v]),Ye(()=>{if(!(r||!X))return oS(X,j),()=>{queueMicrotask(Q0)}},[r,X,j]);const fe=!r&&(s?!E:!0)&&(ee||s);return f.jsxs(m.Fragment,{children:[fe&&f.jsx(Xl,{"data-type":"inside",ref:J,onFocus:V=>{if(s){const oe=Z();np(oe[oe.length-1])}else D?.portalNode&&(O.current=!1,Rl(V,D.portalNode)?X0(v)?.focus():Sa(u??D.beforeOutsideRef)?.focus())}}),n,fe&&f.jsx(Xl,{"data-type":"inside",ref:N,onFocus:V=>{s?np(Z()[0]):D?.portalNode&&(l&&(O.current=!0),Rl(V,D.portalNode)?TO(v)?.focus():Sa(d??D.afterOutsideRef)?.focus())}})]})}function w7(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:i=!0,event:a="click",toggle:o=!0,ignoreMouse:s=!1,stickIfOpen:l=!0,touchOpenDelay:c=0,reason:d=Mu}=t,u=m.useRef(void 0),p=U0(),h=Kr(),g=m.useMemo(()=>({onPointerDown(y){u.current=y.pointerType},onMouseDown(y){const x=u.current,v=y.nativeEvent,_=n.select("open");if(y.button!==0||a==="click"||Ru(x,!0)&&s)return;const b=r.current.openEvent,k=b?.type,S=n.select("domReferenceElement")!==y.currentTarget,w=_&&S||!(_&&o&&(!(b&&l)||k==="click"||k==="mousedown")),E=Nr(v);if(tm(E)){const C=ht(d,v,E);w&&x==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,C)}):n.setOpen(w,C);return}const j=y.currentTarget;p.request(()=>{const C=ht(d,v,j);w&&x==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,C)}):n.setOpen(w,C)})},onClick(y){if(a==="mousedown-only")return;const x=u.current;if(a==="mousedown"&&x){u.current=void 0;return}if(Ru(x,!0)&&s)return;const v=n.select("open"),_=r.current.openEvent,b=n.select("domReferenceElement")!==y.currentTarget,k=v&&b||!(v&&o&&(!(_&&l)||gO(_))),S=ht(d,y.nativeEvent,y.currentTarget);k&&x==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,S)}):n.setOpen(k,S)},onKeyDown(){u.current=void 0}}),[r,a,s,n,l,o,p,h,c,d]);return m.useMemo(()=>i?{reference:g}:Yn,[i,g])}const _7={intentional:"onClick",sloppy:"onPointerDown"};function k7(){return!1}function S7(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function BO(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),i=n.useState("floatingElement"),{dataRef:a}=n.context,{enabled:o=!0,escapeKey:s=!0,outsidePress:l=!0,outsidePressEvent:c="sloppy",referencePress:d=k7,referencePressEvent:u="sloppy",bubbles:p,externalTree:h}=t,g=Fo(h),y=et(typeof l=="function"?l:()=>!1),x=typeof l=="function"?y:l,v=x!==!1,_=et(()=>c),b=m.useRef(!1),k=m.useRef(!1),S=m.useRef(!1),{escapeKey:w,outsidePress:E}=S7(p),j=m.useRef(null),C=Kr(),A=Kr(),R=et(()=>{A.clear(),a.current.insideReactTree=!1}),P=m.useRef(!1),D=m.useRef(""),O=et(d),M=et(Q=>{if(!r||!o||!s||Q.key!=="Escape"||P.current)return;const J=a.current.floatingContext?.nodeId,N=g?oa(g.nodesRef.current,J):[];if(!w&&N.length>0){let B=!0;if(N.forEach(ee=>{ee.context?.open&&!ee.context.dataRef.current.__escapeKeyBubbles&&(B=!1)}),!B)return}const z=N9(Q)?Q.nativeEvent:Q,L=ht(H0,z);n.setOpen(!1,L),!w&&!L.isPropagationAllowed&&Q.stopPropagation()}),I=et(()=>{a.current.insideReactTree=!0,A.start(0,R)});m.useEffect(()=>{if(!r||!o)return;a.current.__escapeKeyBubbles=w,a.current.__outsidePressBubbles=E;const Q=new da,J=new da;function N(){Q.clear(),P.current=!0}function z(){Q.start(Zh()?5:0,()=>{P.current=!1})}function L(){S.current=!0,J.start(0,()=>{S.current=!1})}function B(){b.current=!1,k.current=!1}function ee(){const q=D.current,ue=q==="pen"||!q?"mouse":q,Te=_(),G=typeof Te=="function"?Te():Te;return typeof G=="string"?G:G[ue]}function X(q){const ue=ee();return ue==="intentional"&&q.type!=="click"||ue==="sloppy"&&q.type==="click"}function Z(q){const ue=a.current.floatingContext?.nodeId,Te=g&&oa(g.nodesRef.current,ue).some(G=>bi(q,G.context?.elements.floating));return bi(q,n.select("floatingElement"))||bi(q,n.select("domReferenceElement"))||Te}function ne(q){if(X(q)){R();return}if(a.current.insideReactTree){R();return}const ue=Nr(q),Te=`[${Iu("inert")}]`,G=ut(ue)?ue.getRootNode():null,le=Array.from((Gl(G)?G:pt(n.select("floatingElement"))).querySelectorAll(Te)),Ce=n.context.triggerElements;if(ue&&(Ce.hasElement(ue)||Ce.hasMatchingElement(Re=>Qe(Re,ue))))return;let Ee=ut(ue)?ue:null;for(;Ee&&!ra(Ee);){const Re=ua(Ee);if(ra(Re)||!ut(Re))break;Ee=Re}if(le.length&&ut(ue)&&!R9(ue)&&!Qe(ue,n.select("floatingElement"))&&le.every(Re=>!Qe(Ee,Re)))return;if(Lt(ue)&&!("touches"in q)){const Re=ra(ue),nt=Or(ue),_t=/auto|scroll/,kn=Re||_t.test(nt.overflowX),Mt=Re||_t.test(nt.overflowY),xn=kn&&ue.clientWidth>0&&ue.scrollWidth>ue.clientWidth,tt=Mt&&ue.clientHeight>0&&ue.scrollHeight>ue.clientHeight,St=nt.direction==="rtl",Sn=tt&&(St?q.offsetX<=ue.offsetWidth-ue.clientWidth:q.offsetX>ue.clientWidth),En=xn&&q.offsetY>ue.clientHeight;if(Sn||En)return}if(Z(q))return;if(ee()==="intentional"&&S.current){J.clear(),S.current=!1;return}if(typeof x=="function"&&!x(q))return;const ae=a.current.floatingContext?.nodeId,ke=g?oa(g.nodesRef.current,ae):[];if(ke.length>0){let Re=!0;if(ke.forEach(nt=>{nt.context?.open&&!nt.context.dataRef.current.__outsidePressBubbles&&(Re=!1)}),!Re)return}n.setOpen(!1,ht(B0,q)),R()}function fe(q){ee()!=="sloppy"||q.pointerType==="touch"||!n.select("open")||!o||bi(q,n.select("floatingElement"))||bi(q,n.select("domReferenceElement"))||ne(q)}function V(q){if(ee()!=="sloppy"||!n.select("open")||!o||bi(q,n.select("floatingElement"))||bi(q,n.select("domReferenceElement")))return;const ue=q.touches[0];ue&&(j.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},C.start(1e3,()=>{j.current&&(j.current.dismissOnTouchEnd=!1,j.current.dismissOnMouseDown=!1)}))}function oe(q,ue){const Te=Nr(q);if(!Te)return;const G=st(Te,q.type,()=>{ue(q),G()})}function me(q){D.current="touch",oe(q,V)}function Ne(q){C.clear(),q.type==="pointerdown"&&(D.current=q.pointerType),!(q.type==="mousedown"&&j.current&&!j.current.dismissOnMouseDown)&&oe(q,ue=>{ue.type==="pointerdown"?fe(ue):ne(ue)})}function xe(q){if(!b.current)return;const ue=k.current;if(B(),ee()==="intentional"){if(q.type==="pointercancel"){ue&&L();return}if(!Z(q)){if(ue){L();return}typeof x=="function"&&!x(q)||(J.clear(),S.current=!0,R())}}}function be(q){if(ee()!=="sloppy"||!j.current||bi(q,n.select("floatingElement"))||bi(q,n.select("domReferenceElement")))return;const ue=q.touches[0];if(!ue)return;const Te=Math.abs(ue.clientX-j.current.startX),G=Math.abs(ue.clientY-j.current.startY),le=Math.sqrt(Te*Te+G*G);le>5&&(j.current.dismissOnTouchEnd=!0),le>10&&(ne(q),C.clear(),j.current=null)}function je(q){oe(q,be)}function ge(q){ee()!=="sloppy"||!j.current||bi(q,n.select("floatingElement"))||bi(q,n.select("domReferenceElement"))||(j.current.dismissOnTouchEnd&&ne(q),C.clear(),j.current=null)}function de(q){oe(q,ge)}const ce=pt(i),ve=ia(s&&ia(st(ce,"keydown",M),st(ce,"compositionstart",N),st(ce,"compositionend",z)),v&&ia(st(ce,"click",Ne,!0),st(ce,"pointerdown",Ne,!0),st(ce,"pointerup",xe,!0),st(ce,"pointercancel",xe,!0),st(ce,"mousedown",Ne,!0),st(ce,"mouseup",xe,!0),st(ce,"touchstart",me,!0),st(ce,"touchmove",je,!0),st(ce,"touchend",de,!0)));return()=>{ve(),Q.clear(),J.clear(),B(),S.current=!1}},[a,i,s,v,x,r,o,w,E,M,R,_,g,n,C]),m.useEffect(R,[x,R]);const $=m.useMemo(()=>({onKeyDown:M,[_7[u]]:Q=>{O()&&n.setOpen(!1,ht(Mu,Q.nativeEvent))},...u!=="intentional"&&{onClick(Q){O()&&n.setOpen(!1,ht(Mu,Q.nativeEvent))}}}),[M,n,u,O]),U=et(Q=>{if(!r||!o||Q.button!==0)return;const J=Nr(Q.nativeEvent);Qe(n.select("floatingElement"),J)&&(b.current||(b.current=!0,k.current=!1))}),F=et(Q=>{!r||!o||(Q.defaultPrevented||Q.nativeEvent.defaultPrevented)&&b.current&&(k.current=!0)}),T=m.useMemo(()=>({onKeyDown:M,onPointerDown:F,onMouseDown:F,onClickCapture:I,onMouseDownCapture(Q){I(),U(Q)},onPointerDownCapture(Q){I(),U(Q)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[M,I,U,F]);return m.useMemo(()=>o?{reference:$,floating:T,trigger:$}:{},[o,$,T])}function sS(e,t,n){let{reference:r,floating:i}=e;const a=li(t),o=G0(t),s=K0(o),l=Pr(t),c=a==="y",d=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,p=r[s]/2-i[s]/2;let h;switch(l){case"top":h={x:d,y:r.y-i.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-i.width,y:u};break;default:h={x:r.x,y:r.y}}switch(zo(t)){case"start":h[o]-=p*(n&&c?-1:1);break;case"end":h[o]+=p*(n&&c?-1:1);break}return h}async function E7(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:o,elements:s,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:p=!1,padding:h=0}=Ba(t,e),g=wO(h),x=s[p?u==="floating"?"reference":"floating":u],v=Tp(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:c,rootBoundary:d,strategy:l})),_=u==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),k=await(a.isElement==null?void 0:a.isElement(b))?await(a.getScale==null?void 0:a.getScale(b))||{x:1,y:1}:{x:1,y:1},S=Tp(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:_,offsetParent:b,strategy:l}):_);return{top:(v.top-S.top+g.top)/k.y,bottom:(S.bottom-v.bottom+g.bottom)/k.y,left:(v.left-S.left+g.left)/k.x,right:(S.right-v.right+g.right)/k.x}}const C7=50,j7=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:E7},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:u}=sS(c,r,l),p=r,h=0;const g={};for(let y=0;y<a.length;y++){const x=a[y];if(!x)continue;const{name:v,fn:_}=x,{x:b,y:k,data:S,reset:w}=await _({x:d,y:u,initialPlacement:r,placement:p,strategy:i,middlewareData:g,rects:c,platform:s,elements:{reference:e,floating:t}});d=b??d,u=k??u,g[v]={...g[v],...S},w&&h<C7&&(h++,typeof w=="object"&&(w.placement&&(p=w.placement),w.rects&&(c=w.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):w.rects),{x:d,y:u}=sS(c,p,l)),y=-1)}return{x:d,y:u,placement:p,strategy:i,middlewareData:g}},N7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:o,initialPlacement:s,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...x}=Ba(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=Pr(i),_=li(s),b=Pr(s)===s,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=p||(b||!y?[Pp(s)]:F9(s)),w=g!=="none";!p&&w&&S.push(...U9(s,y,g,k));const E=[s,...S],j=await l.detectOverflow(t,x),C=[];let A=((r=a.flip)==null?void 0:r.overflows)||[];if(d&&C.push(j[v]),u){const O=z9(i,o,k);C.push(j[O[0]],j[O[1]])}if(A=[...A,{placement:i,overflows:C}],!C.every(O=>O<=0)){var R,P;const O=(((R=a.flip)==null?void 0:R.index)||0)+1,M=E[O];if(M&&(!(u==="alignment"?_!==li(M):!1)||A.every(U=>li(U.placement)===_?U.overflows[0]>0:!0)))return{data:{index:O,overflows:A},reset:{placement:M}};let I=(P=A.filter($=>$.overflows[0]<=0).sort(($,U)=>$.overflows[1]-U.overflows[1])[0])==null?void 0:P.placement;if(!I)switch(h){case"bestFit":{var D;const $=(D=A.filter(U=>{if(w){const F=li(U.placement);return F===_||F==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(F=>F>0).reduce((F,T)=>F+T,0)]).sort((U,F)=>U[1]-F[1])[0])==null?void 0:D[0];$&&(I=$);break}case"initialPlacement":I=s;break}if(i!==I)return{reset:{placement:I}}}return{}}}};function lS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cS(e){return L9.some(t=>e[t]>=0)}const P7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=Ba(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...a,elementContext:"reference"}),s=lS(o,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:cS(s)}}}case"escaped":{const o=await r.detectOverflow(t,{...a,altBoundary:!0}),s=lS(o,n.floating);return{data:{escapedOffsets:s,escaped:cS(s)}}}default:return{}}}}},HO=new Set(["left","top"]);async function T7(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Pr(n),s=zo(n),l=li(n)==="y",c=HO.has(o)?-1:1,d=a&&l?-1:1,u=Ba(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&typeof g=="number"&&(h=s==="end"?g*-1:g),l?{x:h*d,y:p*c}:{x:p*c,y:h*d}}const A7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:o,middlewareData:s}=t,l=await T7(t,e);return o===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:a+l.y,data:{...l,placement:o}}}}},O7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:l={fn:v=>{let{x:_,y:b}=v;return{x:_,y:b}}},...c}=Ba(e,t),d={x:n,y:r},u=await a.detectOverflow(t,c),p=li(Pr(i)),h=q0(p);let g=d[h],y=d[p];if(o){const v=h==="y"?"top":"left",_=h==="y"?"bottom":"right",b=g+u[v],k=g-u[_];g=vx(b,g,k)}if(s){const v=p==="y"?"top":"left",_=p==="y"?"bottom":"right",b=y+u[v],k=y-u[_];y=vx(b,y,k)}const x=l.fn({...t,[h]:g,[p]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:o,[p]:s}}}}}},M7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:l=!0,crossAxis:c=!0}=Ba(e,t),d={x:n,y:r},u=li(i),p=q0(u);let h=d[p],g=d[u];const y=Ba(s,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const b=p==="y"?"height":"width",k=a.reference[p]-a.floating[b]+x.mainAxis,S=a.reference[p]+a.reference[b]-x.mainAxis;h<k?h=k:h>S&&(h=S)}if(c){var v,_;const b=p==="y"?"width":"height",k=HO.has(Pr(i)),S=a.reference[u]-a.floating[b]+(k&&((v=o.offset)==null?void 0:v[u])||0)+(k?0:x.crossAxis),w=a.reference[u]+a.reference[b]+(k?0:((_=o.offset)==null?void 0:_[u])||0)-(k?x.crossAxis:0);g<S?g=S:g>w&&(g=w)}return{[p]:h,[u]:g}}}},R7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:a,platform:o,elements:s}=t,{apply:l=()=>{},...c}=Ba(e,t),d=await o.detectOverflow(t,c),u=Pr(i),p=zo(i),h=li(i)==="y",{width:g,height:y}=a.floating;let x,v;u==="top"||u==="bottom"?(x=u,v=p===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(v=u,x=p==="end"?"top":"bottom");const _=y-d.top-d.bottom,b=g-d.left-d.right,k=Zl(y-d[x],_),S=Zl(g-d[v],b),w=!t.middlewareData.shift;let E=k,j=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=_),w&&!p){const A=Br(d.left,0),R=Br(d.right,0),P=Br(d.top,0),D=Br(d.bottom,0);h?j=g-2*(A!==0||R!==0?A+R:Br(d.left,d.right)):E=y-2*(P!==0||D!==0?P+D:Br(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const C=await o.getDimensions(s.floating);return g!==C.width||y!==C.height?{reset:{rects:!0}}:{}}}};function WO(e){const t=Or(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Lt(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Np(n)!==a||Np(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function J0(e){return ut(e)?e:e.contextElement}function Il(e){const t=J0(e);if(!Lt(t))return aa(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=WO(t);let o=(a?Np(n.width):n.width)/r,s=(a?Np(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}const I7=aa(0);function UO(e){const t=yn(e);return!Zh()||!t.visualViewport?I7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function D7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yn(e)?!1:t}function ks(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=J0(e);let o=aa(1);t&&(r?ut(r)&&(o=Il(r)):o=Il(e));const s=D7(a,n,r)?UO(a):aa(0);let l=(i.left+s.x)/o.x,c=(i.top+s.y)/o.y,d=i.width/o.x,u=i.height/o.y;if(a){const p=yn(a),h=r&&ut(r)?yn(r):r;let g=p,y=px(g);for(;y&&r&&h!==g;){const x=Il(y),v=y.getBoundingClientRect(),_=Or(y),b=v.left+(y.clientLeft+parseFloat(_.paddingLeft))*x.x,k=v.top+(y.clientTop+parseFloat(_.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,u*=x.y,l+=b,c+=k,g=yn(y),y=px(g)}}return Tp({width:d,height:u,x:l,y:c})}function rm(e,t){const n=Qh(e).scrollLeft;return t?t.left+n:ks(wa(e)).left+n}function VO(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-rm(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function L7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",o=wa(r),s=t?Xh(t.floating):!1;if(r===o||s&&a)return n;let l={scrollLeft:0,scrollTop:0},c=aa(1);const d=aa(0),u=Lt(r);if((u||!u&&!a)&&((or(r)!=="body"||$o(o))&&(l=Qh(r)),u)){const h=ks(r);c=Il(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=o&&!u&&!a?VO(o,l):aa(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function $7(e){return Array.from(e.getClientRects())}function z7(e){const t=wa(e),n=Qh(e),r=e.ownerDocument.body,i=Br(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Br(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+rm(e);const s=-n.scrollTop;return Or(r).direction==="rtl"&&(o+=Br(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}const uS=25;function F7(e,t){const n=yn(e),r=wa(e),i=n.visualViewport;let a=r.clientWidth,o=r.clientHeight,s=0,l=0;if(i){a=i.width,o=i.height;const d=Zh();(!d||d&&t==="fixed")&&(s=i.offsetLeft,l=i.offsetTop)}const c=rm(r);if(c<=0){const d=r.ownerDocument,u=d.body,p=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-u.clientWidth-h);g<=uS&&(a-=g)}else c<=uS&&(a+=c);return{width:a,height:o,x:s,y:l}}function B7(e,t){const n=ks(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Lt(e)?Il(e):aa(1),o=e.clientWidth*a.x,s=e.clientHeight*a.y,l=i*a.x,c=r*a.y;return{width:o,height:s,x:l,y:c}}function dS(e,t,n){let r;if(t==="viewport")r=F7(e,n);else if(t==="document")r=z7(wa(e));else if(ut(t))r=B7(t,n);else{const i=UO(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Tp(r)}function qO(e,t){const n=ua(e);return n===t||!ut(n)||ra(n)?!1:Or(n).position==="fixed"||qO(n,t)}function H7(e,t){const n=t.get(e);if(n)return n;let r=Ou(e,[],!1).filter(s=>ut(s)&&or(s)!=="body"),i=null;const a=Or(e).position==="fixed";let o=a?ua(e):e;for(;ut(o)&&!ra(o);){const s=Or(o),l=z0(o);!l&&s.position==="fixed"&&(i=null),(a?!l&&!i:!l&&s.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||$o(o)&&!l&&qO(e,o))?r=r.filter(d=>d!==o):i=s,o=ua(o)}return t.set(e,r),r}function W7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Xh(t)?[]:H7(t,this._c):[].concat(n),r],s=dS(t,o[0],i);let l=s.top,c=s.right,d=s.bottom,u=s.left;for(let p=1;p<o.length;p++){const h=dS(t,o[p],i);l=Br(h.top,l),c=Zl(h.right,c),d=Zl(h.bottom,d),u=Br(h.left,u)}return{width:c-u,height:d-l,x:u,y:l}}function U7(e){const{width:t,height:n}=WO(e);return{width:t,height:n}}function V7(e,t,n){const r=Lt(t),i=wa(t),a=n==="fixed",o=ks(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const l=aa(0);function c(){l.x=rm(i)}if(r||!r&&!a)if((or(t)!=="body"||$o(i))&&(s=Qh(t)),r){const h=ks(t,!0,a,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else i&&c();a&&!r&&i&&c();const d=i&&!r&&!a?VO(i,s):aa(0),u=o.left+s.scrollLeft-l.x-d.x,p=o.top+s.scrollTop-l.y-d.y;return{x:u,y:p,width:o.width,height:o.height}}function Dg(e){return Or(e).position==="static"}function fS(e,t){if(!Lt(e)||Or(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wa(e)===n&&(n=n.ownerDocument.body),n}function KO(e,t){const n=yn(e);if(Xh(e))return n;if(!Lt(e)){let i=ua(e);for(;i&&!ra(i);){if(ut(i)&&!Dg(i))return i;i=ua(i)}return n}let r=fS(e,t);for(;r&&l9(r)&&Dg(r);)r=fS(r,t);return r&&ra(r)&&Dg(r)&&!z0(r)?n:r||d9(e)||n}const q7=async function(e){const t=this.getOffsetParent||KO,n=this.getDimensions,r=await n(e.floating);return{reference:V7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function K7(e){return Or(e).direction==="rtl"}const G7={convertOffsetParentRelativeRectToViewportRelativeRect:L7,getDocumentElement:wa,getClippingRect:W7,getOffsetParent:KO,getElementRects:q7,getClientRects:$7,getDimensions:U7,getScale:Il,isElement:ut,isRTL:K7};function GO(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Y7(e,t){let n=null,r;const i=wa(e);function a(){var s;clearTimeout(r),(s=n)==null||s.disconnect(),n=null}function o(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),a();const c=e.getBoundingClientRect(),{left:d,top:u,width:p,height:h}=c;if(s||t(),!p||!h)return;const g=us(u),y=us(i.clientWidth-(d+p)),x=us(i.clientHeight-(u+h)),v=us(d),b={rootMargin:-g+"px "+-y+"px "+-x+"px "+-v+"px",threshold:Br(0,Zl(1,l))||1};let k=!0;function S(w){const E=w[0].intersectionRatio;if(E!==l){if(!k)return o();E?o(!1,E):r=setTimeout(()=>{o(!1,1e-7)},1e3)}E===1&&!GO(c,e.getBoundingClientRect())&&o(),k=!1}try{n=new IntersectionObserver(S,{...b,root:i.ownerDocument})}catch{n=new IntersectionObserver(S,b)}n.observe(e)}return o(!0),a}function pS(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=J0(e),d=i||a?[...c?Ou(c):[],...t?Ou(t):[]]:[];d.forEach(v=>{i&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const u=c&&s?Y7(c,n):null;let p=-1,h=null;o&&(h=new ResizeObserver(v=>{let[_]=v;_&&_.target===c&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var b;(b=h)==null||b.observe(t)})),n()}),c&&!l&&h.observe(c),t&&h.observe(t));let g,y=l?ks(e):null;l&&x();function x(){const v=ks(e);y&&!GO(y,v)&&n(),y=v,g=requestAnimationFrame(x)}return n(),()=>{var v;d.forEach(_=>{i&&_.removeEventListener("scroll",n),a&&_.removeEventListener("resize",n)}),u?.(),(v=h)==null||v.disconnect(),h=null,l&&cancelAnimationFrame(g)}}const X7=A7,Z7=O7,Q7=N7,J7=R7,eV=P7,tV=M7,nV=(e,t,n)=>{const r=new Map,i={platform:G7,...n},a={...i.platform,_c:r};return j7(e,t,{...i,platform:a})};var rV=typeof document<"u",iV=function(){},rp=rV?m.useLayoutEffect:iV;function Op(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(!Op(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;){const a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!Op(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function YO(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function hS(e,t){const n=YO(e);return Math.round(t*n)/n}function Lg(e){const t=m.useRef(e);return rp(()=>{t.current=e}),t}function aV(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:l,open:c}=e,[d,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);Op(p,r)||h(r);const[g,y]=m.useState(null),[x,v]=m.useState(null),_=m.useCallback(U=>{U!==w.current&&(w.current=U,y(U))},[]),b=m.useCallback(U=>{U!==E.current&&(E.current=U,v(U))},[]),k=a||g,S=o||x,w=m.useRef(null),E=m.useRef(null),j=m.useRef(d),C=l!=null,A=Lg(l),R=Lg(i),P=Lg(c),D=m.useCallback(()=>{if(!w.current||!E.current)return;const U={placement:t,strategy:n,middleware:p};R.current&&(U.platform=R.current),nV(w.current,E.current,U).then(F=>{const T={...F,isPositioned:P.current!==!1};O.current&&!Op(j.current,T)&&(j.current=T,qr.flushSync(()=>{u(T)}))})},[p,t,n,R,P]);rp(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,u(U=>({...U,isPositioned:!1})))},[c]);const O=m.useRef(!1);rp(()=>(O.current=!0,()=>{O.current=!1}),[]),rp(()=>{if(k&&(w.current=k),S&&(E.current=S),k&&S){if(A.current)return A.current(k,S,D);D()}},[k,S,D,A,C]);const M=m.useMemo(()=>({reference:w,floating:E,setReference:_,setFloating:b}),[_,b]),I=m.useMemo(()=>({reference:k,floating:S}),[k,S]),$=m.useMemo(()=>{const U={position:n,left:0,top:0};if(!I.floating)return U;const F=hS(I.floating,d.x),T=hS(I.floating,d.y);return s?{...U,transform:"translate("+F+"px, "+T+"px)",...YO(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:T}},[n,s,I.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:D,refs:M,elements:I,floatingStyles:$}),[d,D,M,I,$])}const oV=(e,t)=>{const n=X7(e);return{name:n.name,fn:n.fn,options:[e,t]}},sV=(e,t)=>{const n=Z7(e);return{name:n.name,fn:n.fn,options:[e,t]}},lV=(e,t)=>({fn:tV(e).fn,options:[e,t]}),cV=(e,t)=>{const n=Q7(e);return{name:n.name,fn:n.fn,options:[e,t]}},uV=(e,t)=>{const n=J7(e);return{name:n.name,fn:n.fn,options:[e,t]}},dV=(e,t)=>{const n=eV(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xe=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw new Error(ba(1));let s;if(e)s=e;else throw new Error("Missing arguments");return s};function fV(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function pV(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function hV(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var mS=e=>Array.isArray(e)?e:[e];function mV(e){const t=Array.isArray(e[0])?e[0]:e;return hV(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function gV(e,t){const n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}var yV=class{constructor(e){this.value=e}deref(){return this.value}},vV=typeof WeakRef<"u"?WeakRef:yV,xV=0,gS=1;function Jd(){return{s:xV,v:void 0,o:null,p:null}}function XO(e,t={}){let n=Jd();const{resultEqualityCheck:r}=t;let i,a=0;function o(){let s=n;const{length:l}=arguments;for(let u=0,p=l;u<p;u++){const h=arguments[u];if(typeof h=="function"||typeof h=="object"&&h!==null){let g=s.o;g===null&&(s.o=g=new WeakMap);const y=g.get(h);y===void 0?(s=Jd(),g.set(h,s)):s=y}else{let g=s.p;g===null&&(s.p=g=new Map);const y=g.get(h);y===void 0?(s=Jd(),g.set(h,s)):s=y}}const c=s;let d;if(s.s===gS)d=s.v;else if(d=e.apply(null,arguments),a++,r){const u=i?.deref?.()??i;u!=null&&r(u,d)&&(d=u,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new vV(d):d}return c.s=gS,c.v=d,d}return o.clearCache=()=>{n=Jd(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function bV(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let a=0,o=0,s,l={},c=i.pop();typeof c=="object"&&(l=c,c=i.pop()),fV(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const d={...n,...l},{memoize:u,memoizeOptions:p=[],argsMemoize:h=XO,argsMemoizeOptions:g=[]}=d,y=mS(p),x=mS(g),v=mV(i),_=u(function(){return a++,c.apply(null,arguments)},...y),b=h(function(){o++;const S=gV(v,arguments);return s=_.apply(null,S),s},...x);return Object.assign(b,{resultFunc:c,memoizedResultFunc:_,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>s,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:u,argsMemoize:h})};return Object.assign(r,{withTypes:()=>r}),r}var re=bV(XO),wV=Object.assign((e,t=re)=>{pV(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(a=>e[a]);return t(r,(...a)=>a.reduce((o,s,l)=>(o[n[l]]=s,o),{}))},{withTypes:()=>wV}),$g={exports:{}},zg={};var yS;function _V(){if(yS)return zg;yS=1;var e=Ib(),t=F2();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,a=e.useRef,o=e.useEffect,s=e.useMemo,l=e.useDebugValue;return zg.useSyncExternalStoreWithSelector=function(c,d,u,p,h){var g=a(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=s(function(){function v(w){if(!_){if(_=!0,b=w,w=p(w),h!==void 0&&y.hasValue){var E=y.value;if(h(E,w))return k=E}return k=w}if(E=k,r(b,w))return E;var j=p(w);return h!==void 0&&h(E,j)?(b=w,E):(b=w,k=j)}var _=!1,b,k,S=u===void 0?null:u;return[function(){return v(d())},S===null?void 0:function(){return v(S())}]},[d,u,p,h]);var x=i(c,g[0],g[1]);return o(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},zg}var vS;function kV(){return vS||(vS=1,$g.exports=_V()),$g.exports}var ZO=kV();const _x=[];let kx;function SV(){return kx}function EV(e){_x.push(e)}function QO(e){const t=(n,r)=>{const i=hr(jV).current;let a;try{kx=i;for(const o of _x)o.before(i);a=e(n,r);for(const o of _x)o.after(i);i.didInitialize=!0}finally{kx=void 0}return a};return t.displayName=e.displayName||e.name,t}function CV(e){return m.forwardRef(QO(e))}function jV(){return{didInitialize:!1}}const NV=R0(19),PV=NV?AV:OV;function JO(e,t,n,r,i){return PV(e,t,n,r,i)}function TV(e,t,n,r,i){const a=m.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return o0.useSyncExternalStore(e.subscribe,a,a)}EV({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const i of e.syncHooks)n.add(i.store);const r=[];for(const i of n)r.push(i.subscribe(t));return()=>{for(const i of r)i()}}),o0.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function AV(e,t,n,r,i){const a=SV();if(!a)return TV(e,t,n,r,i);const o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function OV(e,t,n,r,i){return ZO.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,n,r,i))}class MV{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,r,i){return JO(this,t,n,r,i)}}class ew extends MV{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}useSyncedValue(t,n){m.useDebugValue(t),Ye(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ye(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);Ye(()=>{n.update(t)},[n,...r])}useControlledProp(t,n){m.useDebugValue(t);const r=n!==void 0;Ye(()=>{r&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,r])}select(t,n,r,i){const a=this.selectors[t];return a(this.state,n,r,i)}useState(t,n,r,i){return m.useDebugValue(t),JO(this,this.selectors[t],n,r,i)}useContextCallback(t,n){m.useDebugValue(t);const r=et(n??I0);this.context[t]=r}useStateSetter(t){const n=m.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let i=r(this.state);return n(i,i,this),this.subscribe(a=>{const o=r(a);if(!Object.is(i,o)){const s=i;i=o,n(o,s,this)}})}}const RV={open:Xe(e=>e.open),transitionStatus:Xe(e=>e.transitionStatus),domReferenceElement:Xe(e=>e.domReferenceElement),referenceElement:Xe(e=>e.positionReference??e.referenceElement),floatingElement:Xe(e=>e.floatingElement),floatingId:Xe(e=>e.floatingId)};class tw extends ew{constructor(t){const{syncOnly:n,nested:r,onOpenChange:i,triggerElements:a,...o}=t;super({...o,positionReference:o.referenceElement,domReferenceElement:o.referenceElement},{onOpenChange:i,dataRef:{current:{}},events:DO(),nested:r,triggerElements:a},RV),this.syncOnly=n}syncOpenEvent=(t,n)=>{(!t||!this.state.open||n!=null&&gO(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)};dispatchOpenChange=(t,n)=>{this.syncOpenEvent(t,n.event);const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)};setOpen=(t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)}}function IV(e,t=!1,n=!1){const[r,i]=m.useState(e&&t?"idle":void 0),[a,o]=m.useState(e);return e&&!a&&(o(!0),i("starting")),!e&&a&&r!=="ending"&&!n&&i("ending"),!e&&!a&&r==="ending"&&i(void 0),Ye(()=>{if(!e&&a&&r!=="ending"&&n){const s=Gi.request(()=>{i("ending")});return()=>{Gi.cancel(s)}}},[e,a,r,n]),Ye(()=>{if(!e||t)return;const s=Gi.request(()=>{i(void 0)});return()=>{Gi.cancel(s)}},[t,e]),Ye(()=>{if(!e||!t)return;e&&a&&r!=="idle"&&i("starting");const s=Gi.request(()=>{i("idle")});return()=>{Gi.cancel(s)}},[t,e,a,r]),{mounted:a,setMounted:o,transitionStatus:r}}function eM(e,t=!1,n=!0){const r=U0();return et((i,a=null)=>{r.cancel();const o=Sa(e);if(o==null)return;const s=o,l=()=>{qr.flushSync(i)};if(typeof s.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function c(){Promise.all(s.getAnimations().map(d=>d.finished)).then(()=>{a?.aborted||l()}).catch(()=>{if(n){a?.aborted||l();return}const d=s.getAnimations();!a?.aborted&&d.length>0&&d.some(u=>u.pending||u.playState!=="finished")&&c()})}if(t){const d=Au.startingStyle;if(!s.hasAttribute(d)){r.request(c);return}const u=new MutationObserver(()=>{s.hasAttribute(d)||(u.disconnect(),c())});u.observe(s,{attributes:!0,attributeFilter:[d]}),a?.addEventListener("abort",()=>u.disconnect(),{once:!0});return}r.request(c)})}function nw(e){const{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=et(i),o=eM(r,n,!1);m.useEffect(()=>{if(!t)return;const s=new AbortController;return o(a,s.signal),()=>{s.abort()}},[t,n,a,o])}function DV(e,t){const n=m.useRef(null),r=m.useRef(null);return m.useCallback(i=>{if(e!==void 0){if(n.current!==null){const a=n.current,o=r.current,s=t.context.triggerElements.getById(a);o&&s===o&&t.context.triggerElements.delete(a),n.current=null,r.current=null}i!==null&&(n.current=e,r.current=i,t.context.triggerElements.add(e,i))}},[t,e])}function LV(e,t,n,r){const i=n.useState("isMountedByTrigger",e),a=DV(e,n),o=et(s=>{if(a(s),!s||!n.select("open"))return;const l=n.select("activeTriggerId");if(l===e){n.update({activeTriggerElement:s,...r});return}l==null&&n.update({activeTriggerId:e,activeTriggerElement:s,...r})});return Ye(()=>{i&&n.update({activeTriggerElement:t.current,...r})},[i,n,t,...Object.values(r)]),{registerTrigger:o,isMountedByThisTrigger:i}}function tM(e){const t=e.useState("open");Ye(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,i]=n.value;e.update({activeTriggerId:r,activeTriggerElement:i})}}},[t,e])}function nM(e,t,n){const{mounted:r,setMounted:i,transitionStatus:a}=IV(e);t.useSyncedValues({mounted:r,transitionStatus:a});const o=et(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),s=t.useState("preventUnmountingOnClose");return nw({enabled:!s,open:e,ref:t.context.popupRef,onComplete(){e||o()}}),{forceUnmount:o,transitionStatus:a}}class im{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elementsSet.delete(r),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function $V(){return new tw({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new im,floatingId:"",syncOnly:!1,nested:!1,onOpenChange:void 0})}function rM(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:$V(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Yn,inactiveTriggerProps:Yn,popupProps:Yn}}const ef=Xe(e=>e.triggerIdProp??e.activeTriggerId),iM={open:Xe(e=>e.openProp??e.open),mounted:Xe(e=>e.mounted),transitionStatus:Xe(e=>e.transitionStatus),floatingRootContext:Xe(e=>e.floatingRootContext),preventUnmountingOnClose:Xe(e=>e.preventUnmountingOnClose),payload:Xe(e=>e.payload),activeTriggerId:ef,activeTriggerElement:Xe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Xe((e,t)=>t!==void 0&&ef(e)===t),isOpenedByTrigger:Xe((e,t)=>t!==void 0&&ef(e)===t&&e.open),isMountedByTrigger:Xe((e,t)=>t!==void 0&&ef(e)===t&&e.mounted),triggerProps:Xe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Xe(e=>e.popupProps),popupElement:Xe(e=>e.popupElement),positionerElement:Xe(e=>e.positionerElement)};function zV(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Ds(),a=qa()!=null,o=hr(()=>new tw({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new im,floatingId:i,syncOnly:!1,nested:a})).current;return Ye(()=>{const s={open:t,floatingId:i};r.reference!==void 0&&(s.referenceElement=r.reference,s.domReferenceElement=ut(r.reference)?r.reference:null),r.floating!==void 0&&(s.floatingElement=r.floating),o.update(s)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function FV(e={}){const{nodeId:t,externalTree:n}=e,r=zV(e),i=e.rootContext||r,a={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[o,s]=m.useState(null),l=m.useRef(null),c=Fo(n);Ye(()=>{a.domReference&&(l.current=a.domReference)},[a.domReference]);const d=aV({...e,elements:{...a,...o&&{reference:o}}}),u=m.useCallback(j=>{const C=ut(j)?{getBoundingClientRect:()=>j.getBoundingClientRect(),getClientRects:()=>j.getClientRects(),contextElement:j}:j;s(C),d.refs.setReference(C)},[d.refs]),[p,h]=m.useState(void 0),[g,y]=m.useState(null);i.useSyncedValue("referenceElement",p??null);const x=ut(p)?p:null;i.useSyncedValue("domReferenceElement",p===void 0?a.domReference:x),i.useSyncedValue("floatingElement",g);const v=m.useCallback(j=>{(ut(j)||j===null)&&(l.current=j,h(j)),(ut(d.refs.reference.current)||d.refs.reference.current===null||j!==null&&!ut(j))&&d.refs.setReference(j)},[d.refs,h]),_=m.useCallback(j=>{y(j),d.refs.setFloating(j)},[d.refs]),b=m.useMemo(()=>({...d.refs,setReference:v,setFloating:_,setPositionReference:u,domReference:l}),[d.refs,v,_,u]),k=m.useMemo(()=>({...d.elements,domReference:a.domReference}),[d.elements,a.domReference]),S=i.useState("open"),w=i.useState("floatingId"),E=m.useMemo(()=>({...d,dataRef:i.context.dataRef,open:S,onOpenChange:i.setOpen,events:i.context.events,floatingId:w,refs:b,elements:k,nodeId:t,rootStore:i}),[d,b,k,t,i,S,w]);return Ye(()=>{i.context.dataRef.current.floatingContext=E;const j=c?.nodesRef.current.find(C=>C.id===t);j&&(j.context=E)}),m.useMemo(()=>({...d,context:E,refs:b,elements:k,rootStore:i}),[d,b,k,E,i])}function aM(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,onOpenChange:r}=e,i=Ds(),a=qa()!=null,o=t.useState("open"),s=t.useState("activeTriggerElement"),l=t.useState(n?"popupElement":"positionerElement"),c=t.context.triggerElements,d=hr(()=>new tw({open:o,transitionStatus:void 0,referenceElement:s,floatingElement:l,triggerElements:c,onOpenChange:r,floatingId:i,syncOnly:!0,nested:a})).current;return Ye(()=>{const u={open:o,floatingId:i,referenceElement:s,floatingElement:l};ut(s)&&(u.domReferenceElement=s),d.state.positionReference===d.state.referenceElement&&(u.positionReference=s),d.update(u)},[o,i,s,l,d]),d.context.onOpenChange=r,d.context.nested=a,d}const Fg=fO&&dO;function BV(e,t={}){const n="rootStore"in e?e.rootStore:e,{events:r,dataRef:i}=n.context,{enabled:a=!0,delay:o}=t,s=m.useRef(!1),l=m.useRef(null),c=Kr(),d=m.useRef(!0);m.useEffect(()=>{const p=n.select("domReferenceElement");if(!a)return;const h=yn(p);function g(){const v=n.select("domReferenceElement");!n.select("open")&&Lt(v)&&v===oi(pt(v))&&(s.current=!0)}function y(){d.current=!0}function x(){d.current=!1}return ia(st(h,"blur",g),Fg&&st(h,"keydown",y,!0),Fg&&st(h,"pointerdown",x,!0))},[n,a]),m.useEffect(()=>{if(!a)return;function p(h){if(h.reason===Mu||h.reason===H0){const g=n.select("domReferenceElement");ut(g)&&(l.current=g,s.current=!0)}}return r.on("openchange",p),()=>{r.off("openchange",p)}},[r,a,n]);const u=m.useMemo(()=>({onMouseLeave(){s.current=!1,l.current=null},onFocus(p){const h=p.currentTarget;if(s.current){if(l.current===h)return;s.current=!1,l.current=null}const g=Nr(p.nativeEvent);if(ut(g)){if(Fg&&!p.relatedTarget){if(!d.current&&!tm(g))return}else if(!D9(g))return}const y=Cp(p.relatedTarget,n.context.triggerElements),{nativeEvent:x,currentTarget:v}=p,_=typeof o=="function"?o():o;if(n.select("open")&&y||_===0||_===void 0){n.setOpen(!0,ht(du,x,v));return}c.start(_,()=>{s.current||n.setOpen(!0,ht(du,x,v))})},onBlur(p){s.current=!1,l.current=null;const h=p.relatedTarget,g=p.nativeEvent,y=ut(h)&&h.hasAttribute(Iu("focus-guard"))&&h.getAttribute("data-type")==="outside";c.start(0,()=>{const x=n.select("domReferenceElement"),v=oi(pt(x));!h&&v===x||Qe(i.current.floatingContext?.refs.floating.current,v)||Qe(x,v)||y||Cp(h??v,n.context.triggerElements)||n.setOpen(!1,ht(du,g))})}}),[i,n,c,o]);return m.useMemo(()=>a?{reference:u,trigger:u}:{},[a,u])}class rw{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new da,this.restTimeout=new da,this.handleCloseOptions=void 0}static create(){return new rw}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const Mp=new WeakMap;function Rp(e){if(!e.performedPointerEventsMutation)return;const t=e.pointerEventsScopeElement;t&&Mp.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),Mp.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function oM(e,t){const{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Mp.get(n);a&&a!==e&&Rp(a),Rp(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Mp.set(n,e),n.style.pointerEvents="none",r.style.pointerEvents="auto",i.style.pointerEvents="auto"}function sM(e){const t=hr(rw.create).current,n=e.context.dataRef.current;return n.hoverInteractionState||(n.hoverInteractionState=t),W0(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function HV(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),i=n.useState("floatingElement"),a=n.useState("domReferenceElement"),{dataRef:o}=n.context,{enabled:s=!0,closeDelay:l=0,nodeId:c}=t,d=sM(n),u=Fo(),p=qa(),h=et(()=>yO(o.current.openEvent?.type,d.interactedInside)),g=et(()=>{const k=o.current.openEvent?.type;return k?.includes("mouse")&&k!=="mousedown"}),y=et(k=>Cp(k,n.context.triggerElements)),x=m.useCallback(k=>{const S=mx(l,"close",d.pointerType),w=()=>{n.setOpen(!1,ht(kr,k)),u?.events.emit("floating.closed",k)};S?d.openChangeTimeout.start(S,w):(d.openChangeTimeout.clear(),w())},[l,n,d,u]),v=et(()=>{Rp(d)}),_=et(k=>{const S=Nr(k);if(!I9(S)){d.interactedInside=!1;return}d.interactedInside=S?.closest("[aria-haspopup]")!=null});Ye(()=>{r||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,v())},[r,d,v]),m.useEffect(()=>v,[v]),Ye(()=>{if(s&&r&&d.handleCloseOptions?.blockPointerEvents&&g()&&ut(a)&&i){const k=a,S=i,w=pt(i),E=u?.nodesRef.current.find(C=>C.id===p)?.context?.elements.floating;E&&(E.style.pointerEvents="");const j=d.handleCloseOptions?.getScope?.()??d.pointerEventsScopeElement??E??k.closest("[data-rootownerid]")??w.body;return oM(d,{scopeElement:j,referenceElement:k,floatingElement:S}),()=>{v()}}},[s,r,a,i,d,g,u,p,v]);const b=Kr();m.useEffect(()=>{if(!s)return;function k(){d.openChangeTimeout.clear(),b.clear(),u?.events.off("floating.closed",w),v()}function S(j){if(u&&p&&oa(u.nodesRef.current,p).length>0){u.events.on("floating.closed",w);return}if(y(j.relatedTarget))return;const C=o.current.floatingContext?.nodeId??c,A=j.relatedTarget;if(!(u&&C&&ut(A)&&oa(u.nodesRef.current,C,!1).some(P=>Qe(P.context?.elements.floating,A)))){if(d.handler){d.handler(j);return}v(),h()||x(j)}}function w(j){!u||!p||oa(u.nodesRef.current,p).length>0||b.start(0,()=>{u.events.off("floating.closed",w),n.setOpen(!1,ht(kr,j)),u.events.emit("floating.closed",j)})}const E=i;return ia(E&&st(E,"mouseenter",k),E&&st(E,"mouseleave",S),E&&st(E,"pointerdown",_,!0),()=>{u?.events.off("floating.closed",w)})},[s,i,n,o,c,h,y,x,v,_,d,u,p,b])}const WV={current:null};function UV(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:i}=n.context,{enabled:a=!0,delay:o=0,handleClose:s=null,mouseOnly:l=!1,restMs:c=0,move:d=!0,triggerElementRef:u=WV,externalTree:p,isActiveTrigger:h=!0,getHandleCloseContext:g,isClosing:y}=t,x=Fo(p),v=sM(n),_=m.useRef(!1),b=Gn(s),k=Gn(o),S=Gn(c),w=Gn(a),E=Gn(y);h&&(v.handleCloseOptions=b.current?.__options);const j=et(()=>yO(r.current.openEvent?.type,v.interactedInside)),C=et(O=>Cp(O,n.context.triggerElements)),A=et((O,M,I)=>{const $=n.context.triggerElements;if($.hasElement(M))return!O||!Qe(O,M);if(!ut(I))return!1;const U=I;return $.hasMatchingElement(F=>Qe(F,U))&&(!O||!Qe(O,U))}),R=et((O,M=!0)=>{const I=mx(k.current,"close",v.pointerType);I?v.openChangeTimeout.start(I,()=>{n.setOpen(!1,ht(kr,O)),x?.events.emit("floating.closed",O)}):M&&(v.openChangeTimeout.clear(),n.setOpen(!1,ht(kr,O)),x?.events.emit("floating.closed",O))}),P=et(()=>{if(!v.handler)return;pt(n.select("domReferenceElement")).removeEventListener("mousemove",v.handler),v.handler=void 0}),D=et(()=>{Rp(v)});return m.useEffect(()=>P,[P]),m.useEffect(()=>{if(!a)return;function O(M){M.open?_.current=!1:(_.current=M.reason===kr,P(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return i.on("openchange",O),()=>{i.off("openchange",O)}},[a,i,v,P]),m.useEffect(()=>{if(!a)return;const O=u.current??(h?n.select("domReferenceElement"):null);if(!ut(O))return;function M($){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,l&&!Ru(v.pointerType))return;const U=Yk(S.current),F=mx(k.current,"open",v.pointerType),T=Nr($),Q=$.currentTarget??null,J=n.select("domReferenceElement");let N=Q;if(ut(T)&&!n.context.triggerElements.hasElement(T)){for(const V of n.context.triggerElements.elements())if(Qe(V,T)){N=V;break}}ut(Q)&&ut(J)&&!n.context.triggerElements.hasElement(Q)&&Qe(Q,J)&&(N=J);const z=N==null?!1:A(J,N,T),L=n.select("open"),B=E.current?.()??n.select("transitionStatus")==="ending",ee=!L&&B&&_.current,X=!z&&ut(N)&&ut(J)&&Qe(J,N)&&ee,Z=U>0&&!F,ne=z&&(L||ee)||X,fe=!L||z;if(ne){n.setOpen(!0,ht(kr,$,N));return}Z||(F?v.openChangeTimeout.start(F,()=>{fe&&n.setOpen(!0,ht(kr,$,N))}):fe&&n.setOpen(!0,ht(kr,$,N)))}function I($){if(j()){D();return}P();const U=n.select("domReferenceElement"),F=pt(U);v.restTimeout.clear(),v.restTimeoutPending=!1;const T=r.current.floatingContext??g?.();if(C($.relatedTarget))return;if(b.current&&T){n.select("open")||v.openChangeTimeout.clear();const N=u.current;v.handler=b.current({...T,tree:x,x:$.clientX,y:$.clientY,onClose(){D(),P(),w.current&&!j()&&N===n.select("domReferenceElement")&&R($,!0)}}),F.addEventListener("mousemove",v.handler),v.handler($);return}(v.pointerType!=="touch"||!Qe(n.select("floatingElement"),$.relatedTarget))&&R($)}return d?ia(st(O,"mousemove",M,{once:!0}),st(O,"mouseenter",M),st(O,"mouseleave",I)):ia(st(O,"mouseenter",M),st(O,"mouseleave",I))},[P,D,r,k,R,n,a,b,v,h,A,j,C,l,d,S,u,x,w,g,E]),m.useMemo(()=>{if(!a)return;function O(M){v.pointerType=M.pointerType}return{onPointerDown:O,onPointerEnter:O,onMouseMove(M){const{nativeEvent:I}=M,$=M.currentTarget,U=n.select("domReferenceElement"),F=n.select("open"),T=A(U,$,M.target);if(l&&!Ru(v.pointerType))return;if(F&&T&&v.handleCloseOptions?.blockPointerEvents){const N=n.select("floatingElement");if(N){const z=v.handleCloseOptions?.getScope?.()??$.ownerDocument.body;oM(v,{scopeElement:z,referenceElement:$,floatingElement:N})}}const Q=Yk(S.current);if(F&&!T||Q===0||!T&&v.restTimeoutPending&&M.movementX**2+M.movementY**2<2)return;v.restTimeout.clear();function J(){if(v.restTimeoutPending=!1,j())return;const N=n.select("open");!v.blockMouseMove&&(!N||T)&&n.setOpen(!0,ht(kr,I,$))}v.pointerType==="touch"?qr.flushSync(()=>{J()}):T&&F?J():(v.restTimeoutPending=!0,v.restTimeout.start(Q,J))}}},[a,v,j,A,l,n,S])}function iw(e=[]){const t=e.map(c=>c?.reference),n=e.map(c=>c?.floating),r=e.map(c=>c?.item),i=e.map(c=>c?.trigger),a=m.useCallback(c=>tf(c,e,"reference"),t),o=m.useCallback(c=>tf(c,e,"floating"),n),s=m.useCallback(c=>tf(c,e,"item"),r),l=m.useCallback(c=>tf(c,e,"trigger"),i);return m.useMemo(()=>({getReferenceProps:a,getFloatingProps:o,getItemProps:s,getTriggerProps:l}),[a,o,s,l])}function tf(e,t,n){const r=new Map,i=n==="item",a={};n==="floating"&&(a.tabIndex=-1,a[gx]="");for(const o in e)i&&e&&(o===vO||o===xO)||(a[o]=e[o]);for(let o=0;o<t.length;o+=1){let s;const l=t[o]?.[n];typeof l=="function"?s=e?l(e):null:s=l,s&&xS(a,s,i,r)}return xS(a,e,i,r),a}function xS(e,t,n,r){for(const i in t){const a=t[i];n&&(i===vO||i===xO)||(i.startsWith("on")?(r.has(i)||r.set(i,[]),typeof a=="function"&&(r.get(i)?.push(a),e[i]=(...o)=>r.get(i)?.map(s=>s(...o)).find(s=>s!==void 0))):e[i]=a)}}const VV="Escape";function am(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function nf(e,t){return am(t,e===V0||e===ud,e===Co||e===jo)}function Bg(e,t,n){return am(t,e===ud,n?e===Co:e===jo)||e==="Enter"||e===" "||e===""}function qV(e,t,n){return am(t,n?e===Co:e===jo,e===ud)}function KV(e,t,n,r){const i=n?e===jo:e===Co,a=e===V0;return t==="both"||t==="horizontal"&&r&&r>1?e===VV:am(t,i,a)}function GV(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),i=n.useState("floatingElement"),a=n.useState("domReferenceElement"),o=n.context.dataRef,{listRef:s,activeIndex:l,onNavigate:c=()=>{},enabled:d=!0,selectedIndex:u=null,allowEscape:p=!1,loopFocus:h=!1,nested:g=!1,rtl:y=!1,virtual:x=!1,focusItemOnOpen:v="auto",focusItemOnHover:_=!0,openOnArrowKeyDown:b=!0,disabledIndices:k=void 0,orientation:S="vertical",parentOrientation:w,cols:E=1,id:j,resetOnPointerLeave:C=!0,externalTree:A}=t,R=jp(i),P=Gn(R),D=qa(),O=Fo(A);Ye(()=>{o.current.orientation=S},[o,S]);const M=yx(a),I=m.useRef(v),$=m.useRef(u??-1),U=m.useRef(null),F=m.useRef(!0),T=et(ce=>{c($.current===-1?null:$.current,ce)}),Q=m.useRef(T),J=m.useRef(!!i),N=m.useRef(r),z=m.useRef(!1),L=m.useRef(!1),B=m.useRef(null),ee=Gn(k),X=Gn(r),Z=Gn(u),ne=Gn(C),fe=et(()=>{function ce(Te){x?O?.events.emit("virtualfocus",Te):B.current=np(Te,{sync:z.current,preventScroll:!0})}const ve=s.current[$.current],q=L.current;ve&&ce(ve),(z.current?Te=>Te():requestAnimationFrame)(()=>{const Te=s.current[$.current]||ve;if(!Te)return;ve||ce(Te),me&&(q||!F.current)&&Te.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Ye(()=>{d&&(r&&i?($.current=u??-1,I.current&&u!=null&&(L.current=!0,T())):J.current&&($.current=-1,Q.current()))},[d,r,i,u,T]),Ye(()=>{if(d){if(!r){z.current=!1;return}if(i)if(l==null){if(z.current=!1,Z.current!=null)return;if(J.current&&($.current=-1,fe()),(!N.current||!J.current)&&I.current&&(U.current!=null||I.current===!0&&U.current==null)){let ce=0;const ve=()=>{s.current[0]==null?(ce<2&&(ce?requestAnimationFrame:queueMicrotask)(ve),ce+=1):($.current=U.current==null||Bg(U.current,S,y)||g?Tg(s):Qk(s),U.current=null,T())};ve()}}else Ap(s.current,l)||($.current=l,fe(),L.current=!1)}},[d,r,i,l,Z,g,s,S,y,T,fe,ee]),Ye(()=>{if(!d||i||!O||x||!J.current)return;const ce=O.nodesRef.current,ve=ce.find(Te=>Te.id===D)?.context?.elements.floating,q=oi(pt(i)),ue=ce.some(Te=>Te.context&&Qe(Te.context.elements.floating,q));ve&&!ue&&F.current&&ve.focus({preventScroll:!0})},[d,i,O,D,x]),Ye(()=>{Q.current=T,N.current=r,J.current=!!i}),Ye(()=>{r||(U.current=null,I.current=v)},[r,v]);const V=l!=null,oe=et(ce=>{if(!X.current)return;const ve=s.current.indexOf(ce.currentTarget);ve!==-1&&($.current!==ve||l!==ve)&&($.current=ve,T(ce))}),me=m.useMemo(()=>({onFocus(ve){z.current=!0,oe(ve)},onClick:({currentTarget:ve})=>ve.focus({preventScroll:!0}),onMouseMove(ve){z.current=!0,L.current=!1,_&&oe(ve)},onPointerLeave(ve){if(!X.current||!F.current||ve.pointerType==="touch")return;z.current=!0;const q=ve.relatedTarget;if(!(!_||s.current.includes(q))&&ne.current&&(B.current?.(),B.current=null,$.current=-1,T(ve),!x)){const ue=P.current,Te=oi(pt(ue));ue&&Qe(ue,Te)&&ue.focus({preventScroll:!0})}}}),[oe,X,P,_,s,T,ne,x]),Ne=m.useCallback(()=>w??O?.nodesRef.current.find(ce=>ce.id===D)?.context?.dataRef?.current.orientation,[D,O,w]),xe=et(ce=>{if(F.current=!1,z.current=!0,ce.which===229||!X.current&&ce.currentTarget===P.current)return;if(g&&KV(ce.key,S,y,E)){nf(ce.key,Ne())||zr(ce),n.setOpen(!1,ht(tp,ce.nativeEvent)),Lt(a)&&(x?O?.events.emit("virtualfocus",a):a.focus());return}const ve=$.current,q=Tg(s,k),ue=Qk(s,k);if(M||(ce.key==="Home"&&(zr(ce),$.current=q,T(ce)),ce.key==="End"&&(zr(ce),$.current=ue,T(ce))),E>1){const Te=Array.from({length:s.current.length},()=>({width:1,height:1})),G=K9(Te,E),le=G.findIndex(ae=>ae!=null&&!Ml(s.current,ae,k)),Ce=G.reduce((ae,ke,Re)=>ke!=null&&!Ml(s.current,ke,k)?Re:ae,-1),Ee=G[q9(G.map(ae=>ae!=null?s.current[ae]:null),{event:ce,orientation:S,loopFocus:h,rtl:y,cols:E,disabledIndices:Y9([...(typeof k!="function"?k:null)||s.current.map((ae,ke)=>Ml(s.current,ke,k)?ke:void 0),void 0],G),minIndex:le,maxIndex:Ce,prevIndex:G9($.current>ue?q:$.current,Te,G,E,ce.key===ud?"bl":ce.key===(y?Co:jo)?"tr":"tl"),stopEvent:!0})];if(Ee!=null&&($.current=Ee,T(ce)),S==="both")return}if(nf(ce.key,S)){if(zr(ce),r&&!x&&oi(ce.currentTarget.ownerDocument)===ce.currentTarget){$.current=Bg(ce.key,S,y)?q:ue,T(ce);return}Bg(ce.key,S,y)?h?ve>=ue?p&&ve!==s.current.length?$.current=-1:(z.current=!1,$.current=q):$.current=ur(s.current,{startingIndex:ve,disabledIndices:k}):$.current=Math.min(ue,ur(s.current,{startingIndex:ve,disabledIndices:k})):h?ve<=q?p&&ve!==-1?$.current=s.current.length:(z.current=!1,$.current=ue):$.current=ur(s.current,{startingIndex:ve,decrement:!0,disabledIndices:k}):$.current=Math.max(q,ur(s.current,{startingIndex:ve,decrement:!0,disabledIndices:k})),Ap(s.current,$.current)&&($.current=-1),T(ce)}}),be=m.useMemo(()=>x&&r&&V&&{"aria-activedescendant":`${j}-${l}`},[x,r,V,j,l]),je=m.useMemo(()=>({"aria-orientation":S==="both"?void 0:S,...M?{}:be,onKeyDown(ce){if(ce.key==="Tab"&&ce.shiftKey&&r&&!x){const ve=Nr(ce.nativeEvent);if(ve&&!Qe(P.current,ve))return;zr(ce),n.setOpen(!1,ht(Yl,ce.nativeEvent)),Lt(a)&&a.focus();return}xe(ce)},onPointerMove(){F.current=!0}}),[be,xe,P,S,M,n,r,x,a]),ge=m.useMemo(()=>{function ce(q){v==="auto"&&hO(q.nativeEvent)&&(I.current=!x)}function ve(q){I.current=v,v==="auto"&&mO(q.nativeEvent)&&(I.current=!0)}return{onKeyDown(q){const ue=n.select("open");F.current=!1;const Te=q.key.startsWith("Arrow"),G=qV(q.key,Ne(),y),le=nf(q.key,S),Ce=(g?G:le)||q.key==="Enter"||q.key.trim()==="";if(x&&ue)return xe(q);if(!(!ue&&!b&&Te)){if(Ce){const Ee=nf(q.key,Ne());U.current=g&&Ee?null:q.key}if(g){G&&(zr(q),ue?($.current=Tg(s,ee.current),T(q)):n.setOpen(!0,ht(tp,q.nativeEvent,q.currentTarget)));return}le&&(Z.current!=null&&($.current=Z.current),zr(q),!ue&&b?n.setOpen(!0,ht(tp,q.nativeEvent,q.currentTarget)):xe(q),ue&&T(q))}},onFocus(q){n.select("open")&&!x&&($.current=-1,T(q))},onPointerDown:ve,onPointerEnter:ve,onMouseDown:ce,onClick:ce}},[xe,ee,v,s,g,T,n,b,S,Ne,y,Z,x]),de=m.useMemo(()=>({...be,...ge}),[be,ge]);return m.useMemo(()=>d?{reference:de,floating:je,item:me,trigger:ge}:{},[d,de,je,ge,me])}const YV=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function lM(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),i=n.useState("floatingId"),a=n.useState("domReferenceElement"),o=n.useState("floatingElement"),{role:s="dialog"}=t,l=Ds(),c=a?.id||l,d=m.useMemo(()=>jp(o)?.id||i,[o,i]),u=YV.get(s)??s,h=qa()!=null,g=m.useMemo(()=>u==="tooltip"||s==="label"?Yn:{"aria-haspopup":u==="alertdialog"?"dialog":u,"aria-expanded":"false",...u==="listbox"&&{role:"combobox"},...u==="menu"&&h&&{role:"menuitem"},...s==="select"&&{"aria-autocomplete":"none"},...s==="combobox"&&{"aria-autocomplete":"list"}},[u,h,s]),y=m.useMemo(()=>u==="tooltip"||s==="label"?{[`aria-${s==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...g,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...u==="menu"&&{id:c}},[u,d,r,c,s,g]),x=m.useMemo(()=>{const _={id:d,...u&&{role:u}};return u==="tooltip"||s==="label"?_:{..._,...u==="menu"&&{"aria-labelledby":c}}},[u,d,c,s]),v=m.useCallback(({active:_,selected:b})=>{const k={role:"option",..._&&{id:`${d}-fui-option`}};switch(s){case"select":case"combobox":return{...k,"aria-selected":b}}return{}},[d,s]);return m.useMemo(()=>({reference:y,floating:x,item:v,trigger:g}),[y,x,g,v])}function XV(e,t){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,i=n.useState("open"),{listRef:a,elementsRef:o,activeIndex:s,onMatch:l,onTypingChange:c,enabled:d=!0,resetMs:u=750,selectedIndex:p=null}=t,h=Kr(),g=m.useRef(""),y=m.useRef(p??s??-1),x=m.useRef(null);Ye(()=>{!i&&p!==null||(h.clear(),x.current=null,g.current!==""&&(g.current=""))},[i,p,h]),Ye(()=>{i&&g.current===""&&(y.current=p??s??-1)},[i,p,s]);const v=et(w=>{w?r.current.typing||(r.current.typing=w,c?.(w)):r.current.typing&&(r.current.typing=w,c?.(w))}),_=et(w=>{function E(M){const I=o?.current[M];return!I||nm(I)}function j(M,I,$=0){if(M.length===0)return-1;const U=($%M.length+M.length)%M.length,F=I.toLocaleLowerCase();for(let T=0;T<M.length;T+=1){const Q=(U+T)%M.length;if(!(!M[Q]?.toLocaleLowerCase().startsWith(F)||!E(Q)))return Q}return-1}const C=a.current;if(g.current.length>0&&w.key===" "&&(zr(w),v(!0)),g.current.length>0&&g.current[0]!==" "&&j(C,g.current)===-1&&w.key!==" "&&v(!1),C==null||w.key.length!==1||w.ctrlKey||w.metaKey||w.altKey)return;i&&w.key!==" "&&(zr(w),v(!0));const A=g.current==="";A&&(y.current=p??s??-1),C.every(M=>M?M[0]?.toLocaleLowerCase()!==M[1]?.toLocaleLowerCase():!0)&&g.current===w.key&&(g.current="",y.current=x.current),g.current+=w.key,h.start(u,()=>{g.current="",y.current=x.current,v(!1)});const D=((A?p??s??-1:y.current)??0)+1,O=j(C,g.current,D);O!==-1?(l?.(O),x.current=O):w.key!==" "&&(g.current="",v(!1))}),b=et(w=>{const E=w.relatedTarget,j=n.select("domReferenceElement"),C=n.select("floatingElement"),A=Qe(j,E),R=Qe(C,E);A||R||(h.clear(),g.current="",y.current=x.current,v(!1))}),k=m.useMemo(()=>({onKeyDown:_,onBlur:b}),[_,b]),S=m.useMemo(()=>({onKeyDown:_,onBlur:b}),[_,b]);return m.useMemo(()=>d?{reference:k,floating:S}:{},[d,k,S])}const bS=.1,ZV=bS*bS,Pt=.5;function rf(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function af(e,t,n,r,i,a,o,s,l,c){let d=!1;return rf(e,t,n,r,i,a)&&(d=!d),rf(e,t,i,a,o,s)&&(d=!d),rf(e,t,o,s,l,c)&&(d=!d),rf(e,t,l,c,n,r)&&(d=!d),d}function QV(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function of(e,t,n,r,i,a){const o=Math.min(n,i),s=Math.max(n,i),l=Math.min(r,a),c=Math.max(r,a);return e>=o&&e<=s&&t>=l&&t<=c}function JV(e={}){const{blockPointerEvents:t=!1}=e,n=new da,r=({x:i,y:a,placement:o,elements:s,onClose:l,nodeId:c,tree:d})=>{const u=o?.split("-")[0];let p=!1,h=null,g=null,y=typeof performance<"u"?performance.now():0;function x(_,b){const k=performance.now(),S=k-y;if(h===null||g===null||S===0)return h=_,g=b,y=k,!1;const w=_-h,E=b-g,j=w*w+E*E,C=S*S*ZV;return h=_,g=b,y=k,j<C}function v(){n.clear(),l()}return function(b){n.clear();const k=s.domReference,S=s.floating;if(!k||!S||u==null||i==null||a==null)return;const{clientX:w,clientY:E}=b,j=Nr(b),C=b.type==="mouseleave",A=Qe(S,j),R=Qe(k,j);if(A&&(p=!0,!C))return;if(R&&(p=!1,!C)){p=!0;return}if(C&&ut(b.relatedTarget)&&Qe(S,b.relatedTarget))return;function P(){return!!(d&&oa(d.nodesRef.current,c).length>0)}function D(){P()||v()}if(P())return;const O=k.getBoundingClientRect(),M=S.getBoundingClientRect(),I=i>M.right-M.width/2,$=a>M.bottom-M.height/2,U=M.width>O.width,F=M.height>O.height,T=(U?O:M).left,Q=(U?O:M).right,J=(F?O:M).top,N=(F?O:M).bottom;if(u==="top"&&a>=O.bottom-1||u==="bottom"&&a<=O.top+1||u==="left"&&i>=O.right-1||u==="right"&&i<=O.left+1){D();return}let z=!1;switch(u){case"top":z=of(w,E,T,O.top+1,Q,M.bottom-1);break;case"bottom":z=of(w,E,T,M.top+1,Q,O.bottom-1);break;case"left":z=of(w,E,M.right-1,N,O.left+1,J);break;case"right":z=of(w,E,O.right-1,N,M.left+1,J);break}if(z)return;if(p&&!QV(w,E,O)){D();return}if(!C&&x(w,E)){D();return}let L=!1;switch(u){case"top":{const B=U?Pt/2:Pt*4,ee=U||I?i+B:i-B,X=U?i-B:I?i+B:i-B,Z=a+Pt+1,ne=I||U?M.bottom-Pt:M.top,fe=I?U?M.bottom-Pt:M.top:M.bottom-Pt;L=af(w,E,ee,Z,X,Z,M.left,ne,M.right,fe);break}case"bottom":{const B=U?Pt/2:Pt*4,ee=U||I?i+B:i-B,X=U?i-B:I?i+B:i-B,Z=a-Pt,ne=I||U?M.top+Pt:M.bottom,fe=I?U?M.top+Pt:M.bottom:M.top+Pt;L=af(w,E,ee,Z,X,Z,M.left,ne,M.right,fe);break}case"left":{const B=F?Pt/2:Pt*4,ee=F||$?a+B:a-B,X=F?a-B:$?a+B:a-B,Z=i+Pt+1,ne=$||F?M.right-Pt:M.left,fe=$?F?M.right-Pt:M.left:M.right-Pt;L=af(w,E,ne,M.top,fe,M.bottom,Z,ee,Z,X);break}case"right":{const B=F?Pt/2:Pt*4,ee=F||$?a+B:a-B,X=F?a-B:$?a+B:a-B,Z=i-Pt,ne=$||F?M.left+Pt:M.right,fe=$?F?M.left+Pt:M.right:M.left+Pt;L=af(w,E,Z,ee,Z,X,ne,M.top,fe,M.bottom);break}}L?p||n.start(40,D):D()}};return r.__options={...e,blockPointerEvents:t},r}let eq=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),tq=(function(e){return e[e.open=Ci.open]="open",e[e.closed=Ci.closed]="closed",e[e.startingStyle=Ci.startingStyle]="startingStyle",e[e.endingStyle=Ci.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const cM=m.createContext(void 0);function uM(){const e=m.useContext(cM);if(e===void 0)throw new Error(ba(26));return e}const dM="ArrowUp",fM="ArrowDown",pM="ArrowLeft",hM="ArrowRight",mM="Home",gM="End",nq=new Set([pM,hM]),rq=new Set([dM,fM]),iq=new Set([...nq,...rq]);[...iq];const yM=new Set([dM,fM,pM,hM,mM,gM]),aq={...cd,...Gh,nestedDialogOpen(e){return e?{[tq.nestedDialogOpen]:""}:null}},oq=m.forwardRef(function(t,n){const{className:r,finalFocus:i,initialFocus:a,render:o,style:s,...l}=t,{store:c}=Lo(),d=c.useState("descriptionElementId"),u=c.useState("disablePointerDismissal"),p=c.useState("floatingRootContext"),h=c.useState("popupProps"),g=c.useState("modal"),y=c.useState("mounted"),x=c.useState("nested"),v=c.useState("nestedOpenDialogCount"),_=c.useState("open"),b=c.useState("openMethod"),k=c.useState("titleElementId"),S=c.useState("transitionStatus"),w=c.useState("role");uM(),nw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function E(P){return P==="touch"?c.context.popupRef.current:!0}const j=a===void 0?E:a,C=v>0,R=Zr("div",t,{state:{open:_,nested:x,transitionStatus:S,nestedDialogOpen:C},props:[h,{"aria-labelledby":k??void 0,"aria-describedby":d??void 0,role:w,tabIndex:-1,hidden:!y,onKeyDown(P){yM.has(P.key)&&P.stopPropagation()},style:{[eq.nestedDialogs]:v}},l],ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],stateAttributesMapping:aq});return f.jsx(FO,{context:p,openInteractionType:b,disabled:!y,closeOnFocusOut:!u,initialFocus:j,returnFocus:i,modal:g!==!1,restoreFocus:"popup",children:R})});function vM(e){return R0(19)?e:e?"true":void 0}const xM=m.forwardRef(function(t,n){const{cutout:r,...i}=t;let a;if(r){const o=r.getBoundingClientRect();a=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${o.left}px ${o.top}px,${o.left}px ${o.bottom}px,${o.right}px ${o.bottom}px,${o.right}px ${o.top}px,${o.left}px ${o.top}px)`}return f.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),sq=m.forwardRef(function(t,n){const{keepMounted:r=!1,...i}=t,{store:a}=Lo(),o=a.useState("mounted"),s=a.useState("modal"),l=a.useState("open");return o||r?f.jsx(cM.Provider,{value:r,children:f.jsxs(IO,{ref:n,...i,children:[o&&s===!0&&f.jsx(xM,{ref:a.context.internalBackdropRef,inert:vM(!l)}),t.children]})}):null});function bM(e){const t=m.useRef(!0);t.current&&(t.current=!1,e())}let wS={},_S={},kS="";function lq(e){if(typeof document>"u")return!1;const t=pt(e);return yn(t).innerWidth-t.documentElement.clientWidth>0}function cq(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=pt(e),r=n.documentElement,i=n.body,a=$o(r)?r:i,o=a.style.overflowY,s=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const l=a.offsetWidth;a.style.overflowY="hidden";const c=a.offsetWidth;return a.style.overflowY=o,r.style.scrollbarGutter=s,l===c}function uq(e){const t=pt(e),n=t.documentElement,r=t.body,i=$o(n)?n:r,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(i.style,a)}}function dq(e){const t=pt(e),n=t.documentElement,r=t.body,i=yn(n);let a=0,o=0,s=!1;const l=Gi.create();if(cO&&(i.visualViewport?.scale??1)!==1)return()=>{};function c(){const h=i.getComputedStyle(n),g=i.getComputedStyle(r),v=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,o=n.scrollLeft,wS={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},kS=n.style.scrollBehavior,_S={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const _=n.scrollHeight>n.clientHeight,b=n.scrollWidth>n.clientWidth,k=h.overflowY==="scroll"||g.overflowY==="scroll",S=h.overflowX==="scroll"||g.overflowX==="scroll",w=Math.max(0,i.innerWidth-r.clientWidth),E=Math.max(0,i.innerHeight-r.clientHeight),j=parseFloat(g.marginTop)+parseFloat(g.marginBottom),C=parseFloat(g.marginLeft)+parseFloat(g.marginRight),A=$o(n)?n:r;if(s=cq(e),s){n.style.scrollbarGutter=v,A.style.overflowY="hidden",A.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:v,overflowY:"hidden",overflowX:"hidden"}),(_||k)&&(n.style.overflowY="scroll"),(b||S)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:j||E?`calc(100dvh - ${j+E}px)`:"100dvh",width:C||w?`calc(100vw - ${C+w}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,wS),Object.assign(r.style,_S),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=kS)}function u(){d(),l.request(c)}c();const p=st(i,"resize",u);return()=>{l.cancel(),d(),typeof i.removeEventListener=="function"&&p()}}class fq{lockCount=0;restore=null;timeoutLock=da.create();timeoutUnlock=da.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=pt(t).documentElement,i=yn(r).getComputedStyle(r).overflowY;if(i==="hidden"||i==="clip"){this.restore=I0;return}const a=uO||!lq(t);this.restore=a?uq(t):dq(t)}}const pq=new fq;function wM(e=!0,t=null){Ye(()=>{if(e)return pq.acquire(t)},[e,t])}function hq(e){const t=m.useRef(""),n=m.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:m.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i?e(i,i.pointerType):e(i,t.current),t.current=""},[e]),onPointerDown:n}}function mq(e,t){const n=m.useRef(e),r=et(t);Ye(()=>{n.current!==e&&r(n.current)},[e,r]),Ye(()=>{n.current=e},[e])}function _M(e){const[t,n]=m.useState(null),r=et((o,s)=>{e||n(s||(uO?"touch":""))});mq(e,o=>{o&&!e&&n(null)});const{onClick:i,onPointerDown:a}=hq(r);return m.useMemo(()=>({openMethod:t,triggerProps:{onClick:i,onPointerDown:a}}),[t,i,a])}function gq(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:i}=e,a=t.useState("open"),o=t.useState("disablePointerDismissal"),s=t.useState("modal"),l=t.useState("popupElement"),{openMethod:c,triggerProps:d}=_M(a);tM(t);const{forceUnmount:u}=nM(a,t),p=m.useCallback(()=>{t.setOpen(!1,ht(aO))},[t]);m.useImperativeHandle(r,()=>({unmount:u,close:p}),[u,p]);const h=aM({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0}),[g,y]=m.useState(0),[x,v]=m.useState(0),_=g===0,b=lM(h),k=BO(h,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:s==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(R){if(!t.context.outsidePressEnabledRef.current||"button"in R&&R.button!==0||"touches"in R&&R.touches.length!==1)return!1;const P=Nr(R);if(_&&!o){const D=P;return s&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===D||t.context.backdropRef.current===D||Qe(D,l)&&!D?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:_});wM(a&&s===!0,l);const{getReferenceProps:S,getFloatingProps:w,getTriggerProps:E}=iw([b,k]);t.useContextCallback("onNestedDialogOpen",(R,P)=>{y(R),v(P)}),t.useContextCallback("onNestedDialogClose",()=>{y(0),v(0)}),m.useEffect(()=>(n?.onNestedDialogOpen&&a&&n.onNestedDialogOpen(g+1,x+(i?1:0)),n?.onNestedDialogClose&&!a&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&a&&n.onNestedDialogClose()}),[i,a,g,x,n]);const j=m.useMemo(()=>S(d),[S,d]),C=m.useMemo(()=>E(d),[E,d]),A=m.useMemo(()=>w(),[w]);t.useSyncedValues({openMethod:c,activeTriggerProps:j,inactiveTriggerProps:C,popupProps:A,floatingRootContext:h,nestedOpenDialogCount:g,nestedOpenDrawerCount:x})}const yq={...iM,modal:Xe(e=>e.modal),nested:Xe(e=>e.nested),nestedOpenDialogCount:Xe(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:Xe(e=>e.nestedOpenDrawerCount),disablePointerDismissal:Xe(e=>e.disablePointerDismissal),openMethod:Xe(e=>e.openMethod),descriptionElementId:Xe(e=>e.descriptionElementId),titleElementId:Xe(e=>e.titleElementId),viewportElement:Xe(e=>e.viewportElement),role:Xe(e=>e.role)};class aw extends ew{constructor(t){super(vq(t),{popupRef:m.createRef(),backdropRef:m.createRef(),internalBackdropRef:m.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new im,onOpenChange:void 0,onOpenChangeComplete:void 0},yq)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,n);const r={open:t},i=n.trigger?.id??null;(i||t)&&(r.activeTriggerId=i,r.activeTriggerElement=n.trigger??null),this.update(r)};static useStore(t,n){const r=hr(()=>new aw(n)).current;return t??r}}function vq(e={}){return{...rM(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}const SS=m.createContext(!1);function xq(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:l,handle:c,triggerId:d,defaultTriggerId:u=null}=e,p=Lo(!0),h=m.useContext(SS),g=!!p,y=aw.useStore(c?.store,{open:r,openProp:n,activeTriggerId:u,triggerIdProp:d,modal:s,disablePointerDismissal:o,nested:g});bM(()=>{n===void 0&&y.state.open===!1&&r===!0&&y.update({open:!0,activeTriggerId:u})}),y.useControlledProp("openProp",n),y.useControlledProp("triggerIdProp",d),y.useSyncedValues({disablePointerDismissal:o,nested:g,modal:s}),y.useContextCallback("onOpenChange",i),y.useContextCallback("onOpenChangeComplete",a);const x=y.useState("payload");gq({store:y,actionsRef:l,parentContext:p?.store.context,isDrawer:h});const v=m.useMemo(()=>({store:y}),[y]);return f.jsx(SS.Provider,{value:!1,children:f.jsx(YA.Provider,{value:v,children:typeof t=="function"?t({payload:x}):t})})}let ES=(function(e){return e[e.open=Ci.open]="open",e[e.closed=Ci.closed]="closed",e[e.startingStyle=Ci.startingStyle]="startingStyle",e[e.endingStyle=Ci.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const bq={...cd,...Gh,nested(e){return e?{[ES.nested]:""}:null},nestedDialogOpen(e){return e?{[ES.nestedDialogOpen]:""}:null}},wq=m.forwardRef(function(t,n){const{className:r,render:i,children:a,style:o,...s}=t,l=uM(),{store:c}=Lo(),d=c.useState("open"),u=c.useState("nested"),p=c.useState("transitionStatus"),h=c.useState("nestedOpenDialogCount"),g=c.useState("mounted"),y=h>0;return Zr("div",t,{enabled:l||g,state:{open:d,nested:u,transitionStatus:p,nestedDialogOpen:y},ref:[n,c.useStateSetter("viewportElement")],stateAttributesMapping:bq,props:[{role:"presentation",hidden:!g,style:{pointerEvents:d?void 0:"none"},children:a},s]})}),_q=m.forwardRef(function(t,n){const{render:r,className:i,style:a,id:o,...s}=t,{store:l}=Lo(),c=em(o);return l.useSyncedValueWithCleanup("titleElementId",c),Zr("h2",t,{ref:n,props:[{id:c},s]})}),kq=m.forwardRef(function(t,n){const{render:r,className:i,disabled:a=!1,focusableWhenDisabled:o=!1,nativeButton:s=!0,style:l,...c}=t,{getButtonProps:d,buttonRef:u}=Jh({disabled:a,focusableWhenDisabled:o,native:s});return Zr("button",t,{state:{disabled:a},ref:[n,u],props:[c,d]})}),CS=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jS=kt,Sq=(e,t)=>n=>{var r;if(t?.variants==null)return jS(e,n?.class,n?.className);const{variants:i,defaultVariants:a}=t,o=Object.keys(i).map(c=>{const d=n?.[c],u=a?.[c];if(d===null)return null;const p=CS(d)||CS(u);return i[c][p]}),s=n&&Object.entries(n).reduce((c,d)=>{let[u,p]=d;return p===void 0||(c[u]=p),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,d)=>{let{class:u,className:p,...h}=d;return Object.entries(h).every(g=>{let[y,x]=g;return Array.isArray(x)?x.includes({...a,...s}[y]):{...a,...s}[y]===x})?[...c,u,p]:c},[]);return jS(e,o,l,n?.class,n?.className)},Eq=Sq("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function kM({className:e,variant:t="default",size:n="default",...r}){return f.jsx(kq,{"data-slot":"button",className:se(Eq({variant:t,size:n,className:e})),...r})}function ln({...e}){return f.jsx(xq,{"data-slot":"dialog",...e})}function Cq({...e}){return f.jsx(sq,{"data-slot":"dialog-portal",...e})}function jq({className:e,...t}){return f.jsx(s9,{"data-slot":"dialog-overlay",className:se("te-dialog-overlay",e),...t})}function cn({className:e,children:t,showCloseButton:n=!0,...r}){return f.jsxs(Cq,{children:[f.jsx(jq,{}),f.jsx("div",{"data-tauri-drag-region":!0,"aria-hidden":!0,className:"pointer-events-auto fixed inset-x-0 top-0 z-[70] h-8"}),f.jsx(wq,{className:"te-dialog-viewport fixed inset-0 z-[60] flex items-center justify-center",children:f.jsxs(oq,{"data-slot":"dialog-content",className:se("te-dialog-popup relative grid w-full max-w-[calc(100%-2rem)] gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 sm:max-w-sm",e),...r,children:[t,n&&f.jsxs(oO,{"data-slot":"dialog-close",render:f.jsx(kM,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[f.jsx(Dn,{}),f.jsx("span",{className:"sr-only",children:"Close"})]})]})})]})}function un({className:e,...t}){return f.jsx("div",{"data-slot":"dialog-header",className:se("flex flex-col gap-2",e),...t})}function ow({className:e,showCloseButton:t=!1,children:n,...r}){return f.jsxs("div",{"data-slot":"dialog-footer",className:se("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...r,children:[n,t&&f.jsx(oO,{render:f.jsx(kM,{variant:"outline"}),children:"Close"})]})}function dn({className:e,...t}){return f.jsx(_q,{"data-slot":"dialog-title",className:se("font-heading text-base leading-none font-medium",e),...t})}function fn({className:e,...t}){return f.jsx(k9,{"data-slot":"dialog-description",className:se("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}async function Ip(e){const t=await H("openloaf_web_url",{path:e});await _0(t)}function Nq(e){switch(e){case"lite":return"dialogs:account.membership.lite";case"pro":return"dialogs:account.membership.pro";case"premium":return"dialogs:account.membership.premium";default:return"dialogs:account.membership.free"}}function Hg({label:e,children:t}){return f.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-te-gray/30 py-3 last:border-b-0",children:[f.jsx("span",{className:"shrink-0 pt-0.5 font-mono text-xs uppercase tracking-[0.2em] text-te-light-gray",children:e}),f.jsx("div",{className:"min-w-0 flex-1 text-right",children:t})]})}function Pq({open:e,onOpenChange:t}){const{t:n,i18n:r}=he(),{user:i,profile:a,isAuthenticated:o,init:s,loaded:l,logout:c}=ct(),[d,u]=m.useState(!1),p=a?.membershipLevel,h=n(p==="premium"?"dialogs:account.subscribe_button.manage":p==="pro"?"dialogs:account.subscribe_button.upgrade_to_premium":"dialogs:account.subscribe_button.default");m.useEffect(()=>{e&&s()},[e,s]),m.useEffect(()=>{e&&l&&!o&&t(!1)},[e,l,o,t]);const g=async()=>{if(!d){u(!0);try{await c()}finally{u(!1)}}},y=(a?.provider??"").toLowerCase()==="wechat",x=n(y?"dialogs:account.row.wechat":"dialogs:account.row.email"),v=y?a?.name??i?.name??"—":i?.email??a?.email??i?.name??"—",_=y?AH:DB;return f.jsx(ln,{open:e,onOpenChange:t,children:f.jsxs(cn,{className:"flex max-h-[88vh] w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0",children:[f.jsxs(un,{className:"border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:n("dialogs:account.title")}),f.jsx(fn,{className:"sr-only",children:n("dialogs:account.description")})]}),f.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:l?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"mb-5",children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"h-px w-4 bg-te-accent"}),f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.25em] text-te-light-gray",children:n("dialogs:account.section.identity")})]}),f.jsx(Hg,{label:x,children:f.jsxs("span",{className:"inline-flex max-w-full items-start gap-2 font-mono text-sm text-te-fg",children:[f.jsx(_,{className:"mt-[3px] size-3.5 shrink-0 text-te-light-gray"}),f.jsx("span",{className:"break-all text-left",children:v})]})}),f.jsx(Hg,{label:n("dialogs:account.row.subscription"),children:f.jsxs("span",{className:"inline-flex items-center gap-2 border border-te-accent/60 bg-te-accent/8 px-2.5 py-1 font-mono text-[11px] uppercase tracking-[0.15em] text-te-accent",children:[f.jsx("span",{className:"size-1.5 bg-te-accent"}),n(Nq(p))]})}),f.jsx(Hg,{label:n("dialogs:account.row.credits_balance"),children:f.jsx("span",{className:"font-mono text-sm tabular-nums text-te-fg",children:Math.round(a?.creditsBalance??0).toLocaleString(r.language)})})]}),f.jsxs("div",{className:"mb-5",children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"h-px w-4 bg-te-accent"}),f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.25em] text-te-light-gray",children:n("dialogs:account.section.subscription")})]}),f.jsxs("button",{type:"button",onClick:()=>{Ip("/pricing")},className:"inline-flex w-full items-center justify-center gap-2 bg-te-accent px-4 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-accent-fg transition-colors hover:bg-te-accent/90",children:[f.jsx(In,{className:"size-4"}),h]}),f.jsx("p",{className:"mt-2 font-sans text-xs text-te-light-gray",children:n("dialogs:account.subscribe_hint")})]}),f.jsxs("div",{className:"mb-5",children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"h-px w-4 bg-te-accent"}),f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.25em] text-te-light-gray",children:n("dialogs:account.section.recharge")})]}),f.jsxs("button",{type:"button",onClick:()=>{Ip("/recharge")},className:"inline-flex w-full items-center justify-center gap-2 border border-te-gray px-4 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(aA,{className:"size-4"}),n("dialogs:account.recharge_button")]}),f.jsx("p",{className:"mt-2 font-sans text-xs text-te-light-gray",children:n("dialogs:account.recharge_hint")})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"h-px w-4 bg-te-accent"}),f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.25em] text-te-light-gray",children:n("dialogs:account.section.session")})]}),f.jsxs("button",{type:"button",onClick:g,disabled:d,className:"inline-flex w-full items-center justify-center gap-2 border border-te-gray px-4 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent disabled:opacity-50",children:[f.jsx(RB,{className:"size-4"}),n(d?"dialogs:account.logout_busy":"dialogs:account.logout_button")]}),f.jsx("p",{className:"mt-2 font-sans text-xs text-te-light-gray",children:n("dialogs:account.logout_hint")})]})]}):f.jsx("div",{className:"py-10 text-center font-mono text-xs uppercase tracking-[0.25em] text-te-light-gray",children:n("dialogs:account.loading")})})]})})}var NS;(function(e){e.Nsis="nsis",e.Msi="msi",e.Deb="deb",e.Rpm="rpm",e.AppImage="appimage",e.App="app"})(NS||(NS={}));async function fd(){return H("plugin:app|version")}async function Tq(){return await H("plugin:autostart|is_enabled")}async function Aq(){await H("plugin:autostart|enable")}async function Oq(){await H("plugin:autostart|disable")}async function SM(e){try{if(await Tq()===e)return;e?await Aq():await Oq(),console.log("[autostart] synced →",e)}catch(t){console.warn("[autostart] sync failed:",t)}}async function Mq(e){return await H("dictation_test_provider",{req:e})}function Rq(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`ex_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}const EM=["*","chat","code","doc","email","browser","meeting","other"];function Iq(e){const t=(e??"").trim().toLowerCase();return EM.includes(t)?t:"*"}function Wg({description:e,value:t,isCustom:n,onChange:r,onReset:i,textareaRows:a=18}){const{t:o}=he("settings");return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx(Dq,{description:e,isCustom:n,onReset:i}),f.jsx("textarea",{value:t,onChange:s=>r(s.target.value),rows:a,className:"w-full resize-y border border-te-gray/40 bg-te-surface p-3 font-mono text-xs leading-relaxed text-te-fg outline-none transition-colors focus:border-te-accent"}),f.jsx("p",{className:"font-sans text-[11px] leading-relaxed text-te-light-gray/70",children:o("ai.prompt_panel_save_hint")})]})}function Dq({description:e,isCustom:t,onReset:n}){const{t:r}=he("settings");return f.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-te-gray/30 pb-3",children:[f.jsxs("div",{className:"flex flex-1 flex-col gap-1.5",children:[f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("span",{className:se("border px-1.5 py-px font-mono text-[10px] uppercase tracking-[0.2em]",t?"border-te-accent/60 text-te-accent":"border-te-gray/40 text-te-light-gray"),children:r(t?"ai.refine_status_modified":"ai.refine_status_default")})}),f.jsx("p",{className:"font-sans text-xs leading-relaxed text-te-light-gray",children:e})]}),f.jsxs("button",{type:"button",disabled:!t,onClick:n,className:"inline-flex shrink-0 items-center gap-1.5 border border-te-gray bg-te-surface px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray transition-colors enabled:hover:border-te-accent enabled:hover:text-te-accent disabled:cursor-not-allowed disabled:opacity-40",children:[f.jsx(Fa,{className:"size-3"}),r("ai.prompt_reset")]})]})}function Lq({examples:e,onChange:t}){const{t:n}=he("settings"),r=e.length>=ax,i=(s,l)=>{t(e.map((c,d)=>d===s?{...c,...l}:c))},a=s=>{t(e.filter((l,c)=>c!==s))},o=()=>{r||t([...e,{id:Rq(),target:"*",input:"",focus:"",output:""}])};return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[f.jsx("h3",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-te-fg",children:n("ai.refine_examples_my_title")}),f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:n("ai.refine_examples_count",{current:e.length,max:ax})})]}),e.length>0&&f.jsx("div",{className:"flex flex-col gap-4",children:e.map((s,l)=>f.jsx($q,{example:s,onChange:c=>i(l,c),onRemove:()=>a(l)},s.id))}),f.jsxs("button",{type:"button",disabled:r,onClick:o,className:"inline-flex w-full items-center justify-center gap-2 border border-dashed border-te-gray/60 px-4 py-3 font-mono text-xs uppercase tracking-[0.2em] text-te-light-gray transition-colors enabled:hover:border-te-accent enabled:hover:text-te-accent disabled:cursor-not-allowed disabled:opacity-40",children:[f.jsx(ws,{className:"size-3.5"}),n("ai.refine_example_add")]})]})}function $q({example:e,onChange:t,onRemove:n}){const{t:r}=he("settings"),i=Iq(e.target);return f.jsxs("div",{className:"flex flex-col gap-3 border border-te-gray/40 bg-te-surface/50 px-4 py-4",children:[f.jsxs("div",{className:"flex items-start justify-between gap-3",children:[f.jsxs("label",{className:"flex flex-1 flex-col gap-1.5",children:[f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:r("ai.refine_example_target_label")}),f.jsx("select",{value:i,onChange:a=>t({target:a.target.value}),className:"w-full appearance-none border border-te-gray/40 bg-te-surface px-3 py-1.5 font-sans text-sm text-te-fg outline-none transition-colors focus:border-te-accent",children:EM.map(a=>f.jsx("option",{value:a,children:r(`ai.refine_example_target_option.${a}`)},a))})]}),f.jsxs("button",{type:"button",onClick:n,"aria-label":r("ai.refine_example_remove")??"Remove",className:"mt-6 inline-flex shrink-0 items-center gap-1 border border-te-gray/40 px-2 py-1.5 font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:border-red-400 hover:text-red-400",children:[f.jsx(Mr,{className:"size-3"}),r("ai.refine_example_remove")]})]}),f.jsxs("label",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:r("ai.refine_example_input_label")}),f.jsx("textarea",{value:e.input,onChange:a=>t({input:a.target.value}),rows:3,placeholder:r("ai.refine_example_input_placeholder_v2")??"",className:"w-full resize-y border border-te-gray/40 bg-te-surface p-2 font-sans text-sm leading-relaxed text-te-fg outline-none transition-colors focus:border-te-accent"})]}),f.jsxs("label",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:r("ai.refine_example_output_label")}),f.jsx("textarea",{value:e.output,onChange:a=>t({output:a.target.value}),rows:3,placeholder:r("ai.refine_example_output_placeholder_v2")??"",className:"w-full resize-y border border-te-gray/40 bg-te-surface p-2 font-sans text-sm leading-relaxed text-te-fg outline-none transition-colors focus:border-te-accent"})]}),f.jsxs("label",{className:"flex flex-col gap-1.5",children:[f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:r("ai.refine_example_focus_label")}),f.jsx("input",{type:"text",value:e.focus,onChange:a=>t({focus:a.target.value}),placeholder:r("ai.refine_example_focus_placeholder_v2")??"",className:"w-full border border-te-gray/40 bg-te-surface px-3 py-1.5 font-sans text-sm text-te-fg outline-none transition-colors focus:border-te-accent"})]})]})}function zq({scenarios:e,onChange:t}){const{t:n}=he("settings"),r=Y(u=>u.general.interfaceLang),i=Y(u=>u.dictation.lang),a=Ln(i,r),o=e??cs[a],s=e!==null,l=(u,p)=>{const g=(e??cs[a]).map((y,x)=>x===u?{...y,...p}:y);t(g)},c=u=>{const h=(e??cs[a]).filter((g,y)=>y!==u);t(h)},d=()=>{const u=e??cs[a],p=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`scn_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,h=[...u,{id:p,name:n("ai.polish_scenario_default_name"),instruction:""}];t(h)};return f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{className:"flex items-end justify-between gap-3",children:[f.jsxs("div",{children:[f.jsx("div",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:n("ai.polish_scenarios_title")}),f.jsx("div",{className:"mt-1 font-sans text-xs text-te-light-gray/80",children:n("ai.polish_scenarios_hint")})]}),f.jsxs("button",{type:"button",disabled:!s,onClick:()=>t(null),className:"inline-flex items-center gap-1.5 border border-te-gray bg-te-surface px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray transition-colors enabled:hover:border-te-accent enabled:hover:text-te-accent disabled:cursor-not-allowed disabled:opacity-40",children:[f.jsx(Fa,{className:"size-3"}),n("ai.prompt_reset")]})]}),o.length===0?f.jsx("div",{className:"border border-dashed border-te-gray/40 px-4 py-6 text-center font-mono text-xs text-te-light-gray",children:n("ai.polish_scenarios_empty")}):f.jsx("div",{className:"flex flex-col gap-3",children:o.map((u,p)=>f.jsxs("div",{className:"flex flex-col gap-2 border border-te-gray/40 bg-te-surface/50 px-3 py-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"text",value:u.name,onChange:h=>l(p,{name:h.target.value}),className:"flex-1 border border-te-gray/40 bg-te-surface px-3 py-1.5 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"}),f.jsxs("button",{type:"button",onClick:()=>c(p),className:"inline-flex items-center gap-1 border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:border-red-400 hover:text-red-400",children:[f.jsx(Mr,{className:"size-3"}),n("ai.polish_scenario_remove")]})]}),f.jsx("textarea",{value:u.instruction,onChange:h=>l(p,{instruction:h.target.value}),rows:3,placeholder:n("ai.polish_scenario_instruction_placeholder")??"",className:"w-full resize-y border border-te-gray/40 bg-te-surface p-2 font-mono text-xs text-te-fg outline-none transition-colors focus:border-te-accent"})]},u.id))}),f.jsx("div",{children:f.jsxs("button",{type:"button",onClick:d,className:"inline-flex items-center gap-2 border border-te-gray/60 px-4 py-2 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(ws,{className:"size-3.5"}),n("ai.polish_scenario_add")]})})]})}const Fq="openspeech://hotkey-recording",Bq=4e3,PS=8e3,sw={comfortable:{row:"py-5",label:"text-sm",hint:"mt-1 text-[11px] text-te-light-gray/70",button:"h-[44px] w-[20rem]",chip:"h-7 min-w-[1.75rem] px-2 text-xs",chipSep:"text-xs",placeholder:"text-xs tracking-[0.18em]"},compact:{row:"py-3",label:"text-sm",hint:null,button:"h-[34px] min-w-[12rem]",chip:"h-5 min-w-[1.4rem] px-1.5 text-[11px]",chipSep:"text-[10px]",placeholder:"text-[11px] tracking-[0.15em]"}};function lw({filterIds:e,divided:t=!0,size:n="compact"}){const r=e&&e.length>0?e:Db;return f.jsx("div",{className:se(t&&"divide-y divide-te-gray/30"),children:r.map(i=>f.jsx(Hq,{id:i,size:n},i))})}function Hq({id:e,size:t}){const n=sw[t],{t:r}=he(),i=sn(),a=mn(z=>z.bindings[e]),o=mn(z=>z.allowSpecialKeys),s=mn(z=>z.setBinding),l=mn(z=>z.recordUndo),c=mn(z=>z.applyUndo),d=Ke(z=>z.clearHotkeyConflict),[u,p]=m.useState({kind:"idle"}),h=m.useRef(null),g=m.useRef(null),y=m.useRef(null),x=m.useRef([]),v=m.useRef([]),_=m.useRef({}),b=m.useRef(!1),k=m.useRef(!1),S=m.useRef(!1),w=m.useRef({}),E=()=>{const{down:z,up:L}=w.current;z&&document.removeEventListener("keydown",z,{capture:!0}),L&&document.removeEventListener("keyup",L,{capture:!0}),w.current={}},j=()=>{E();const z=B=>{B.preventDefault(),B.stopPropagation(),B.stopImmediatePropagation(),M.current(B.code)},L=B=>{I.current(B.code)};document.addEventListener("keydown",z,{capture:!0}),document.addEventListener("keyup",L,{capture:!0}),w.current={down:z,up:L}},C=()=>{k.current||(k.current=!0,H("set_hotkey_recording",{enabled:!0}).catch(z=>console.warn("[HotkeyBinder] set_hotkey_recording(true) failed:",z)))},A=()=>{k.current&&(k.current=!1,H("set_hotkey_recording",{enabled:!1}).catch(z=>console.warn("[HotkeyBinder] set_hotkey_recording(false) failed:",z)))},R=()=>{u.kind!=="recording"&&(x.current=[],v.current=[],_.current={},b.current=!1,S.current=!1,y.current&&(window.clearTimeout(y.current),y.current=null),j(),C(),p({kind:"recording",everPressedMods:[],everPressedSides:{}}),g.current&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{E(),A(),p({kind:"idle"})},Bq))},P=()=>{E(),A(),g.current&&(window.clearTimeout(g.current),g.current=null),p({kind:"idle"})};m.useEffect(()=>()=>{E(),A(),g.current&&window.clearTimeout(g.current),y.current&&window.clearTimeout(y.current)},[]);const D=z=>{E(),A(),g.current&&(window.clearTimeout(g.current),g.current=null),y.current&&window.clearTimeout(y.current),p({kind:"error",message:z}),y.current=window.setTimeout(()=>{y.current=null,p({kind:"idle"})},2500)};m.useEffect(()=>{if(u.kind!=="recording")return;const z=B=>{h.current&&!h.current.contains(B.target)&&P()},L=()=>{window.setTimeout(()=>{document.visibilityState==="hidden"&&P()},800)};return window.addEventListener("mousedown",z),window.addEventListener("blur",L),()=>{window.removeEventListener("mousedown",z),window.removeEventListener("blur",L)}},[u.kind]);const O=async z=>{await s(e,z),d(e)},M=m.useRef(()=>{}),I=m.useRef(()=>{});M.current=z=>{if(S.current)return;if(z==="Escape"){P();return}if(u_(z)){const X=fp(z);if(!X)return;const Z=Lb(z),ne=x.current.includes(X),fe=v.current.includes(X);if(ne&&fe)return;if(ne||(x.current=Df([...x.current,X])),!fe){v.current=Df([...v.current,X]),X!=="fn"&&Z&&(_.current={..._.current,[X]:Z});const V=v.current,oe=_.current;p(me=>me.kind==="recording"?{kind:"recording",everPressedMods:V,everPressedSides:oe}:me)}return}if(b.current)return;b.current=!0;const L=Df(x.current),B=j4(z,L,o);if(!B.ok){D(B.reason??r("dialogs:hotkey_field.error_illegal_combo"));return}const ee={kind:"combo",mods:L,code:z,modSides:TS(_.current,L)};$(ee)},I.current=z=>{if(S.current||!u_(z))return;const L=fp(z);if(L&&x.current.includes(L)&&(x.current=x.current.filter(B=>B!==L),x.current.length===0&&!b.current&&v.current.length>0)){const B={kind:"modifierOnly",mods:v.current,code:"",modSides:TS(_.current,v.current)};$(B)}};const $=z=>{if(S.current)return;S.current=!0;const L=N4(z,i,o);if(!L.ok){S.current=!1,D(L.reason??r("dialogs:hotkey_field.error_illegal_combo"));return}const B=P4(mn.getState().bindings,z,e);if(B){E(),A(),g.current&&(window.clearTimeout(g.current),g.current=null),p({kind:"conflict",with:B.with,candidate:z,reason:B.kind});return}O(z),P()};m.useEffect(()=>{if(u.kind!=="recording")return;let z=!1,L=null;return Le(Fq,B=>{const{code:ee,phase:X}=B.payload;X==="pressed"?M.current(ee):I.current(ee)}).then(B=>{z?B():L=B}),()=>{z=!0,L?.()}},[u.kind]);const U=async()=>{if(u.kind!=="conflict")return;const z=u.with,L=u.candidate,B=mn.getState().bindings[z];await s(z,null),await s(e,L),await l({replacedId:z,oldValue:B,changedId:e,newValue:L,expiresAt:Date.now()+PS}),d(e),d(z),ye(r("dialogs:hotkey_field.replaced_toast",{name:ng[z]}),{duration:PS,action:{label:r("dialogs:hotkey_field.undo"),onClick:()=>{c()}}}),P()},F=()=>{p({kind:"idle"}),requestAnimationFrame(()=>R())},T=()=>P(),J=e!=="dictate_ptt"&&!!a&&u.kind!=="recording",N=u.kind==="idle"&&a?T4(a,i):[];return f.jsxs("div",{className:se("flex flex-col gap-1.5",n.row),ref:h,children:[f.jsxs("div",{className:"flex items-center justify-between gap-4",children:[f.jsxs("div",{className:"flex flex-col",children:[f.jsx("span",{className:se("font-sans text-te-fg",n.label),children:ng[e]}),n.hint?f.jsx("span",{className:se("font-sans",n.hint),children:r(`hotkey:binding_hint.${e}`)}):null]}),f.jsxs("div",{className:"group relative",children:[f.jsx(Ut,{mode:"wait",initial:!1,children:u.kind==="recording"?f.jsx(Ae.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:se("inline-flex items-center justify-center border px-3","border-te-accent bg-te-accent/8",n.button),"aria-live":"polite",children:u.everPressedMods.length===0?f.jsx("span",{className:se("font-mono uppercase text-te-accent opacity-80 animate-[pulse_1.4s_ease-in-out_infinite]",n.placeholder),children:r("dialogs:hotkey_field.press_new")}):f.jsx(Ug,{items:u.everPressedMods.map(z=>jM(z,i,z==="fn"?null:u.everPressedSides[z]??null)),tone:"active",size:t})},"recording"):u.kind==="conflict"?f.jsx(Ae.button,{type:"button",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},onClick:F,className:se("inline-flex items-center justify-center border border-te-accent/70 bg-te-accent/8 px-3",n.button),children:f.jsx(Ug,{items:AS(u.candidate,i),tone:"active",size:t})},"conflict"):f.jsx(Ae.button,{type:"button",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},onClick:R,className:se("inline-flex items-center justify-center border px-3 transition-colors","border-te-gray/40 bg-te-surface hover:border-te-gray",u.kind==="error"&&"border-te-accent/70 animate-[shake_0.25s]",J&&"px-7",n.button),children:a?f.jsx(Ug,{items:AS(a,i),tone:"idle",size:t}):f.jsx("span",{className:se("font-mono uppercase text-te-light-gray",n.placeholder),children:r("hotkey:format.unbound")})},"display")}),J?f.jsx("button",{type:"button",title:r("dialogs:hotkey_field.clear_title"),"aria-label":r("dialogs:hotkey_field.clear_aria"),onClick:z=>{z.stopPropagation(),O(null)},onMouseDown:z=>z.stopPropagation(),className:"absolute top-1/2 right-1.5 -translate-y-1/2 flex size-5 items-center justify-center text-te-light-gray opacity-0 transition-opacity group-hover:opacity-100 hover:text-te-fg focus-visible:opacity-100",children:f.jsx(Dn,{className:"size-3.5"})}):null]})]}),f.jsxs(Ut,{initial:!1,children:[u.kind==="recording"?f.jsx(Ae.p,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"text-right font-mono text-[10px] tracking-[0.18em] text-te-light-gray/70 uppercase",children:r("dialogs:hotkey_field.recording_hint")},"hint"):null,u.kind==="error"?f.jsxs(Ae.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"flex items-center justify-end gap-1.5 font-mono text-[11px] text-te-accent",children:[f.jsx(yp,{className:"size-3"}),f.jsxs("span",{children:[r("dialogs:hotkey_field.error_prefix"),": ",u.message]})]},"error"):null,u.kind==="conflict"?f.jsxs(Ae.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"flex flex-col items-end gap-1.5 font-mono text-[11px]",children:[f.jsx("span",{className:"text-te-light-gray",children:r(`dialogs:hotkey_field.conflict_reason.${u.reason}`,{name:ng[u.with]})}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx(Vg,{variant:"ghost",onClick:T,children:r("dialogs:hotkey_field.cancel")}),f.jsxs(Vg,{variant:"ghost",onClick:F,children:[f.jsx(Fa,{className:"size-3","aria-hidden":!0}),r("dialogs:hotkey_field.rebind")]}),f.jsx(Vg,{variant:"solid",onClick:()=>{U()},children:r("dialogs:hotkey_field.replace")})]})]},"conflict-bar"):null,N.length>0?f.jsx(Ae.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"flex flex-col items-end gap-0.5 font-mono text-[11px] text-te-accent/70",children:N.map(z=>f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(yp,{className:"size-3"}),r(z)]},z))},"warning-bar"):null]})]})}function TS(e,t){const n={};for(const r of t){if(r==="fn")continue;const i=e[r];i&&(n[r]=i)}return n}function Wq({label:e,icon:t,side:n,tone:r,size:i}){return f.jsxs("span",{className:se("inline-flex items-center justify-center border font-mono leading-none normal-case",r==="active"?"border-te-accent/50 bg-te-accent/12 text-te-accent":"border-te-gray/50 bg-te-surface-hover text-te-fg",sw[i].chip),children:[t?f.jsx("span",{"aria-hidden":!0,className:"mr-1 inline-flex items-center opacity-70",children:t}):null,n?f.jsx("span",{"aria-hidden":!0,className:"mr-1 text-[0.7em] font-bold opacity-70",children:n==="left"?"L":"R"}):null,e]})}function Ug({items:e,tone:t,size:n}){return f.jsx("span",{className:"inline-flex items-center gap-1.5",children:e.map((r,i)=>f.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i>0?f.jsx("span",{className:se("font-mono leading-none",t==="active"?"text-te-accent/55":"text-te-light-gray/60",sw[n].chipSep),children:"+"}):null,f.jsx(Wq,{label:r.label,icon:r.icon,side:r.side,tone:t,size:n})]},i))})}function CM(e,t){return Fb(e,t,11)}function jM(e,t,n){return{label:Dh(e,t),icon:CM(e,t),side:$b(e,t,n)??void 0}}function AS(e,t){if(e.kind==="doubleTap"&&e.mods.length>0){const r=e.mods[0];return[{label:`2× ${Dh(r,t)}`,icon:CM(r,t),side:$b(r,t,qv(e,r))??void 0}]}const n=e.mods.map(r=>jM(r,t,qv(e,r)));return e.kind==="combo"&&e.code&&n.push({label:zb(e.code),icon:A4[e.code]}),n}function Vg({onClick:e,children:t,variant:n}){return f.jsx("button",{type:"button",onClick:e,onMouseDown:r=>r.stopPropagation(),className:se("inline-flex items-center gap-1 px-2.5 py-1 font-mono text-[11px] uppercase tracking-[0.15em] transition-colors",n==="solid"?"border border-te-accent bg-te-accent text-te-accent-fg hover:bg-te-accent/90":"border border-te-gray/40 text-te-light-gray hover:border-te-gray hover:text-te-fg"),children:t})}const ip=yi(e=>({forced:{},setForced:(t,n)=>e(r=>({forced:{...r.forced,[t]:n}})),clearAll:()=>e({forced:{}})}));function Uq(){const{t:e}=he("settings"),t=Y(u=>u.ui),n=Y(u=>u.setShowHints),r=Y(u=>u.markHintSuccess),i=Y(u=>u.dismissHint),a=Y(u=>u.resetHint),o=Y(u=>u.resetAllHints),s=ip(u=>u.forced),l=ip(u=>u.setForced),c=ip(u=>u.clearAll),d=Object.keys(_s);return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("div",{className:"flex items-center justify-between gap-3 border border-te-accent/40 bg-te-surface px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-te-accent",children:e("dev_hints.title")}),f.jsx("span",{className:"font-mono text-[10px] text-te-light-gray",children:e("dev_hints.subtitle")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("label",{className:"flex items-center gap-2 font-mono text-[11px] text-te-fg",children:[f.jsx("input",{type:"checkbox",checked:t.showHints,onChange:u=>{n(u.target.checked)},className:"size-3.5 accent-te-accent"}),e("dev_hints.global_switch")]}),f.jsx("button",{type:"button",onClick:()=>{o(),c()},className:"border border-te-gray/60 px-2 py-1 font-mono text-[11px] uppercase tracking-[0.1em] text-te-light-gray hover:border-te-accent hover:text-te-accent",children:e("dev_hints.reset_all")})]})]}),f.jsx("div",{className:"overflow-x-auto",children:f.jsxs("table",{className:"w-full border-collapse font-mono text-[11px]",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"border-b border-te-gray/40 text-left text-te-light-gray",children:[f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_id")}),f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_category")}),f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_threshold")}),f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_success")}),f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_dismissed")}),f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_should")}),f.jsx("th",{className:"px-2 py-2",children:e("dev_hints.col_actions")})]})}),f.jsx("tbody",{children:d.map(u=>{const p=_s[u],h=t.hints[u]??{successCount:0,dismissed:!1},g=ju(t,u),y=s[u]===!0;return f.jsxs("tr",{className:"border-b border-te-gray/30 align-top text-te-fg",children:[f.jsxs("td",{className:"px-2 py-2",children:[f.jsx("div",{children:u}),f.jsx("div",{className:"mt-0.5 text-te-light-gray/80",children:p.devDescription})]}),f.jsx("td",{className:"px-2 py-2 text-te-light-gray",children:p.category}),f.jsx("td",{className:"px-2 py-2 tabular-nums",children:p.threshold}),f.jsx("td",{className:"px-2 py-2 tabular-nums",children:h.successCount}),f.jsx("td",{className:"px-2 py-2",children:h.dismissed?f.jsx("span",{className:"text-te-accent",children:e("dev_hints.yes")}):f.jsx("span",{className:"text-te-light-gray",children:e("dev_hints.no")})}),f.jsx("td",{className:"px-2 py-2",children:f.jsx("span",{className:se("px-1.5 py-0.5",g?"border border-te-accent text-te-accent":"border border-te-gray/40 text-te-light-gray"),children:e(g?"dev_hints.yes":"dev_hints.no")})}),f.jsx("td",{className:"px-2 py-2",children:f.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[f.jsx("button",{type:"button",onClick:()=>{r(u)},className:"border border-te-gray/60 px-1.5 py-0.5 text-te-light-gray hover:border-te-accent hover:text-te-accent",children:"+1"}),f.jsx("button",{type:"button",onClick:()=>{i(u)},disabled:h.dismissed,className:"border border-te-gray/60 px-1.5 py-0.5 text-te-light-gray hover:border-te-accent hover:text-te-accent disabled:opacity-40",children:e("dev_hints.dismiss")}),f.jsx("button",{type:"button",onClick:()=>{a(u)},className:"border border-te-gray/60 px-1.5 py-0.5 text-te-light-gray hover:border-te-accent hover:text-te-accent",children:e("dev_hints.reset")}),f.jsx("button",{type:"button",onClick:()=>l(u,!y),className:se("border px-1.5 py-0.5",y?"border-te-accent bg-te-accent text-te-bg":"border-te-gray/60 text-te-light-gray hover:border-te-accent hover:text-te-accent"),children:e(y?"dev_hints.forcing":"dev_hints.force")})]})})]},u)})})]})}),f.jsx("p",{className:"font-mono text-[10px] leading-relaxed text-te-light-gray/80",children:e("dev_hints.note")})]})}function Vq(){const{t:e}=he("settings");return[{id:"GENERAL",label:e("tabs.general"),icon:yH},{id:"HOTKEYS",label:e("tabs.hotkeys"),icon:sA},{id:"DICTATION",label:e("tabs.dictation"),icon:_o},{id:"AI",label:e("tabs.ai"),icon:J2},{id:"PROMPTS",label:e("tabs.prompts"),icon:ld},{id:"ABOUT",label:e("tabs.about"),icon:d0}]}function ci({children:e}){return f.jsxs("div",{className:"mt-10 mb-4 flex items-center gap-3 first:mt-0",children:[f.jsx("span",{className:"h-px w-4 bg-te-accent"}),f.jsx("h3",{className:"font-mono text-xs uppercase tracking-[0.25em] text-te-light-gray",children:e})]})}function Wt({label:e,hint:t,children:n}){return f.jsxs("div",{className:"flex items-center justify-between gap-6 border-b border-te-gray/30 py-4 last:border-b-0",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:"font-sans text-sm text-te-fg",children:e}),t?f.jsx("div",{className:"mt-1 font-sans text-xs text-te-light-gray/80",children:t}):null]}),f.jsx("div",{className:"shrink-0",children:n})]})}function ho({checked:e,onChange:t,disabled:n}){return f.jsx("button",{type:"button",disabled:n,onClick:()=>t(!e),className:se("relative flex h-[22px] w-10 items-center rounded-sm border transition-colors",e?"border-te-accent bg-te-accent":"border-te-gray/60 bg-te-gray",n&&"cursor-not-allowed opacity-40"),"aria-pressed":e,"aria-disabled":n,children:f.jsx(Ae.span,{layout:!0,transition:{type:"tween",duration:.18},className:se("size-4",e?"ml-auto mr-[2px] bg-te-accent-fg":"ml-[2px] bg-te-bg")})})}function Na({value:e,options:t,onChange:n,className:r}){const i=t.map(a=>typeof a=="string"?{value:a,label:a}:a);return f.jsxs("div",{className:se("relative inline-flex items-center border border-te-gray/40 bg-te-surface transition-colors focus-within:border-te-accent hover:border-te-gray",r),children:[f.jsx("select",{value:e,onChange:a=>n(a.target.value),className:"min-w-[10rem] cursor-pointer appearance-none bg-transparent py-2 pr-8 pl-3 font-mono text-sm text-te-fg focus:outline-none",children:i.map(a=>f.jsx("option",{value:a.value,children:a.label},a.value))}),f.jsx(ji,{className:"pointer-events-none absolute right-2 size-3.5 text-te-light-gray"})]})}function Sx({value:e,options:t,onChange:n}){return f.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:t.map(r=>{const i=r.value===e;return f.jsxs("button",{type:"button",onClick:()=>n(r.value),className:se("group relative flex flex-col items-start gap-1 border px-4 py-3 text-left transition-colors",i?"border-te-accent bg-te-accent/8 text-te-accent":"border-te-gray/40 text-te-fg hover:border-te-gray"),children:[f.jsxs("div",{className:"flex w-full items-center justify-between",children:[f.jsx("span",{className:"font-mono text-xs uppercase tracking-[0.15em]",children:r.label}),f.jsx("span",{className:se("size-2",i?"bg-te-accent":"bg-te-gray")})]}),r.hint?f.jsx("span",{className:se("font-sans text-xs",i?"text-te-accent/80":"text-te-light-gray"),children:r.hint}):null]},r.value)})})}function qq({peak:e}){const t=Math.max(0,Math.min(1,e)),n=t<.03?0:Math.sqrt(t),r=n===0?0:Math.min(5,Math.max(1,Math.ceil(n*5)));return f.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:5}).map((i,a)=>f.jsx("span",{className:se("h-4 w-6 border transition-colors",a<r?"border-te-accent bg-te-accent":"border-te-gray/40 bg-te-surface")},a))})}function Kq(){const{t:e}=he("settings"),t=Y(y=>y.general),n=Y(y=>y.setGeneral),r=Y(y=>y.dictation),i=Y(y=>y.setDictationLang),a=Y(y=>y.setDictationStreamingInject),o=Y(y=>y.setDictationClipboardCopy),s=Y(y=>y.loaded),l=Y(y=>y.ui),c=Y(y=>y.setShowHints),d=Y(y=>y.resetAllHints),u=m.useMemo(()=>Object.keys(_s),[]),p=m.useMemo(()=>u.filter(y=>{const x=l.hints[y]??{successCount:0,dismissed:!1};return!x.dismissed&&x.successCount<_s[y].threshold}).length,[u,l.hints]),g=m.useMemo(()=>t8(r.lang,t.interfaceLang),[r.lang,t.interfaceLang])===t.translateTargetLang;return f.jsxs("div",{children:[f.jsx(ci,{children:e("section.language")}),f.jsx(Wt,{label:e("general.interface_lang"),children:f.jsx(Na,{value:t.interfaceLang,onChange:y=>{n("interfaceLang",y)},options:[{value:"system",label:e("common:lang.system")},{value:"zh-CN",label:e("common:lang.zh-CN")},{value:"zh-TW",label:e("common:lang.zh-TW")},{value:"en",label:e("common:lang.en")}]})}),f.jsx(Wt,{label:e("general.dictation_output_lang"),hint:e("general.dictation_output_lang_hint"),children:f.jsx(Na,{value:r.lang==="follow_interface"?"auto":r.lang,onChange:y=>{i(y)},options:[{value:"auto",label:e("dictation_lang.auto")},{value:"zh",label:e("dictation_lang.zh")},{value:"en",label:e("dictation_lang.en")},{value:"ja",label:e("dictation_lang.ja")},{value:"ko",label:e("dictation_lang.ko")},{value:"yue",label:e("dictation_lang.yue")}]})}),f.jsx(Wt,{label:e("general.translate_target_lang"),hint:e("general.translate_target_lang_hint"),children:f.jsx(Na,{value:t.translateTargetLang,onChange:y=>{n("translateTargetLang",y)},options:[{value:"en",label:e("translate_target_lang.en")},{value:"zh",label:e("translate_target_lang.zh")},{value:"zh-TW",label:e("translate_target_lang.zh-TW")},{value:"ja",label:e("translate_target_lang.ja")},{value:"ko",label:e("translate_target_lang.ko")},{value:"fr",label:e("translate_target_lang.fr")},{value:"de",label:e("translate_target_lang.de")},{value:"es",label:e("translate_target_lang.es")}]})}),g&&f.jsx("div",{className:"-mt-2 mb-3 px-1 font-mono text-[11px] uppercase tracking-[0.15em] text-red-500",children:e("general.translate_conflict_warning")}),f.jsx(Wt,{label:e("general.translate_output_mode"),hint:e("general.translate_output_mode_hint"),children:f.jsx(Na,{value:t.translateOutputMode,onChange:y=>{n("translateOutputMode",y)},options:[{value:"target_only",label:e("translate_output_mode.target_only")},{value:"bilingual",label:e("translate_output_mode.bilingual")}]})}),f.jsx(ci,{children:e("section.behavior")}),f.jsx(Wt,{label:e("general.launch_startup"),children:f.jsx(ho,{checked:t.launchStartup,onChange:y=>{n("launchStartup",y),SM(y)}})}),f.jsx(Wt,{label:e("general.close_to_tray"),hint:e("general.close_to_tray_hint"),children:f.jsx(ho,{checked:t.closeBehavior==="HIDE",onChange:y=>{n("closeBehavior",y?"HIDE":"ASK")}})}),f.jsx(Wt,{label:e("general.update_policy"),hint:e("general.update_policy_hint"),children:f.jsx(Na,{value:t.updatePolicy,onChange:y=>{n("updatePolicy",y)},options:[{value:"PROMPT",label:e("general.update_policy_options.prompt")},{value:"AUTO",label:e("general.update_policy_options.auto")},{value:"DISABLED",label:e("general.update_policy_options.disabled")}]})}),f.jsx(ci,{children:e("section.output")}),f.jsx(Wt,{label:e("output.streaming_inject.label"),hint:e("output.streaming_inject.hint"),children:f.jsx(ho,{checked:r.streamingInject,onChange:y=>{a(y)}})}),f.jsx(Wt,{label:e("output.clipboard_copy.label"),hint:e("output.clipboard_copy.hint"),children:f.jsx(ho,{checked:r.clipboardCopy,onChange:y=>{o(y)}})}),f.jsx(ci,{children:e("section.hints")}),f.jsx(Wt,{label:e("general.show_hints"),hint:e("general.show_hints_hint"),children:f.jsx(ho,{checked:l.showHints,onChange:y=>{c(y)}})}),f.jsx(Wt,{label:e("general.reset_hints"),hint:p>0?e("general.hints_pending_count",{pending:p,total:u.length}):e("general.hints_all_learned"),children:f.jsx("button",{type:"button",onClick:()=>{d(),ye(e("general.reset_hints_done"))},className:"inline-flex items-center gap-2 border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:e("general.reset_hints_action")})}),s?null:f.jsx("div",{className:"mt-6 font-mono text-xs text-te-light-gray/70",children:e("general.loading")})]})}function Gq(){const{t:e}=he("settings"),t=mn(a=>a.resetAll),[n,r]=m.useState(!1),i=async()=>{await t(),r(!1),ye.success(e("hotkeys.reset_all_done"))};return f.jsxs("div",{children:[f.jsxs("div",{className:"mt-10 mb-4 flex items-center justify-between gap-3 first:mt-0",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"h-px w-4 bg-te-accent"}),f.jsx("h3",{className:"font-mono text-xs uppercase tracking-[0.25em] text-te-light-gray",children:e("section.shortcuts")})]}),f.jsx("button",{type:"button",onClick:()=>r(!0),className:"border border-te-gray/40 bg-te-surface px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.15em] text-te-light-gray transition-colors hover:border-te-accent hover:text-te-accent",children:e("hotkeys.reset_all")})]}),f.jsx(lw,{size:"comfortable"}),f.jsx(Yq,{open:n,onOpenChange:r,onConfirm:()=>{i()}})]})}function Yq({open:e,onOpenChange:t,onConfirm:n}){const{t:r}=he("settings");return f.jsx(ln,{open:e,onOpenChange:t,children:f.jsxs(cn,{showCloseButton:!1,className:"flex w-[92vw] max-w-sm flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-sm",children:[f.jsxs(un,{className:"border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:r("hotkeys.reset_all")}),f.jsx(fn,{className:"sr-only",children:r("hotkeys.reset_all_confirm")})]}),f.jsx("div",{className:"px-5 py-5 font-sans text-sm text-te-light-gray",children:r("hotkeys.reset_all_confirm")}),f.jsxs("div",{className:"flex items-stretch border-t border-te-dialog-border",children:[f.jsx("button",{type:"button",onClick:()=>t(!1),className:"flex-1 border-r border-te-dialog-border px-4 py-3 font-mono text-xs uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:bg-te-surface-hover hover:text-te-fg",children:r("common:actions.cancel")}),f.jsx("button",{type:"button",onClick:n,className:"flex-1 bg-te-accent px-4 py-3 font-mono text-xs uppercase tracking-[0.2em] text-te-accent-fg transition-colors hover:bg-te-accent/90",children:r("common:actions.confirm")})]})]})})}function Xq(){const{t:e}=he("settings"),t=Y(w=>w.general),n=Y(w=>w.setGeneral),r=Y(w=>w.loaded),i=Y(w=>w.aiRefine),a=Y(w=>w.setAiRefineEnabled),o=Y(w=>w.dictation),s=Y(w=>w.setDictationMode),l=Y(w=>w.setDictationLang),c=Y(w=>w.addDictationProvider),d=Y(w=>w.updateDictationProvider),u=Y(w=>w.removeDictationProvider),p=Y(w=>w.setActiveDictationProvider),[h,g]=m.useState([]);m.useEffect(()=>{(async()=>{const w=await RW();g(w)})()},[]);const[y,x]=m.useState(0),v=m.useRef(null);m.useEffect(()=>{let w,E=!1;const j=k0(t.inputDevice||null);return(async()=>{const C=await Le("openspeech://audio-level",A=>{const R=Math.max(0,Math.min(1,Number(A.payload)||0));x(R)});E?C():w=C})(),v.current=window.setInterval(()=>{x(C=>C>.02?C*.6:0)},150),()=>{E=!0,w?.(),Tl(),j.then(C=>{C&&Tl()}),v.current!==null&&(clearInterval(v.current),v.current=null)}},[t.inputDevice]);const _=m.useMemo(()=>h.find(w=>w.isDefault)?.name??"",[h]),b=t.inputDevice,k=b!==""&&h.some(w=>w.name===b)?b:_,S=m.useMemo(()=>{const w=[{value:"",label:_?e("device.system_default_with_current",{name:_}):e("device.system_default")}];for(const E of h)w.push({value:E.name,label:E.isDefault?e("device.is_default_suffix",{name:E.name}):E.name});return b&&!h.some(E=>E.name===b)&&w.push({value:b,label:_?e("device.disconnected_with_fallback",{name:b,fallback:_}):e("device.disconnected",{name:b})}),w},[h,b,_,e]);return f.jsxs("div",{children:[f.jsx(ci,{children:e("dictation_provider.section_mode")}),f.jsx("div",{className:"py-3",children:f.jsx(Sx,{value:o.mode,onChange:w=>{s(w)},options:[{value:"saas",label:e("dictation_provider.mode_saas_label"),hint:e("dictation_provider.mode_saas_hint")},{value:"custom",label:e("dictation_provider.mode_custom_label"),hint:e("dictation_provider.mode_custom_hint")}]})}),o.mode==="custom"&&f.jsxs(f.Fragment,{children:[f.jsx(ci,{children:e("dictation_provider.section_providers")}),o.customProviders.length===0?f.jsx("div",{className:"border border-dashed border-te-gray/40 px-4 py-6 text-center font-mono text-xs text-te-light-gray",children:e("dictation_provider.providers_empty")}):f.jsx("div",{className:"flex flex-col gap-3",children:o.customProviders.map(w=>f.jsx(eK,{provider:w,isActive:w.id===o.activeCustomProviderId,onUpdate:E=>{d(w.id,E)},onRemove:()=>{u(w.id)},onSetActive:()=>{p(w.id)}},w.id))}),f.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[f.jsxs("button",{type:"button",onClick:()=>{const w=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`dict_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;c({id:w,name:e("dictation_provider.tencent_default_name"),vendor:"tencent",tencentAppId:"",tencentRegion:"ap-shanghai"})},className:"inline-flex items-center gap-2 border border-te-gray/60 px-4 py-2 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(ws,{className:"size-3.5"}),e("dictation_provider.add_tencent")]}),f.jsxs("button",{type:"button",onClick:()=>{const w=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`dict_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;c({id:w,name:e("dictation_provider.aliyun_default_name"),vendor:"aliyun"})},className:"inline-flex items-center gap-2 border border-te-gray/60 px-4 py-2 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(ws,{className:"size-3.5"}),e("dictation_provider.add_aliyun")]})]})]}),f.jsx(ci,{children:e("section.audio")}),f.jsx(Wt,{label:e("general.input_device"),children:f.jsx(Na,{value:t.inputDevice,onChange:w=>{n("inputDevice",w)},className:"min-w-[18rem]",options:S})}),f.jsx(Wt,{label:e("general.input_level"),hint:k?e("general.input_level_hint_listening",{name:k}):e("general.input_level_hint"),children:f.jsx(qq,{peak:y})}),f.jsx(Wt,{label:e("general.cue_sound"),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ho,{checked:t.cueSound,onChange:w=>{n("cueSound",w)}}),f.jsx("button",{type:"button",className:"px-2 py-1 text-xs font-mono uppercase tracking-wider border border-te-border text-te-fg hover:bg-te-accent hover:text-te-accent-fg transition-colors",onClick:async()=>{const w=await N6();if(!w){ye.error(e("general.cue_test_failed",{defaultValue:"诊断调用失败,查看日志"}));return}const E=`enabled=${w.enabled} active=${w.active} age=${w.active_age_ms}ms mixer=${w.mixer_ready}`;w.enabled?w.mixer_ready?ye.success(e("general.cue_test_played",{defaultValue:"已播放"}),{description:E}):ye.error(e("general.cue_test_no_mixer",{defaultValue:"音频设备未就绪,检查系统输出设备"}),{description:E}):ye.warning(e("general.cue_test_disabled",{defaultValue:"提示音开关已关闭,请先打开"}),{description:E})},children:e("general.cue_test",{defaultValue:"测试"})})]})}),f.jsx(Wt,{label:e("dictation_lang.label"),hint:e("dictation_lang.hint"),children:f.jsx(Na,{value:o.lang==="follow_interface"?"auto":o.lang,onChange:w=>{l(w)},options:[{value:"auto",label:e("dictation_lang.auto")},{value:"zh",label:e("dictation_lang.zh")},{value:"en",label:e("dictation_lang.en")},{value:"ja",label:e("dictation_lang.ja")},{value:"ko",label:e("dictation_lang.ko")},{value:"yue",label:e("dictation_lang.yue")}]})}),f.jsx(ci,{children:e("section.asr_segment")}),f.jsx("div",{className:"py-3",children:f.jsx(Sx,{value:t.asrSegmentMode,onChange:w=>{n("asrSegmentMode",w)},options:[{value:"UTTERANCE",label:e("asr_segment.utterance_label"),hint:e("asr_segment.utterance_hint")},{value:"REALTIME",label:e("asr_segment.realtime_label"),hint:e("asr_segment.realtime_hint")}]})}),f.jsx(Wt,{label:e("asr_segment.ai_refine_toggle.label"),hint:t.asrSegmentMode==="REALTIME"?e("asr_segment.ai_refine_toggle.disabled_in_realtime"):e("asr_segment.ai_refine_toggle.hint"),children:f.jsx(ho,{checked:t.asrSegmentMode!=="REALTIME"&&i.enabled,disabled:t.asrSegmentMode==="REALTIME",onChange:w=>{a(w)}})}),r?null:f.jsx("div",{className:"mt-6 font-mono text-xs text-te-light-gray/70",children:e("general.loading")})]})}function Zq(){const{t:e}=he("settings"),t=Y(d=>d.aiRefine),n=Y(d=>d.setAiRefineMode),r=Y(d=>d.addAiProvider),i=Y(d=>d.updateAiProvider),a=Y(d=>d.removeAiProvider),o=Y(d=>d.setActiveAiProvider),s=Y(d=>d.setAiIncludeHistory),l=Y(d=>d.setAiRecentHistoryCount),c=Y(d=>d.setAiStripTrailingPeriod);return f.jsxs("div",{children:[f.jsx(ci,{children:e("ai.section_mode")}),f.jsx("div",{className:"py-3",children:f.jsx(Sx,{value:t.mode,onChange:d=>{n(d)},options:[{value:"saas",label:e("ai.mode_saas_label"),hint:e("ai.mode_saas_hint")},{value:"custom",label:e("ai.mode_custom_label"),hint:e("ai.mode_custom_hint")}]})}),t.mode==="custom"&&f.jsxs(f.Fragment,{children:[f.jsx(ci,{children:e("ai.section_providers")}),t.customProviders.length===0?f.jsx("div",{className:"border border-dashed border-te-gray/40 px-4 py-6 text-center font-mono text-xs text-te-light-gray",children:e("ai.providers_empty")}):f.jsx("div",{className:"flex flex-col gap-3",children:t.customProviders.map(d=>f.jsx(Jq,{provider:d,isActive:d.id===t.activeCustomProviderId,onUpdate:u=>{i(d.id,u)},onRemove:()=>{a(d.id)},onSetActive:()=>{o(d.id)}},d.id))}),f.jsx("div",{className:"mt-4 flex",children:f.jsxs("button",{type:"button",onClick:()=>{const d=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`prov_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;r({id:d,name:e("ai.provider_default_name"),baseUrl:e("ai.provider_default_base_url"),model:e("ai.provider_default_model")})},className:"inline-flex items-center gap-2 border border-te-gray/60 px-4 py-2 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(ws,{className:"size-3.5"}),e("ai.provider_add")]})})]}),f.jsx(ci,{children:e("ai.section_history")}),f.jsx(Wt,{label:e("ai.include_history"),hint:e("ai.include_history_hint"),children:f.jsx(ho,{checked:t.includeHistory,onChange:d=>{s(d)}})}),f.jsx(Wt,{label:e("ai.recent_history_count"),hint:e("ai.recent_history_count_hint"),children:f.jsx(Na,{value:String(t.recentHistoryCount),onChange:d=>{l(Number(d))},options:[{value:"3",label:"3"},{value:"5",label:"5"},{value:"10",label:"10"},{value:"15",label:"15"},{value:"20",label:"20"},{value:"30",label:"30"}]})}),f.jsx(Wt,{label:e("ai.strip_trailing_period",{defaultValue:"自动去除结尾句号"}),hint:e("ai.strip_trailing_period_hint",{defaultValue:"auto = 仅在用户原话不带句号时砍;off = 完全不动;always = 无视原话强制砍。省略号、缩写、引号闭合不动。"}),children:f.jsx(Na,{value:t.stripTrailingPeriod,onChange:d=>{c(d)},options:[{value:"auto",label:e("ai.strip_trailing_period_auto",{defaultValue:"自动"})},{value:"off",label:e("ai.strip_trailing_period_off",{defaultValue:"关闭"})},{value:"always",label:e("ai.strip_trailing_period_always",{defaultValue:"总是去除"})}]})})]})}function Qq(){const{t:e}=he("settings"),t=Y(x=>x.general.interfaceLang),n=Y(x=>x.dictation.lang),r=Ln(n,t),i=Y(x=>x.aiRefine),a=Y(x=>x.setCustomExamples),o=Y(x=>x.setAiTranslationSystemPrompt),s=Y(x=>x.setAiPolishSystemPrompt),l=Y(x=>x.setAiMeetingSummaryPrompt),c=Y(x=>x.setPolishScenarios),[d,u]=m.useState("refine"),p=[{id:"refine",label:e("ai.prompt_tab_refine")},{id:"translate",label:e("ai.prompt_tab_translate")},{id:"polish",label:e("ai.prompt_tab_polish")},{id:"meeting",label:e("ai.prompt_tab_meeting")}],h=dA[r],g=pA[r],y=fA[r];return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsx("p",{className:"font-sans text-xs leading-relaxed text-te-light-gray",children:e("ai.prompts_intro")}),f.jsx("div",{className:"flex items-center gap-px border-b border-te-gray/30",children:p.map(x=>{const v=x.id===d;return f.jsx("button",{type:"button",onClick:()=>u(x.id),className:se("relative -mb-px border-b-2 px-4 py-2 font-mono text-[11px] uppercase tracking-[0.2em] transition-colors",v?"border-te-accent text-te-accent":"border-transparent text-te-light-gray hover:text-te-fg"),children:x.label},x.id)})}),f.jsxs("div",{className:"pt-2",children:[d==="refine"&&f.jsxs("div",{className:"flex flex-col gap-6",children:[f.jsx("p",{className:"font-sans text-xs leading-relaxed text-te-light-gray",children:e("ai.refine_panel_intro")}),f.jsx(Lq,{examples:i.customExamples,onChange:x=>{a(x)}})]}),d==="translate"&&f.jsx(Wg,{description:e("ai.prompt_desc_translate"),value:i.customTranslationSystemPrompt??h,isCustom:i.customTranslationSystemPrompt!==null,onChange:x=>{o(x)},onReset:()=>{o(null)}}),d==="polish"&&f.jsxs("div",{className:"flex flex-col gap-8",children:[f.jsx(Wg,{description:e("ai.prompt_desc_polish"),value:i.customPolishSystemPrompt??g,isCustom:i.customPolishSystemPrompt!==null,onChange:x=>{s(x)},onReset:()=>{s(null)}}),f.jsx("div",{className:"border-t border-te-gray/30 pt-6",children:f.jsx(zq,{scenarios:i.customPolishScenarios,onChange:x=>{c(x)}})})]}),d==="meeting"&&f.jsx(Wg,{description:e("ai.prompt_desc_meeting"),value:i.customMeetingSummaryPrompt??y,isCustom:i.customMeetingSummaryPrompt!==null,onChange:x=>{l(x)},onReset:()=>{l(null)}})]})]})}function Jq({provider:e,isActive:t,onUpdate:n,onRemove:r,onSetActive:i}){const{t:a}=he("settings"),o=Y(x=>x.setAiProviderVerified),[s,l]=m.useState(""),[c,d]=m.useState(!1);m.useEffect(()=>{let x=!1;return(async()=>{try{const v=await _6(e.id);!x&&v!==null&&l(v)}catch(v){console.warn("[ai-refine] load api key failed:",v)}})(),()=>{x=!0}},[e.id]);const u=async()=>{if(c)try{await w6(e.id,s),d(!1),e.verified&&await o(e.id,!1)}catch(x){console.warn("[ai-refine] save api key failed:",x)}},[p,h]=m.useState(!1),g=async()=>{if(p)return!1;h(!0);try{await u();const x=(e.baseUrl??"").trim(),v=(e.model??"").trim();if(!x||!v)return ye.error(a("ai.provider_test_fail",{message:a("ai.provider_test_missing_fields")})),e.verified&&await o(e.id,!1),!1;let _="";const k=((await Ni({mode:"custom",systemPrompt:"Reply with the single word: OK.",userText:"ping",customBaseUrl:x,customModel:v,customKeyringId:`ai_provider_${e.id}`},S=>{_+=S})).refinedText??_).trim();return console.info("[ai-refine][test] reply:",k),Oe(`[ai-refine][test] provider=${e.id} reply=${JSON.stringify(k)}`),k.length===0?(ye.error(a("ai.provider_test_fail",{message:a("ai.provider_test_empty_reply")})),e.verified&&await o(e.id,!1),!1):(ye.success(a("ai.provider_test_pass")),await o(e.id,!0),!0)}catch(x){const v=x instanceof Error?x.message:String(x);return ye.error(a("ai.provider_test_fail",{message:v})),e.verified&&await o(e.id,!1),!1}finally{h(!1)}},y=async()=>{p||!e.verified&&!await g()||i()};return f.jsxs("div",{className:se("flex flex-col gap-3 border px-4 py-3 transition-colors",t?"border-te-accent bg-te-accent/8":"border-te-gray/40"),children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:se("size-2",t?"bg-te-accent":"bg-te-gray")}),f.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:t?a("ai.provider_active"):e.id.slice(0,8)}),f.jsx("span",{className:se("border px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.2em]",e.verified?"border-te-accent/60 text-te-accent":"border-amber-500/60 text-amber-500"),children:e.verified?a("dictation_provider.verified_badge"):a("dictation_provider.unverified_badge")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[!t&&f.jsx("button",{type:"button",onClick:()=>{y()},disabled:p,className:"border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-fg transition-colors enabled:hover:border-te-accent enabled:hover:text-te-accent disabled:cursor-not-allowed disabled:opacity-50",children:a("ai.provider_set_active")}),f.jsxs("button",{type:"button",onClick:()=>{g()},disabled:p,className:"inline-flex items-center gap-1 border border-te-accent bg-te-accent px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-bg transition-colors enabled:hover:bg-te-accent/85 disabled:cursor-not-allowed disabled:opacity-50",children:[p?f.jsx(ar,{className:"size-3 animate-spin"}):f.jsx(rA,{className:"size-3"}),a(p?"ai.provider_test_running":"ai.provider_test")]}),f.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:border-red-400 hover:text-red-400",children:[f.jsx(Mr,{className:"size-3"}),a("ai.provider_remove")]})]})]}),f.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[f.jsx(Dl,{label:a("ai.provider_name"),value:e.name,onChange:x=>n({name:x})}),f.jsx(Dl,{label:a("ai.provider_model"),value:e.model,onChange:x=>n({model:x})})]}),f.jsx(Dl,{label:a("ai.provider_base_url"),value:e.baseUrl,onChange:x=>n({baseUrl:x})}),f.jsxs("div",{children:[f.jsx("div",{className:"mb-1 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:a("ai.provider_api_key")}),f.jsx("input",{type:"password",value:s,onChange:x=>{l(x.target.value),d(!0)},onBlur:()=>{u()},className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"}),f.jsx("div",{className:"mt-1 font-mono text-[11px] text-te-light-gray/80",children:a("ai.provider_api_key_hint")})]})]})}function eK({provider:e,isActive:t,onUpdate:n,onRemove:r,onSetActive:i}){const{t:a}=he("settings"),o=Y(S=>S.setDictationProviderVerified),[s,l]=m.useState(""),[c,d]=m.useState(""),[u,p]=m.useState(""),[h,g]=m.useState(!1);m.useEffect(()=>{let S=!1;return(async()=>{try{const w=await E6(e.id);if(S||!w)return;w.vendor==="aliyun"&&l(w.apiKey),w.vendor==="tencent"&&(d(w.secretId),p(w.secretKey))}catch(w){console.warn("[dictation] load credentials failed:",w)}})(),()=>{S=!0}},[e.id]);const y=async()=>{if(h)try{const S=e.vendor==="aliyun"?{vendor:"aliyun",apiKey:s}:{vendor:"tencent",secretId:c,secretKey:u};await S6(e.id,S),g(!1),e.verified&&await o(e.id,!1)}catch(S){console.warn("[dictation] save credentials failed:",S)}},[x,v]=m.useState(!1),_=async()=>{if(x)return!1;v(!0);try{if(await y(),e.vendor==="aliyun"){if(!s.trim())return ye.error(a("dictation_provider.test_fail",{message:a("dictation_provider.test_missing_fields")})),!1}else if(!(e.tencentAppId??"").trim()||!c.trim()||!u.trim())return ye.error(a("dictation_provider.test_fail",{message:a("dictation_provider.test_missing_fields")})),!1;const S=await Mq(e.vendor==="aliyun"?{vendor:"aliyun",apiKey:s}:{vendor:"tencent",appId:e.tencentAppId??"",region:e.tencentRegion??null,secretId:c,secretKey:u,cosBucket:e.tencentCosBucket??null});if(S.ok)return ye.success(a("dictation_provider.test_pass")),await o(e.id,!0),!0;const w=a(`dictation_provider.test_code.${S.code}`,{defaultValue:S.message})||S.message;return ye.error(a("dictation_provider.test_fail",{message:w})),e.verified&&await o(e.id,!1),!1}catch(S){const w=S instanceof Error?S.message:String(S);return ye.error(a("dictation_provider.test_fail",{message:w})),e.verified&&await o(e.id,!1),!1}finally{v(!1)}},b=async()=>{x||!e.verified&&!await _()||i()},k=e.vendor==="tencent"?a("dictation_provider.vendor_tencent"):a("dictation_provider.vendor_aliyun");return f.jsxs("div",{className:se("flex flex-col gap-3 border px-4 py-3 transition-colors",t?"border-te-accent bg-te-accent/8":"border-te-gray/40"),children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:se("size-2",t?"bg-te-accent":"bg-te-gray")}),f.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:t?a("dictation_provider.active_label",{vendor:k}):`${k} · ${e.id.slice(0,8)}`}),f.jsx("span",{className:se("border px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.2em]",e.verified?"border-te-accent/60 text-te-accent":"border-amber-500/60 text-amber-500"),children:e.verified?a("dictation_provider.verified_badge"):a("dictation_provider.unverified_badge")})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[!t&&f.jsx("button",{type:"button",onClick:()=>{b()},disabled:x,className:"border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-fg transition-colors enabled:hover:border-te-accent enabled:hover:text-te-accent disabled:cursor-not-allowed disabled:opacity-50",children:a("dictation_provider.set_active")}),f.jsxs("button",{type:"button",onClick:()=>{_()},disabled:x,className:"inline-flex items-center gap-1 border border-te-accent bg-te-accent px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-bg transition-colors enabled:hover:bg-te-accent/85 disabled:cursor-not-allowed disabled:opacity-50",children:[x?f.jsx(ar,{className:"size-3 animate-spin"}):f.jsx(rA,{className:"size-3"}),a(x?"dictation_provider.test_running":"dictation_provider.test")]}),f.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:border-red-400 hover:text-red-400",children:[f.jsx(Mr,{className:"size-3"}),a("dictation_provider.remove")]})]})]}),f.jsx(Dl,{label:a("dictation_provider.name_label"),value:e.name,onChange:S=>n({name:S})}),e.vendor==="tencent"?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[f.jsx(Dl,{label:a("dictation_provider.tencent_app_id"),value:e.tencentAppId??"",onChange:S=>n({tencentAppId:S}),required:!0}),f.jsx(Dl,{label:a("dictation_provider.tencent_region"),value:e.tencentRegion??"",onChange:S=>n({tencentRegion:S}),required:!0})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"mb-1 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:[a("dictation_provider.tencent_cos_bucket_label"),f.jsx(Yc,{})]}),f.jsx("input",{type:"text",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,placeholder:a("dictation_provider.tencent_cos_bucket_placeholder")??"",value:e.tencentCosBucket??"",onChange:S=>n({tencentCosBucket:S.target.value}),className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"}),f.jsx("div",{className:"mt-1 font-mono text-[11px] text-te-light-gray/80",children:a("dictation_provider.tencent_cos_bucket_hint")})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"mb-1 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:[a("dictation_provider.tencent_secret_id"),f.jsx(Yc,{})]}),f.jsx("input",{type:"text",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,value:c,onChange:S=>{d(S.target.value),g(!0)},onBlur:()=>{y()},className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"mb-1 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:[a("dictation_provider.tencent_secret_key"),f.jsx(Yc,{})]}),f.jsx("input",{type:"password",value:u,onChange:S=>{p(S.target.value),g(!0)},onBlur:()=>{y()},className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"}),f.jsx("div",{className:"mt-1 font-mono text-[11px] text-te-light-gray/80",children:a("dictation_provider.tencent_credentials_hint")})]})]}):f.jsxs("div",{children:[f.jsxs("div",{className:"mb-1 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:[a("dictation_provider.aliyun_api_key"),f.jsx(Yc,{})]}),f.jsx("input",{type:"password",value:s,onChange:S=>{l(S.target.value),g(!0)},onBlur:()=>{y()},className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"}),f.jsx("div",{className:"mt-1 font-mono text-[11px] text-te-light-gray/80",children:a("dictation_provider.aliyun_api_key_hint")})]})]})}function Yc(){return f.jsx("span",{className:"ml-1 text-red-400",children:"*"})}function Dl({label:e,value:t,onChange:n,required:r}){return f.jsxs("div",{children:[f.jsxs("div",{className:"mb-1 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray",children:[e,r?f.jsx(Yc,{}):null]}),f.jsx("input",{type:"text",value:t,onChange:i=>n(i.target.value),className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg outline-none transition-colors focus:border-te-accent"})]})}function tK(){const{t:e}=he("settings"),{t}=he("feedback"),n=ad(),r=Y(k=>k.setGeneral),i=Ke(k=>k.setSettingsOpen),a=Ke(k=>k.openFeedback),[o,s]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(null),[p,h]=m.useState(""),[g,y]=m.useState("stable");m.useEffect(()=>{fd().then(s).catch(()=>s("unknown")),H("get_update_channel").then(k=>y(k==="beta"?"beta":"stable")).catch(()=>{}),H("get_platform_info").then(k=>u({os:k.os,arch:k.arch})).catch(()=>{})},[]);const x=d?(()=>{const k=d.os==="macos"?"macOS":d.os==="windows"?"Windows":d.os==="linux"?"Linux":d.os,S=d.os==="macos"&&d.arch==="aarch64"?"Apple Silicon":d.os==="macos"&&d.arch==="x86_64"?"Intel":d.arch;return`${k} · ${S}`})():"—",v=async k=>{if(k!==g){y(k);try{await H("set_update_channel",{channel:k}),Oe(`[updater] channel switched to ${k}`)}catch(S){Pl(`[updater] channel switch failed: ${String(S?.message??S)}`)}}},_=async()=>{await r("onboardingCompleted",!1),i(!1),n("/onboarding",{replace:!0})},b=async()=>{if(!l){c(!0),Oe("[updater] about-page check start");try{const k=await a0();k?(Oe(`[updater] about-page check found: ${k.version}`),ye.message(te.t("pages:layout.tray.update_found_title"),{description:k.version,duration:3e4,action:{label:te.t("settings:about.install_now"),onClick:()=>{Qv(k,"about-page").catch(()=>{})}}})):(Oe("[updater] about-page check: no update"),ye(te.t("pages:layout.tray.update_none")))}catch(k){Pl(`[updater] about-page check failed: ${String(k?.message??k)}`),ye.error(te.t("pages:layout.tray.update_check_failed"),{description:String(k?.message??k)})}finally{c(!1)}}};return f.jsxs("div",{children:[f.jsx(ci,{children:e("section.build")}),f.jsx(Wt,{label:e("about.version"),children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"font-mono text-sm text-te-fg",children:o?`v${o}`:"—"}),f.jsxs("button",{type:"button",onClick:()=>{b()},disabled:l,className:"inline-flex items-center gap-2 border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent disabled:cursor-not-allowed disabled:opacity-60",children:[f.jsx("span",{className:se("size-1.5 bg-te-accent",l&&"animate-pulse")}),e("about.check_update")]})]})}),!1,f.jsx(Wt,{label:e("about.platform"),children:f.jsx("span",{className:"font-mono text-sm text-te-fg",children:x})}),f.jsx(Wt,{label:e("about.license"),children:f.jsx("span",{className:"font-mono text-sm text-te-fg",children:"PolyForm Noncommercial 1.0.0"})}),f.jsx(Wt,{label:e("about.source"),children:f.jsxs("a",{href:"https://github.com/OpenLoaf/OpenSpeech",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 font-mono text-sm text-te-light-gray transition-colors hover:text-te-accent",children:["github.com/OpenLoaf/OpenSpeech",f.jsx(Hh,{className:"size-3.5"})]})}),f.jsx(Wt,{label:e("about.update_channel"),children:f.jsx("div",{className:"flex items-center gap-px border border-te-gray/60",children:["stable","beta"].map(k=>{const S=g===k;return f.jsx("button",{type:"button",onClick:()=>{v(k)},className:se("px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] transition-colors",S?"bg-te-accent text-te-bg":"bg-te-bg text-te-light-gray hover:text-te-fg"),children:e(`about.update_channel_${k}`)},k)})})}),f.jsx("div",{className:"-mt-2 px-1 pb-2 font-mono text-[11px] leading-relaxed text-te-light-gray",children:e("about.update_channel_hint")}),f.jsxs("div",{className:"flex flex-wrap items-center gap-3 py-4",children:[f.jsxs("button",{type:"button",onClick:()=>{_()},className:"inline-flex items-center gap-2 border border-te-gray/60 px-5 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(tH,{className:"size-3.5"}),e("about.rerun_onboarding")]}),f.jsxs("button",{type:"button",onClick:()=>{a({returnToSettingsTab:"ABOUT"})},className:"inline-flex items-center gap-2 border border-te-gray/60 px-5 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(ld,{className:"size-3.5"}),t("menu_label")]}),f.jsxs("button",{type:"button",onClick:()=>{H("open_log_dir").catch(k=>{Pl(`open_log_dir failed: ${String(k)}`),ye.error(String(k))})},className:"inline-flex items-center gap-2 border border-te-gray/60 px-5 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:[f.jsx(iA,{className:"size-3.5"}),e("about.open_log_dir")]})]})]})}function nK({tabs:e,active:t,onChange:n,actions:r}){const i=sn()==="macos";return f.jsxs("nav",{className:"flex flex-col gap-px border border-te-gray/30 bg-te-surface",children:[e.map((a,o)=>{const s=a.id===t,l=a.icon,c=i?`⌘ ${o+1}`:`Alt + ${o+1}`;return f.jsxs("button",{type:"button",onClick:()=>n(a.id),className:se("group relative flex items-center gap-3 py-3 pr-4 pl-5 font-mono text-xs uppercase tracking-[0.2em] transition-colors",s?"bg-te-surface-hover text-te-accent":"text-te-light-gray hover:text-te-fg"),children:[f.jsx("span",{className:se("absolute top-0 left-0 h-full w-[2px] transition-colors",s?"bg-te-accent":"bg-transparent")}),f.jsx(l,{className:"size-4 shrink-0"}),f.jsx("span",{children:a.label}),f.jsx("span",{"aria-hidden":!0,className:se("ml-auto pl-4 font-mono text-[10px] normal-case tracking-normal transition-colors",s?"text-te-accent/35":"text-te-light-gray/20 group-hover:text-te-light-gray/40"),children:c})]},a.id)}),r?.map(a=>{const o=a.icon;return f.jsxs("button",{type:"button",onClick:a.onClick,className:"group relative flex items-center gap-3 py-3 pr-4 pl-5 font-mono text-xs uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:text-te-fg",children:[f.jsx("span",{className:"absolute top-0 left-0 h-full w-[2px] bg-transparent"}),f.jsx(o,{className:"size-4 shrink-0"}),f.jsx("span",{children:a.label})]},a.id)})]})}function NM({initialTab:e="GENERAL"}={}){const{t}=he("settings"),[n,r]=m.useState(e),i=Vq(),a=o=>{if(o===n)return;const s=Y.getState(),l=[];if(n==="DICTATION"&&_A(s.dictation)&&(s.setDictationMode("saas"),l.push("dictation")),n==="AI"&&kA(s.aiRefine)&&(s.setAiRefineMode("saas"),l.push("ai")),l.length>0){const c=l.length===2?t("provider_rollback.both"):t(`provider_rollback.${l[0]}`);ye.message(f.jsx("span",{className:"text-te-accent",children:t("provider_rollback.title")}),{description:t("provider_rollback.description",{which:c})})}r(o)};return m.useEffect(()=>{const o=sn()==="macos",s=l=>{if(!(o?l.metaKey&&!l.ctrlKey&&!l.altKey:l.altKey&&!l.ctrlKey&&!l.metaKey)||l.shiftKey)return;const d=Number.parseInt(l.key,10);Number.isNaN(d)||d<1||d>i.length||(l.preventDefault(),a(i[d-1].id))};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[i,n]),f.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col md:flex-row",children:[f.jsx(Ae.aside,{className:"flex w-full shrink-0 flex-col gap-6 overflow-y-auto border-b border-te-gray/30 p-3 md:w-60 md:border-b-0 md:border-r",initial:{opacity:0,x:-12},animate:{opacity:1,x:0},transition:{duration:.4},children:f.jsx(nK,{tabs:i,active:n,onChange:a})}),f.jsxs(Ae.div,{className:"min-w-0 min-h-0 flex-1 overflow-y-auto px-5 py-4",initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},children:[n==="GENERAL"&&f.jsx(Kq,{}),n==="HOTKEYS"&&f.jsx(Gq,{}),n==="DICTATION"&&f.jsx(Xq,{}),n==="AI"&&f.jsx(Zq,{}),n==="PROMPTS"&&f.jsx(Qq,{}),n==="ABOUT"&&f.jsx(tK,{}),n==="DEV_HINTS"&&f.jsx(Uq,{})]},n)]})}function rK(){const e=Y.getState();return{dictation:_A(e.dictation),ai:kA(e.aiRefine)}}function iK({open:e,onOpenChange:t,initialTab:n="GENERAL"}){const{t:r}=he("settings"),[i,a]=m.useState(null),o=d=>{if(!d){const u=rK();if(u.dictation||u.ai){a(u);return}}t(d)},s=()=>{a(null)},l=async()=>{const d=Y.getState();i?.dictation&&await d.setDictationMode("saas"),i?.ai&&await d.setAiRefineMode("saas"),a(null),t(!1)},c=i?i.dictation&&i.ai?r("provider_rollback.both"):i.dictation?r("provider_rollback.dictation"):r("provider_rollback.ai"):"";return f.jsxs(f.Fragment,{children:[f.jsx(ln,{open:e,onOpenChange:o,children:f.jsxs(cn,{className:"flex h-[82vh] w-[92vw] max-w-6xl flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-6xl",children:[f.jsxs(un,{className:"border-b border-te-dialog-border bg-te-surface-hover px-4 py-3",children:[f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:r("page.dialog_title")}),f.jsx(fn,{className:"sr-only",children:r("page.dialog_sr")})]}),f.jsx("div",{className:"flex min-h-0 flex-1",children:e?f.jsx(NM,{initialTab:n}):null})]})}),f.jsx(ln,{open:i!=null,onOpenChange:d=>{d||s()},children:f.jsxs(cn,{showCloseButton:!1,className:"flex w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-md",children:[f.jsxs(un,{className:"border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:r("provider_rollback.confirm_title")}),f.jsx(fn,{className:"sr-only",children:r("provider_rollback.confirm_title")})]}),f.jsx("div",{className:"px-5 py-5 font-sans text-sm text-te-light-gray",children:r("provider_rollback.confirm_description",{which:c})}),f.jsxs("div",{className:"flex justify-end gap-2 border-t border-te-dialog-border bg-te-surface-hover px-4 py-3",children:[f.jsx("button",{type:"button",onClick:s,className:"border border-te-gray/60 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-te-fg transition-colors hover:border-te-accent hover:text-te-accent",children:r("provider_rollback.confirm_back_to_test")}),f.jsx("button",{type:"button",onClick:()=>{l()},className:"border border-amber-500/60 bg-amber-500/10 px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.2em] text-amber-200 transition-colors hover:bg-amber-500/20",children:r("provider_rollback.confirm_proceed")})]})]})})]})}function aK({open:e,onOpenChange:t,onConfirm:n}){const{t:r}=he(),[i,a]=m.useState(!1);return f.jsx(ln,{open:e,onOpenChange:o=>{o||a(!1),t(o)},children:f.jsxs(cn,{showCloseButton:!1,className:"flex w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-md",children:[f.jsxs(un,{className:"border-b border-te-dialog-border bg-te-surface-hover px-6 py-4",children:[f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:r("dialogs:close_to_bg.title")}),f.jsx(fn,{className:"sr-only",children:r("dialogs:close_to_bg.description")})]}),f.jsxs("div",{className:"space-y-3 px-6 py-5 font-sans text-sm text-te-fg",children:[f.jsxs("p",{children:[r("dialogs:close_to_bg.body_1_prefix"),f.jsx("span",{className:"text-te-accent",children:r("dialogs:close_to_bg.body_1_highlight")}),r("dialogs:close_to_bg.body_1_suffix")]}),f.jsx("p",{className:"text-te-light-gray",children:r("dialogs:close_to_bg.body_2")}),f.jsxs("label",{className:"mt-4 flex cursor-pointer items-center gap-3 pt-2 select-none",children:[f.jsx("span",{className:se("relative flex size-4 items-center justify-center border transition-colors",i?"border-te-accent bg-te-accent":"border-te-gray/60 bg-te-surface"),children:i?f.jsx("span",{className:"size-1.5 bg-te-accent-fg","aria-hidden":!0}):null}),f.jsx("input",{type:"checkbox",checked:i,onChange:o=>a(o.target.checked),className:"sr-only"}),f.jsx("span",{className:"font-mono text-xs uppercase tracking-[0.15em] text-te-light-gray",children:r("dialogs:close_to_bg.remember")})]})]}),f.jsxs("div",{className:"flex items-stretch border-t border-te-dialog-border",children:[f.jsx("button",{type:"button",onClick:()=>n({remember:i,action:"quit"}),className:"flex-1 border-r border-te-dialog-border px-4 py-3 font-mono text-xs uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:bg-te-surface-hover hover:text-te-fg",children:r("dialogs:close_to_bg.quit")}),f.jsx("button",{type:"button",onClick:()=>n({remember:i,action:"hide"}),className:"flex-1 bg-te-accent px-4 py-3 font-mono text-xs uppercase tracking-[0.2em] text-te-accent-fg transition-colors hover:bg-te-accent/90",children:r("dialogs:close_to_bg.stay")})]})]})})}const PM={AUTH_LOGIN_TIMEOUT:"errors:auth.login_timeout",AUTH_INTERNAL:"errors:auth.internal",AUTH_NOT_AUTHENTICATED:"errors:auth.not_authenticated"};function oK(e){const t=PM[e];return t?te.t(t):e}function sK(e){return e in PM}function lK({className:e}){return f.jsxs("svg",{viewBox:"0 0 48 48",className:e,"aria-hidden":!0,children:[f.jsx("path",{fill:"#FFC107",d:"M43.611 20.083H42V20H24v8h11.303c-1.649 4.657-6.08 8-11.303 8-6.627 0-12-5.373-12-12s5.373-12 12-12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 12.955 4 4 12.955 4 24s8.955 20 20 20 20-8.955 20-20c0-1.341-.138-2.65-.389-3.917z"}),f.jsx("path",{fill:"#FF3D00",d:"M6.306 14.691l6.571 4.819C14.655 15.108 18.961 12 24 12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 16.318 4 9.656 8.337 6.306 14.691z"}),f.jsx("path",{fill:"#4CAF50",d:"M24 44c5.166 0 9.86-1.977 13.409-5.192l-6.19-5.238C29.211 35.091 26.715 36 24 36c-5.202 0-9.619-3.317-11.283-7.946l-6.522 5.025C9.505 39.556 16.227 44 24 44z"}),f.jsx("path",{fill:"#1976D2",d:"M43.611 20.083H42V20H24v8h11.303c-.792 2.237-2.231 4.166-4.087 5.571l.003-.002 6.19 5.238C36.971 39.205 44 34 44 24c0-1.341-.138-2.65-.389-3.917z"})]})}function cK({className:e}){return f.jsxs("svg",{viewBox:"0 0 48 48",className:e,"aria-hidden":!0,children:[f.jsx("path",{fill:"#09B83E",d:"M18.5 6C10.492 6 4 11.83 4 19.02c0 3.973 2.02 7.53 5.192 9.94L7.5 34l5.68-3.184c1.662.462 3.447.71 5.32.71.276 0 .55-.005.822-.016-.227-.828-.35-1.69-.35-2.576 0-5.87 5.604-10.627 12.52-10.627.325 0 .646.011.965.032C30.39 11.336 24.964 6 18.5 6zm-4.75 5.25c.966 0 1.75.784 1.75 1.75s-.784 1.75-1.75 1.75-1.75-.784-1.75-1.75.784-1.75 1.75-1.75zm9.5 0c.966 0 1.75.784 1.75 1.75s-.784 1.75-1.75 1.75-1.75-.784-1.75-1.75.784-1.75 1.75-1.75z"}),f.jsx("path",{fill:"#09B83E",d:"M44 28.87c0-5.89-5.82-10.664-13-10.664S18 22.98 18 28.87c0 5.887 5.82 10.662 13 10.662 1.54 0 3.02-.22 4.402-.623L40 41.066l-1.316-3.924C41.848 35.193 44 32.24 44 28.87zm-17.25-1.62a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm8.5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"})]})}const uK={wechat:cK,google:lK},dK=["wechat","google"];function fK(e,t){if(!e)return t("errors:auth.login_failed");if(sK(e))return oK(e);const n=e.toLowerCase();return n.includes("connection reset")?t("errors:auth.login_connection_reset"):n.includes("timed out")||n.includes("timeout")?t("errors:auth.login_timeout"):n.includes("connection refused")||n.includes("dns")||n.includes("error sending request")||n.includes("network error")?t("errors:auth.login_unreachable"):n.includes("not authenticated")?t("errors:auth.not_authenticated"):t("errors:auth.login_failed")}function pK({open:e,onOpenChange:t}){const{t:n}=he(),{loginStatus:r,loginError:i,lastProvider:a,isAuthenticated:o,startLogin:s,retryLogin:l,cancelLogin:c}=ct(),d=r==="opening"||r==="polling",u=r==="error",[p,h]=m.useState(!1);m.useEffect(()=>{e||h(!1)},[e]),m.useEffect(()=>{!e&&d&&c()},[e,d,c]),m.useEffect(()=>{if(e&&o){const y=window.setTimeout(()=>t(!1),800);return()=>window.clearTimeout(y)}},[e,o,t]);const g=o?n("dialogs:login.subtitle.success"):r==="opening"?n("dialogs:login.subtitle.opening"):r==="polling"?n("dialogs:login.subtitle.polling"):u?fK(i,n):n("dialogs:login.subtitle.idle");return f.jsx(ln,{open:e,onOpenChange:(y,x)=>{if(!y&&d&&x?.reason==="escape-key"){x.cancel(),c();return}t(y)},children:f.jsxs(cn,{className:"flex w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0",children:[f.jsxs(un,{className:"border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:n("dialogs:login.title")}),f.jsx("p",{className:"font-sans text-xs leading-snug text-te-light-gray",children:n("dialogs:login.openloaf_note")}),f.jsx(fn,{className:"sr-only",children:n("dialogs:login.description")})]}),f.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[f.jsx("div",{className:"flex flex-col gap-2",children:dK.map(y=>{const x=uK[y];return f.jsxs("button",{type:"button",disabled:d||o,onClick:()=>{s(y)},className:se("inline-flex w-full items-center justify-center gap-3 border border-te-gray bg-te-surface px-4 py-3 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors",!d&&!o?"hover:border-te-accent hover:text-te-accent":"cursor-not-allowed opacity-50"),children:[f.jsx(x,{className:"size-5"}),n(`dialogs:login.providers.${y}`)]},y)})}),d||u||o?f.jsxs("div",{className:"flex items-center justify-center gap-2 pt-1",children:[f.jsx("span",{className:se("size-1.5 shrink-0",u?"bg-red-500/70":o?"bg-green-500/80":"bg-te-accent")}),f.jsx("span",{className:se("font-mono text-[11px] uppercase tracking-[0.2em]",u?"text-red-500/90":"text-te-light-gray"),children:g}),d?f.jsx(ar,{className:"size-3.5 shrink-0 animate-spin text-te-light-gray"}):null]}):null,u?f.jsxs("div",{className:"flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a?f.jsxs("button",{type:"button",onClick:()=>{l()},className:"inline-flex items-center gap-2 border border-te-accent bg-te-accent/10 px-4 py-2 font-mono text-[11px] uppercase tracking-[0.2em] text-te-accent transition-colors hover:bg-te-accent hover:text-te-bg",children:[f.jsx(Fa,{className:"size-3.5"}),n("dialogs:login.retry")]}):null,f.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex items-center gap-2 border border-te-gray px-4 py-2 font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:border-te-fg hover:text-te-fg",children:n("dialogs:login.close")})]}),i?f.jsxs("div",{className:"flex flex-col items-center gap-1",children:[f.jsxs("button",{type:"button",onClick:()=>h(y=>!y),className:"inline-flex items-center gap-1 font-mono text-[10px] uppercase tracking-[0.25em] text-te-light-gray transition-colors hover:text-te-fg",children:[f.jsx(ji,{className:se("size-3 transition-transform",p?"rotate-180":"rotate-0")}),n(p?"dialogs:login.details_hide":"dialogs:login.details_show")]}),p?f.jsx("pre",{className:"max-h-32 w-full overflow-auto whitespace-pre-wrap break-all border border-te-gray/40 bg-te-surface/40 px-3 py-2 font-mono text-[10px] leading-relaxed text-te-light-gray",children:i}):null]}):null]}):null,d?f.jsx("button",{type:"button",onClick:()=>{c()},className:"self-center font-mono text-[11px] uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:text-te-fg",children:n("dialogs:login.cancel")}):null]})]})})}function hK({open:e,onOpenChange:t}){const{t:n}=he(),[r,i]=m.useState(!1),[a,o]=m.useState(!1);m.useEffect(()=>{if(!e)return;o(!1);const l=()=>t(!1);return window.addEventListener("online",l),()=>window.removeEventListener("online",l)},[e,t]);const s=()=>{i(!0),o(!1),window.setTimeout(()=>{navigator.onLine?t(!1):o(!0),i(!1)},350)};return f.jsx(ln,{open:e,onOpenChange:t,children:f.jsxs(cn,{showCloseButton:!0,className:"flex w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-md",children:[f.jsxs(un,{className:"flex flex-row items-center gap-2 border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(yp,{className:"size-4 shrink-0 text-te-accent","aria-hidden":!0}),f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:n("dialogs:no_internet.title")}),f.jsx(fn,{className:"sr-only",children:n("dialogs:no_internet.description")})]}),f.jsxs("div",{className:"px-5 py-5",children:[f.jsx("p",{className:"font-sans text-sm leading-relaxed text-te-light-gray",children:n("dialogs:no_internet.body")}),a?f.jsx("p",{className:"mt-2 font-mono text-[11px] uppercase tracking-[0.18em] text-te-accent",children:n("dialogs:no_internet.still_offline")}):null,f.jsx("div",{className:"mt-5 flex justify-center",children:f.jsxs("button",{type:"button",disabled:r,onClick:s,className:se("inline-flex items-center justify-center gap-2 border border-te-gray bg-te-surface px-5 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition-colors",r?"cursor-not-allowed opacity-50":"hover:border-te-accent hover:text-te-accent"),children:[f.jsx(Ra,{className:se("size-3.5",r&&"animate-spin"),"aria-hidden":!0}),n("dialogs:no_internet.retry")]})})]})]})})}const mK=["bug","feature","ui","performance","chat","other"];function gK(...e){for(const t of e){const n=t?.trim();if(n&&!(/@wechat\.local$/i.test(n)||/\.local$/i.test(n)))return n}return""}function yK({open:e,onOpenChange:t}){const{t:n}=he("feedback"),r=ct(b=>b.user),i=ct(b=>b.profile),[a,o]=m.useState("bug"),[s,l]=m.useState(""),[c,d]=m.useState(""),[u,p]=m.useState(!0),[h,g]=m.useState(!1),[y,x]=m.useState(!1);m.useEffect(()=>{e&&(o("bug"),l(""),d(gK(r?.email,i?.email)),p(!0),g(!1),x(!1))},[e,r?.email,i?.email]),m.useEffect(()=>{h||p(a==="bug")},[a,h]);const v=m.useMemo(()=>mK.map(b=>({id:b,label:n(`type.${b}`)})),[n]),_=async()=>{if(y)return;const b=s.trim();if(b.length===0){ye.error(n("validation.content_required"));return}const k=c.trim();if(k.length>0&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k)){ye.error(n("validation.email_invalid"));return}x(!0);try{const S=await fd().catch(()=>"");let w=null;if(u)try{w=await H("read_recent_log_tail")}catch(E){console.warn("[feedback] read log tail failed",E),ye.warning(n("attach_logs_failed"))}await H("openloaf_submit_feedback",{payload:{type:a,content:b,email:k||null,context:{platform:sn(),appVersion:S,userAgent:typeof navigator<"u"?navigator.userAgent:"",...w?{logs:w}:{}}}}),ye.success(n("toast.success")),t(!1)}catch(S){const w=String(S??"");w==="FEEDBACK_AUTH_LOST"?ye.error(n("toast.auth_lost")):w==="FEEDBACK_NETWORK"?ye.error(n("toast.network")):w==="FEEDBACK_TIMEOUT"?ye.error(n("toast.timeout")):ye.error(n("toast.generic",{message:w}))}finally{x(!1)}};return f.jsx(ln,{open:e,onOpenChange:t,children:f.jsxs(cn,{showCloseButton:!0,className:"flex w-[92vw] max-w-lg flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-lg",children:[f.jsxs(un,{className:"flex flex-row items-center gap-2 border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(ld,{className:"size-4 shrink-0 text-te-accent","aria-hidden":!0}),f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:n("dialog_title")}),f.jsx(fn,{className:"sr-only",children:n("dialog_description")})]}),f.jsxs("div",{className:"flex flex-col gap-5 px-5 py-5",children:[f.jsx("p",{className:"font-sans text-xs leading-relaxed text-te-light-gray",children:n("dialog_description")}),f.jsxs("div",{children:[f.jsx("label",{className:"mb-1.5 block font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:n("type_label")}),f.jsxs("div",{className:"relative inline-flex w-full items-center border border-te-gray/40 bg-te-surface transition-colors focus-within:border-te-accent hover:border-te-gray",children:[f.jsx("select",{value:a,onChange:b=>o(b.target.value),disabled:y,className:"w-full cursor-pointer appearance-none bg-transparent py-2 pr-8 pl-3 font-mono text-sm text-te-fg focus:outline-none disabled:cursor-not-allowed disabled:opacity-60",children:v.map(b=>f.jsx("option",{value:b.id,children:b.label},b.id))}),f.jsx(ji,{className:"pointer-events-none absolute right-2 size-3.5 text-te-light-gray"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"mb-1.5 block font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:n("content_label")}),f.jsx("textarea",{value:s,onChange:b=>l(b.target.value),disabled:y,placeholder:n("content_placeholder"),rows:6,className:"w-full resize-none border border-te-gray/40 bg-te-surface px-3 py-2 font-sans text-sm text-te-fg placeholder:text-te-light-gray/60 transition-colors focus:border-te-accent focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"mb-1.5 block font-mono text-[10px] uppercase tracking-[0.2em] text-te-light-gray",children:n("email_label")}),f.jsx("input",{type:"email",value:c,onChange:b=>d(b.target.value),disabled:y,placeholder:n("email_placeholder"),className:"w-full border border-te-gray/40 bg-te-surface px-3 py-2 font-mono text-sm text-te-fg placeholder:text-te-light-gray/60 transition-colors focus:border-te-accent focus:outline-none disabled:cursor-not-allowed disabled:opacity-60"}),f.jsx("p",{className:"mt-1 font-sans text-[11px] text-te-light-gray/80",children:n("email_hint")})]}),f.jsx("div",{children:f.jsxs("button",{type:"button",role:"checkbox","aria-checked":u,onClick:()=>{g(!0),p(b=>!b)},disabled:y,className:"group flex w-full items-start gap-3 text-left disabled:cursor-not-allowed disabled:opacity-60",children:[f.jsx("span",{className:se("mt-0.5 flex size-4 shrink-0 items-center justify-center border transition-colors",u?"border-te-accent bg-te-accent text-te-accent-fg":"border-te-gray/60 bg-te-surface group-hover:border-te-gray"),"aria-hidden":!0,children:u&&f.jsx(ir,{className:"size-3",strokeWidth:3})}),f.jsxs("span",{className:"flex-1",children:[f.jsx("span",{className:"block font-mono text-xs text-te-fg",children:n("attach_logs_label")}),f.jsx("span",{className:"mt-1 block font-sans text-[11px] leading-relaxed text-te-light-gray/80",children:n("attach_logs_hint")})]})]})}),f.jsxs("div",{className:"flex flex-row-reverse items-center gap-3 pt-1",children:[f.jsxs("button",{type:"button",onClick:()=>{_()},disabled:y,className:se("inline-flex items-center gap-2 border border-te-accent bg-te-accent px-5 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-accent-fg transition-colors",y?"cursor-not-allowed opacity-60":"hover:bg-te-accent/90"),children:[f.jsx(f0,{className:se("size-3.5",y&&"animate-pulse"),"aria-hidden":!0}),n(y?"submit_loading":"submit")]}),f.jsx("button",{type:"button",onClick:()=>t(!1),disabled:y,className:"inline-flex items-center gap-2 border border-te-gray bg-te-surface px-4 py-2.5 font-mono text-xs uppercase tracking-[0.2em] text-te-light-gray transition-colors hover:border-te-gray hover:text-te-fg disabled:cursor-not-allowed disabled:opacity-60",children:n("cancel")})]})]})]})})}const OS=new Set(Db);function vK(){const{t:e}=he(),t=Ke(s=>s.hotkeyConflicts),n=Ke(s=>s.clearHotkeyConflicts),r=m.useMemo(()=>t.filter(s=>OS.has(s.id)),[t]),i=m.useMemo(()=>r.map(s=>s.id),[r]),a=i.length>0,o=s=>{if(s)return;const l=Ke.getState().hotkeyConflicts.filter(d=>OS.has(d.id));if(l.length===0){n();return}const c=mn.getState().setBinding;Promise.all(l.map(d=>c(d.id,null))).finally(()=>{n()}),ye.message(e("dialogs:hotkey_conflict.cleared_toast",{count:l.length}))};return f.jsx(ln,{open:a,onOpenChange:o,children:f.jsxs(cn,{showCloseButton:!0,className:"flex w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-md",children:[f.jsxs(un,{className:"flex flex-row items-center gap-2 border-b border-te-dialog-border bg-te-surface-hover px-5 py-4",children:[f.jsx(ko,{className:"size-4 shrink-0 text-te-accent","aria-hidden":!0}),f.jsx(dn,{className:"font-mono text-base font-bold tracking-tighter text-te-fg",children:e("dialogs:hotkey_conflict.title")}),f.jsx(fn,{className:"sr-only",children:e("dialogs:hotkey_conflict.description",{count:i.length})})]}),f.jsx("div",{className:"px-5 pt-4 pb-3 font-sans text-sm leading-relaxed text-te-light-gray",children:e("dialogs:hotkey_conflict.description",{count:i.length})}),f.jsx("div",{className:"px-5 pt-1 pb-4",children:f.jsx(lw,{filterIds:i,divided:!0})})]})})}function xK(){const{t:e}=he(),t=Ke(c=>c.authRecoveryDialog),n=Ke(c=>c.closeAuthRecoveryDialog),r=it(c=>c.items),[i,a]=m.useState(!1),o=m.useMemo(()=>t.historyId?r.find(c=>c.id===t.historyId)??null:null,[t.historyId,r]),s=m.useMemo(()=>o?(o.refined_text??o.text??"").trim():"",[o]);m.useEffect(()=>{t.open||a(!1)},[t.open]);const l=async()=>{if(s)try{await gn(s),a(!0),window.setTimeout(()=>a(!1),1800)}catch(c){console.warn("[auth-recovery] copy failed:",c)}};return f.jsx(ln,{open:t.open,onOpenChange:c=>{c||n()},children:f.jsxs(cn,{showCloseButton:!0,className:"flex w-[92vw] max-w-md flex-col !gap-0 rounded-none border border-te-dialog-border bg-te-dialog-bg p-0 shadow-2xl ring-0 sm:max-w-lg",children:[f.jsxs(un,{className:"flex flex-row items-start gap-2 border-b border-te-dialog-border bg-te-surface-hover py-4 pr-12 pl-5",children:[t.status==="pending"?f.jsx(ar,{className:"mt-0.5 size-4 shrink-0 animate-spin text-te-accent","aria-hidden":!0}):t.status==="error"?f.jsx(ko,{className:"mt-0.5 size-4 shrink-0 text-[#ff4d4d]","aria-hidden":!0}):f.jsx(lk,{className:"mt-0.5 size-4 shrink-0 text-te-accent","aria-hidden":!0}),f.jsx(dn,{className:"min-w-0 flex-1 font-mono text-base font-bold tracking-tighter text-te-fg",children:e(`dialogs:auth_recovery.title_${t.status}`)}),f.jsx(fn,{className:"sr-only",children:e(`dialogs:auth_recovery.description_${t.status}`)})]}),f.jsxs("div",{className:"flex flex-col gap-4 px-5 py-5",children:[f.jsx("p",{className:"font-sans text-sm leading-relaxed text-te-light-gray",children:e(`dialogs:auth_recovery.description_${t.status}`)}),t.status==="success"&&f.jsx("div",{className:"flex max-h-72 flex-col gap-2 overflow-hidden",children:f.jsx("div",{className:se("max-h-72 overflow-auto whitespace-pre-wrap break-words border border-te-gray/40 bg-te-surface px-3 py-2 font-sans text-sm leading-relaxed text-te-fg"),children:s||e("dialogs:auth_recovery.empty_transcript")})}),t.status==="error"&&t.errorMessage&&f.jsx("div",{className:"border border-[#ff4d4d]/40 bg-[#ff4d4d]/5 px-3 py-2 font-mono text-xs leading-relaxed break-words text-[#ff4d4d]",children:t.errorMessage}),f.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[t.status==="success"&&f.jsxs("button",{type:"button",onClick:()=>{l()},disabled:!s,className:se("inline-flex items-center justify-center gap-2 border px-4 py-2 font-mono text-xs uppercase tracking-[0.2em] transition",i?"border-te-accent bg-te-accent text-te-accent-fg":"border-te-accent text-te-accent hover:bg-te-accent hover:text-te-accent-fg",!s&&"cursor-not-allowed opacity-40 hover:bg-transparent hover:text-te-accent"),children:[i?f.jsx(lk,{className:"size-3.5","aria-hidden":!0}):f.jsx(Io,{className:"size-3.5","aria-hidden":!0}),e(i?"dialogs:auth_recovery.copied":"dialogs:auth_recovery.copy")]}),f.jsx("button",{type:"button",onClick:n,disabled:t.status==="pending",className:se("inline-flex items-center justify-center border border-te-gray bg-te-surface px-4 py-2 font-mono text-xs uppercase tracking-[0.2em] text-te-fg transition hover:border-te-accent hover:text-te-accent",t.status==="pending"&&"cursor-not-allowed opacity-40 hover:border-te-gray hover:text-te-fg"),children:e(t.status==="pending"?"dialogs:auth_recovery.close_disabled":"dialogs:auth_recovery.close")})]})]})]})})}var bK=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function cw(e){if(typeof e!="string")return!1;var t=bK;return t.includes(e)}var wK=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],_K=new Set(wK);function TM(e){return typeof e!="string"?!1:_K.has(e)}function AM(e){return typeof e=="string"&&e.startsWith("data-")}function Pi(e){if(typeof e!="object"||e===null)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(TM(n)||AM(n))&&(t[n]=e[n]);return t}function pd(e){if(e==null)return null;if(m.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Pi(t)}return typeof e=="object"&&!Array.isArray(e)?Pi(e):null}function mr(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(TM(n)||AM(n)||cw(n))&&(t[n]=e[n]);return t}function kK(e){return e==null?null:m.isValidElement(e)?mr(e.props):typeof e=="object"&&!Array.isArray(e)?mr(e):null}var SK=["children","width","height","viewBox","className","style","title","desc"];function Ex(){return Ex=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ex.apply(null,arguments)}function EK(e,t){if(e==null)return{};var n,r,i=CK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function CK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var OM=m.forwardRef((e,t)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:s,title:l,desc:c}=e,d=EK(e,SK),u=a||{width:r,height:i,x:0,y:0},p=kt("recharts-surface",o);return m.createElement("svg",Ex({},mr(d),{className:p,width:r,height:i,style:s,viewBox:"".concat(u.x," ").concat(u.y," ").concat(u.width," ").concat(u.height),ref:t}),m.createElement("title",null,l),m.createElement("desc",null,c),n)}),jK=["children","className"];function Cx(){return Cx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Cx.apply(null,arguments)}function NK(e,t){if(e==null)return{};var n,r,i=PK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function PK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Gr=m.forwardRef((e,t)=>{var{children:n,className:r}=e,i=NK(e,jK),a=kt("recharts-layer",r);return m.createElement("g",Cx({className:a},mr(i),{ref:t}),n)}),TK=m.createContext(null);function It(e){return function(){return e}}const MM=Math.cos,Dp=Math.sin,Ii=Math.sqrt,Lp=Math.PI,om=2*Lp,jx=Math.PI,Nx=2*jx,ts=1e-6,AK=Nx-ts;function RM(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function OK(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return RM;const n=10**t;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class MK{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?RM:OK(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,a,o){this._append`C${+t},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(t,n,r,i,a){if(t=+t,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,s=this._y1,l=r-t,c=i-n,d=o-t,u=s-n,p=d*d+u*u;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(p>ts)if(!(Math.abs(u*l-c*d)>ts)||!a)this._append`L${this._x1=t},${this._y1=n}`;else{let h=r-o,g=i-s,y=l*l+c*c,x=h*h+g*g,v=Math.sqrt(y),_=Math.sqrt(p),b=a*Math.tan((jx-Math.acos((y+p-x)/(2*v*_)))/2),k=b/_,S=b/v;Math.abs(k-1)>ts&&this._append`L${t+k*d},${n+k*u}`,this._append`A${a},${a},0,0,${+(u*h>d*g)},${this._x1=t+S*l},${this._y1=n+S*c}`}}arc(t,n,r,i,a,o){if(t=+t,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let s=r*Math.cos(i),l=r*Math.sin(i),c=t+s,d=n+l,u=1^o,p=o?i-a:a-i;this._x1===null?this._append`M${c},${d}`:(Math.abs(this._x1-c)>ts||Math.abs(this._y1-d)>ts)&&this._append`L${c},${d}`,r&&(p<0&&(p=p%Nx+Nx),p>AK?this._append`A${r},${r},0,1,${u},${t-s},${n-l}A${r},${r},0,1,${u},${this._x1=c},${this._y1=d}`:p>ts&&this._append`A${r},${r},0,${+(p>=jx)},${u},${this._x1=t+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function uw(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new MK(t)}function dw(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function IM(e){this._context=e}IM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function sm(e){return new IM(e)}function DM(e){return e[0]}function LM(e){return e[1]}function $M(e,t){var n=It(!0),r=null,i=sm,a=null,o=uw(s);e=typeof e=="function"?e:e===void 0?DM:It(e),t=typeof t=="function"?t:t===void 0?LM:It(t);function s(l){var c,d=(l=dw(l)).length,u,p=!1,h;for(r==null&&(a=i(h=o())),c=0;c<=d;++c)!(c<d&&n(u=l[c],c,l))===p&&((p=!p)?a.lineStart():a.lineEnd()),p&&a.point(+e(u,c,l),+t(u,c,l));if(h)return a=null,h+""||null}return s.x=function(l){return arguments.length?(e=typeof l=="function"?l:It(+l),s):e},s.y=function(l){return arguments.length?(t=typeof l=="function"?l:It(+l),s):t},s.defined=function(l){return arguments.length?(n=typeof l=="function"?l:It(!!l),s):n},s.curve=function(l){return arguments.length?(i=l,r!=null&&(a=i(r)),s):i},s.context=function(l){return arguments.length?(l==null?r=a=null:a=i(r=l),s):r},s}function sf(e,t,n){var r=null,i=It(!0),a=null,o=sm,s=null,l=uw(c);e=typeof e=="function"?e:e===void 0?DM:It(+e),t=typeof t=="function"?t:It(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?LM:It(+n);function c(u){var p,h,g,y=(u=dw(u)).length,x,v=!1,_,b=new Array(y),k=new Array(y);for(a==null&&(s=o(_=l())),p=0;p<=y;++p){if(!(p<y&&i(x=u[p],p,u))===v)if(v=!v)h=p,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),g=p-1;g>=h;--g)s.point(b[g],k[g]);s.lineEnd(),s.areaEnd()}v&&(b[p]=+e(x,p,u),k[p]=+t(x,p,u),s.point(r?+r(x,p,u):b[p],n?+n(x,p,u):k[p]))}if(_)return s=null,_+""||null}function d(){return $M().defined(i).curve(o).context(a)}return c.x=function(u){return arguments.length?(e=typeof u=="function"?u:It(+u),r=null,c):e},c.x0=function(u){return arguments.length?(e=typeof u=="function"?u:It(+u),c):e},c.x1=function(u){return arguments.length?(r=u==null?null:typeof u=="function"?u:It(+u),c):r},c.y=function(u){return arguments.length?(t=typeof u=="function"?u:It(+u),n=null,c):t},c.y0=function(u){return arguments.length?(t=typeof u=="function"?u:It(+u),c):t},c.y1=function(u){return arguments.length?(n=u==null?null:typeof u=="function"?u:It(+u),c):n},c.lineX0=c.lineY0=function(){return d().x(e).y(t)},c.lineY1=function(){return d().x(e).y(n)},c.lineX1=function(){return d().x(r).y(t)},c.defined=function(u){return arguments.length?(i=typeof u=="function"?u:It(!!u),c):i},c.curve=function(u){return arguments.length?(o=u,a!=null&&(s=o(a)),c):o},c.context=function(u){return arguments.length?(u==null?a=s=null:s=o(a=u),c):a},c}class zM{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function RK(e){return new zM(e,!0)}function IK(e){return new zM(e,!1)}const fw={draw(e,t){const n=Ii(t/Lp);e.moveTo(n,0),e.arc(0,0,n,0,om)}},DK={draw(e,t){const n=Ii(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},FM=Ii(1/3),LK=FM*2,$K={draw(e,t){const n=Ii(t/LK),r=n*FM;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},zK={draw(e,t){const n=Ii(t),r=-n/2;e.rect(r,r,n,n)}},FK=.8908130915292852,BM=Dp(Lp/10)/Dp(7*Lp/10),BK=Dp(om/10)*BM,HK=-MM(om/10)*BM,WK={draw(e,t){const n=Ii(t*FK),r=BK*n,i=HK*n;e.moveTo(0,-n),e.lineTo(r,i);for(let a=1;a<5;++a){const o=om*a/5,s=MM(o),l=Dp(o);e.lineTo(l*n,-s*n),e.lineTo(s*r-l*i,l*r+s*i)}e.closePath()}},qg=Ii(3),UK={draw(e,t){const n=-Ii(t/(qg*3));e.moveTo(0,n*2),e.lineTo(-qg*n,-n),e.lineTo(qg*n,-n),e.closePath()}},Jr=-.5,ei=Ii(3)/2,Px=1/Ii(12),VK=(Px/2+1)*3,qK={draw(e,t){const n=Ii(t/VK),r=n/2,i=n*Px,a=r,o=n*Px+n,s=-a,l=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,l),e.lineTo(Jr*r-ei*i,ei*r+Jr*i),e.lineTo(Jr*a-ei*o,ei*a+Jr*o),e.lineTo(Jr*s-ei*l,ei*s+Jr*l),e.lineTo(Jr*r+ei*i,Jr*i-ei*r),e.lineTo(Jr*a+ei*o,Jr*o-ei*a),e.lineTo(Jr*s+ei*l,Jr*l-ei*s),e.closePath()}};function KK(e,t){let n=null,r=uw(i);e=typeof e=="function"?e:It(e||fw),t=typeof t=="function"?t:It(t===void 0?64:+t);function i(){let a;if(n||(n=a=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(e=typeof a=="function"?a:It(a),i):e},i.size=function(a){return arguments.length?(t=typeof a=="function"?a:It(+a),i):t},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function $p(){}function zp(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function HM(e){this._context=e}HM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:zp(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:zp(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function GK(e){return new HM(e)}function WM(e){this._context=e}WM.prototype={areaStart:$p,areaEnd:$p,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:zp(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function YK(e){return new WM(e)}function UM(e){this._context=e}UM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:zp(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function XK(e){return new UM(e)}function VM(e){this._context=e}VM.prototype={areaStart:$p,areaEnd:$p,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function ZK(e){return new VM(e)}function MS(e){return e<0?-1:1}function RS(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(MS(a)+MS(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function IS(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Kg(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function Fp(e){this._context=e}Fp.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Kg(this,this._t0,IS(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Kg(this,IS(this,n=RS(this,e,t)),n);break;default:Kg(this,this._t0,n=RS(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function qM(e){this._context=new KM(e)}(qM.prototype=Object.create(Fp.prototype)).point=function(e,t){Fp.prototype.point.call(this,t,e)};function KM(e){this._context=e}KM.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function QK(e){return new Fp(e)}function JK(e){return new qM(e)}function GM(e){this._context=e}GM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=DS(e),i=DS(t),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function DS(e){var t,n=e.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,a[t]=4,o[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/a[t-1],a[t]-=r,o[t]-=r*o[t-1];for(i[n-1]=o[n-1]/a[n-1],t=n-2;t>=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)a[t]=2*e[t+1]-i[t+1];return[i,a]}function eG(e){return new GM(e)}function lm(e,t){this._context=e,this._t=t}lm.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function tG(e){return new lm(e,.5)}function nG(e){return new lm(e,0)}function rG(e){return new lm(e,1)}function Ss(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<s;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Tx(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function iG(e,t){return e[t]}function aG(e){const t=[];return t.key=e,t}function oG(){var e=It([]),t=Tx,n=Ss,r=iG;function i(a){var o=Array.from(e.apply(this,arguments),aG),s,l=o.length,c=-1,d;for(const u of a)for(s=0,++c;s<l;++s)(o[s][c]=[0,+r(u,o[s].key,c,a)]).data=u;for(s=0,d=dw(t(o));s<l;++s)o[d[s]].index=s;return n(o,d),o}return i.keys=function(a){return arguments.length?(e=typeof a=="function"?a:It(Array.from(a)),i):e},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:It(+a),i):r},i.order=function(a){return arguments.length?(t=a==null?Tx:typeof a=="function"?a:It(Array.from(a)),i):t},i.offset=function(a){return arguments.length?(n=a??Ss,i):n},i}function sG(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}Ss(e,t)}}function lG(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,s=0;o<i;++o)s+=e[o][n][1]||0;r[n][1]+=r[n][0]=-s/2}Ss(e,t)}}function cG(e,t){if(!(!((o=e.length)>0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var s=0,l=0,c=0;s<o;++s){for(var d=e[t[s]],u=d[r][1]||0,p=d[r-1][1]||0,h=(u-p)/2,g=0;g<s;++g){var y=e[t[g]],x=y[r][1]||0,v=y[r-1][1]||0;h+=x-v}l+=u,c+=h*u}i[r-1][1]+=i[r-1][0]=n,l&&(n-=c/l)}i[r-1][1]+=i[r-1][0]=n,Ss(e,t)}}var Gg={},Yg={},LS;function uG(){return LS||(LS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==="__proto__"}e.isUnsafeProperty=t})(Yg)),Yg}var Xg={},$S;function YM(){return $S||($S=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}e.isDeepKey=t})(Xg)),Xg}var Zg={},zS;function pw(){return zS||(zS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}e.toKey=t})(Zg)),Zg}var Qg={},Jg={},FS;function dG(){return FS||(FS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(t).join(",");const r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}e.toString=t})(Jg)),Jg}var BS;function hw(){return BS||(BS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=dG(),n=pw();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=t.toString(i);const a=[],o=i.length;if(o===0)return a;let s=0,l="",c="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),s++);s<o;){const u=i[s];c?u==="\\"&&s+1<o?(s++,l+=i[s]):u===c?c="":l+=u:d?u==='"'||u==="'"?c=u:u==="]"?(d=!1,a.push(l),l=""):l+=u:u==="["?(d=!0,l&&(a.push(l),l="")):u==="."?l&&(a.push(l),l=""):l+=u,s++}return l&&a.push(l),a}e.toPath=r})(Qg)),Qg}var HS;function mw(){return HS||(HS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=uG(),n=YM(),r=pw(),i=hw();function a(s,l,c){if(s==null)return c;switch(typeof l){case"string":{if(t.isUnsafeProperty(l))return c;const d=s[l];return d===void 0?n.isDeepKey(l)?a(s,i.toPath(l),c):c:d}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const d=s[l];return d===void 0?c:d}default:{if(Array.isArray(l))return o(s,l,c);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),t.isUnsafeProperty(l))return c;const d=s[l];return d===void 0?c:d}}}function o(s,l,c){if(l.length===0)return c;let d=s;for(let u=0;u<l.length;u++){if(d==null||t.isUnsafeProperty(l[u]))return c;d=d[l[u]]}return d===void 0?c:d}e.get=a})(Gg)),Gg}var ey,WS;function fG(){return WS||(WS=1,ey=mw().get),ey}var pG=fG();const Ql=Mi(pG);var hG=4;function wo(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:hG,n=10**t,r=Math.round(e*n)/n;return Object.is(r,-0)?0:r}function an(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.reduce((i,a,o)=>{var s=n[o-1];return typeof s=="string"?i+s+a:s!==void 0?i+wo(s)+a:i+a},"")}var Sr=e=>e===0?0:e>0?1:-1,fa=e=>typeof e=="number"&&e!=+e,Es=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,$e=e=>(typeof e=="number"||e instanceof Number)&&!fa(e),pa=e=>$e(e)||typeof e=="string",mG=0,Du=e=>{var t=++mG;return"".concat(e||"").concat(t)},Ti=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!$e(t)&&typeof t!="string")return r;var a;if(Es(t)){if(n==null)return r;var o=t.indexOf("%");a=n*parseFloat(t.slice(0,o))/100}else a=+t;return fa(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},XM=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;r<t;r++)if(!n[String(e[r])])n[String(e[r])]=!0;else return!0;return!1};function on(e,t,n){return $e(e)&&$e(t)?wo(e+n*(t-e)):t}function ZM(e,t,n){if(!(!e||!e.length))return e.find(r=>r&&(typeof t=="function"?t(r):Ql(r,t))===n)}var Gt=e=>e===null||typeof e>"u",hd=e=>Gt(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function Er(e){return e!=null}function Ls(){}var gG=["type","size","sizeType"];function Ax(){return Ax=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ax.apply(null,arguments)}function US(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function VS(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?US(Object(n),!0).forEach(function(r){yG(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):US(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function yG(e,t,n){return(t=vG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vG(e){var t=xG(e,"string");return typeof t=="symbol"?t:t+""}function xG(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function bG(e,t){if(e==null)return{};var n,r,i=wG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function wG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var QM={symbolCircle:fw,symbolCross:DK,symbolDiamond:$K,symbolSquare:zK,symbolStar:WK,symbolTriangle:UK,symbolWye:qK},_G=Math.PI/180,kG=e=>{var t="symbol".concat(hd(e));return QM[t]||fw},SG=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*_G;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},EG=(e,t)=>{QM["symbol".concat(hd(e))]=t},JM=e=>{var{type:t="circle",size:n=64,sizeType:r="area"}=e,i=bG(e,gG),a=VS(VS({},i),{},{type:t,size:n,sizeType:r}),o="circle";typeof t=="string"&&(o=t);var s=()=>{var p=kG(o),h=KK().type(p).size(SG(n,r,o)),g=h();if(g!==null)return g},{className:l,cx:c,cy:d}=a,u=mr(a);return $e(c)&&$e(d)&&$e(n)?m.createElement("path",Ax({},u,{className:kt("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(d,")"),d:s()})):null};JM.registerSymbol=EG;var eR=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,gw=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(m.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{cw(i)&&typeof n[i]=="function"&&(r[i]=(a=>n[i](n,a)))}),r},CG=(e,t,n)=>r=>(e(t,n,r),null),yw=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];cw(i)&&typeof a=="function"&&(r||(r={}),r[i]=CG(a,t,n))}),r};function qS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function jG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?qS(Object(n),!0).forEach(function(r){NG(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qS(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function NG(e,t,n){return(t=PG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function PG(e){var t=TG(e,"string");return typeof t=="symbol"?t:t+""}function TG(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function yr(e,t){var n=jG({},e),r=t,i=Object.keys(t),a=i.reduce((o,s)=>(o[s]===void 0&&r[s]!==void 0&&(o[s]=r[s]),o),n);return a}var ty={},ny={},KS;function AG(){return KS||(KS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],s=r(o,a,n);i.has(s)||i.set(s,o)}return Array.from(i.values())}e.uniqBy=t})(ny)),ny}var ry={},GS;function OG(){return GS||(GS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){return function(...i){return n.apply(this,i.slice(0,r))}}e.ary=t})(ry)),ry}var iy={},YS;function tR(){return YS||(YS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n}e.identity=t})(iy)),iy}var ay={},oy={},sy={},XS;function MG(){return XS||(XS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Number.isSafeInteger(n)&&n>=0}e.isLength=t})(sy)),sy}var ZS;function nR(){return ZS||(ZS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=MG();function n(r){return r!=null&&typeof r!="function"&&t.isLength(r.length)}e.isArrayLike=n})(oy)),oy}var ly={},QS;function RG(){return QS||(QS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="object"&&n!==null}e.isObjectLike=t})(ly)),ly}var JS;function IG(){return JS||(JS=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=nR(),n=RG();function r(i){return n.isObjectLike(i)&&t.isArrayLike(i)}e.isArrayLikeObject=r})(ay)),ay}var cy={},uy={},eE;function DG(){return eE||(eE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=mw();function n(r){return function(i){return t.get(i,r)}}e.property=n})(uy)),uy}var dy={},fy={},py={},hy={},tE;function rR(){return tE||(tE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n!==null&&(typeof n=="object"||typeof n=="function")}e.isObject=t})(hy)),hy}var my={},nE;function iR(){return nE||(nE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null||typeof n!="object"&&typeof n!="function"}e.isPrimitive=t})(my)),my}var gy={},rE;function aR(){return rE||(rE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}e.isEqualsSameValueZero=t})(gy)),gy}var iE;function LG(){return iE||(iE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=rR(),n=iR(),r=aR();function i(d,u,p){return typeof p!="function"?i(d,u,()=>{}):a(d,u,function h(g,y,x,v,_,b){const k=p(g,y,x,v,_,b);return k!==void 0?!!k:a(g,y,h,b)},new Map)}function a(d,u,p,h){if(u===d)return!0;switch(typeof u){case"object":return o(d,u,p,h);case"function":return Object.keys(u).length>0?a(d,{...u},p,h):r.isEqualsSameValueZero(d,u);default:return t.isObject(d)?typeof u=="string"?u==="":!0:r.isEqualsSameValueZero(d,u)}}function o(d,u,p,h){if(u==null)return!0;if(Array.isArray(u))return l(d,u,p,h);if(u instanceof Map)return s(d,u,p,h);if(u instanceof Set)return c(d,u,p,h);const g=Object.keys(u);if(d==null||n.isPrimitive(d))return g.length===0;if(g.length===0)return!0;if(h?.has(u))return h.get(u)===d;h?.set(u,d);try{for(let y=0;y<g.length;y++){const x=g[y];if(!n.isPrimitive(d)&&!(x in d)||u[x]===void 0&&d[x]!==void 0||u[x]===null&&d[x]!==null||!p(d[x],u[x],x,d,u,h))return!1}return!0}finally{h?.delete(u)}}function s(d,u,p,h){if(u.size===0)return!0;if(!(d instanceof Map))return!1;for(const[g,y]of u.entries()){const x=d.get(g);if(p(x,y,g,d,u,h)===!1)return!1}return!0}function l(d,u,p,h){if(u.length===0)return!0;if(!Array.isArray(d))return!1;const g=new Set;for(let y=0;y<u.length;y++){const x=u[y];let v=!1;for(let _=0;_<d.length;_++){if(g.has(_))continue;const b=d[_];let k=!1;if(p(b,x,y,d,u,h)&&(k=!0),k){g.add(_),v=!0;break}}if(!v)return!1}return!0}function c(d,u,p,h){return u.size===0?!0:d instanceof Set?l([...d],[...u],p,h):!1}e.isMatchWith=i,e.isSetMatch=c})(py)),py}var aE;function oR(){return aE||(aE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=LG();function n(r,i){return t.isMatchWith(r,i,()=>{})}e.isMatch=n})(fy)),fy}var yy={},vy={},xy={},oE;function $G(){return oE||(oE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}e.getSymbols=t})(xy)),xy}var by={},sE;function vw(){return sE||(sE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}e.getTag=t})(by)),by}var wy={},lE;function sR(){return lE||(lE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",s="[object Date]",l="[object Map]",c="[object Set]",d="[object Array]",u="[object Function]",p="[object ArrayBuffer]",h="[object Object]",g="[object Error]",y="[object DataView]",x="[object Uint8Array]",v="[object Uint8ClampedArray]",_="[object Uint16Array]",b="[object Uint32Array]",k="[object BigUint64Array]",S="[object Int8Array]",w="[object Int16Array]",E="[object Int32Array]",j="[object BigInt64Array]",C="[object Float32Array]",A="[object Float64Array]";e.argumentsTag=a,e.arrayBufferTag=p,e.arrayTag=d,e.bigInt64ArrayTag=j,e.bigUint64ArrayTag=k,e.booleanTag=i,e.dataViewTag=y,e.dateTag=s,e.errorTag=g,e.float32ArrayTag=C,e.float64ArrayTag=A,e.functionTag=u,e.int16ArrayTag=w,e.int32ArrayTag=E,e.int8ArrayTag=S,e.mapTag=l,e.numberTag=r,e.objectTag=h,e.regexpTag=t,e.setTag=c,e.stringTag=n,e.symbolTag=o,e.uint16ArrayTag=_,e.uint32ArrayTag=b,e.uint8ArrayTag=x,e.uint8ClampedArrayTag=v})(wy)),wy}var _y={},ky={},cE;function zG(){return cE||(cE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window||typeof self=="object"&&self||typeof d_=="object"&&d_||(function(){return this})()||Function("return this")();e.globalThis=t})(ky)),ky}var uE;function FG(){return uE||(uE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=zG();function n(r){return typeof t.globalThis.Buffer<"u"&&t.globalThis.Buffer.isBuffer(r)}e.isBuffer=n})(_y)),_y}var Sy={},dE;function BG(){return dE||(dE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}e.isTypedArray=t})(Sy)),Sy}var fE;function lR(){return fE||(fE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=$G(),n=vw(),r=sR(),i=FG(),a=iR(),o=BG();function s(u,p){return l(u,void 0,u,new Map,p)}function l(u,p,h,g=new Map,y=void 0){const x=y?.(u,p,h,g);if(x!==void 0)return x;if(a.isPrimitive(u))return u;if(g.has(u))return g.get(u);if(Array.isArray(u)){const v=new Array(u.length);g.set(u,v);for(let _=0;_<u.length;_++)v[_]=l(u[_],_,h,g,y);return Object.hasOwn(u,"index")&&(v.index=u.index),Object.hasOwn(u,"input")&&(v.input=u.input),v}if(u instanceof Date)return new Date(u.getTime());if(u instanceof RegExp){const v=new RegExp(u.source,u.flags);return v.lastIndex=u.lastIndex,v}if(u instanceof Map){const v=new Map;g.set(u,v);for(const[_,b]of u)v.set(_,l(b,_,h,g,y));return v}if(u instanceof Set){const v=new Set;g.set(u,v);for(const _ of u)v.add(l(_,void 0,h,g,y));return v}if(i.isBuffer(u))return u.subarray();if(o.isTypedArray(u)){const v=new(Object.getPrototypeOf(u)).constructor(u.length);g.set(u,v);for(let _=0;_<u.length;_++)v[_]=l(u[_],_,h,g,y);return v}if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer)return u.slice(0);if(u instanceof DataView){const v=new DataView(u.buffer.slice(0),u.byteOffset,u.byteLength);return g.set(u,v),c(v,u,h,g,y),v}if(typeof File<"u"&&u instanceof File){const v=new File([u],u.name,{type:u.type});return g.set(u,v),c(v,u,h,g,y),v}if(typeof Blob<"u"&&u instanceof Blob){const v=new Blob([u],{type:u.type});return g.set(u,v),c(v,u,h,g,y),v}if(u instanceof Error){const v=structuredClone(u);return g.set(u,v),v.message=u.message,v.name=u.name,v.stack=u.stack,v.cause=u.cause,v.constructor=u.constructor,c(v,u,h,g,y),v}if(u instanceof Boolean){const v=new Boolean(u.valueOf());return g.set(u,v),c(v,u,h,g,y),v}if(u instanceof Number){const v=new Number(u.valueOf());return g.set(u,v),c(v,u,h,g,y),v}if(u instanceof String){const v=new String(u.valueOf());return g.set(u,v),c(v,u,h,g,y),v}if(typeof u=="object"&&d(u)){const v=Object.create(Object.getPrototypeOf(u));return g.set(u,v),c(v,u,h,g,y),v}return u}function c(u,p,h=u,g,y){const x=[...Object.keys(p),...t.getSymbols(p)];for(let v=0;v<x.length;v++){const _=x[v],b=Object.getOwnPropertyDescriptor(u,_);(b==null||b.writable)&&(u[_]=l(p[_],_,h,g,y))}}function d(u){switch(n.getTag(u)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}e.cloneDeepWith=s,e.cloneDeepWithImpl=l,e.copyProperties=c})(vy)),vy}var pE;function HG(){return pE||(pE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=lR();function n(r){return t.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}e.cloneDeep=n})(yy)),yy}var hE;function WG(){return hE||(hE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=oR(),n=HG();function r(i){return i=n.cloneDeep(i),a=>t.isMatch(a,i)}e.matches=r})(dy)),dy}var Ey={},Cy={},jy={},mE;function UG(){return mE||(mE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=lR(),n=vw(),r=sR();function i(a,o){return t.cloneDeepWith(a,(s,l,c,d)=>{const u=o?.(s,l,c,d);if(u!==void 0)return u;if(typeof a=="object"){if(n.getTag(a)===r.objectTag&&typeof a.constructor!="function"){const p={};return d.set(a,p),t.copyProperties(p,a,c,d),p}switch(Object.prototype.toString.call(a)){case r.numberTag:case r.stringTag:case r.booleanTag:{const p=new a.constructor(a?.valueOf());return t.copyProperties(p,a),p}case r.argumentsTag:{const p={};return t.copyProperties(p,a),p.length=a.length,p[Symbol.iterator]=a[Symbol.iterator],p}default:return}}})}e.cloneDeepWith=i})(jy)),jy}var gE;function VG(){return gE||(gE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=UG();function n(r){return t.cloneDeepWith(r)}e.cloneDeep=n})(Cy)),Cy}var Ny={},Py={},yE;function cR(){return yE||(yE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return t.test(r)}}e.isIndex=n})(Py)),Py}var Ty={},vE;function qG(){return vE||(vE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=vw();function n(r){return r!==null&&typeof r=="object"&&t.getTag(r)==="[object Arguments]"}e.isArguments=n})(Ty)),Ty}var xE;function KG(){return xE||(xE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=YM(),n=cR(),r=qG(),i=hw();function a(o,s){let l;if(Array.isArray(s)?l=s:typeof s=="string"&&t.isDeepKey(s)&&o?.[s]==null?l=i.toPath(s):l=[s],l.length===0)return!1;let c=o;for(let d=0;d<l.length;d++){const u=l[d];if((c==null||!Object.hasOwn(c,u))&&!((Array.isArray(c)||r.isArguments(c))&&n.isIndex(u)&&u<c.length))return!1;c=c[u]}return!0}e.has=a})(Ny)),Ny}var bE;function GG(){return bE||(bE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=oR(),n=pw(),r=VG(),i=mw(),a=KG();function o(s,l){switch(typeof s){case"object":{Object.is(s?.valueOf(),-0)&&(s="-0");break}case"number":{s=n.toKey(s);break}}return l=r.cloneDeep(l),function(c){const d=i.get(c,s);return d===void 0?a.has(c,s):l===void 0?d===void 0:t.isMatch(d,l)}}e.matchesProperty=o})(Ey)),Ey}var wE;function YG(){return wE||(wE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=tR(),n=DG(),r=WG(),i=GG();function a(o){if(o==null)return t.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}e.iteratee=a})(cy)),cy}var _E;function XG(){return _E||(_E=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=AG(),n=OG(),r=tR(),i=IG(),a=YG();function o(s,l=r.identity){return i.isArrayLikeObject(s)?t.uniqBy(Array.from(s),n.ary(a.iteratee(l),1)):[]}e.uniqBy=o})(ty)),ty}var Ay,kE;function ZG(){return kE||(kE=1,Ay=XG().uniqBy),Ay}var QG=ZG();const SE=Mi(QG);function JG(e,t,n){return t===!0?SE(e,n):typeof t=="function"?SE(e,t):e}var xw=m.createContext(null),eY=e=>e,Zt=()=>{var e=m.useContext(xw);return e?e.store.dispatch:eY},ap=()=>{},tY=()=>ap,nY=(e,t)=>e===t;function Ve(e){var t=m.useContext(xw),n=m.useMemo(()=>t?r=>{if(r!=null)return e(r)}:ap,[t,e]);return ZO.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:tY,t?t.store.getState:ap,t?t.store.getState:ap,n,nY)}var Oy={},My={},Ry={},EE;function rY(){return EE||(EE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=t(r),s=t(i);if(o===s&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?s-o:o-s}return 0};e.compareValues=n})(Ry)),Ry}var Iy={},Dy={},CE;function uR(){return CE||(CE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="symbol"||n instanceof Symbol}e.isSymbol=t})(Dy)),Dy}var jE;function iY(){return jE||(jE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=uR(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||t.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}e.isKey=i})(Iy)),Iy}var NE;function aY(){return NE||(NE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=rY(),n=iY(),r=hw();function i(a,o,s,l){if(a==null)return[];s=l?void 0:s,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(s)||(s=s==null?[]:[s]),s=s.map(h=>String(h));const c=(h,g)=>{let y=h;for(let x=0;x<g.length&&y!=null;++x)y=y[g[x]];return y},d=(h,g)=>g==null||h==null?g:typeof h=="object"&&"key"in h?Object.hasOwn(g,h.key)?g[h.key]:c(g,h.path):typeof h=="function"?h(g):Array.isArray(h)?c(g,h):typeof g=="object"?g[h]:g,u=o.map(h=>(Array.isArray(h)&&h.length===1&&(h=h[0]),h==null||typeof h=="function"||Array.isArray(h)||n.isKey(h)?h:{key:h,path:r.toPath(h)}));return a.map(h=>({original:h,criteria:u.map(g=>d(g,h))})).slice().sort((h,g)=>{for(let y=0;y<u.length;y++){const x=t.compareValues(h.criteria[y],g.criteria[y],s[y]);if(x!==0)return x}return 0}).map(h=>h.original)}e.orderBy=i})(My)),My}var Ly={},PE;function oY(){return PE||(PE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r=1){const i=[],a=Math.floor(r),o=(s,l)=>{for(let c=0;c<s.length;c++){const d=s[c];Array.isArray(d)&&l<a?o(d,l+1):i.push(d)}};return o(n,0),i}e.flatten=t})(Ly)),Ly}var $y={},TE;function dR(){return TE||(TE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=cR(),n=nR(),r=rR(),i=aR();function a(o,s,l){return r.isObject(l)&&(typeof s=="number"&&n.isArrayLike(l)&&t.isIndex(s)&&s<l.length||typeof s=="string"&&s in l)?i.isEqualsSameValueZero(l[s],o):!1}e.isIterateeCall=a})($y)),$y}var AE;function sY(){return AE||(AE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=aY(),n=oY(),r=dR();function i(a,...o){const s=o.length;return s>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:s>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),t.orderBy(a,n.flatten(o),["asc"])}e.sortBy=i})(Oy)),Oy}var zy,OE;function lY(){return OE||(OE=1,zy=sY().sortBy),zy}var cY=lY();const cm=Mi(cY);var fR=e=>e.legend.settings,uY=e=>e.legend.size,dY=e=>e.legend.payload;re([dY,fR],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?cm(r,n):r});var lf=1;function fY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=m.useState({height:0,left:0,top:0,width:0}),r=m.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-t.height)>lf||Math.abs(o.left-t.left)>lf||Math.abs(o.top-t.top)>lf||Math.abs(o.width-t.width)>lf)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[t.width,t.height,t.top,t.left,...e]);return[t,r]}function Un(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var pY=typeof Symbol=="function"&&Symbol.observable||"@@observable",ME=pY,Fy=()=>Math.random().toString(36).substring(7).split("").join("."),hY={INIT:`@@redux/INIT${Fy()}`,REPLACE:`@@redux/REPLACE${Fy()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Fy()}`},Bp=hY;function bw(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function pR(e,t,n){if(typeof e!="function")throw new Error(Un(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Un(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Un(1));return n(pR)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,l=!1;function c(){o===a&&(o=new Map,a.forEach((x,v)=>{o.set(v,x)}))}function d(){if(l)throw new Error(Un(3));return i}function u(x){if(typeof x!="function")throw new Error(Un(4));if(l)throw new Error(Un(5));let v=!0;c();const _=s++;return o.set(_,x),function(){if(v){if(l)throw new Error(Un(6));v=!1,c(),o.delete(_),a=null}}}function p(x){if(!bw(x))throw new Error(Un(7));if(typeof x.type>"u")throw new Error(Un(8));if(typeof x.type!="string")throw new Error(Un(17));if(l)throw new Error(Un(9));try{l=!0,i=r(i,x)}finally{l=!1}return(a=o).forEach(_=>{_()}),x}function h(x){if(typeof x!="function")throw new Error(Un(10));r=x,p({type:Bp.REPLACE})}function g(){const x=u;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(Un(11));function _(){const k=v;k.next&&k.next(d())}return _(),{unsubscribe:x(_)}},[ME](){return this}}}return p({type:Bp.INIT}),{dispatch:p,subscribe:u,getState:d,replaceReducer:h,[ME]:g}}function mY(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:Bp.INIT})>"u")throw new Error(Un(12));if(typeof n(void 0,{type:Bp.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Un(13))})}function hR(e){const t=Object.keys(e),n={};for(let a=0;a<t.length;a++){const o=t[a];typeof e[o]=="function"&&(n[o]=e[o])}const r=Object.keys(n);let i;try{mY(n)}catch(a){i=a}return function(o={},s){if(i)throw i;let l=!1;const c={};for(let d=0;d<r.length;d++){const u=r[d],p=n[u],h=o[u],g=p(h,s);if(typeof g>"u")throw s&&s.type,new Error(Un(14));c[u]=g,l=l||g!==h}return l=l||r.length!==Object.keys(o).length,l?c:o}}function Hp(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function gY(...e){return t=>(n,r)=>{const i=t(n,r);let a=()=>{throw new Error(Un(15))};const o={getState:i.getState,dispatch:(l,...c)=>a(l,...c)},s=e.map(l=>l(o));return a=Hp(...s)(i.dispatch),{...i,dispatch:a}}}function mR(e){return bw(e)&&"type"in e&&typeof e.type=="string"}var gR=Symbol.for("immer-nothing"),RE=Symbol.for("immer-draftable"),gr=Symbol.for("immer-state");function _i(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Wr=Object,Jl=Wr.getPrototypeOf,Wp="constructor",um="prototype",Ox="configurable",Up="enumerable",op="writable",Lu="value",Ha=e=>!!e&&!!e[gr];function Ai(e){return e?yR(e)||fm(e)||!!e[RE]||!!e[Wp]?.[RE]||pm(e)||hm(e):!1}var yY=Wr[um][Wp].toString(),IE=new WeakMap;function yR(e){if(!e||!ww(e))return!1;const t=Jl(e);if(t===null||t===Wr[um])return!0;const n=Wr.hasOwnProperty.call(t,Wp)&&t[Wp];if(n===Object)return!0;if(!ml(n))return!1;let r=IE.get(n);return r===void 0&&(r=Function.toString.call(n),IE.set(n,r)),r===yY}function dm(e,t,n=!0){md(e)===0?(n?Reflect.ownKeys(e):Wr.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function md(e){const t=e[gr];return t?t.type_:fm(e)?1:pm(e)?2:hm(e)?3:0}var DE=(e,t,n=md(e))=>n===2?e.has(t):Wr[um].hasOwnProperty.call(e,t),Mx=(e,t,n=md(e))=>n===2?e.get(t):e[t],Vp=(e,t,n,r=md(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function vY(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var fm=Array.isArray,pm=e=>e instanceof Map,hm=e=>e instanceof Set,ww=e=>typeof e=="object",ml=e=>typeof e=="function",By=e=>typeof e=="boolean";function xY(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ca=e=>e.copy_||e.base_,_w=e=>e.modified_?e.copy_:e.base_;function Rx(e,t){if(pm(e))return new Map(e);if(hm(e))return new Set(e);if(fm(e))return Array[um].slice.call(e);const n=yR(e);if(t===!0||t==="class_only"&&!n){const r=Wr.getOwnPropertyDescriptors(e);delete r[gr];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[op]===!1&&(s[op]=!0,s[Ox]=!0),(s.get||s.set)&&(r[o]={[Ox]:!0,[op]:!0,[Up]:s[Up],[Lu]:e[o]})}return Wr.create(Jl(e),r)}else{const r=Jl(e);if(r!==null&&n)return{...e};const i=Wr.create(r);return Wr.assign(i,e)}}function kw(e,t=!1){return mm(e)||Ha(e)||!Ai(e)||(md(e)>1&&Wr.defineProperties(e,{set:cf,add:cf,clear:cf,delete:cf}),Wr.freeze(e),t&&dm(e,(n,r)=>{kw(r,!0)},!1)),e}function bY(){_i(2)}var cf={[Lu]:bY};function mm(e){return e===null||!ww(e)?!0:Wr.isFrozen(e)}var qp="MapSet",Ix="Patches",LE="ArrayMethods",vR={};function Cs(e){const t=vR[e];return t||_i(0,e),t}var $E=e=>!!vR[e],$u,xR=()=>$u,wY=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:$E(qp)?Cs(qp):void 0,arrayMethodsPlugin_:$E(LE)?Cs(LE):void 0});function zE(e,t){t&&(e.patchPlugin_=Cs(Ix),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Dx(e){Lx(e),e.drafts_.forEach(_Y),e.drafts_=null}function Lx(e){e===$u&&($u=e.parent_)}var FE=e=>$u=wY($u,e);function _Y(e){const t=e[gr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function BE(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[gr].modified_&&(Dx(t),_i(4)),Ai(e)&&(e=HE(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[gr].base_,e,t)}else e=HE(t,n);return kY(t,e,!0),Dx(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==gR?e:void 0}function HE(e,t){if(mm(t))return t;const n=t[gr];if(!n)return Kp(t,e.handledSet_,e);if(!gm(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);_R(n,e)}return n.copy_}function kY(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&kw(t,n)}function bR(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var gm=(e,t)=>e.scope_===t,SY=[];function wR(e,t,n,r){const i=Ca(e),a=e.type_;if(r!==void 0&&Mx(i,r,a)===t){Vp(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;dm(i,(l,c)=>{if(Ha(c)){const d=s.get(c)||[];d.push(l),s.set(c,d)}})}const o=e.draftLocations_.get(t)??SY;for(const s of o)Vp(i,s,n,a)}function EY(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!gm(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=_w(a);wR(e,a.draft_??a,o,n),_R(a,i)})}function _R(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}bR(e)}}function CY(e,t,n){const{scope_:r}=e;if(Ha(n)){const i=n[gr];gm(i,r)&&i.callbacks_.push(function(){sp(e);const o=_w(i);wR(e,n,o,t)})}else Ai(n)&&e.callbacks_.push(function(){const a=Ca(e);e.type_===3?a.has(n)&&Kp(n,r.handledSet_,r):Mx(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Kp(Mx(e.copy_,t,e.type_),r.handledSet_,r)})}function Kp(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Ha(e)||t.has(e)||!Ai(e)||mm(e)||(t.add(e),dm(e,(r,i)=>{if(Ha(i)){const a=i[gr];if(gm(a,n)){const o=_w(a);Vp(e,r,o,e.type_),bR(a)}}else Ai(i)&&Kp(i,t,n)})),e}function jY(e,t){const n=fm(e),r={type_:n?1:0,scope_:t?t.scope_:xR(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=Gp;n&&(i=[r],a=zu);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Gp={get(e,t){if(t===gr)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t=="string";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Ca(e);if(!DE(i,t,e.type_))return NY(e,i,t);const a=i[t];if(e.finalized_||!Ai(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&xY(t))return a;if(a===Hy(e.base_,t)){sp(e);const o=e.type_===1?+t:t,s=zx(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Ca(e)},ownKeys(e){return Reflect.ownKeys(Ca(e))},set(e,t,n){const r=kR(Ca(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Hy(Ca(e),t),a=i?.[gr];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(vY(n,i)&&(n!==void 0||DE(e.base_,t,e.type_)))return!0;sp(e),$x(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),CY(e,t,n)),!0},deleteProperty(e,t){return sp(e),Hy(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),$x(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ca(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[op]:!0,[Ox]:e.type_!==1||t!=="length",[Up]:r[Up],[Lu]:n[t]}},defineProperty(){_i(11)},getPrototypeOf(e){return Jl(e.base_)},setPrototypeOf(){_i(12)}},zu={};for(let e in Gp){let t=Gp[e];zu[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}zu.deleteProperty=function(e,t){return zu.set.call(this,e,t,void 0)};zu.set=function(e,t,n){return Gp.set.call(this,e[0],t,n,e[0])};function Hy(e,t){const n=e[gr];return(n?Ca(n):e)[t]}function NY(e,t,n){const r=kR(t,n);return r?Lu in r?r[Lu]:r.get?.call(e.draft_):void 0}function kR(e,t){if(!(t in e))return;let n=Jl(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Jl(n)}}function $x(e){e.modified_||(e.modified_=!0,e.parent_&&$x(e.parent_))}function sp(e){e.copy_||(e.assigned_=new Map,e.copy_=Rx(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var PY=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(ml(n)&&!ml(r)){const o=r;r=n;const s=this;return function(c=o,...d){return s.produce(c,u=>r.call(this,u,...d))}}ml(r)||_i(6),i!==void 0&&!ml(i)&&_i(7);let a;if(Ai(n)){const o=FE(this),s=zx(o,n,void 0);let l=!0;try{a=r(s),l=!1}finally{l?Dx(o):Lx(o)}return zE(o,i),BE(a,o)}else if(!n||!ww(n)){if(a=r(n),a===void 0&&(a=n),a===gR&&(a=void 0),this.autoFreeze_&&kw(a,!0),i){const o=[],s=[];Cs(Ix).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:s}),i(o,s)}return a}else _i(1,n)},this.produceWithPatches=(n,r)=>{if(ml(n))return(s,...l)=>this.produceWithPatches(s,c=>n(c,...l));let i,a;return[this.produce(n,r,(s,l)=>{i=s,a=l}),i,a]},By(t?.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),By(t?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),By(t?.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Ai(t)||_i(8),Ha(t)&&(t=ui(t));const n=FE(this),r=zx(n,t,void 0);return r[gr].isManual_=!0,Lx(n),r}finishDraft(t,n){const r=t&&t[gr];(!r||!r.isManual_)&&_i(9);const{scope_:i}=r;return zE(i,n),BE(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Cs(Ix).applyPatches_;return Ha(t)?i(t,n):this.produce(t,a=>i(a,n))}};function zx(e,t,n,r){const[i,a]=pm(t)?Cs(qp).proxyMap_(t,n):hm(t)?Cs(qp).proxySet_(t,n):jY(t,n);return(n?.scope_??xR()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?EY(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:c}=l;a.modified_&&c&&c.generatePatches_(a,[],l)}),i}function ui(e){return Ha(e)||_i(10,e),SR(e)}function SR(e){if(!Ai(e)||mm(e))return e;const t=e[gr];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Rx(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Rx(e,!0);return dm(n,(i,a)=>{Vp(n,i,SR(a))},r),t&&(t.finalized_=!1),n}var TY=new PY,ER=TY.produce;function CR(e){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,e):i(a)}var AY=CR(),OY=CR,MY=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Hp:Hp.apply(null,arguments)};function Yr(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(Vr(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>mR(r)&&r.type===e,n}var jR=class Xc extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Xc.prototype)}static get[Symbol.species](){return Xc}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Xc(...t[0].concat(this)):new Xc(...t.concat(this))}};function WE(e){return Ai(e)?ER(e,()=>{}):e}function uf(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function RY(e){return typeof e=="boolean"}var IY=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=t??{};let o=new jR;return n&&(RY(n)?o.push(AY):o.push(OY(n.extraArgument))),o},NR="RTK_autoBatch",zt=()=>e=>({payload:e,meta:{[NR]:!0}}),UE=e=>t=>{setTimeout(t,e)},PR=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,a=!1,o=!1;const s=new Set,l=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:UE(10):e.type==="callback"?e.queueNotification:UE(e.timeout),c=()=>{o=!1,a&&(a=!1,s.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const u=()=>i&&d(),p=r.subscribe(u);return s.add(d),()=>{p(),s.delete(d)}},dispatch(d){try{return i=!d?.meta?.[NR],a=!i,a&&(o||(o=!0,l(c))),r.dispatch(d)}finally{i=!0}}})},DY=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new jR(e);return r&&i.push(PR(typeof r=="object"?r:void 0)),i};function LY(e){const t=IY(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=e||{};let s;if(typeof n=="function")s=n;else if(bw(n))s=hR(n);else throw new Error(Vr(1));let l;typeof r=="function"?l=r(t):l=t();let c=Hp;i&&(c=MY({trace:!1,...typeof i=="object"&&i}));const d=gY(...l),u=DY(d);let p=typeof o=="function"?o(u):u();const h=c(...p);return pR(s,a,h)}function TR(e){const t={},n=[];let r;const i={addCase(a,o){const s=typeof a=="string"?a:a.type;if(!s)throw new Error(Vr(28));if(s in t)throw new Error(Vr(29));return t[s]=o,i},addAsyncThunk(a,o){return o.pending&&(t[a.pending.type]=o.pending),o.rejected&&(t[a.rejected.type]=o.rejected),o.fulfilled&&(t[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return e(i),[t,n,r]}function $Y(e){return typeof e=="function"}function zY(e,t){let[n,r,i]=TR(t),a;if($Y(e))a=()=>WE(e());else{const s=WE(e);a=()=>s}function o(s=a(),l){let c=[n[l.type],...r.filter(({matcher:d})=>d(l)).map(({reducer:d})=>d)];return c.filter(d=>!!d).length===0&&(c=[i]),c.reduce((d,u)=>{if(u)if(Ha(d)){const h=u(d,l);return h===void 0?d:h}else{if(Ai(d))return ER(d,p=>u(p,l));{const p=u(d,l);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},s)}return o.getInitialState=a,o}var FY="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",BY=(e=21)=>{let t="",n=e;for(;n--;)t+=FY[Math.random()*64|0];return t},HY=Symbol.for("rtk-slice-createasyncthunk");function WY(e,t){return`${e}/${t}`}function UY({creators:e}={}){const t=e?.asyncThunk?.[HY];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Vr(11));const o=(typeof r.reducers=="function"?r.reducers(qY()):r.reducers)||{},s=Object.keys(o),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(b,k){const S=typeof b=="string"?b:b.type;if(!S)throw new Error(Vr(12));if(S in l.sliceCaseReducersByType)throw new Error(Vr(13));return l.sliceCaseReducersByType[S]=k,c},addMatcher(b,k){return l.sliceMatchers.push({matcher:b,reducer:k}),c},exposeAction(b,k){return l.actionCreators[b]=k,c},exposeCaseReducer(b,k){return l.sliceCaseReducersByName[b]=k,c}};s.forEach(b=>{const k=o[b],S={reducerName:b,type:WY(i,b),createNotation:typeof r.reducers=="function"};GY(k)?XY(S,k,c,t):KY(S,k,c)});function d(){const[b={},k=[],S=void 0]=typeof r.extraReducers=="function"?TR(r.extraReducers):[r.extraReducers],w={...b,...l.sliceCaseReducersByType};return zY(r.initialState,E=>{for(let j in w)E.addCase(j,w[j]);for(let j of l.sliceMatchers)E.addMatcher(j.matcher,j.reducer);for(let j of k)E.addMatcher(j.matcher,j.reducer);S&&E.addDefaultCase(S)})}const u=b=>b,p=new Map,h=new WeakMap;let g;function y(b,k){return g||(g=d()),g(b,k)}function x(){return g||(g=d()),g.getInitialState()}function v(b,k=!1){function S(E){let j=E[b];return typeof j>"u"&&k&&(j=uf(h,S,x)),j}function w(E=u){const j=uf(p,k,()=>new WeakMap);return uf(j,E,()=>{const C={};for(const[A,R]of Object.entries(r.selectors??{}))C[A]=VY(R,E,()=>uf(h,E,x),k);return C})}return{reducerPath:b,getSelectors:w,get selectors(){return w(S)},selectSlice:S}}const _={name:i,reducer:y,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:x,...v(a),injectInto(b,{reducerPath:k,...S}={}){const w=k??a;return b.inject({reducerPath:w,reducer:y},S),{..._,...v(w,!0)}}};return _}}function VY(e,t,n,r){function i(a,...o){let s=t(a);return typeof s>"u"&&r&&(s=n()),e(s,...o)}return i.unwrapped=e,i}var sr=UY();function qY(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function KY({type:e,reducerName:t,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!YY(r))throw new Error(Vr(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?Yr(e,o):Yr(e))}function GY(e){return e._reducerDefinitionType==="asyncThunk"}function YY(e){return e._reducerDefinitionType==="reducerWithPrepare"}function XY({type:e,reducerName:t},n,r,i){if(!i)throw new Error(Vr(18));const{payloadCreator:a,fulfilled:o,pending:s,rejected:l,settled:c,options:d}=n,u=i(e,a,d);r.exposeAction(t,u),o&&r.addCase(u.fulfilled,o),s&&r.addCase(u.pending,s),l&&r.addCase(u.rejected,l),c&&r.addMatcher(u.settled,c),r.exposeCaseReducer(t,{fulfilled:o||df,pending:s||df,rejected:l||df,settled:c||df})}function df(){}var ZY="task",AR="listener",OR="completed",Sw="cancelled",QY=`task-${Sw}`,JY=`task-${OR}`,Fx=`${AR}-${Sw}`,eX=`${AR}-${OR}`,ym=class{constructor(e){this.code=e,this.message=`${ZY} ${Sw} (reason: ${e})`}name="TaskAbortError";message},Ew=(e,t)=>{if(typeof e!="function")throw new TypeError(Vr(32))},Yp=()=>{},MR=(e,t=Yp)=>(e.catch(t),e),RR=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),vs=e=>{if(e.aborted)throw new ym(e.reason)};function IR(e,t){let n=Yp;return new Promise((r,i)=>{const a=()=>i(new ym(e.reason));if(e.aborted){a();return}n=RR(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=Yp})}var tX=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof ym?"cancelled":"rejected",error:n}}finally{t?.()}},Xp=e=>t=>MR(IR(e,t).then(n=>(vs(e),n))),DR=e=>{const t=Xp(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:Ll}=Object,VE={},vm="listenerMiddleware",nX=(e,t)=>{const n=r=>RR(e,()=>r.abort(e.reason));return(r,i)=>{Ew(r);const a=new AbortController;n(a);const o=tX(async()=>{vs(e),vs(a.signal);const s=await r({pause:Xp(a.signal),delay:DR(a.signal),signal:a.signal});return vs(a.signal),s},()=>a.abort(JY));return i?.autoJoin&&t.push(o.catch(Yp)),{result:Xp(e)(o),cancel(){a.abort(QY)}}}},rX=(e,t)=>{const n=async(r,i)=>{vs(t);let a=()=>{};const s=[new Promise((l,c)=>{let d=e({predicate:r,effect:(u,p)=>{p.unsubscribe(),l([u,p.getState(),p.getOriginalState()])}});a=()=>{d(),c()}})];i!=null&&s.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await IR(t,Promise.race(s));return vs(t),l}finally{a()}};return(r,i)=>MR(n(r,i))},LR=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=Yr(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Vr(21));return Ew(a),{predicate:i,type:t,effect:a}},$R=Ll(e=>{const{type:t,predicate:n,effect:r}=LR(e);return{id:BY(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Vr(22))}}},{withTypes:()=>$R}),qE=(e,t)=>{const{type:n,effect:r,predicate:i}=LR(t);return Array.from(e.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},Bx=e=>{e.pending.forEach(t=>{t.abort(Fx)})},iX=(e,t)=>()=>{for(const n of t.keys())Bx(n);e.clear()},KE=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},zR=Ll(Yr(`${vm}/add`),{withTypes:()=>zR}),aX=Yr(`${vm}/removeAll`),FR=Ll(Yr(`${vm}/remove`),{withTypes:()=>FR}),oX=(...e)=>{console.error(`${vm}/error`,...e)},gd=(e={})=>{const t=new Map,n=new Map,r=h=>{const g=n.get(h)??0;n.set(h,g+1)},i=h=>{const g=n.get(h)??1;g===1?n.delete(h):n.set(h,g-1)},{extra:a,onError:o=oX}=e;Ew(o);const s=h=>(h.unsubscribe=()=>t.delete(h.id),t.set(h.id,h),g=>{h.unsubscribe(),g?.cancelActive&&Bx(h)}),l=h=>{const g=qE(t,h)??$R(h);return s(g)};Ll(l,{withTypes:()=>l});const c=h=>{const g=qE(t,h);return g&&(g.unsubscribe(),h.cancelActive&&Bx(g)),!!g};Ll(c,{withTypes:()=>c});const d=async(h,g,y,x)=>{const v=new AbortController,_=rX(l,v.signal),b=[];try{h.pending.add(v),r(h),await Promise.resolve(h.effect(g,Ll({},y,{getOriginalState:x,condition:(k,S)=>_(k,S).then(Boolean),take:_,delay:DR(v.signal),pause:Xp(v.signal),extra:a,signal:v.signal,fork:nX(v.signal,b),unsubscribe:h.unsubscribe,subscribe:()=>{t.set(h.id,h)},cancelActiveListeners:()=>{h.pending.forEach((k,S,w)=>{k!==v&&(k.abort(Fx),w.delete(k))})},cancel:()=>{v.abort(Fx),h.pending.delete(v)},throwIfCancelled:()=>{vs(v.signal)}})))}catch(k){k instanceof ym||KE(o,k,{raisedBy:"effect"})}finally{await Promise.all(b),v.abort(eX),i(h),h.pending.delete(v)}},u=iX(t,n);return{middleware:h=>g=>y=>{if(!mR(y))return g(y);if(zR.match(y))return l(y.payload);if(aX.match(y)){u();return}if(FR.match(y))return c(y.payload);let x=h.getState();const v=()=>{if(x===VE)throw new Error(Vr(23));return x};let _;try{if(_=g(y),t.size>0){const b=h.getState(),k=Array.from(t.values());for(const S of k){let w=!1;try{w=S.predicate(y,b,x)}catch(E){w=!1,KE(o,E,{raisedBy:"predicate"})}w&&d(S,y,h,v)}}}finally{x=VE}return _},startListening:l,stopListening:c,clearListeners:u}};function Vr(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var sX={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},BR=sr({name:"chartLayout",initialState:sX,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,i,a;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(a=t.payload.left)!==null&&a!==void 0?a:0},setScale(e,t){e.scale=t.payload}}}),{setMargin:lX,setLayout:cX,setChartSize:uX,setScale:dX}=BR.actions,fX=BR.reducer;function HR(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function ft(e){return Number.isFinite(e)}function ha(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function GE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Sl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?GE(Object(n),!0).forEach(function(r){pX(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):GE(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pX(e,t,n){return(t=hX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hX(e){var t=mX(e,"string");return typeof t=="symbol"?t:t+""}function mX(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function vn(e,t,n){return Gt(e)||Gt(t)?n:pa(t)?Ql(e,t,n):typeof t=="function"?t(e):n}var gX=(e,t,n)=>{if(t&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:s}=t;if((s==="vertical"||s==="horizontal"&&o==="middle")&&a!=="center"&&$e(e[a]))return Sl(Sl({},e),{},{[a]:e[a]+(r||0)});if((s==="horizontal"||s==="vertical"&&a==="center")&&o!=="middle"&&$e(e[o]))return Sl(Sl({},e),{},{[o]:e[o]+(i||0)})}return e},Ka=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",WR=(e,t,n,r)=>{if(r)return e.map(s=>s.coordinate);var i,a,o=e.map(s=>(s.coordinate===t&&(i=!0),s.coordinate===n&&(a=!0),s.coordinate));return i||o.push(t),a||o.push(n),o},UR=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:s,isCategorical:l,categoricalDomain:c,tickCount:d,ticks:u,niceTicks:p,axisType:h}=e;if(!o)return null;var g=s==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/g:0;if(y=h==="angleAxis"&&a&&a.length>=2?Sr(a[0]-a[1])*2*y:y,u||p){var x=(u||p||[]).map((v,_)=>{var b=r?r.indexOf(v):v,k=o.map(b);return ft(k)?{coordinate:k+y,value:v,offset:y,index:_}:null}).filter(Er);return x}return l&&c?c.map((v,_)=>{var b=o.map(v);return ft(b)?{coordinate:b+y,value:v,index:_,offset:y}:null}).filter(Er):o.ticks&&d!=null?o.ticks(d).map((v,_)=>{var b=o.map(v);return ft(b)?{coordinate:b+y,value:v,index:_,offset:y}:null}).filter(Er):o.domain().map((v,_)=>{var b=o.map(v);return ft(b)?{coordinate:b+y,value:r?r[v]:v,index:_,offset:y}:null}).filter(Er)},yX=(e,t)=>{if(!t||t.length!==2||!$e(t[0])||!$e(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!$e(e[0])||e[0]<n)&&(i[0]=n),(!$e(e[1])||e[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},vX=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var a=0,o=0,s=0;s<n;++s){var l=e[s],c=l?.[i];if(c!=null){var d=c[1],u=c[0],p=fa(d)?u:d;p>=0?(c[0]=a,a+=p,c[1]=a):(c[0]=o,o+=p,c[1]=o)}}}},xX=e=>{var t,n=e.length;if(!(n<=0)){var r=(t=e[0])===null||t===void 0?void 0:t.length;if(!(r==null||r<=0))for(var i=0;i<r;++i)for(var a=0,o=0;o<n;++o){var s=e[o],l=s?.[i];if(l!=null){var c=fa(l[1])?l[0]:l[1];c>=0?(l[0]=a,a+=c,l[1]=a):(l[0]=0,l[1]=0)}}}},bX={sign:vX,expand:sG,none:Ss,silhouette:lG,wiggle:cG,positive:xX},wX=(e,t,n)=>{var r,i=(r=bX[n])!==null&&r!==void 0?r:Ss,a=oG().keys(t).value((s,l)=>Number(vn(s,l,0))).order(Tx).offset(i),o=a(e);return o.forEach((s,l)=>{s.forEach((c,d)=>{var u=vn(e[d],t[l],0);Array.isArray(u)&&u.length===2&&$e(u[0])&&$e(u[1])&&(c[0]=u[0],c[1]=u[1])})}),o};function _X(e){return e==null?void 0:String(e)}function YE(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=e;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Gt(i[t.dataKey])){var s=ZM(n,"value",i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var l=vn(i,Gt(o)?t.dataKey:o),c=t.scale.map(l);return $e(c)?c:null}var XE=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:a,index:o}=e;if(t.type==="category")return n[o]?n[o].coordinate+r:null;var s=vn(a,t.dataKey,t.scale.domain()[o]);if(Gt(s))return null;var l=t.scale.map(s);return $e(l)?l-i/2+r:null},kX=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},SX=e=>{var t=e.flat(2).filter($e);return[Math.min(...t),Math.max(...t)]},EX=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],CX=(e,t,n)=>{if(e!=null)return EX(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var{stackedData:o}=a,s=o.reduce((l,c)=>{var d=HR(c,t,n),u=SX(d);return!ft(u[0])||!ft(u[1])?l:[Math.min(l[0],u[0]),Math.max(l[1],u[1])]},[1/0,-1/0]);return[Math.min(s[0],r[0]),Math.max(s[1],r[1])]},[1/0,-1/0]))},ZE=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,QE=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,ec=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=cm(t,d=>d.coordinate),a=1/0,o=1,s=i.length;o<s;o++){var l=i[o],c=i[o-1];a=Math.min((l?.coordinate||0)-(c?.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function JE(e){var{tooltipEntrySettings:t,dataKey:n,payload:r,value:i,name:a}=e;return Sl(Sl({},t),{},{dataKey:n,payload:r,value:i,name:a})}function xm(e,t){if(e)return String(e);if(typeof t=="string")return t}var jX=(e,t)=>{if(t==="horizontal")return e.relativeX;if(t==="vertical")return e.relativeY},NX=(e,t)=>t==="centric"?e.angle:e.radius,Ga=e=>e.layout.width,Ya=e=>e.layout.height,PX=e=>e.layout.scale,VR=e=>e.layout.margin,bm=re(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),wm=re(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),TX="data-recharts-item-index",AX="data-recharts-item-id",yd=60;function eC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function ff(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?eC(Object(n),!0).forEach(function(r){OX(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eC(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function OX(e,t,n){return(t=MX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function MX(e){var t=RX(e,"string");return typeof t=="symbol"?t:t+""}function RX(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var IX=e=>e.brush.height;function DX(e){var t=wm(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:yd;return n+i}return n},0)}function LX(e){var t=wm(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:yd;return n+i}return n},0)}function $X(e){var t=bm(e);return t.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function zX(e){var t=bm(e);return t.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var $n=re([Ga,Ya,VR,IX,DX,LX,$X,zX,fR,uY],(e,t,n,r,i,a,o,s,l,c)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},u={top:(n.top||0)+o,bottom:(n.bottom||0)+s},p=ff(ff({},u),d),h=p.bottom;p.bottom+=r,p=gX(p,l,c);var g=e-p.left-p.right,y=t-p.top-p.bottom;return ff(ff({brushBottom:h},p),{},{width:Math.max(g,0),height:Math.max(y,0)})}),FX=re($n,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Cw=re(Ga,Ya,(e,t)=>({x:0,y:0,width:e,height:t})),BX=m.createContext(null),lr=()=>m.useContext(BX)!=null,_m=e=>e.brush,km=re([_m,$n,VR],(e,t,n)=>({height:e.height,x:$e(e.x)?e.x:t.left,y:$e(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:$e(e.width)?e.width:t.width})),Wy={},Uy={},Vy={},tC;function HX(){return tC||(tC=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r,{signal:i,edges:a}={}){let o,s=null;const l=a!=null&&a.includes("leading"),c=a==null||a.includes("trailing"),d=()=>{s!==null&&(n.apply(o,s),o=void 0,s=null)},u=()=>{c&&d(),y()};let p=null;const h=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,u()},r)},g=()=>{p!==null&&(clearTimeout(p),p=null)},y=()=>{g(),o=void 0,s=null},x=()=>{d()},v=function(..._){if(i?.aborted)return;o=this,s=_;const b=p==null;h(),l&&b&&d()};return v.schedule=h,v.cancel=y,v.flush=x,i?.addEventListener("abort",y,{once:!0}),v}e.debounce=t})(Vy)),Vy}var nC;function WX(){return nC||(nC=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=HX();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:s=!0,maxWait:l}=a,c=Array(2);o&&(c[0]="leading"),s&&(c[1]="trailing");let d,u=null;const p=t.debounce(function(...y){d=r.apply(this,y),u=null},i,{edges:c}),h=function(...y){return l!=null&&(u===null&&(u=Date.now()),Date.now()-u>=l)?(d=r.apply(this,y),u=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,y),d)},g=()=>(p.flush(),d);return h.cancel=p.cancel,h.flush=g,h}e.debounce=n})(Uy)),Uy}var rC;function UX(){return rC||(rC=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=WX();function n(r,i=0,a={}){const{leading:o=!0,trailing:s=!0}=a;return t.debounce(r,i,{leading:o,maxWait:i,trailing:s})}e.throttle=n})(Wy)),Wy}var qy,iC;function VX(){return iC||(iC=1,qy=UX().throttle),qy}var qX=VX();const KX=Mi(qX);var Zp=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!t))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},ta={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},qR=(e,t,n)=>{var{width:r=ta.width,height:i=ta.height,aspect:a,maxHeight:o}=n,s=Es(r)?e:Number(r),l=Es(i)?t:Number(i);return a&&a>0&&(s?l=s/a:l&&(s=l*a),o&&l!=null&&l>o&&(l=o)),{calculatedWidth:s,calculatedHeight:l}},GX={width:0,height:0,overflow:"visible"},YX={width:0,overflowX:"visible"},XX={height:0,overflowY:"visible"},ZX={},QX=e=>{var{width:t,height:n}=e,r=Es(t),i=Es(n);return r&&i?GX:r?YX:i?XX:ZX};function JX(e){var{width:t,height:n,aspect:r}=e,i=t,a=n;return i===void 0&&a===void 0?(i=ta.width,a=ta.height):i===void 0?i=r&&r>0?void 0:ta.width:a===void 0&&(a=r&&r>0?void 0:ta.height),{width:i,height:a}}function Hx(){return Hx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Hx.apply(null,arguments)}function aC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function oC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?aC(Object(n),!0).forEach(function(r){eZ(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aC(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function eZ(e,t,n){return(t=tZ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tZ(e){var t=nZ(e,"string");return typeof t=="symbol"?t:t+""}function nZ(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var KR=m.createContext(ta.initialDimension);function rZ(e){return ha(e.width)&&ha(e.height)}function GR(e){var{children:t,width:n,height:r}=e,i=m.useMemo(()=>({width:n,height:r}),[n,r]);return rZ(i)?m.createElement(KR.Provider,{value:i},t):null}var jw=()=>m.useContext(KR),iZ=m.forwardRef((e,t)=>{var{aspect:n,initialDimension:r=ta.initialDimension,width:i,height:a,minWidth:o=ta.minWidth,minHeight:s,maxHeight:l,children:c,debounce:d=ta.debounce,id:u,className:p,onResize:h,style:g={}}=e,y=m.useRef(null),x=m.useRef();x.current=h,m.useImperativeHandle(t,()=>y.current);var[v,_]=m.useState({containerWidth:r.width,containerHeight:r.height}),b=m.useCallback((j,C)=>{_(A=>{var R=Math.round(j),P=Math.round(C);return A.containerWidth===R&&A.containerHeight===P?A:{containerWidth:R,containerHeight:P}})},[]);m.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return Ls;var j=P=>{var D,O=P[0];if(O!=null){var{width:M,height:I}=O.contentRect;b(M,I),(D=x.current)===null||D===void 0||D.call(x,M,I)}};d>0&&(j=KX(j,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(j),{width:A,height:R}=y.current.getBoundingClientRect();return b(A,R),C.observe(y.current),()=>{C.disconnect()}},[b,d]);var{containerWidth:k,containerHeight:S}=v;Zp(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:w,calculatedHeight:E}=qR(k,S,{width:i,height:a,aspect:n,maxHeight:l});return Zp(w!=null&&w>0||E!=null&&E>0,`The width(%s) and height(%s) of chart should be greater than 0,
807
807
  please check the style of container, or the props width(%s) and height(%s),