Repository navigation
Expand file tree
/
Copy pathoptions.js
More file actions
2 lines (2 loc) · 23.5 KB
/
Copy pathoptions.js
File metadata and controls
2 lines (2 loc) · 23.5 KB
1
2
/*! For license information please see options.js.LICENSE.txt */
(()=>{"use strict";var e,a={463:(e,a)=>{function n(e,a){var n=e.length;e.push(a);e:for(;0<n;){var t=n-1>>>1,o=e[t];if(!(0<r(o,a)))break e;e[t]=a,e[n]=o,n=t}}function t(e){return 0===e.length?null:e[0]}function o(e){if(0===e.length)return null;var a=e[0],n=e.pop();if(n!==a){e[0]=n;e:for(var t=0,o=e.length,i=o>>>1;t<i;){var l=2*(t+1)-1,s=e[l],c=l+1,d=e[c];if(0>r(s,n))c<o&&0>r(d,s)?(e[t]=d,e[c]=n,t=c):(e[t]=s,e[l]=n,t=l);else{if(!(c<o&&0>r(d,n)))break e;e[t]=d,e[c]=n,t=c}}}return a}function r(e,a){var n=e.sortIndex-a.sortIndex;return 0!==n?n:e.id-a.id}if("object"==typeof performance&&"function"==typeof performance.now){var i=performance;a.unstable_now=function(){return i.now()}}else{var l=Date,s=l.now();a.unstable_now=function(){return l.now()-s}}var c=[],d=[],p=1,u=null,h=3,m=!1,v=!1,g=!1,f="function"==typeof setTimeout?setTimeout:null,b="function"==typeof clearTimeout?clearTimeout:null,y="undefined"!=typeof setImmediate?setImmediate:null;function x(e){for(var a=t(d);null!==a;){if(null===a.callback)o(d);else{if(!(a.startTime<=e))break;o(d),a.sortIndex=a.expirationTime,n(c,a)}a=t(d)}}function k(e){if(g=!1,x(e),!v)if(null!==t(c))v=!0,P(w);else{var a=t(d);null!==a&&L(k,a.startTime-e)}}function w(e,n){v=!1,g&&(g=!1,b(N),N=-1),m=!0;var r=h;try{for(x(n),u=t(c);null!==u&&(!(u.expirationTime>n)||e&&!M());){var i=u.callback;if("function"==typeof i){u.callback=null,h=u.priorityLevel;var l=i(u.expirationTime<=n);n=a.unstable_now(),"function"==typeof l?u.callback=l:u===t(c)&&o(c),x(n)}else o(c);u=t(c)}if(null!==u)var s=!0;else{var p=t(d);null!==p&&L(k,p.startTime-n),s=!1}return s}finally{u=null,h=r,m=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var j,_=!1,z=null,N=-1,C=5,E=-1;function M(){return!(a.unstable_now()-E<C)}function S(){if(null!==z){var e=a.unstable_now();E=e;var n=!0;try{n=z(!0,e)}finally{n?j():(_=!1,z=null)}}else _=!1}if("function"==typeof y)j=function(){y(S)};else if("undefined"!=typeof MessageChannel){var A=new MessageChannel,T=A.port2;A.port1.onmessage=S,j=function(){T.postMessage(null)}}else j=function(){f(S,0)};function P(e){z=e,_||(_=!0,j())}function L(e,n){N=f(function(){e(a.unstable_now())},n)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(e){e.callback=null},a.unstable_continueExecution=function(){v||m||(v=!0,P(w))},a.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<e?Math.floor(1e3/e):5},a.unstable_getCurrentPriorityLevel=function(){return h},a.unstable_getFirstCallbackNode=function(){return t(c)},a.unstable_next=function(e){switch(h){case 1:case 2:case 3:var a=3;break;default:a=h}var n=h;h=a;try{return e()}finally{h=n}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(e,a){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return a()}finally{h=n}},a.unstable_scheduleCallback=function(e,o,r){var i=a.unstable_now();switch(r="object"==typeof r&&null!==r&&"number"==typeof(r=r.delay)&&0<r?i+r:i,e){case 1:var l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}return e={id:p++,callback:o,priorityLevel:e,startTime:r,expirationTime:l=r+l,sortIndex:-1},r>i?(e.sortIndex=r,n(d,e),null===t(c)&&e===t(d)&&(g?(b(N),N=-1):g=!0,L(k,r-i))):(e.sortIndex=l,n(c,e),v||m||(v=!0,P(w))),e},a.unstable_shouldYield=M,a.unstable_wrapCallback=function(e){var a=h;return function(){var n=h;h=a;try{return e.apply(this,arguments)}finally{h=n}}}},982:(e,a,n)=>{e.exports=n(463)},207:(e,a,n)=>{var t=n(848),o=n(540),r=n(338);const i={price:99,guaranteeDays:30,trialDays:7,reframe:"",utm:{source:"definedict",medium:"extension",campaign:"upgrade"},checkoutUrl:"https://zovo.one/pricing"};function l(){const e=i.utm,a=i.checkoutUrl.includes("?")?"&":"?";return i.checkoutUrl+a+`utm_source=${e.source}&utm_medium=${e.medium}&utm_campaign=${e.campaign}`}function s(e,a){try{return"undefined"!=typeof chrome&&chrome.i18n&&chrome.i18n.getMessage?chrome.i18n.getMessage(e,a):""}catch{return""}}let c=!1;const d=[{id:"dictionaryapi.dev",label:"Free Dictionary API (default)"},{id:"wiktionary",label:"Wiktionary"},{id:"wordnet",label:"WordNet (bundled)"},{id:"custom",label:"Custom endpoint"}],p=[{code:"en",label:"English (default)"},{code:"fr",label:"French"},{code:"es",label:"Spanish"},{code:"de",label:"German"},{code:"ja",label:"Japanese"},{code:"zh",label:"Chinese"},{code:"pt",label:"Portuguese"},{code:"it",label:"Italian"},{code:"ko",label:"Korean"},{code:"ar",label:"Arabic"},{code:"hi",label:"Hindi"},{code:"ru",label:"Russian"}],u=[{id:"openai",label:"OpenAI",url:"https://api.openai.com/v1/chat/completions"},{id:"anthropic",label:"Anthropic",url:"https://api.anthropic.com/v1/messages"},{id:"groq",label:"Groq",url:"https://api.groq.com/openai/v1/chat/completions"},{id:"custom",label:"Custom endpoint",url:""}];function h(e){try{"light"===e?document.documentElement.setAttribute("data-theme","light"):"dark"===e?document.documentElement.setAttribute("data-theme","dark"):document.documentElement.removeAttribute("data-theme")}catch{}}function m({active:e,onSelect:a,tier:n}){return(0,t.jsxs)("nav",{className:"dd-opt-sidebar","aria-label":"Settings navigation",children:[(0,t.jsxs)("div",{className:"dd-opt-brand",children:[(0,t.jsx)("img",{className:"dd-opt-brand__icon",src:"icons/48.png",alt:"","aria-hidden":"true"}),(0,t.jsx)("span",{className:"dd-opt-brand__name",children:"Define"}),"pro"===n?(0,t.jsx)("span",{className:"defif0f1-badge defif0f1-badge--pro",children:"PRO"}):(0,t.jsx)("span",{className:"defif0f1-badge defif0f1-badge--free",children:"FREE"})]}),(0,t.jsx)("div",{className:"dd-opt-nav",role:"tablist",children:[{id:"dictionary",label:"Dictionary"},{id:"appearance",label:"Appearance"},{id:"byok",label:"BYOK / LLM"},{id:"study",label:"Study Tools"},{id:"license",label:"License"}].map(n=>(0,t.jsx)("button",{type:"button",className:"dd-opt-nav-btn",role:"tab","aria-selected":e===n.id,onClick:()=>a(n.id),children:n.label},n.id))})]})}function v({label:e,pro:a,desc:n,children:o}){return(0,t.jsxs)("div",{className:"dd-opt-row",children:[(0,t.jsxs)("div",{className:"dd-opt-row__label-container",style:{flex:1},children:[(0,t.jsx)("span",{className:"dd-opt-row__label"+(a?" dd-opt-row__label--pro":""),children:e}),n&&(0,t.jsx)("span",{className:"dd-opt-row__desc",children:n})]}),o]})}function g({checked:e,onChange:a,ariaLabel:n}){return(0,t.jsx)("button",{type:"button",className:"dd-toggle",role:"switch","aria-checked":e,"aria-label":n,onClick:()=>a(!e),children:(0,t.jsx)("span",{className:"dd-toggle__knob"})})}function f({prefs:e,tier:a,onChange:n}){return(0,t.jsxs)("div",{className:"dd-opt-section--active",children:[(0,t.jsx)("h2",{className:"dd-opt-section__title",children:chrome.i18n.getMessage("optDictSource")}),(0,t.jsx)("p",{className:"dd-opt-section__desc",children:"Choose where Define fetches word definitions from."}),(0,t.jsxs)("div",{className:"dd-opt-card",children:[(0,t.jsx)("h3",{className:"dd-opt-card__title",children:"Source"}),(0,t.jsx)(v,{label:"Dictionary API",desc:"The backend that serves definitions",children:(0,t.jsx)("select",{className:"dd-select",value:e.dictionarySource,"aria-label":"Dictionary source",onChange:e=>n({dictionarySource:e.target.value}),children:d.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))})}),(0,t.jsx)(v,{label:chrome.i18n.getMessage("optTargetLang")||"Translate mode target",pro:!0,desc:"Define words in a target language (Pro)",children:(0,t.jsx)("select",{className:"dd-select",value:e.targetLanguage,disabled:"pro"!==a,"aria-label":"Target language",onChange:e=>n({targetLanguage:e.target.value}),children:p.map(e=>(0,t.jsx)("option",{value:e.code,children:e.label},e.code))})})]})]})}function b({theme:e,onChange:a}){const n=[{id:"auto",label:chrome.i18n.getMessage("themeAuto")||"System"},{id:"light",label:chrome.i18n.getMessage("themeLight")||"Light"},{id:"dark",label:chrome.i18n.getMessage("themeDark")||"Dark"}];return(0,t.jsxs)("div",{className:"dd-opt-section--active",children:[(0,t.jsx)("h2",{className:"dd-opt-section__title",children:chrome.i18n.getMessage("optTheme")}),(0,t.jsx)("p",{className:"dd-opt-section__desc",children:"Choose how Define looks. Dark mode uses a deep indigo-black surface."}),(0,t.jsxs)("div",{className:"dd-opt-card",children:[(0,t.jsx)("h3",{className:"dd-opt-card__title",children:chrome.i18n.getMessage("optTheme")}),(0,t.jsx)("div",{className:"dd-theme-group",role:"radiogroup","aria-label":"Theme",children:n.map(n=>(0,t.jsx)("button",{type:"button",className:"dd-theme-btn",role:"radio","aria-checked":e===n.id,onClick:()=>a(n.id),children:n.label},n.id))})]})]})}function y({prefs:e,tier:a,onChange:n}){return(0,t.jsxs)("div",{className:"dd-byok-config",children:[(0,t.jsxs)("div",{className:"dd-byok-config__field",children:[(0,t.jsx)("label",{htmlFor:"byok-model",children:chrome.i18n.getMessage("optByokModel")||"Model"}),(0,t.jsx)("input",{id:"byok-model",type:"text",className:"dd-input",value:e.byokModel,disabled:"pro"!==a,placeholder:"gpt-4o-mini",onChange:e=>n({byokModel:e.target.value})})]}),"custom"===e.byokEndpoint&&(0,t.jsxs)("div",{className:"dd-byok-config__field",children:[(0,t.jsx)("label",{htmlFor:"byok-url",children:chrome.i18n.getMessage("optByokEndpoint")||"Custom endpoint URL"}),(0,t.jsx)("input",{id:"byok-url",type:"url",className:"dd-input",disabled:"pro"!==a,placeholder:"https://your-api.com/v1/chat",onChange:()=>n({byokEndpoint:"custom"})})]})]})}function x({prefs:e,tier:a,onChange:n}){return(0,t.jsxs)("div",{className:"dd-opt-section--active",children:[(0,t.jsx)("h2",{className:"dd-opt-section__title",children:chrome.i18n.getMessage("optByokTitle")}),(0,t.jsx)("p",{className:"dd-opt-section__desc",children:'Bring your own API key for "Explain in context" features. Your key is stored locally only — never sent to servers.'}),(0,t.jsxs)("div",{className:"dd-opt-card",children:[(0,t.jsx)("h3",{className:"dd-opt-card__title",children:"Configuration"}),(0,t.jsx)(v,{label:chrome.i18n.getMessage("optByokProvider")||"Provider",pro:!0,desc:"Which LLM provider to use",children:(0,t.jsx)("select",{className:"dd-select",value:e.byokEndpoint,disabled:"pro"!==a,"aria-label":"BYOK provider",onChange:e=>n({byokEndpoint:e.target.value}),children:u.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))})}),(0,t.jsx)(y,{prefs:e,tier:a,onChange:n}),(0,t.jsx)(v,{label:"API key",pro:!0,desc:"Stored in chrome.storage.local only. Never logged or synced.",children:(0,t.jsx)("input",{type:"password",className:"dd-input",style:{maxWidth:"240px",fontFamily:"var(--defif0f1-font-mono)"},value:e.byokKey,disabled:"pro"!==a,placeholder:"sk-...","aria-label":"API key",onChange:e=>n({byokKey:e.target.value})})})]})]})}function k({tier:e}){const a=(0,o.useCallback)(e=>{try{chrome.runtime.sendMessage({type:"DEFIF0F1_EXPORT",payload:{format:e}})}catch{}},[]);return(0,t.jsxs)("div",{className:"dd-opt-card",children:[(0,t.jsx)("h3",{className:"dd-opt-card__title",children:chrome.i18n.getMessage("optExportTitle")}),(0,t.jsx)(v,{label:"Export to CSV",pro:!0,desc:"Comma-separated values for spreadsheets",children:(0,t.jsx)("button",{type:"button",className:"defif0f1-btn defif0f1-btn--secondary",disabled:"pro"!==e,onClick:()=>a("csv"),children:chrome.i18n.getMessage("exportCsv")||"Download CSV"})}),(0,t.jsx)(v,{label:"Export to Anki",pro:!0,desc:"Tab-separated for Anki import (.apkg compatible)",children:(0,t.jsx)("button",{type:"button",className:"defif0f1-btn defif0f1-btn--secondary",disabled:"pro"!==e,onClick:()=>a("anki"),children:chrome.i18n.getMessage("exportAnki")||"Download Anki TSV"})})]})}function w(){return(0,t.jsx)("div",{className:"dd-review-info",children:[{num:"SM-2",label:"Algorithm"},{num:"4",label:"Mastery levels"},{num:"Daily",label:"Review queue"}].map(e=>(0,t.jsxs)("div",{className:"dd-review-stat",children:[(0,t.jsx)("div",{className:"dd-review-stat__num",children:e.num}),(0,t.jsx)("div",{className:"dd-review-stat__label",children:e.label})]},e.label))})}function j({tier:e,reviewEnabled:a,onReviewToggle:n}){return(0,t.jsxs)("div",{className:"dd-opt-section--active",children:[(0,t.jsx)("h2",{className:"dd-opt-section__title",children:"Study Tools"}),(0,t.jsx)("p",{className:"dd-opt-section__desc",children:"Export your study list or enable spaced-repetition flashcards."}),(0,t.jsx)(k,{tier:e}),(0,t.jsxs)("div",{className:"dd-opt-card",children:[(0,t.jsx)("h3",{className:"dd-opt-card__title",children:chrome.i18n.getMessage("optReviewTitle")}),(0,t.jsx)(v,{label:"Enable review mode",pro:!0,desc:"Words reappear based on mastery",children:(0,t.jsx)(g,{checked:a&&"pro"===e,onChange:n,ariaLabel:"Toggle spaced repetition review mode"})}),a&&"pro"===e&&(0,t.jsx)(w,{})]})]})}function _({license:e}){const a="pro"===e.tier;return(0,t.jsxs)("div",{className:"dd-license-status",children:[(0,t.jsx)("div",{className:`dd-license-status__icon dd-license-status__icon--${e.tier}`,"aria-hidden":"true",children:a?(0,t.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{d:"M5 3l5 3 5-3v6a5 5 0 01-10 0V3z"})}):(0,t.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("circle",{cx:"10",cy:"10",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:a?"Define Pro":"Free tier"}),a&&e.key&&(0,t.jsxs)("p",{className:"defif0f1-muted defif0f1-mono",style:{fontSize:"12px",margin:"4px 0 0"},children:["Key: ",e.key.slice(0,8),"...",e.key.slice(-4)]}),!a&&(0,t.jsx)("p",{className:"defif0f1-muted",style:{fontSize:"13px",margin:"4px 0 0"},children:"50-word limit on saved words"})]})]})}function z(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"dd-paywall-mount",id:"paywall-mount"}),(0,t.jsx)("div",{className:"dd-btn-row",children:(0,t.jsx)("button",{type:"button",className:"defif0f1-btn defif0f1-btn--pro",onClick:()=>{const e=document.getElementById("paywall-mount");e&&function(e){!function(){if(!c)try{const e=document.createElement("style");e.textContent="\n.defif0f1-paywall-overlay {\n position: fixed; inset: 0; z-index: 2147483647;\n display: flex; align-items: center; justify-content: center;\n background: rgba(0,0,0,0.55);\n backdrop-filter: blur(2px);\n}\n.defif0f1-paywall-card {\n width: 340px; max-width: 90vw;\n background: var(--defif0f1-bg, #fff);\n border: 1px solid var(--defif0f1-border, #E5E7EB);\n border-radius: var(--defif0f1-radius-card, 12px);\n box-shadow: var(--defif0f1-shadow-lg, 0 24px 48px -12px rgba(0,0,0,0.28));\n padding: 28px 24px 24px;\n font-family: var(--defif0f1-font, 'Inter', sans-serif);\n color: var(--defif0f1-text, #1A1A2E);\n}\n.defif0f1-paywall-head {\n display: flex; align-items: center; gap: 8px;\n margin-bottom: 12px;\n}\n.defif0f1-paywall-title {\n flex: 1; margin: 0; font-size: 22px; font-weight: 700;\n letter-spacing: -0.02em;\n}\n.defif0f1-paywall-close {\n background: none; border: none; font-size: 24px; line-height: 1;\n cursor: pointer; color: var(--defif0f1-text-secondary, #6B7280);\n padding: 4px 8px; border-radius: 6px;\n}\n.defif0f1-paywall-close:hover { background: var(--defif0f1-surface-2, #F1F2F4); }\n.defif0f1-paywall-reframe {\n font-size: 15px; font-weight: 600; color: var(--defif0f1-pro, #F59E0B);\n margin: 0 0 16px;\n}\n.defif0f1-paywall-features {\n list-style: none; margin: 0 0 20px; padding: 0;\n display: flex; flex-direction: column; gap: 8px;\n}\n.defif0f1-paywall-features li {\n font-size: 14px; line-height: 1.5; color: var(--defif0f1-text, #1A1A2E);\n padding-left: 24px; position: relative;\n}\n.defif0f1-paywall-features li::before {\n content: '\\2713'; position: absolute; left: 0; top: 0;\n color: var(--defif0f1-success, #10B981); font-weight: 700;\n}\n.defif0f1-paywall-pricing {\n display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px;\n}\n.defif0f1-paywall-orig {\n font-size: 18px; text-decoration: line-through;\n color: var(--defif0f1-text-secondary, #6B7280);\n}\n.defif0f1-paywall-price {\n font-size: 40px; font-weight: 700; letter-spacing: -0.03em;\n color: var(--defif0f1-text, #1A1A2E);\n}\n.defif0f1-paywall-once {\n font-size: 13px; font-weight: 500;\n color: var(--defif0f1-text-secondary, #6B7280);\n}\n.defif0f1-paywall-socialproof {\n font-size: 13px; color: var(--defif0f1-text-secondary, #6B7280);\n margin: 0 0 4px;\n}\n.defif0f1-paywall-socialproof strong { color: var(--defif0f1-text, #1A1A2E); }\n.defif0f1-paywall-guarantee {\n font-size: 12px; color: var(--defif0f1-text-secondary, #6B7280);\n margin: 0 0 20px;\n}\n.defif0f1-paywall-cta { font-size: 16px; min-height: 48px; text-decoration: none; }\n",document.head.appendChild(e),c=!0}catch{}}(),e.innerHTML=function(){const e=i,a=s("paywallReframe")||"$99 once vs $9/mo forever",n="One-time payment",t="no subscription",o=s("paywallGuarantee",[String(e.guaranteeDays)])||`${e.guaranteeDays}-day money-back guarantee`,r=s("paywallTrial",[String(e.trialDays)])||`${e.trialDays}-day free trial, no card needed`;return['<div class="defif0f1-paywall-overlay" role="dialog"',' aria-modal="true" aria-label="Upgrade to Define Pro">',"",' <div class="defif0f1-paywall-card">',"",' <div class="defif0f1-paywall-head">',' <span class="defif0f1-badge defif0f1-badge--pro">PRO</span>',' <h2 class="defif0f1-paywall-title">Define Pro</h2>',' <button class="defif0f1-paywall-close" aria-label="Close">×</button>'," </div>","",` <p class="defif0f1-paywall-reframe">${a}</p>`,"",' <ul class="defif0f1-paywall-features">'," <li>Unlimited saved words</li>"," <li>Spaced-repetition flashcards</li>",' <li>BYOK "Explain in context" (OpenAI, Anthropic, Groq)</li>'," <li>Translate mode (30+ languages)</li>"," <li>Export to CSV & Anki</li>"," <li>Multi-dictionary source selector</li>"," </ul>","",' <div class="defif0f1-paywall-pricing">',"",` <span class="defif0f1-paywall-price">$${e.price}</span>`,' <span class="defif0f1-paywall-once">one-time</span>'," </div>","",' <p class="defif0f1-paywall-socialproof">',` <strong>${n}</strong> ·`,` <strong>${t}</strong>`," </p>","",' <p class="defif0f1-paywall-guarantee">',` ${o}`," </p>","",' <a class="defif0f1-btn defif0f1-btn--pro defif0f1-btn--block defif0f1-paywall-cta"',' href="'+l()+'" target="_blank"',' rel="noopener noreferrer">Upgrade to Pro</a>',""," </div>","</div>"].join("\n")}();const a=e.querySelector(".defif0f1-paywall-overlay");if(!a)return;const n=e.querySelector(".defif0f1-paywall-close"),t=()=>{try{e.removeChild(a)}catch{}};n&&n.addEventListener("click",t),a.addEventListener("click",e=>{e.target===a&&t()})}(e)},children:"View upgrade options"})})]})}function N({keyInput:e,verifying:a,error:n,onKeyChange:o,onActivate:r}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"dd-license-key-input",children:[(0,t.jsx)("input",{type:"text",className:"dd-input",placeholder:chrome.i18n.getMessage("licensePlaceholder")||"DEFI-XXXX-XXXX-XXXX-XXXX",value:e,"aria-label":"License key",onChange:e=>o(e.target.value)}),(0,t.jsx)("button",{type:"button",className:"defif0f1-btn defif0f1-btn--primary",disabled:!e.trim()||a,onClick:r,children:a?(0,t.jsx)("span",{className:"dd-spinner","aria-label":chrome.i18n.getMessage("licenseVerifying")||"Verifying"}):chrome.i18n.getMessage("licenseActivate")||"Activate"})]}),n&&(0,t.jsx)("p",{style:{color:"var(--defif0f1-error)",fontSize:"13px",marginTop:"8px"},children:n})]})}function C({onActivate:e}){const[a,n]=(0,o.useState)(""),[r,i]=(0,o.useState)(!1),[l,s]=(0,o.useState)(""),c=(0,o.useCallback)(()=>{if(a.trim()){i(!0),s("");try{chrome.runtime.sendMessage({type:"DEFIF0F1_VERIFY_LICENSE",payload:{key:a.trim()}},t=>{i(!1),"pro"===t?.tier?(e(a.trim()),n("")):s(t?.error??"Invalid key")})}catch{i(!1),s("Could not reach license server")}}},[a,e]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N,{keyInput:a,verifying:r,error:l,onKeyChange:n,onActivate:c}),(0,t.jsx)(z,{})]})}function E({license:e,onActivate:a}){const n="pro"===e.tier;return(0,t.jsxs)("div",{className:"dd-opt-section--active",children:[(0,t.jsx)("h2",{className:"dd-opt-section__title",children:chrome.i18n.getMessage("optLicenseTitle")}),(0,t.jsx)("p",{className:"dd-opt-section__desc",children:"Manage your Define Pro membership."}),(0,t.jsxs)("div",{className:"dd-opt-card",children:[(0,t.jsx)(_,{license:e}),!n&&(0,t.jsx)(C,{onActivate:a})]})]})}function M({activeTab:e,prefs:a,license:n,onPrefChange:o,onActivate:r}){switch(e){case"dictionary":return(0,t.jsx)(f,{prefs:a,tier:n.tier,onChange:o});case"appearance":return(0,t.jsx)(b,{theme:a.theme,onChange:e=>o({theme:e})});case"byok":return(0,t.jsx)(x,{prefs:a,tier:n.tier,onChange:o});case"study":return(0,t.jsx)(j,{tier:n.tier,reviewEnabled:a.reviewEnabled,onReviewToggle:e=>o({reviewEnabled:e})});case"license":return(0,t.jsx)(E,{license:n,onActivate:r});default:return null}}const S=document.getElementById("root");S&&(0,r.H)(S).render((0,t.jsx)(function(){const[e,a]=(0,o.useState)(null),[n,r]=(0,o.useState)({tier:"free",key:"",lastVerified:0}),[i,l]=(0,o.useState)("dictionary");(0,o.useEffect)(()=>{new Promise(e=>{try{chrome.storage.local.get(["definedict_prefs"],a=>{const n=a.definedict_prefs;e({dictionarySource:n?.dictionarySource??"dictionaryapi.dev",targetLanguage:n?.targetLanguage??"en",theme:n?.theme??"auto",byokEndpoint:n?.byokEndpoint??"openai",byokModel:n?.byokModel??"gpt-4o-mini",byokKey:n?.byokKey??"",reviewEnabled:n?.reviewEnabled??!1})})}catch{e({dictionarySource:"dictionaryapi.dev",targetLanguage:"en",theme:"auto",byokEndpoint:"openai",byokModel:"gpt-4o-mini",byokKey:"",reviewEnabled:!1})}}).then(e=>{a(e),h(e.theme)}),new Promise(e=>{try{chrome.storage.local.get(["definedict_license"],a=>{const n=a.definedict_license;e({tier:"pro"===n?.tier?"pro":"free",key:n?.key??"",lastVerified:n?.lastVerified??0})})}catch{e({tier:"free",key:"",lastVerified:0})}}).then(r)},[]);const s=(0,o.useCallback)(e=>{a(a=>{if(!a)return a;const n={...a,...e};return function(e){try{chrome.storage.local.set({definedict_prefs:e})}catch{}}(n),e.theme&&h(e.theme),n})},[]),c=(0,o.useCallback)(e=>{r({tier:"pro",key:e,lastVerified:Date.now()})},[]);return e?(0,t.jsxs)("div",{className:"dd-opt-layout",children:[(0,t.jsx)(m,{active:i,onSelect:l,tier:n.tier}),(0,t.jsx)("main",{className:"dd-opt-main",role:"tabpanel",children:(0,t.jsx)(M,{activeTab:i,prefs:e,license:n,onPrefChange:s,onActivate:c})})]}):(0,t.jsx)("div",{style:{padding:"60px",textAlign:"center"},children:(0,t.jsx)("span",{className:"dd-spinner","aria-label":"Loading"})})},{}))}},n={};function t(e){var o=n[e];if(void 0!==o)return o.exports;var r=n[e]={exports:{}};return a[e](r,r.exports,t),r.exports}t.m=a,e=[],t.O=(a,n,o,r)=>{if(!n){var i=1/0;for(d=0;d<e.length;d++){for(var[n,o,r]=e[d],l=!0,s=0;s<n.length;s++)(!1&r||i>=r)&&Object.keys(t.O).every(e=>t.O[e](n[s]))?n.splice(s--,1):(l=!1,r<i&&(i=r));if(l){e.splice(d--,1);var c=o();void 0!==c&&(a=c)}}return a}r=r||0;for(var d=e.length;d>0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[n,o,r]},t.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),(()=>{var e={575:0};t.O.j=a=>0===e[a];var a=(a,n)=>{var o,r,[i,l,s]=n,c=0;if(i.some(a=>0!==e[a])){for(o in l)t.o(l,o)&&(t.m[o]=l[o]);if(s)var d=s(t)}for(a&&a(n);c<i.length;c++)r=i[c],t.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return t.O(d)},n=self.webpackChunkdefine_dict=self.webpackChunkdefine_dict||[];n.forEach(a.bind(null,0)),n.push=a.bind(null,n.push.bind(n))})();var o=t.O(void 0,[411],()=>t(207));o=t.O(o)})();