import{b as G}from"./_commonjsHelpers-CjYu-_XP.js";import{r as m,j as u,e as W,d as X,R as V,s as g,C as w,E as C,c as J,T as S}from"./base-n-UdXcsV.js";/**
 * @license lucide-react v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Q=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),R=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();/**
 * @license lucide-react v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */var Y={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
 * @license lucide-react v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ee=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:d,...r},c)=>m.createElement("svg",{ref:c,...Y,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:R("lucide",a),...r},[...d.map(([o,F])=>m.createElement(o,F)),...Array.isArray(i)?i:[i]]));/**
 * @license lucide-react v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const T=(e,t)=>{const n=m.forwardRef(({className:s,...a},i)=>m.createElement(ee,{ref:i,iconNode:t,className:R(`lucide-${Q(e)}`,s),...a}));return n.displayName=`${e}`,n};/**
 * @license lucide-react v0.468.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=T("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
 * @license lucide-react v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ne=T("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function O(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=O(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function N(){for(var e,t,n=0,s="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=O(e))&&(s&&(s+=" "),s+=t);return s}function te({className:e,size:t="md",variant:n="secondary"}){return N("zw-button",`zw-button--${n}`,`zw-button--${t}`,e)}function q({children:e,className:t,disabled:n,loading:s=!1,size:a="md",type:i="button",variant:d="secondary",...r}){return u.jsxs("button",{className:te({className:t,size:a,variant:d}),disabled:n||s,type:i,...r,children:[s?u.jsx(ue,{"aria-hidden":"true",className:"zw-button__spinner"}):null,u.jsx("span",{className:"zw-button__content",children:e})]})}var se=W();const B=[],A=new Map,re=82;let Z=0,K="",D=null;const H=m.createContext(null),ae=["a[href]","area[href]","button:not([disabled])","input:not([disabled]):not([type='hidden'])","select:not([disabled])","textarea:not([disabled])","iframe","object","embed","[contenteditable='true']","[tabindex]:not([tabindex='-1'])"].join(",");function P(e){return Array.from(e.querySelectorAll(ae)).filter(t=>!t.hidden&&t.getAttribute("aria-hidden")!=="true"&&!t.closest("[inert]"))}function v(){return U().at(-1)??null}function U(){const e=B.filter(r=>r.element.isConnected),t=new Map(e.map(r=>[r.element,r])),n=new Map,s=[];e.forEach(r=>{const c=r.parentElement?t.get(r.parentElement):void 0;if(!c||c===r){s.push(r);return}const o=n.get(c)??[];o.push(r),n.set(c,o)});const a=[],i=new Set,d=r=>{i.has(r)||(i.add(r),a.push(r),(n.get(r)??[]).slice().sort((c,o)=>c.sequence-o.sequence).forEach(d))};return s.slice().sort((r,c)=>r.sequence-c.sequence).forEach(d),e.slice().sort((r,c)=>r.sequence-c.sequence).forEach(d),a}function oe(e){if(B.forEach(n=>{n.element.style.zIndex=n.previousZIndex}),e.length<2)return;const t=e.reduce((n,s)=>{const a=Number.parseInt(getComputedStyle(s.element).zIndex,10);return Number.isFinite(a)?Math.max(n,a):n},re);e.forEach((n,s)=>{n.element.style.zIndex=String(t+s)})}function k(){const e=U(),t=e.at(-1)??null;if(oe(e),!t){A.forEach((n,s)=>{s.isConnected&&(s.inert=n.inert)}),A.clear(),D==null||D.disconnect(),D=null,document.body.style.overflow=K;return}Array.from(document.body.children).forEach(n=>{n instanceof HTMLElement&&(A.has(n)||A.set(n,{inert:n.inert}),n.inert=n!==t.element)})}function ce(e,t,n){B.length===0&&(K=document.body.style.overflow,document.body.style.overflow="hidden",D=new MutationObserver(()=>k()),D.observe(document.body,{childList:!0})),B.push({element:e,panel:t,parentElement:n,previousZIndex:e.style.zIndex,sequence:Z++}),k()}function ie(e){const t=B.findIndex(n=>n.element===e);if(t!==-1){const[n]=B.splice(t,1);n&&(n.element.style.zIndex=n.previousZIndex)}k(),B.length===0&&(Z=0)}function $(e){(e.querySelector("[data-autofocus]")??P(e)[0]??e).focus()}function le({layerRef:e,onClose:t,open:n,panelRef:s}){const a=m.useContext(H),i=m.useRef(t);m.useEffect(()=>{i.current=t},[t]),m.useEffect(()=>{var x;if(!n)return;const d=e.current,r=s.current;if(!d||!r)return;const c=d,o=r,F=document.activeElement instanceof HTMLElement?document.activeElement:null;ce(c,o,(a==null?void 0:a.current)??null),((x=v())==null?void 0:x.element)===c&&$(o);function h(l){var y;if(((y=v())==null?void 0:y.element)!==c)return;if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),i.current();return}if(l.key!=="Tab")return;const E=P(o);if(E.length===0){l.preventDefault(),o.focus();return}const b=E[0],p=E.at(-1),j=document.activeElement;l.shiftKey&&(j===b||!o.contains(j))?(l.preventDefault(),p==null||p.focus()):!l.shiftKey&&(j===p||!o.contains(j))&&(l.preventDefault(),b==null||b.focus())}return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h),ie(c);const l=v();l!=null&&l.panel.contains(document.activeElement)||F!=null&&F.isConnected&&(!l||l.element.contains(F))&&(F.focus(),document.activeElement===F)||l&&$(l.panel)}},[e,n,s,a])}function de({children:e,className:t,closeLabel:n="\u5173\u95ED",contentMode:s="scroll",description:a,footer:i,onClose:d,open:r,role:c="dialog",size:o="md",title:F}){const h=m.useId(),x=m.useId(),l=m.useRef(null),E=m.useRef(null);return le({layerRef:l,onClose:d,open:r,panelRef:E}),r?se.createPortal(u.jsx(H.Provider,{value:l,children:u.jsxs("div",{className:"zw-dialog__layer",ref:l,children:[u.jsx("button",{"aria-label":n,className:"zw-dialog__backdrop",onClick:d,type:"button"}),u.jsxs("section",{"aria-describedby":a?x:void 0,"aria-labelledby":h,"aria-modal":"true",className:N("zw-dialog",`zw-dialog--${o}`,`zw-dialog--content-${s}`,t),ref:E,role:c,tabIndex:-1,children:[u.jsxs("header",{className:"zw-dialog__header",children:[u.jsxs("div",{children:[u.jsx("h2",{id:h,children:F}),a?u.jsx("p",{className:"zw-dialog__description",id:x,children:a}):null]}),u.jsx("button",{"aria-label":n,className:"zw-dialog__close",onClick:d,type:"button",children:u.jsx(ne,{"aria-hidden":"true"})})]}),u.jsx("div",{className:"zw-dialog__body",children:e}),i?u.jsx("footer",{className:"zw-dialog__footer",children:i}):null]})]})}),document.body):null}function me({cancelLabel:e="\u53D6\u6D88",children:t,className:n,closeLabel:s="\u5173\u95ED\u786E\u8BA4",confirmDisabled:a=!1,confirmIcon:i,confirmLabel:d="\u786E\u8BA4",description:r,loading:c=!1,onClose:o,onConfirm:F,open:h,size:x="sm",title:l,tone:E="default"}){const b=E==="danger"?"destructive":"primary",p=c?()=>{}:o;return u.jsx(de,{className:N("zw-confirm-dialog",`zw-confirm-dialog--${E}`,n),closeLabel:s,description:r,footer:u.jsxs(u.Fragment,{children:[u.jsx(q,{disabled:c,onClick:o,type:"button",variant:"ghost",children:e}),u.jsxs(q,{disabled:a,loading:c,onClick:F,type:"button",variant:b,children:[i,d]})]}),onClose:p,open:h,role:"alertdialog",size:x,title:l,children:u.jsx("div",{className:"zw-confirm-dialog__content",children:t})})}m.createContext(null);function fe(){var y,I,z,L,M,_;const[e,t]=m.useState(null),[n,s]=m.useState(!1),[a,i]=m.useState(!1),[d,r]=m.useState(""),[c,o]=m.useState(null),F=G.runtime.getManifest().version,h=m.useCallback(async()=>{t(await g({type:"settings.get-public"}))},[]);m.useEffect(()=>{h().catch(f=>o({kind:"error",message:f instanceof Error?f.message:"\u8BFB\u53D6\u8D26\u53F7\u72B6\u6001\u5931\u8D25\u3002"}))},[h]);async function x(){s(!0),o(null);try{await g({type:"auth.login"}),await h(),o({kind:"success",message:"\u9020\u7269\u8D26\u53F7\u5DF2\u8FDE\u63A5\u3002"})}catch(f){o({kind:"error",message:f instanceof Error?f.message:"\u767B\u5F55\u5931\u8D25\u3002"})}finally{s(!1)}}async function l(){s(!0),o(null);try{await g({type:"auth.logout"}),await h(),o({kind:"success",message:"\u5DF2\u9000\u51FA\u5F53\u524D\u8BBE\u5907\u3002"})}catch(f){o({kind:"error",message:f instanceof Error?f.message:"\u9000\u51FA\u5931\u8D25\u3002"})}finally{s(!1)}}async function E(){s(!0),o(null);try{await g({type:"auth.refresh"}),await h(),o({kind:"success",message:"\u8D26\u53F7\u4E0E\u529F\u80FD\u6743\u9650\u5DF2\u5237\u65B0\u3002"})}catch(f){await h().catch(()=>{}),o({kind:"error",message:f instanceof Error?f.message:"\u5237\u65B0\u5931\u8D25\u3002"})}finally{s(!1)}}async function b(){s(!0),r("");try{const f=await g({type:"jobs.clear-terminal"});i(!1),o({kind:"success",message:`\u5DF2\u6E05\u9664 ${f.cleared} \u6761\u672C\u5730\u4EFB\u52A1\u8BB0\u5F55\u3002`})}catch(f){r(f instanceof Error?f.message:"\u6E05\u7406\u5931\u8D25\u3002")}finally{s(!1)}}const p=((I=(y=e==null?void 0:e.viewer)==null?void 0:y.profile)==null?void 0:I.displayName)||((z=e==null?void 0:e.viewer)==null?void 0:z.user.displayName)||"\u9020\u7269\u793E\u533A\u7528\u6237",j=((L=e==null?void 0:e.subscription)==null?void 0:L.active)===!0;return u.jsxs("main",{className:"options-shell",children:[u.jsxs("header",{className:"options-header",children:[u.jsxs("div",{className:"brand-lockup",children:[u.jsx("img",{alt:"",src:"/icon-32.png"}),u.jsx("strong",{children:"\u9020\u7269\u52A9\u624B"})]}),u.jsxs("span",{children:["v",F]})]}),u.jsxs("section",{className:"settings-section",children:[u.jsxs("div",{className:"section-copy",children:[u.jsx("h1",{children:"\u767B\u5F55\u9020\u7269\u8D26\u53F7"}),u.jsx("p",{children:"\u767B\u5F55\u540E\u540C\u6B65\u8BA2\u9605\u72B6\u6001\u548C\u53EF\u7528\u529F\u80FD\uFF1B\u6269\u5C55\u4E0D\u8BFB\u53D6\u7F51\u7AD9 Cookie\uFF0C\u4E5F\u4E0D\u9700\u8981\u540E\u53F0 Token\u3002"})]}),u.jsx("div",{className:"account-panel",children:e!=null&&e.authenticated?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"account-summary",children:[u.jsx("span",{className:"account-avatar",children:p.slice(0,1).toUpperCase()}),u.jsxs("div",{children:[u.jsx("strong",{children:p}),u.jsxs("small",{children:["\u5DF2\u767B\u5F55 \xB7 ",he((M=e.viewer)==null?void 0:M.user.role)," \xB7 ",Ee(e.subscription)]})]}),u.jsxs("span",{className:j?"account-state":"account-state is-locked",children:[j?u.jsx(w,{}):u.jsx(C,{}),j?"\u529F\u80FD\u5DF2\u5F00\u653E":"\u529F\u80FD\u5DF2\u9501\u5B9A"]})]}),u.jsxs("div",{className:"form-actions",children:[j?null:u.jsx("a",{className:"button subscription-button",href:((_=e.subscription)==null?void 0:_.manageUrl)||"https://zaowujuzhen.com/prime",rel:"noreferrer",target:"_blank",children:"\u67E5\u770B\u8BA2\u9605"}),u.jsxs("button",{className:"button",disabled:n,onClick:()=>void E(),type:"button",children:[u.jsx(J,{}),"\u5237\u65B0\u6743\u9650"]}),u.jsx("button",{className:"button",disabled:n,onClick:()=>void l(),type:"button",children:"\u9000\u51FA\u8FD9\u53F0\u8BBE\u5907"})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"account-empty",children:[u.jsx("span",{className:"mini-mark",children:"\u9020"}),u.jsxs("div",{children:[u.jsx("strong",{children:"\u767B\u5F55\u540E\u53EF\u4F7F\u7528\u5C0F\u7EA2\u4E66\u4FDD\u5B58\u548C GitHub \u63A8\u8350"}),u.jsx("small",{children:"\u6D4F\u89C8\u5668\u53EA\u4FDD\u5B58\u5F53\u524D\u8BBE\u5907\u7684\u53EF\u64A4\u9500\u4F1A\u8BDD\uFF1B\u8BA2\u9605\u4E0E\u6743\u9650\u7531\u670D\u52A1\u7AEF\u6821\u9A8C\u3002"})]})]}),u.jsx("button",{className:"button button--primary login-button",disabled:n,onClick:()=>void x(),type:"button",children:n?"\u6B63\u5728\u767B\u5F55\u2026":"\u767B\u5F55\u9020\u7269\u8D26\u53F7"})]})})]}),c?u.jsxs("p",{className:`settings-status is-${c.kind}`,role:c.kind==="error"?"alert":"status",children:[c.kind==="success"?u.jsx(w,{}):u.jsx(C,{}),c.message]}):null,u.jsxs("section",{className:"settings-section capability-section",children:[u.jsxs("div",{className:"section-copy",children:[u.jsx("h2",{children:"\u53EF\u7528\u529F\u80FD"}),u.jsx("p",{children:"\u6240\u6709\u529F\u80FD\u4EC5\u5411\u8BA2\u9605\u6709\u6548\u671F\u5185\u7684\u7528\u6237\u5F00\u653E\uFF1B\u63D2\u4EF6\u6BCF\u6B21\u64CD\u4F5C\u90FD\u4F1A\u7531\u670D\u52A1\u7AEF\u91CD\u65B0\u6821\u9A8C\u3002"})]}),u.jsx("div",{className:"capability-list",children:e!=null&&e.authenticated?e.capabilities.map(f=>u.jsx(Fe,{capability:f},f.key)):u.jsx("p",{className:"muted-copy",children:"\u767B\u5F55\u540E\u663E\u793A\u5F53\u524D\u8D26\u53F7\u53EF\u7528\u7684\u529F\u80FD\u4E0E\u5269\u4F59\u989D\u5EA6\u3002"})})]}),u.jsxs("section",{className:"settings-section local-section",children:[u.jsxs("div",{className:"section-copy",children:[u.jsx("h2",{children:"\u672C\u5730\u4EFB\u52A1"}),u.jsx("p",{children:"\u4E0D\u540C\u8D26\u53F7\u7684\u4EFB\u52A1\u76F8\u4E92\u9694\u79BB\uFF1B\u4EFB\u52A1\u63D0\u4EA4\u5B8C\u6210\u540E\uFF0C\u4E34\u65F6\u6B63\u6587\u548C\u5A92\u4F53\u4F1A\u7ACB\u5373\u6E05\u7406\u3002"})]}),u.jsxs("div",{className:"local-action",children:[u.jsxs("button",{className:"button button--danger",disabled:n||!(e!=null&&e.configured),onClick:()=>{r(""),i(!0)},type:"button",children:[u.jsx(S,{}),"\u6E05\u9664\u5DF2\u7ED3\u675F\u4EFB\u52A1"]}),u.jsx("small",{children:"\u53EA\u6E05\u7406\u5F53\u524D\u8D26\u53F7\u5728\u8FD9\u4E2A\u6D4F\u89C8\u5668\u4E2D\u7684\u8BB0\u5F55\uFF0C\u4E0D\u5220\u9664\u540E\u53F0\u5185\u5BB9\u3002"})]})]}),u.jsxs("footer",{children:[u.jsx("span",{children:"\u9020\u7269\u52A9\u624B"}),u.jsx("span",{children:"\u5C0F\u7EA2\u4E66\u4FDD\u5B58 \xB7 GitHub \u63A8\u8350"})]}),u.jsxs(me,{confirmIcon:u.jsx(S,{}),confirmLabel:"\u6E05\u9664\u8BB0\u5F55",loading:n,onClose:()=>{i(!1),r("")},onConfirm:()=>void b(),open:a,title:"\u6E05\u9664\u5DF2\u7ED3\u675F\u4EFB\u52A1\uFF1F",tone:"danger",children:[u.jsx("p",{children:"\u53EA\u4F1A\u6E05\u9664\u5F53\u524D\u8D26\u53F7\u5728\u8FD9\u4E2A\u6D4F\u89C8\u5668\u5185\u5DF2\u7ECF\u7ED3\u675F\u7684\u4EFB\u52A1\u8BB0\u5F55\u548C\u4E34\u65F6\u6587\u4EF6\uFF0C\u540E\u53F0\u8BB0\u5F55\u4E0D\u53D7\u5F71\u54CD\u3002"}),d?u.jsxs("p",{className:"options-dialog-error",role:"alert",children:[u.jsx(C,{}),d]}):null]})]})}function Fe({capability:e}){var a,i,d;const t=e.availability==="enabled",n=((a=e.quota)==null?void 0:a.windowKind)==="hour"?"\u672C\u5C0F\u65F6":((i=e.quota)==null?void 0:i.windowKind)==="day"?"\u4ECA\u65E5":"\u672C\u671F",s=((d=e.quota)==null?void 0:d.remaining)==null?"\u6309\u8D26\u53F7\u6743\u9650\u5F00\u653E":`${n}\u5269\u4F59 ${e.quota.remaining}/${e.quota.limit} \u6B21`;return u.jsxs("article",{className:`capability-row is-${e.availability}`,children:[u.jsx("span",{children:t?u.jsx(w,{}):u.jsx(C,{})}),u.jsxs("div",{children:[u.jsx("strong",{children:e.label}),u.jsx("small",{children:t?s:e.userMessage||"\u5F53\u524D\u4E0D\u53EF\u7528"})]}),u.jsx("em",{children:t?"\u5DF2\u5F00\u653E":e.availability==="hidden"?"\u672A\u5F00\u653E":"\u53D7\u9650"})]})}function he(e){return{curator:"\u7B56\u5C55\u4EBA",free:"\u793E\u533A\u6210\u5458",subscriber:"\u8BA2\u9605\u6210\u5458",super_admin:"\u7BA1\u7406\u5458"}[e??""]??"\u793E\u533A\u6210\u5458"}function Ee(e){return e!=null&&e.active?e.endsAt?`\u8BA2\u9605\u6709\u6548\u81F3 ${new Intl.DateTimeFormat("zh-CN",{dateStyle:"medium"}).format(new Date(e.endsAt))}`:"\u8BA2\u9605\u6709\u6548 \xB7 \u957F\u671F\u6743\u76CA":"\u65E0\u6709\u6548\u8BA2\u9605"}X.createRoot(document.getElementById("root")).render(u.jsx(V.StrictMode,{children:u.jsx(fe,{})}));
