1"use strict";(self.webpackChunkrevolut_tracker_frontend=self.webpackChunkrevolut_tracker_frontend||[]).push([[108],{3108(e,s,t){t.r(s),t.d(s,{default:()=>u});var a=t(9379),r=t(5043),i=t(3216),n=t(1009),d=t(5925),l=t(8655),o=t(4385),c=t(9941),x=t(8382),m=t(171),g=t(579);const u=()=>{var e,s;const{currentOrganization:t}=(0,d.A)(),u=(0,l.dj)(),h=(0,i.Zp)(),[b,p]=(0,r.useState)(!1),[k,j]=(0,r.useState)(()=>{try{return JSON.parse(sessionStorage.getItem("aiCategorizeResult"))}catch(e){return null}}),[y,f]=(0,r.useState)(null),[v,N]=(0,r.useState)(()=>{try{return JSON.parse(sessionStorage.getItem("aiCategorizeAdded"))||{}}catch(e){return{}}}),[w,z]=(0,r.useState)(null),A=(0,r.useCallback)(e=>{j(e),e?sessionStorage.setItem("aiCategorizeResult",JSON.stringify(e)):sessionStorage.removeItem("aiCategorizeResult")},[]),_=(0,r.useCallback)(e=>{N(s=>{const t="function"===typeof e?e(s):e;return sessionStorage.setItem("aiCategorizeAdded",JSON.stringify(t)),t})},[]),C=async()=>{p(!0),f(null);try{const e=await(0,c.vK)();A(e),_({}),null!==t&&void 0!==t&&t.id&&await(0,x.Lk)(t.id,"ai_categorize","complete").catch(()=>{})}catch(a){var e,s;const t=(null===a||void 0===a||null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||"Failed to run AI categorization";f(t),u.error(t)}finally{p(!1)}};return(0,g.jsxs)("div",{className:"max-w-4xl mx-auto",children:[(0,g.jsxs)("div",{className:"mb-6",children:[(0,g.jsx)("h1",{className:"text-2xl font-bold text-black dark:text-white",children:"AI Categorization"}),(0,g.jsx)("p",{className:"text-body mt-1",children:"Let Claude AI analyze your untagged transactions, suggest tags, and propose reusable tagging rules."})]}),!k&&!b&&(0,g.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark p-8 text-center",children:[(0,g.jsx)("div",{className:"inline-flex items-center justify-center h-16 w-16 rounded-full bg-brand-500/10 text-brand-500 mb-4",children:(0,g.jsx)(n.FrA,{size:28})}),(0,g.jsx)("h2",{className:"text-lg font-semibold text-black dark:text-white mb-2",children:"Analyze Transactions with AI"}),(0,g.jsx)("p",{className:"text-sm text-body max-w-md mx-auto mb-6",children:"Claude will review up to 50 of your untagged transactions, suggest appropriate tags for each, and propose simple rules to automatically categorize similar transactions in the future."}),y&&(0,g.jsxs)("div",{className:"flex items-center gap-2 justify-center text-sm text-danger mb-4",children:[(0,g.jsx)(n.y3G,{size:14}),y]}),(0,g.jsx)(o.$n,{onClick:C,variant:"primary",icon:n.FrA,children:"Run AI Analysis"}),(0,g.jsx)("p",{className:"text-xs text-body/50 mt-3",children:"Uses Claude Haiku for fast, cost-effective analysis"})]}),b&&(0,g.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark p-12 flex flex-col items-center",children:[(0,g.jsx)(o.y$,{size:"lg"}),(0,g.jsx)("p",{className:"text-sm text-body mt-4",children:"Analyzing transactions..."}),(0,g.jsx)("p",{className:"text-xs text-body/50 mt-1",children:"This usually takes 5-15 seconds"})]}),k&&!b&&(0,g.jsxs)("div",{className:"space-y-6",children:[(0,g.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark p-4 flex items-center justify-between",children:[(0,g.jsxs)("div",{className:"text-sm text-body",children:["Analyzed ",(0,g.jsx)("span",{className:"font-semibold text-black dark:text-white",children:k.transactions_analyzed})," transactions",k.usage&&(0,g.jsxs)("span",{className:"text-body/50 ml-2",children:["(",k.usage.input_tokens+k.usage.output_tokens," tokens)"]})]}),(0,g.jsx)(o.$n,{size:"sm",variant:"outline",onClick:C,icon:n.FrA,children:"Re-run"})]}),(null===(e=k.proposed_rules)||void 0===e?void 0:e.length)>0&&(0,g.jsxs)("div",{children:[(0,g.jsxs)("h2",{className:"flex items-center gap-2 text-lg font-semibold text-black dark:text-white mb-3",children:[(0,g.jsx)(n.Wm,{size:18}),"Proposed Tagging Rules"]}),(0,g.jsx)("p",{className:"text-sm text-body mb-4",children:"These rules can automatically tag future transactions. Review and add the ones that make sense."}),(0,g.jsx)("div",{className:"space-y-3",children:k.proposed_rules.map((e,s)=>{var t,r;const i=v[s],d=w===s;return(0,g.jsx)("div",{className:"rounded-lg border bg-white dark:bg-boxdark p-4 ".concat(i?"border-success/30 bg-success/5":"border-stroke dark:border-strokedark"),children:(0,g.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,g.jsxs)("div",{className:"min-w-0",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2",children:[(0,g.jsx)("h3",{className:"text-sm font-semibold text-black dark:text-white",children:e.name}),i&&(0,g.jsxs)(o.Ex,{variant:"success",size:"sm",children:[(0,g.jsx)(n.YrT,{size:10,
1className:"mr-1"}),"Added"]})]}),(0,g.jsx)("p",{className:"text-xs text-body mt-1",children:e.reason}),(0,g.jsxs)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[null===(t=e.conditions)||void 0===t?void 0:t.map((e,s)=>(0,g.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 text-[11px] font-medium rounded bg-gray-2 dark:bg-meta-4 text-body",children:[e.field," ",e.operator,' "',e.value,'"']},s)),e.condition_operator&&(null===(r=e.conditions)||void 0===r?void 0:r.length)>1&&(0,g.jsxs)("span",{className:"text-[11px] text-body/50 self-center",children:["(",e.condition_operator,")"]})]}),e.estimated_matches>0&&(0,g.jsxs)("p",{className:"text-xs text-body/50 mt-1.5",children:["~",e.estimated_matches," matching transactions"]})]}),(0,g.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:i?(0,g.jsx)("span",{className:"text-xs text-success font-medium",children:"Rule created"}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o.$n,{size:"sm",variant:"outline",onClick:()=>(e=>{h("/tagging-rules/new",{state:{prefill:{name:e.name,tag_id:e.tag_id,conditions:e.conditions,condition_operator:e.condition_operator||"AND"}}})})(e),disabled:d,icon:n.WXf,children:"Customize & Add"}),(0,g.jsx)(o.$n,{size:"sm",variant:"primary",onClick:()=>(async(e,s)=>{z(s);try{await m.A.createRule({name:e.name,tag_id:e.tag_id,conditions:e.conditions,condition_operator:e.condition_operator||"AND",enabled:!0}),_(e=>(0,a.A)((0,a.A)({},e),{},{[s]:!0})),u.success('Rule "'.concat(e.name,'" added'))}catch(t){u.error('Failed to add rule "'.concat(e.name,'"'))}finally{z(null)}})(e,s),disabled:d,children:d?(0,g.jsx)(o.y$,{size:"sm",color:"white"}):"Add"})]})})]})},s)})})]}),(null===(s=k.suggestions)||void 0===s?void 0:s.length)>0&&(0,g.jsxs)("div",{children:[(0,g.jsxs)("h2",{className:"flex items-center gap-2 text-lg font-semibold text-black dark:text-white mb-3",children:[(0,g.jsx)(n.cnX,{size:18}),"Tag Suggestions"]}),(0,g.jsx)("p",{className:"text-sm text-body mb-4",children:"Individual tag suggestions for analyzed transactions. Go to Auto-tagging to review and apply."}),(0,g.jsxs)("div",{className:"rounded-lg border border-stroke bg-white dark:border-strokedark dark:bg-boxdark overflow-hidden",children:[(0,g.jsxs)("table",{className:"w-full text-sm",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{className:"border-b border-stroke dark:border-strokedark",children:[(0,g.jsx)("th",{className:"px-4 py-3 text-left font-semibold text-black dark:text-white bg-gray-1 dark:bg-boxdark-2",children:"Transaction"}),(0,g.jsx)("th",{className:"px-4 py-3 text-left font-semibold text-black dark:text-white bg-gray-1 dark:bg-boxdark-2",children:"Suggested Tag"}),(0,g.jsx)("th",{className:"px-4 py-3 text-left font-semibold text-black dark:text-white bg-gray-1 dark:bg-boxdark-2",children:"Confidence"})]})}),(0,g.jsx)("tbody",{children:k.suggestions.slice(0,20).map((e,s)=>{return(0,g.jsxs)("tr",{className:"border-b border-stroke dark:border-strokedark last:border-0",children:[(0,g.jsxs)("td",{className:"px-4 py-3 text-body dark:text-bodydark",children:[(0,g.jsxs)("span",{className:"text-xs text-body/50",children:["#",e.transaction_id]}),e.reason&&(0,g.jsx)("span",{className:"ml-2 text-xs",children:e.reason})]}),(0,g.jsx)("td",{className:"px-4 py-3",children:(0,g.jsxs)(o.Ex,{variant:"primary",size:"sm",children:["Tag #",e.tag_id]})}),(0,g.jsx)("td",{className:"px-4 py-3",children:(0,g.jsx)(o.Ex,{variant:(t=e.confidence,"high"===t?"success":"medium"===t?"warning":"default"),size:"sm",children:e.confidence})})]},s);var t})})]}),k.suggestions.length>20&&(0,g.jsxs)("div",{className:"px-4 py-3 text-xs text-body/50 border-t border-stroke dark:border-strokedark",children:["Showing 20 of ",k.suggestions.length," suggestions"]})]})]}),(0,g.jsxs)("div",{className:"rounded-lg border border-brand-500/20 bg-brand-500/5 p-4 flex items-center justify-between",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("p",{className:"text-sm font-medium text-black dark:text-white",children:"What's next?"}),(0,g.jsx)("p",{className:"text-xs text-body mt-0.5",children:"Add the proposed rules to automate tagging, or review individual suggestions in Auto-tagging."})]}),(0,g.jsxs)("div",{className:"flex gap-2",children:[(0,g.jsx)(o.$n,{size:"sm",variant:"outline",onClick:()=>h("/tagging-rules"),children:"Tagging Rules"}),(0,g.jsx)(o.$n,{size:"sm",onClick:()=>h("/setup"),icon:n.dyV,iconPosition:"right",children:"Back to Setup"})]})]})]})]})}}}]); 2//# sourceMappingURL=108.69aa7dc5.chunk.js.map
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.