1import{c as X,Q as V,r as g,a0 as H,j as e,A as G,E as K,B as j,N as F,L as C,a1 as Q,a2 as W,t as Y,a3 as Z,X as q,a4 as ee,o as N,a5 as se,a6 as J,$ as te}from"./index-DS5xRvqr.js";import{A as ae}from"./arrow-left-CKjW-YBi.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ne=X("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),w=20,re=1,ie=700,le=1e3*60*30,L="batch-patent:",ce=n=>new Promise(r=>setTimeout(r,n));function oe(n){try{const r=sessionStorage.getItem(L+n);if(!r)return null;const x=JSON.parse(r);return Date.now()-x.t>le?(sessionStorage.removeItem(L+n),null):x.d}catch{return null}}function de(n,r){try{sessionStorage.setItem(L+n,JSON.stringify({t:Date.now(),d:r}))}catch{}}async function me(n){const r=oe(n);if(r)return r;const a=await(await te("https://rrvraugvigylkdpstwsl.supabase.co/functions/v1/fetch-patent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJydnJhdWd2aWd5bGtkcHN0d3NsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg5NTk4MTgsImV4cCI6MjA4NDUzNTgxOH0.Ie360VrutksbiJ8vTxW7FCSMPij7qf-BPzvwoBsMFU8"},body:JSON.stringify({patentNumber:n}),timeoutMs:45e3,retries:0})).json().catch(()=>({success:!1,error:"ìëµ íì ì¤ë¥"}));if(!a.success||!a.data)throw new Error(a.error||"í¹í ì 보를 ì°¾ì ì ììµëë¤.");const u=a.data;return de(n,u),u}function xe(n,r=2){if(!n)return"";const a=n.replace(/\s+/g," ").trim().split(new RegExp("(?<=[.ã])\\s+")).slice(0,r).join(" ");return a.length>240?`${a.slice(0,240)}â¦`:a}const he=()=>{const[n]=V(),[r,x]=g.useState(""),[a,u]=g.useState([]),[v,E]=g.useState(!1),[c,P]=g.useState(null),R=g.useRef(null),{isLoading:A,summary:T,currentPatent:z,patentData:M,relatedPatents:O,generateSummary:_}=H(),$=s=>{P(s),s!==z&&_(s),setTimeout(()=>{var i;return(i=R.current)==null?void 0:i.scrollIntoView({behavior:"smooth",block:"start"})},80)},D=async s=>{if(v){N.info("ì´ë¯¸ ì¡°íê° ì§í ì¤ì ëë¤.");return}const{supported:i,unsupported:p,invalid:m}=se(s);if(p.length>0&&N.warning(`${p.map(l=>J[l.kind]).join("·")} ë²í¸ë ì§ìíì§ ìì ì ì¸íìµëë¤.`),m.length>0&&N.warning(`ë²í¸ íìì´ ìë í목 ${m.length}ê±´ì ì ì¸íìµëë¤.`),i.length===0){N.error("ì¡°í ê°ë¥í í¹í·ì¤ì©ì ì ë²í¸ê° ììµëë¤.");return}const o=new Set;let t=i.filter(l=>o.has(l.digits)?!1:(o.add(l.digits),!0));t.length<i.length&&N.info(`ì¤ë³µë ë²í¸ ${i.length-t.length}ê±´ì ì ì¸íìµëë¤.`),t.length>w&&(N.info(`í ë²ì ìµë ${w}ê±´ê¹ì§ ì¡°íí©ëë¤.`),t=t.slice(0,w));const d=t.map(l=>({key:l.digits,number:l.normalized,kindLabel:J[l.kind],status:"pending"}));u(d),E(!0);let k=0;const U=async()=>{for(;k<t.length;){const l=k++,I=t[l];l>0&&await ce(ie),u(f=>f.map(h=>h.key===I.digits?{...h,status:"loading"}:h));try{const f=await me(I.normalized);u(h=>h.map(b=>b.key===I.digits?{...b,status:"done",data:f}:b))}catch(f){const h=f instanceof Error?f.message:"ì¡°í ì¤í¨";u(b=>b.map(S=>S.key===I.digits?{...S,status:"error",error:h}:S))}}};await Promise.all(Array.from({length:Math.min(re,t.length)},U)),E(!1)};g.useEffect(()=>{const s=n.get("numbers");s&&(x(s.replace(/,/g,` 7`)),D(s))},[]);const y=g.useMemo(()=>({total:a.length,done:a.filter(s=>s.status==="done").length,error:a.filter(s=>s.status==="error").length}),[a]),B=()=>
7{const s=["ì¶ì·ë±ë¡ë²í¸","ëª ì¹","ì¶ìì¸","ì¶ìì¼","ë±ë¡ì¼","IPC","ì´ë¡"],i=a.filter(t=>t.data).map(t=>{const d=t.data;return[t.number,d.titleKo||d.title||"",d.assignee||"",d.filingDate||"",d.registrationDate||"",(d.classifications||[]).join(" "),(d.abstract||"").replace(/\s+/g," ")].map(k=>`"${String(k).replace(/"/g,'""')}"`).join(",")}),p="\uFEFF"+[s.join(","),...i].join(` 8`),m=URL.createObjectURL(new Blob([p],{type:"text/csv;charset=utf-8;"})),o=document.createElement("a");o.href=m,o.download=`AIS_ì¼ê´ì¡°í_${new Date().toISOString().slice(0,10)}.csv`,o.click(),URL.revokeObjectURL(m)};return e.jsx(G,{headerRight:e.jsx(K,{to:"/",children:e.jsxs(j,{variant:"outline",size:"sm",className:"rounded-full text-xs h-8 px-3 gap-1.5",children:[e.jsx(ae,{className:"w-3.5 h-3.5"})," íì¼ë¡"]})}),children:e.jsxs("div",{className:`${c?"max-w-[1500px]":"max-w-5xl"} mx-auto px-4 py-8 space-y-6 transition-all`,children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("div",{className:"font-mono text-[11px] tracking-[0.2em] text-primary uppercase",children:"§ Batch Lookup"}),e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight flex items-center gap-2",children:[e.jsx(F,{className:"w-6 h-6 text-primary"})," ì¼ê´ì¡°í"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["ì¬ë¬ ì¶ì·ë±ë¡ë²í¸ë¥¼ ì¤ë°ê¿ ëë ì¼íë¡ êµ¬ë¶í´ ì ë ¥íë©´ 목ë¡ì¼ë¡ í ë²ì ì ë¦¬í´ ë립ëë¤. (ìµë ",w,"ê±´)"]})]}),e.jsxs("div",{className:"rounded-2xl border border-border/50 bg-card p-4 space-y-3",children:[e.jsx("textarea",{value:r,onChange:s=>x(s.target.value),rows:5,spellCheck:!1,placeholder:`10-2021-0162560 920-2019-0003962 1010-2456789`,className:"w-full resize-y rounded-xl border border-border/50 bg-background p-3 text-sm font-mono outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/20"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(j,{onClick:()=>D(r),disabled:v||!r.trim(),className:"rounded-xl gap-2",children:[v?e.jsx(C,{className:"w-4 h-4 animate-spin"}):e.jsx(F,{className:"w-4 h-4"}),v?"ì¡°í ì¤":"ì¼ê´ì¡°í"]}),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{variant:"outline",className:"rounded-xl gap-2",onClick:B,disabled:y.done===0,children:[e.jsx(Q,{className:"w-4 h-4"})," CSV ì ì¥"]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["ì´ ",y.total,"ê±´ · ìë£ ",y.done,"ê±´",y.error>0?` · ì¤í¨ ${y.error}ê±´`:""]})]})]})]}),e.jsxs("div",{className:c?"flex flex-col lg:flex-row gap-5 items-start":"",children:[e.jsx("div",{className:c?"space-y-3 w-full lg:w-[340px] shrink-0 lg:sticky lg:top-24 lg:max-h-[calc(100vh-8rem)] lg:overflow-y-auto lg:pr-1":"space-y-3",children:a.map((s,i)=>{var m,o,t;const p=c===s.number;return e.jsx("article",{className:`rounded-2xl border bg-card p-4 transition-colors ${p?"border-primary/60 ring-1 ring-primary/20":"border-border/50"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground pt-1 w-8 shrink-0",children:String(i+1).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-primary",children:s.number}),e.jsx("span",{className:"text-[10px] rounded-full border border-border/60 px-2 py-0.5 text-muted-foreground",children:s.kindLabel}),s.status==="loading"&&e.jsx(C,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"}),s.status==="done"&&e.jsx(ne,{className:"w-3.5 h-3.5 text-primary"}),s.status==="error"&&e.jsx(W,{className:"w-3.5 h-3.5 text-destructive"})]}),s.status==="error"&&e.jsx("p",{className:"text-sm text-destructive",children:s.error}),s.status!=="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-[15px] font-semibold leading-snug",children:((m=s.data)==null?void 0:m.titleKo)||((o=s.data)==null?void 0:o.title)||(s.status==="done"?"ëª ì¹ ìì":"ì¡°í ì¤â¦")}),s.data&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs text-muted-foreground flex flex-wrap gap-x-3 gap-y-1",children:[s.data.assignee&&e.jsxs("span",{children:["ì¶ìì¸ ",s.data.assignee]}),s.data.filingDate&&e.jsxs("span",{children:["ì¶ìì¼ ",s.data.filingDate]}),!c&&s.data.registrationDate&&e.jsxs("span",{children:["ë±ë¡ì¼ ",s.data.registrationDate]}),!c&&((t=s.data.classifications)==null?void 0:t[0])&&e.jsxs("span",{children:["IPC ",s.data.classifications[0]]})]}),!c&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:xe(s.data.abstract)})]})]}),s.status==="done"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[e.jsxs(j,{size:"sm",variant:p?"default":"outline",className:"rounded-xl gap-1.5 h-8 text-xs",onClick:()=>$(s.number),children:[e.jsx(Y,{className:"w-3.5 h-3.5"})," AI ìì½ì"]}),e.jsxs(j,{size:"sm",variant:"ghost",className:"rounded-xl gap-1.5 h-8 text-xs text-muted-foreground",onClick:()=>window.open(`/?patent=${encodeURIComponent(s.number)}`,"_blank"),children:[e.jsx(Z,{className:"w-3.5 h-3.5"})," ì ì°½"]})]})]})]})},s.key)})}),c&&e.jsx("div",{ref:R,className:"min-w-0 flex-1 w-full",children:e.jsxs("div",{className:"rounded-2xl border border-border/50 bg-card p-4 md:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-[10px] tracking-[0.2em] text-primary uppercase",children:"§ AI Summary"}),e.jsx("div",{className:"font-mono text-xs text-muted-foreground truncate",children:c})]}),e.jsx(j,{size:"sm",variant:"ghost",className:"rounded-full h-8 px-2",onClick:()=>P(null),children:e.jsx(q,{className:"w-4 h-4"})})]}),A&&!T?e.jsxs("div",{className:"py-16 flex flex-col items-center gap-3 text-sm text-muted-foreground",children:[e.jsx(C,{className:"w-6 h-6 animate-spin text-primary"}),"AI ìì½ì를 ìì±íë ì¤ì ëë¤â¦"]}):e.jsx(ee,{content:T,patentNumber:z,isStreaming:A,patentData:M,relatedPatents:O,onRelatedPatentClick:s=>
10$(s)})]})})]})]})})};export{he as default};
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.