1import{r as l,j as e}from"./react-vendor-CR6PEHFZ.js";import{P as ce}from"./PitchAccentCarousel-Dyzc6lO4.js";import{b as de}from"./PitchAccentSVG-DQwSD2bK.js";import{c as pe}from"./popup-positioning-exIlhfJJ.js";import{u as ue}from"./useVisualViewportRect-D1a4QLn_.js";import"./index-4BgFHtDy.js";import"./charts-B4FZmgI2.js";import"./motion-CJOt5odT.js";import"./sentry-vendor-TOuwz_QY.js";import"./chevron-right-DpQDBVGz.js";const me={noun:"Noun",verb:"Verb","adj-i":"i-adj","adj-na":"na-adj",adverb:"Adverb",adv:"Adverb",propn:"Proper Noun","suru-verb":"Suru Verb",particle:"Particle",auxiliary:"Auxiliary",conjunction:"Conjunction",interjection:"Interjection",pronoun:"Pronoun",counter:"Counter",prefix:"Prefix",suffix:"Suffix"};function fe(n){return n?me[n]||n:null}const c={solid:"hsl(var(--module-accent))"},a={text:"#2a3540",textSecondary:"#55606c",textMuted:"rgba(42, 53, 64, 0.50)",subtle:"rgba(42, 53, 64, 0.045)",borderNeutral:"rgba(42, 53, 64, 0.14)",paper:"#fdfbf7"},o={family:"'Inter', system-ui, -apple-system, sans-serif",familyJP:"'Noto Serif JP', 'Hiragino Mincho ProN', 'Yu Mincho', serif",familyMono:"'JetBrains Mono', ui-monospace, monospace",xs:11,base:13,md:14},Q=300,J=8,j=.55,w="sepia(0.15)",he=8;function O(n){const i=Number.parseFloat(n);return`url('/watercolor/cta-square-secondary-${Number.isFinite(i)?i>=15&&i<45?"orange":i>=45&&i<150?"green":i>=150&&i<255?"blue":i>=255&&i<320?"purple":i>=320&&i<350?"pink":"red":"blue"}--sq.webp')`}function ge(){return{panel:{position:"fixed",width:Q,fontFamily:o.family,fontSize:o.md,color:a.text,background:a.paper,border:0,borderRadius:4,boxShadow:"0 12px 32px rgba(42, 53, 64, 0.16), 0 3px 10px rgba(42, 53, 64, 0.10)",isolation:"isolate",zIndex:220,pointerEvents:"auto"},scrollWrap:{overflowY:"auto",borderRadius:4},panelInner:{padding:"18px 18px 16px"},closeBtn:{position:"absolute",top:12,right:12,width:22,height:22,background:"transparent",border:"none",cursor:"pointer",color:a.textMuted,fontSize:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:4,padding:0,zIndex:2},wordHeader:{marginBottom:10,paddingRight:20},wordText:{fontSize:27,fontWeight:600,lineHeight:1.25,fontFamily:o.familyJP,color:a.text},reading:{fontSize:"0.48em",color:c.solid,letterSpacing:"0.04em",fontWeight:400},lemma:{fontSize:o.xs,color:a.textMuted,marginTop:2},badgeRow:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:10},badge:n=>({display:"inline-flex",alignItems:"center",padding:"3px 9px",fontFamily:o.familyMono,fontSize:10,fontWeight:500,letterSpacing:"0.08em",textTransform:"uppercase",borderRadius:0,background:n?"transparent":a.subtle,color:n?c.solid:a.textSecondary}),meanings:{display:"flex",flexDirection:"column",gap:5},meaning:{display:"flex",gap:8,alignItems:"baseline",fontSize:o.base},meaningNum:{color:a.textMuted,fontSize:o.xs,fontWeight:500,minWidth:16,textAlign:"right",flexShrink:0},divider:{marginTop:12},pencilRule:{height:3,background:"var(--wc-asset-pencil-long-hori) left center / auto 100% repeat-x",opacity:j,filter:w},saveBtn:{width:"100%",padding:"8px 0",background:"transparent",color:c.solid,borderStyle:"solid",borderColor:"transparent",borderWidth:"6px 14px",borderImageSlice:"21 42 fill",borderImageWidth:"6px 14px",borderImageRepeat:"stretch",borderRadius:0,cursor:"pointer",fontSize:o.base,fontWeight:500,fontFamily:o.family},skeleton:{background:a.subtle,borderRadius:he},navRow:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginBottom:8},navBtn:n=>({width:26,height:26,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:0,borderRadius:0,cursor:n?"default":"pointer",color:n?a.textMuted:a.textSecondary,fontSize:o.md,fontWeight:700,padding:0,fontFamily:o.family}),navCounter:{fontSize:o.xs,color:a.textMuted,minWidth:28,textAlign:"center",fontVariantNumeric:"tabular-nums"},deckHeader:{display:"flex",alignItems:"center",gap:8,marginBottom:10,paddingRight:20},deckBackBtn:{width:26,height:26,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:0,borderRadius:0,cursor:"pointer",color:c.solid,fontSize:o.md,fontWeight:700,padding:0,fontFamily:o.family,flexShrink:0},deckTitle:{fontSize:o.md,fontWeight:600,color:c.solid},deckWordLabel:{fontSize:o.xs,color:a.textMuted,fontFamily:o.familyJP,padding:"4px 0"},deckList:{maxHeight:180,overflowY:"auto",margin:"0",padding:"0"},deckRow:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",cursor:"pointer",background:"transparent",border:"none",borderRadius:4,width:"100%",textAlign:"left",fontFamily:o.family,fontSize:o.base,color:a.text},deckCheckbox:n=>({width:16,height:16,borderRadius:4,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:n?c.solid:"transparent",border:n?`1px solid ${c.solid}`:`1px solid ${a.borderNeutral}`,transition:"background 0.15s, border-color 0.15s"}),deckName:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},deckSpinner:{width:12,height:12,border:`2px solid ${a.borderNeutral}`,borderTopColor:c.solid,borderRadius:"50%",flexShrink:0,animation:"scanner-popup-spin 0.6s linear infinite"},deckEmpty:{textAlign:"center",padding:"16px 0",color:a.textMuted,fontSize:o.base},deckFooter:{margin:"10px 0 0",padding:"10px 0 0"},createBtn:{display:"flex",alignItems:"center",gap:6,background:"transparent",border:"none",cursor:"pointer",color:c.solid,fontSize:o.base,fontFamily:o.family,padding:0,width:"100%"},createForm:{display:"flex",alignItems:"center",gap:6},createInput:{flex:1,height:28,padding:"0 8px",fontSize:o.base,fontFamily:o.family,color:a.text,background:a.subtle,border:`1px solid ${a.borderNeutral}`,borderRadius:8,outline:"none"},createSubmit:{height:28,padding:"0 10px",fontSize:o.xs,fontWeight:600,fontFamily:o.family,color:"white",background:c.solid,border:"none",borderRadius:8,cursor:"pointer",flexShrink:0}}}let K=!1;function xe(){if(K)return;K=!0;
1const n=document.createElement("style"),i=".wc-scanner-popup";n.textContent=["@keyframes scanner-popup-shimmer{0%{opacity:0.4}50%{opacity:0.7}100%{opacity:0.4}}","@keyframes scanner-popup-spin{to{transform:rotate(360deg)}}","@keyframes scanner-popup-fadein{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}",`${i}::before{content:'';position:absolute;inset:0;pointer-events:none;border-style:solid;border-color:transparent;border-width:8px 12px;border-image-source:var(--wc-asset-pencil-container);border-image-slice:80 120 fill;border-image-width:8px 12px;border-image-repeat:stretch;opacity:${j};filter:${w};z-index:0}`,`${i}>*{position:relative;z-index:1}`,`${i} .wc-sp-arrow{position:relative;isolation:isolate}`,`${i} .wc-sp-arrow::before{content:'';position:absolute;inset:0;pointer-events:none;border-style:solid;border-color:transparent;border-width:7px;border-image-source:var(--wc-asset-pencil-square);border-image-slice:110 fill;border-image-width:7px;border-image-repeat:stretch;opacity:${j};filter:${w};z-index:0}`,`${i} .wc-sp-arrow:disabled::before{opacity:0.22}`,`${i} .wc-sp-arrow>*{position:relative;z-index:1}`,`${i} .wc-sp-chip{position:relative;isolation:isolate}`,`${i} .wc-sp-chip::before{content:'';position:absolute;inset:0;pointer-events:none;border-style:solid;border-color:transparent;border-width:5px 8px;border-image-source:var(--wc-asset-pencil-container);border-image-slice:80 120 fill;border-image-width:5px 8px;border-image-repeat:stretch;opacity:${j};filter:${w};z-index:0}`,`${i} .wc-sp-chip>*{position:relative;z-index:1}`,`${i} .wc-sp-chip-cta{position:relative;isolation:isolate}`,`${i} .wc-sp-chip-cta::before{content:'';position:absolute;inset:0;pointer-events:none;border-style:solid;border-color:transparent;border-width:5px 8px;border-image-source:var(--pos-brush);border-image-slice:21 42 fill;border-image-width:5px 8px;border-image-repeat:stretch;z-index:0}`,`${i} .wc-sp-chip-cta>*{position:relative;z-index:1}`].join(""),document.head.appendChild(n)}const G={animation:"scanner-popup-fadein 0.18s ease-out both"};function Ne({word:n,isLoading:i,error:S,position:C,writingMode:U,onClose:X,deckApi:h,totalResults:I,currentIndex:R,onPrev:Z,onNext:ee}){xe();const M=ue(),r=ge(),x=n?.reading??null,$=x?de(x,n?.pitchAccent,n?.pitchPattern):[],[b,D]=l.useState("word"),[N,g]=l.useState([]),[P,E]=l.useState(!1),[z,F]=l.useState(null),[y,v]=l.useState(!1),[d,k]=l.useState(""),[f,L]=l.useState(!1),T=l.useRef(null),[W,te]=l.useState(0);l.useEffect(()=>{D("word")},[n?.vocabId]),l.useEffect(()=>{if(b!=="deck"||!n?.vocabId)return;let t=!1;return(async()=>{E(!0);try{const s=await h.fetchDecks(n.vocabId);t||g(s)}catch{}finally{t||E(!1)}})(),()=>{t=!0}},[b,n?.vocabId,h]),l.useEffect(()=>{y&&T.current?.focus()},[y]);const V=l.useCallback(t=>{D(t),te(s=>s+1)},[]),ne=l.useCallback(async(t,s)=>{if(!(z||!n?.vocabId)){F(t),g(p=>p.map(u=>u.deckId===t?{...u,containsVocab:!s}:u));try{await h.toggleVocab(t,n.vocabId,!s)||g(u=>u.map(B=>B.deckId===t?{...B,containsVocab:s}:B))}catch{g(p=>p.map(u=>u.deckId===t?{...u,containsVocab:s}:u))}finally{F(null)}}},[z,h,n?.vocabId]),A=l.useCallback(async()=>{const t=d.trim();if(!(!t||t.length<2||f)){L(!0);try{const s=await h.createDeck(t);s&&(g(p=>[...p,s]),k(""),v(!1))}catch{}finally{L(!1)}}},[d,f,h]),re=I>1,H=R>0,_=R<I-1,q=l.useRef(null),[ie,oe]=l.useState(void 0);l.useLayoutEffect(()=>{const t=q.current;if(!t||typeof ResizeObserver>"u")return;const s=()=>oe(t.getBoundingClientRect().height);s();const p=new ResizeObserver(s);return p.observe(t),()=>p.disconnect()},[]);const{left:ae,top:se}=pe({position:C,panelWidth:Q,panelHeight:ie,writingMode:U,margin:J,viewportRect:M}),le=`${Math.max(0,M.height-2*J)}px`;let m;const Y=document.elementFromPoint(C.x,C.y-20);return Y&&(m=getComputedStyle(Y).getPropertyValue("--module-accent").trim()),m||(m=getComputedStyle(document.documentElement).getPropertyValue("--module-accent").trim()),m||(m="206 51% 54%"),e.jsxs("div",{ref:q,className:"wc-scanner-popup",style:{...r.panel,left:ae,top:se,"--module-accent":m},onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onClick:t=>t.stopPropagation(),children:[e.jsx("button",{style:r.closeBtn,onClick:X,onMouseEnter:t=>{t.currentTarget.style.color=a.textSecondary},onMouseLeave:t=>{t.currentTarget.style.color=a.textMuted},"aria-label":"Close",children:"â"}),e.jsxs("div",{style:{...r.scrollWrap,maxHeight:le},children:[i&&e.jsxs("div",{style:r.panelInner,children:[e.jsx("div",{style:{...r.skeleton,height:30,width:100,marginBottom:8,animation:"scanner-popup-shimmer 1.2s infinite"}}),e.jsx("div",{style:{...r.skeleton,height:12,width:70,marginBottom:10,animation:"scanner-popup-shimmer 1.2s infinite"}}),e.jsx("div",{style:{...r.skeleton,height:14,width:"100%",marginBottom:5,animation:"scanner-popup-shimmer 1.2s infinite"}}),e.jsx("div",{style:{...r.skeleton,height:14,width:"80%",animation:"scanner-popup-shimmer 1.2s infinite"}})]}),!i&&S==="not_found"&&e.jsx("div",{style:{...r.panelInner,textAlign:"center",padding:"24px 16px",color:a.textMuted,fontSize:o.base},children:"Not in dictionary yet."}),!i&&S==="fetch_error"&&e.jsx("div",{style:{...r.panelInner,textAlign:"center",padding:"24px 16px",color:"#f87171",fontSize:o.base},children:"Lookup failed. Check connection."}),!i&&n&&b==="word"&&e.jsxs("div",{style:{...r.panelInner,...G},children:[re&&e.jsxs("div",{style:r.navRow,children:[e.jsx("button",{className:"wc-sp-arrow",style:r.navBtn(!H),onClick:Z,disabled:!H,"aria-label":"Previous result",children:e.jsx("span",{children:"â¹"})}),e.jsxs("span",{style:r.navCounter,children:[R+1,"/",I]}),e.jsx("button",{className:"wc-sp-arrow",style:r.navBtn(!_),onClick:ee,disabled:!_,"aria-label":"Next result",children:e.jsx("span",{children:"âº"})})]}),e.jsxs("div",{style:r.wordHeader,children:[e.jsx("div",{style:r.wordText,children:e.jsxs("ruby",{children:[n.lemmaSurface,e.jsx("rt",{style:r.reading,children:n.reading||""})]})}),n.lemmaSurface!==n.surface&&e.jsxs("div",{style:r.lemma,children:["â³"," ",n.surface]})]}),$.length>0&&x&&e.jsx("div",{style:{display:"flex",marginBottom:10},children:e.jsx(ce,{reading:x,patterns:$,showLabel:!1,textColor:a.text,arrowColor:a.textSecondary,idPrefix:"scan"})}),e.jsxs("div",{style:r.badgeRow,children:[n.pos&&e.jsx("span",{className:"wc-sp-chip-cta",style:{...r.badge(!0),"--pos-brush":O(m)},children:e.jsx("span",{children:fe(n.pos)})}),n.jlptLevel&&e.jsx("span",{className:"wc-sp-chip",style:r.badge(!1),children:e.jsx("span",{children:typeof n.jlptLevel=="number"?`N${n.jlptLevel}`:n.jlptLevel})}),n.freqRank&&n.freqRank<=2e4&&e.jsx("span",{className:"wc-sp-chip",style:r.badge(!1),children:e.jsxs("span",{children:["#",n.freqRank]})})]}),n.meanings.length>0&&e.jsx("div",{style:r.meanings,children:n.meanings.map((t,s)=>e.jsxs("div",{style:r.meaning,children:[e.jsxs("span",{style:r.meaningNum,children:[s+1,"."]}),e.jsx("span",{style:{lineHeight:1.4},children:t})]},s))}),n.vocabId&&e.jsxs("div",{style:r.divider,children:[e.jsx("div",{style:r.pencilRule}),e.jsx("div",{style:{paddingTop:10}
1,children:e.jsx("button",{style:{...r.saveBtn,borderImageSource:O(m)},onClick:()=>{V("deck"),v(!1),k("")},onMouseEnter:t=>{t.currentTarget.style.filter="brightness(0.9)"},onMouseLeave:t=>{t.currentTarget.style.filter="none"},children:"Save to Deck"})})]})]},`word-${W}`),!i&&n&&b==="deck"&&e.jsxs("div",{style:{...r.panelInner,...G},children:[e.jsxs("div",{style:r.deckHeader,children:[e.jsx("button",{className:"wc-sp-arrow",style:r.deckBackBtn,onClick:()=>V("word"),"aria-label":"Back to word",children:e.jsx("span",{children:"â¹"})}),e.jsx("span",{style:r.deckTitle,children:"Save to Deck"})]}),e.jsxs("div",{style:r.deckWordLabel,children:[n.lemmaSurface,n.reading?e.jsxs("span",{style:{color:c.solid},children:[" ","(",n.reading,")"]}):""]}),e.jsx("div",{style:{...r.pencilRule,marginBottom:10}}),P&&e.jsxs("div",{children:[e.jsx("div",{style:{...r.skeleton,height:32,width:"100%",marginBottom:6,animation:"scanner-popup-shimmer 1.2s infinite"}}),e.jsx("div",{style:{...r.skeleton,height:32,width:"100%",marginBottom:6,animation:"scanner-popup-shimmer 1.2s infinite"}}),e.jsx("div",{style:{...r.skeleton,height:32,width:"80%",animation:"scanner-popup-shimmer 1.2s infinite"}})]}),!P&&N.length===0&&!y&&e.jsx("div",{style:r.deckEmpty,children:"No custom decks yet"}),!P&&N.length>0&&e.jsx("div",{style:r.deckList,children:N.map(t=>e.jsxs("button",{style:r.deckRow,onClick:()=>ne(t.deckId,t.containsVocab),onMouseEnter:s=>{s.currentTarget.style.background=a.subtle},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:r.deckCheckbox(t.containsVocab),children:t.containsVocab&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:e.jsx("path",{d:"M2 5.5L4 7.5L8 3",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("span",{style:r.deckName,children:t.title}),z===t.deckId&&e.jsx("div",{style:r.deckSpinner})]},t.deckId))}),e.jsx("div",{style:r.pencilRule}),e.jsx("div",{style:r.deckFooter,children:y?e.jsxs("div",{style:r.createForm,children:[e.jsx("input",{ref:T,value:d,onChange:t=>k(t.target.value),onKeyDown:t=>{t.key==="Enter"?(t.preventDefault(),A()):t.key==="Escape"&&(v(!1),k(""))},placeholder:"Deck name...",style:r.createInput,onFocus:t=>{t.currentTarget.style.borderColor=c.solid},onBlur:t=>{t.currentTarget.style.borderColor=a.borderNeutral},maxLength:50,disabled:f}),e.jsx("button",{style:{...r.createSubmit,opacity:!d.trim()||d.trim().length<2||f?.5:1,cursor:!d.trim()||d.trim().length<2||f?"default":"pointer"},onClick:A,disabled:!d.trim()||d.trim().length<2||f,children:f?"...":"Create"})]}):e.jsxs("button",{style:r.createBtn,onClick:()=>v(!0),onMouseEnter:t=>{t.currentTarget.style.color=a.text},onMouseLeave:t=>{t.currentTarget.style.color=c.solid},children:[e.jsx("span",{style:{fontSize:15,lineHeight:1},children:"+"}),"Create new deck"]})})]},`deck-${W}`)]})]})}export{Ne as ScannerPopup};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.