import{a as y,r as o,j as r,B as A,p as ee,f as L,c as g,q as U}from"./index-Daq5M5bC.js";import{z as te,S as k}from"./index-CTnVPfHU.js";import{D as ae,v as re,w as se,x as C,d as ne,b as oe}from"./user-status-C4MB9Ruf.js";import{u as ie,c as B,P,a as ce}from"./index-B33Yn3RC.js";/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const le=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Oe=y("circle-check-big",le);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ue=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],de=y("monitor",ue);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pe=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],T=y("moon",pe);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],j=y("sun",fe);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const me=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],He=y("zap",me);function Ke(){const{theme:e,setTheme:t}=te(),[a,s]=o.useState(!1);o.useEffect(()=>{s(!0)},[]);const n=async u=>{t(u);try{await ee(u)}catch(c){console.error("Failed to save theme to global settings:",c)}};return a?r.jsxs(ae,{children:[r.jsx(re,{asChild:!0,children:r.jsxs(A,{variant:"outline",size:"icon",className:"h-9 w-9 relative z-10",children:[r.jsx(j,{className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),r.jsx(T,{className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),r.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),r.jsxs(se,{align:"end",className:"z-[999]",children:[r.jsxs(C,{onClick:()=>n("light"),className:"flex items-center gap-2 cursor-pointer",children:[r.jsx(j,{className:"h-4 w-4"}),r.jsx("span",{children:"Light"}),e==="light"&&r.jsx("span",{className:"ml-auto",children:"✓"})]}),r.jsxs(C,{onClick:()=>n("dark"),className:"flex items-center gap-2 cursor-pointer",children:[r.jsx(T,{className:"h-4 w-4"}),r.jsx("span",{children:"Dark"}),e==="dark"&&r.jsx("span",{className:"ml-auto",children:"✓"})]}),r.jsxs(C,{onClick:()=>n("system"),className:"flex items-center gap-2 cursor-pointer",children:[r.jsx(de,{className:"h-4 w-4"}),r.jsx("span",{children:"System"}),e==="system"&&r.jsx("span",{className:"ml-auto",children:"✓"})]})]})]}):r.jsx(A,{variant:"outline",size:"icon",className:"h-9 w-9 relative z-10",children:r.jsx(j,{className:"h-4 w-4"})})}var E="Switch",[he,Qe]=B(E),[ge,ve]=he(E),D=o.forwardRef((e,t)=>{const{__scopeSwitch:a,name:s,checked:n,defaultChecked:u,required:c,disabled:i,value:l="on",onCheckedChange:f,form:p,...h}=e,[v,x]=o.useState(null),b=L(t,N=>x(N)),d=o.useRef(!1),m=v?p||!!v.closest("form"):!0,[w,Y]=ie({prop:n,defaultProp:u??!1,onChange:f,caller:E});return r.jsxs(ge,{scope:a,checked:w,disabled:i,children:[r.jsx(P.button,{type:"button",role:"switch","aria-checked":w,"aria-required":c,"data-state":F(w),"data-disabled":i?"":void 0,disabled:i,value:l,...h,ref:b,onClick:ce(e.onClick,N=>{Y(J=>!J),m&&(d.current=N.isPropagationStopped(),d.current||N.stopPropagation())})}),m&&r.jsx(G,{control:v,bubbles:!d.current,name:s,value:l,checked:w,required:c,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});D.displayName=E;var z="SwitchThumb",V=o.forwardRef((e,t)=>{const{__scopeSwitch:a,...s}=e,n=ve(z,a);return r.jsx(P.span,{"data-state":F(n.checked),"data-disabled":n.disabled?"":void 0,...s,ref:t})});V.displayName=z;var xe="SwitchBubbleInput",G=o.forwardRef(({__scopeSwitch:e,control:t,checked:a,bubbles:s=!0,...n},u)=>{const c=o.useRef(null),i=L(c,u),l=ne(a),f=oe(t);return o.useEffect(()=>{const p=c.current;if(!p)return;const h=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==a&&x){const b=new Event("click",{bubbles:s});x.call(p,a),p.dispatchEvent(b)}},[l,a,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a,...n,tabIndex:-1,ref:i,style:{...n.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});G.displayName=xe;function F(e){return e?"checked":"unchecked"}var q=D,be=V;const ye=o.forwardRef(({className:e,...t},a)=>r.jsx(q,{className:g("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:a,children:r.jsx(be,{className:g("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));ye.displayName=q.displayName;const we=U("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ne=o.forwardRef(({className:e,variant:t,...a},s)=>r.jsx("div",{ref:s,role:"alert",className:g(we({variant:t}),e),...a}));Ne.displayName="Alert";const ke=o.forwardRef(({className:e,...t},a)=>r.jsx("h5",{ref:a,className:g("mb-1 font-medium leading-none tracking-tight",e),...t}));ke.displayName="AlertTitle";const Se=o.forwardRef(({className:e,...t},a)=>r.jsx("div",{ref:a,className:g("text-sm [&_p]:leading-relaxed",e),...t}));Se.displayName="AlertDescription";const Pe=U("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Xe({className:e,variant:t,...a}){return r.jsx("div",{className:g(Pe({variant:t}),e),...a})}var _="Progress",M=100,[Ee,Ze]=B(_),[Ce,je]=Ee(_),O=o.forwardRef((e,t)=>{const{__scopeProgress:a,value:s=null,max:n,getValueLabel:u=_e,...c}=e;(n||n===0)&&!R(n)&&console.error(Me(`${n}`,"Progress"));const i=R(n)?n:M;s!==null&&!I(s,i)&&console.error(Ae(`${s}`,"Progress"));const l=I(s,i)?s:null,f=S(l)?u(l,i):void 0;return r.jsx(Ce,{scope:a,value:l,max:i,children:r.jsx(P.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":S(l)?l:void 0,"aria-valuetext":f,role:"progressbar","data-state":Q(l,i),"data-value":l??void 0,"data-max":i,...c,ref:t})})});O.displayName=_;var H="ProgressIndicator",K=o.forwardRef((e,t)=>{const{__scopeProgress:a,...s}=e,n=je(H,a);return r.jsx(P.div,{"data-state":Q(n.value,n.max),"data-value":n.value??void 0,"data-max":n.max,...s,ref:t})});K.displayName=H;function _e(e,t){return`${Math.round(e/t*100)}%`}function Q(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function S(e){return typeof e=="number"}function R(e){return S(e)&&!isNaN(e)&&e>0}function I(e,t){return S(e)&&!isNaN(e)&&e<=t&&e>=0}function Me(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${M}\`.`}function Ae(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
  - a positive number
  - less than the value passed to \`max\` (or ${M} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}var X=O,Te=K;const Re=o.forwardRef(({className:e,value:t,...a},s)=>r.jsx(X,{ref:s,className:g("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...a,children:r.jsx(Te,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Re.displayName=X.displayName;const Z="subscription_status",W="subscription_status_updated_at",Ie=60*60*1e3;async function $e(){const e=await k.get(W);return!e||Date.now()-e>Ie?null:k.get(Z)}async function Le(e){await k.set(Z,e),await k.set(W,Date.now())}const Ue={free:0,pro:1,premium:2},Be={asrTranscription:"free",aiTranslation:"free",subtitleEnhance:"free"};function $(e){return Ue[e]??0}function De(e,t){const a=Be[e];return $(t)>=$(a)}function We(e,t){const[a,s]=o.useState("free"),[n,u]=o.useState(!1),[c,i]=o.useState(null),[l,f]=o.useState(!0),p=o.useCallback(d=>{s(d.plan),u(!!d.cancelAtPeriodEnd),i(d.currentPeriodEnd??null)},[]),h=o.useCallback(async()=>{if(!e){s("free"),u(!1),i(null),f(!1);return}try{const d=await $e();d&&(p(d),f(!1));const m=await t("ACQUIRE_LANGUAGE:GET_SUBSCRIPTION",{},"background");m!=null&&m.success&&m.data&&(p(m.data),await Le(m.data))}catch(d){console.error("Failed to fetch subscription status:",d)}finally{f(!1)}},[e,t,p]);o.useEffect(()=>{h()},[h]);const v=a==="pro"||a==="premium",x=a==="premium",b=o.useMemo(()=>d=>De(d,a),[a]);return{plan:a,isPro:v,isPremium:x,isLoading:l,cancelAtPeriodEnd:n,currentPeriodEnd:c,canAccessFeature:b,refresh:h}}function Ye(e,t){const[a,s]=o.useState(null),[n,u]=o.useState(!0),c=o.useCallback(async()=>{if(!e){s(null),u(!1);return}try{const i=await t("ACQUIRE_LANGUAGE:GET_USAGE",{},"background");i!=null&&i.success&&i.data&&s(i.data)}catch(i){console.error("Failed to fetch usage status:",i)}finally{u(!1)}},[e,t]);return o.useEffect(()=>{c()},[c]),{usage:a,isLoading:n,refresh:c}}function ze(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function Je(e,t,a,s=ze){return e?e.limit===-1?a:e.limit<=0?null:`${Math.round(Math.min(e.used/e.limit*100,100))}% · ${s(e.used)} / ${s(e.limit)} ${t}`:null}export{Ne as A,Xe as B,Oe as C,Re as P,ye as S,Ke as T,He as Z,Se as a,Ye as b,Je as c,ze as f,We as u};
