larkup 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/diagnostics/route-bundle-stats.json +22 -22
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +16 -16
- package/.next/server/app/_not-found.segments/_full.segment.rsc +16 -16
- package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/analytics/page.js.nft.json +1 -1
- package/.next/server/app/analytics/page_client-reference-manifest.js +1 -1
- package/.next/server/app/analytics.html +1 -1
- package/.next/server/app/analytics.rsc +17 -17
- package/.next/server/app/analytics.segments/_full.segment.rsc +17 -17
- package/.next/server/app/analytics.segments/_head.segment.rsc +4 -4
- package/.next/server/app/analytics.segments/_index.segment.rsc +11 -11
- package/.next/server/app/analytics.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/analytics.segments/analytics/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/analytics.segments/analytics.segment.rsc +3 -3
- package/.next/server/app/api/chat/route.js +8 -9
- package/.next/server/app/api/chat/route.js.nft.json +1 -1
- package/.next/server/app/api/config/test-provider/route.js +4 -4
- package/.next/server/app/api/config/test-provider/route.js.nft.json +1 -1
- package/.next/server/app/api/config/verify/route.js +3 -3
- package/.next/server/app/api/config/verify/route.js.nft.json +1 -1
- package/.next/server/app/api/marketplace/[toolId]/route.js +1 -1
- package/.next/server/app/api/marketplace/[toolId]/route.js.nft.json +1 -1
- package/.next/server/app/api/marketplace/route.js +1 -1
- package/.next/server/app/api/marketplace/route.js.nft.json +1 -1
- package/.next/server/app/api/media/process/route.js +2 -2
- package/.next/server/app/api/media/process/route.js.nft.json +1 -1
- package/.next/server/app/api/media/route.js +1 -1
- package/.next/server/app/api/media/route.js.nft.json +1 -1
- package/.next/server/app/chat/page.js.nft.json +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +17 -17
- package/.next/server/app/chat.segments/_full.segment.rsc +17 -17
- package/.next/server/app/chat.segments/_head.segment.rsc +4 -4
- package/.next/server/app/chat.segments/_index.segment.rsc +11 -11
- package/.next/server/app/chat.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/chat.segments/chat.segment.rsc +3 -3
- package/.next/server/app/data/page.js.nft.json +1 -1
- package/.next/server/app/data/page_client-reference-manifest.js +1 -1
- package/.next/server/app/data.html +1 -1
- package/.next/server/app/data.rsc +17 -17
- package/.next/server/app/data.segments/_full.segment.rsc +17 -17
- package/.next/server/app/data.segments/_head.segment.rsc +4 -4
- package/.next/server/app/data.segments/_index.segment.rsc +11 -11
- package/.next/server/app/data.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/data.segments/data/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/data.segments/data.segment.rsc +3 -3
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +16 -16
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +16 -16
- package/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/server/app/index.segments/_index.segment.rsc +11 -11
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +18 -18
- package/.next/server/app/settings.segments/_full.segment.rsc +18 -18
- package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
- package/.next/server/app/settings.segments/_index.segment.rsc +11 -11
- package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/settings.segments/settings.segment.rsc +3 -3
- package/.next/server/chunks/0598_next_dist_esm_build_templates_app-route_0kbcuk-.js +4 -3
- package/.next/server/chunks/0598_next_dist_esm_build_templates_app-route_1f4h7rr.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__067hiof._.js +18 -6
- package/.next/server/chunks/[root-of-the-server]__0a_0ywc._.js +18 -6
- package/.next/server/chunks/[root-of-the-server]__0c80bj0._.js +3 -0
- package/.next/server/chunks/{[root-of-the-server]__1m7m2x7._.js → [root-of-the-server]__0drkoru._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__0vnm6_8._.js → [root-of-the-server]__0kmh740._.js} +6 -6
- package/.next/server/chunks/{[root-of-the-server]__0ou70-v._.js → [root-of-the-server]__0nfenje._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__0omd-x0._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0u17zp8._.js +18 -6
- package/.next/server/chunks/{[root-of-the-server]__1s1zui-._.js → [root-of-the-server]__10v5qsi._.js} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__1xuhh_i._.js → [root-of-the-server]__16jk_se._.js} +2 -2
- package/.next/server/chunks/[root-of-the-server]__1ahdfq9._.js +19 -7
- package/.next/server/chunks/[root-of-the-server]__1idgvjh._.js +172 -0
- package/.next/server/chunks/[root-of-the-server]__1ip05r1._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1jc54o2._.js +3 -0
- package/.next/server/chunks/{[root-of-the-server]__0748x7h._.js → [root-of-the-server]__1lhls88._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__1o3rcbz._.js +2 -1
- package/.next/server/chunks/{[root-of-the-server]__10gcb7d._.js → [root-of-the-server]__1qh2h5v._.js} +2 -2
- package/.next/server/chunks/[root-of-the-server]__1s9is1o._.js +2 -1
- package/.next/server/chunks/[root-of-the-server]__1vsvck0._.js +18 -6
- package/.next/server/chunks/{[root-of-the-server]__0g_q-44._.js → [root-of-the-server]__1wy6wes._.js} +2 -2
- package/.next/server/chunks/[root-of-the-server]__1zptg4z._.js +2 -1
- package/.next/server/chunks/{packages_1f4dx4h._.js → packages_1ggqion._.js} +2 -2
- package/.next/server/chunks/packages_core_src_generator_server-runtime_ts_1_68l7t._.js +4 -4
- package/.next/server/chunks/packages_marketplace_src_125_g2p._.js +1 -1
- package/.next/server/chunks/{packages_vector-stores_src_064-9ay._.js → packages_vector-stores_src_1fib7u-._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__0wdatpx._.js → [root-of-the-server]__0m21fli._.js} +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__1r9ap67._.js → [root-of-the-server]__0t8ud_u._.js} +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__046ldu_._.js → [root-of-the-server]__0xyo3ni._.js} +1 -1
- package/.next/server/chunks/ssr/{_0k81--x._.js → _0ckxy33._.js} +2 -2
- package/.next/server/chunks/ssr/_169pdlf._.js +6 -6
- package/.next/server/chunks/ssr/_1hetwwu._.js +4 -3
- package/.next/server/chunks/ssr/_1yqlx1m._.js +1 -1
- package/.next/server/chunks/ssr/apps_web_components_analytics_analytics-dashboard_tsx_1056-z3._.js +1 -1
- package/.next/server/chunks/ssr/apps_web_lib_pdf-images_ts_13-l5wa._.js +1 -1
- package/.next/server/functions-config-manifest.json +3 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/{3bpr59xr-_rv7.js → 0ge3nirnmx_np.js} +1 -1
- package/.next/static/chunks/{0rgt7-bqxonef.js → 1uzf7x2okeuab.js} +6 -6
- package/.next/static/chunks/{3g_wl1fri6jb-.js → 21_6-9hjj2i68.js} +1 -1
- package/.next/static/chunks/2ib3e0xrrdait.js +1 -0
- package/.next/static/chunks/2jrpgzxyrmuqp.js +121 -0
- package/.next/static/chunks/390ds7l_plpmd.js +1 -0
- package/.next/static/chunks/{3een1tiktxr6a.js → 3zw6tgf7mxo39.js} +1 -1
- package/CHANGELOG.md +22 -0
- package/app/api/chat/route.ts +1 -0
- package/app/api/chat/tools.ts +5 -1
- package/app/api/config/test-provider/route.ts +16 -18
- package/app/api/config/verify/route.ts +5 -7
- package/app/api/describe-image/route.ts +12 -4
- package/app/api/firecrawl/local/route.ts +1 -1
- package/app/api/jobs/route.ts +1 -2
- package/app/api/marketplace/[toolId]/route.ts +1 -0
- package/components/analytics/analytics-dashboard.tsx +1 -1
- package/components/data/firecrawl-notice.tsx +49 -98
- package/components/data/media-panel.tsx +34 -5
- package/components/data/scrape-panel.tsx +17 -1
- package/components/data/upload-panel.tsx +2 -1
- package/components/onboarding/welcome-screen.tsx +45 -15
- package/components/settings/general-section.tsx +15 -10
- package/components/settings/marketplace-section.tsx +14 -2
- package/components/settings/server-section.tsx +3 -3
- package/lib/error-formatter.ts +19 -4
- package/lib/pdf-images.ts +20 -5
- package/package.json +7 -7
- package/.next/server/chunks/[root-of-the-server]__00r1kgp._.js +0 -143
- package/.next/server/chunks/[root-of-the-server]__064gb96._.js +0 -3
- package/.next/server/chunks/_0ce9vcg._.js +0 -32
- package/.next/static/chunks/00z1f-adeq1lg.js +0 -1
- package/.next/static/chunks/0k405nomf6s4e.js +0 -120
- package/.next/static/chunks/13hmtkhrbm4t3.js +0 -1
- /package/.next/static/{bDwMIFYSTVBKUJkJJx77o → Laf7YhpONHOZXSCw6POiL}/_buildManifest.js +0 -0
- /package/.next/static/{bDwMIFYSTVBKUJkJJx77o → Laf7YhpONHOZXSCw6POiL}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{bDwMIFYSTVBKUJkJJx77o → Laf7YhpONHOZXSCw6POiL}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,288134,e=>{"use strict";let t=(0,e.i(874822).default)("zap",[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]);e.s(["Zap",0,t],288134)},1717,e=>{"use strict";var t=e.i(523829),s=e.i(178328),a=e.i(668548),r=e.i(831892),i=e.i(501375),n=e.i(887216),o=e.i(112786),l=e.i(104872),d=e.i(597343),c=e.i(7544),x=e.i(794189),u=e.i(370317),m=e.i(134018),h=e.i(300033),p=e.i(874822);let f=(0,p.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);var j=e.i(518864),g=e.i(501706);let y=(0,p.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var v=e.i(288134),C=e.i(842646);let b=e=>fetch(e).then(e=>e.json());function k(e,t,s){if("all"===t||!e)return e||[];let a=30;"7d"===t?a=7:"14d"===t?a=14:"30d"===t?a=30:"90d"===t&&(a=90);let r=[],i=new Date,n=new Map(e.map(e=>[e.date,e]));for(let e=a-1;e>=0;e--){let t=new Date(i);t.setDate(t.getDate()-e);let a=t.toISOString().split("T")[0];n.has(a)?r.push(n.get(a)):r.push({date:a,...s()})}return r}function N(e){return(e/1e6).toFixed(2)+"M"}e.s(["AnalyticsDashboard",0,function(){var e;let[p,w]=(0,s.useState)("overview"),[T,S]=(0,s.useState)("14d"),{data:L,isLoading:D,error:A}=(0,C.default)(`/api/analytics?timeframe=${T}`,b);if(D)return(0,t.jsxs)("div",{className:"p-8 flex-col gap-2 text-center text-muted-foreground animate-pulse flex items-center justify-center h-full",children:[(0,t.jsx)(g.Loader2,{className:"size-6 animate-spin"}),(0,t.jsx)("span",{className:"text-[15px]",children:"Loading analytics data..."})]});if(A||!L)return(0,t.jsx)("div",{className:"p-8 text-center text-destructive",children:"Failed to load analytics data."});let z=!L.serverTimeSeries?.length||L.serverTimeSeries.every(e=>0===e.requests),I=!L.embeddingTimeSeries?.length||L.embeddingTimeSeries.every(e=>0===e.tokens),O=!L.chatTimeSeries?.length||L.chatTimeSeries.every(e=>0===e.tokens),R=({title:e,description:s})=>(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-md",children:(0,t.jsxs)("div",{className:"flex flex-col items-center space-y-2 dark:bg-zinc-900/90 px-5 py-4 rounded-lg max-w-xl text-center",children:[(0,t.jsx)("div",{className:"p-2 border border-border/70 rounded-lg bg-white",children:(0,t.jsx)(f,{className:"size-6 text-black/80"})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-[16px] font-semibold text-foreground",children:e}),(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground",children:s})]})]})});return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Total Cost"}),(0,t.jsx)(f,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:0===(e=L.totalCost)?"$0.00":e<.01?e<1e-4?"<$0.0001":`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Across all paid models"})]})]}),(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Chat Tokens"}),(0,t.jsx)(y,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:N(L.totalChatTokens)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed in conversations"})]})]}),(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Embedding Tokens"}),(0,t.jsx)(j.Database,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:N(L.totalEmbeddingTokens)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed during indexing"})]})]}),(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Total Requests"}),(0,t.jsx)(v.Zap,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:L.totalRequests.toLocaleString()}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"To local RAG server this week"})]})]})]}),(0,t.jsxs)(m.Tabs,{value:p,onValueChange:w,className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,t.jsxs)(m.TabsList,{className:"inline-flex bg-white/70 dark:bg-muted/70 h-9 items-center justify-center rounded-lg border border-border p-0.5 text-muted-foreground",children:[(0,t.jsxs)(m.TabsTrigger,{value:"indexing",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,t.jsx)(j.Database,{className:"size-3.5 mr-1.5"}),"Indexing Usage"]}),(0,t.jsxs)(m.TabsTrigger,{value:"chat",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,t.jsx)(y,{className:"size-3.5 mr-1.5"}),"Chat Usage"]}),(0,t.jsxs)(m.TabsTrigger,{value:"overview",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,t.jsx)(f,{className:"size-3.5 mr-1.5"}),"Server Traffic"]})]}),(0,t.jsx)("div",{className:"flex items-center",children:(0,t.jsxs)(h.Select,{value:T,onValueChange:e=>e&&S(e),children:[(0,t.jsx)(h.SelectTrigger,{className:"w-[140px] h-10! text-sm bg-white dark:bg-background focus:ring-0 focus:border-input data-[state=open]:ring-0 data-[state=open]:border-input outline-none focus:outline-none",children:(0,t.jsxs)(h.SelectValue,{placeholder:"Select timeframe",children:["7d"===T&&"Last 7 days","14d"===T&&"Last 14 days","30d"===T&&"Last 30 days","90d"===T&&"Last 90 days","all"===T&&"All time"]})}),(0,t.jsxs)(h.SelectContent,{children:[(0,t.jsx)(h.SelectItem,{value:"7d",children:"Last 7 days"}),(0,t.jsx)(h.SelectItem,{value:"14d",children:"Last 14 days"}),(0,t.jsx)(h.SelectItem,{value:"30d",children:"Last 30 days"}),(0,t.jsx)(h.SelectItem,{value:"90d",children:"Last 90 days"}),(0,t.jsx)(h.SelectItem,{value:"all",children:"All time"})]})]})})]}),(0,t.jsx)(m.TabsContent,{value:"overview",className:"space-y-4",children:(0,t.jsxs)(u.Card,{className:"shadow-none! rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{children:[(0,t.jsx)(u.CardTitle,{children:"Requests to RAG Server"}),(0,t.jsx)(u.CardDescription,{children:"Daily requests sent to your local or remote deployed RAG endpoints."})]}),(0,t.jsx)(u.CardContent,{className:"px-2 sm:p-6",children:(0,t.jsxs)("div",{className:"h-[300px] w-full relative",children:[z&&(0,t.jsx)(R,{title:"No Server Traffic Yet",description:"Once you start sending requests to the RAG server, usage will appear here."}),(0,t.jsx)(l.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,t.jsxs)(n.BarChart,{data:k(L.serverTimeSeries,T,()=>({requests:0,avgLatencyMs:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,t.jsx)(o.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,t.jsx)(c.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:e=>{if(!e.includes("-"))return e;let[t,s,a]=e.split("-");return new Date(parseInt(t,10),parseInt(s,10)-1,parseInt(a,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,t.jsx)(x.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}`}),(0,t.jsx)(d.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"},cursor:{fill:"var(--color-muted)",opacity:.4}}),(0,t.jsx)(i.Bar,{dataKey:"requests",fill:"#3b82f6",radius:[4,4,0,0],maxBarSize:40,activeBar:{className:"outline-none focus:outline-none"}})]})})]})})]})}),(0,t.jsx)(m.TabsContent,{value:"indexing",className:"space-y-4",children:(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{children:[(0,t.jsx)(u.CardTitle,{children:"Indexing Token Usage"}),(0,t.jsx)(u.CardDescription,{children:"Daily tokens processed for document indexing."})]}),(0,t.jsx)(u.CardContent,{className:"px-2 sm:p-6",children:(0,t.jsxs)("div",{className:"h-[300px] w-full relative",children:[I&&(0,t.jsx)(R,{title:"No Indexing Data Yet",description:"Add documents to your knowledge bases to see embedding token usage here."}),(0,t.jsx)(l.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,t.jsxs)(r.AreaChart,{data:k(L.embeddingTimeSeries,T,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"colorIndexing",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",stopColor:"#f97316",stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:"#f97316",stopOpacity:0})]})}),(0,t.jsx)(o.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,t.jsx)(c.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:e=>{if(!e.includes("-"))return e;let[t,s,a]=e.split("-");return new Date(parseInt(t,10),parseInt(s,10)-1,parseInt(a,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,t.jsx)(x.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>`${e>=1e3?e/1e3+"k":e}`}),(0,t.jsx)(d.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,t.jsx)(a.Area,{type:"monotone",dataKey:"tokens",stroke:"#f97316",strokeWidth:2,fillOpacity:1,fill:"url(#colorIndexing)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})}),(0,t.jsx)(m.TabsContent,{value:"chat",className:"space-y-4",children:(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{children:[(0,t.jsx)(u.CardTitle,{children:"Chat Token Usage"}),(0,t.jsx)(u.CardDescription,{children:"Daily tokens processed for chat completions."})]}),(0,t.jsx)(u.CardContent,{className:"px-2 sm:p-6",children:(0,t.jsxs)("div",{className:"h-[300px] w-full relative",children:[O&&(0,t.jsx)(R,{title:"No Chat Data Yet",description:"Chat with the AI to see your token usage metrics here."}),(0,t.jsx)(l.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,t.jsxs)(r.AreaChart,{data:k(L.chatTimeSeries,T,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"colorChat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),(0,t.jsx)(o.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,t.jsx)(c.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:e=>{if(!e.includes("-"))return e;let[t,s,a]=e.split("-");return new Date(parseInt(t,10),parseInt(s,10)-1,parseInt(a,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,t.jsx)(x.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>`${e>=1e3?e/1e3+"k":e}`}),(0,t.jsx)(d.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,t.jsx)(a.Area,{type:"monotone",dataKey:"tokens",stroke:"#3b82f6",strokeWidth:2,fillOpacity:1,fill:"url(#colorChat)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})})]})]})}],1717)}]);
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,288134,e=>{"use strict";let t=(0,e.i(874822).default)("zap",[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]);e.s(["Zap",0,t],288134)},1717,e=>{"use strict";var t=e.i(523829),s=e.i(178328),a=e.i(668548),r=e.i(831892),i=e.i(501375),n=e.i(887216),o=e.i(112786),l=e.i(104872),d=e.i(597343),c=e.i(7544),x=e.i(794189),u=e.i(370317),m=e.i(134018),h=e.i(300033),p=e.i(874822);let f=(0,p.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);var j=e.i(518864),g=e.i(501706);let y=(0,p.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var v=e.i(288134),C=e.i(842646);let b=e=>fetch(e).then(e=>e.json());function k(e,t,s){if("all"===t||!e)return e||[];let a=30;"7d"===t?a=7:"14d"===t?a=14:"30d"===t?a=30:"90d"===t&&(a=90);let r=[],i=new Date,n=new Map(e.map(e=>[e.date,e]));for(let e=a-1;e>=0;e--){let t=new Date(i);t.setDate(t.getDate()-e);let a=t.toISOString().split("T")[0];n.has(a)?r.push(n.get(a)):r.push({date:a,...s()})}return r}function N(e){return(e/1e6).toFixed(2)+"M"}e.s(["AnalyticsDashboard",0,function(){var e;let[p,w]=(0,s.useState)("indexing"),[T,S]=(0,s.useState)("14d"),{data:L,isLoading:D,error:A}=(0,C.default)(`/api/analytics?timeframe=${T}`,b);if(D)return(0,t.jsxs)("div",{className:"p-8 flex-col gap-2 text-center text-muted-foreground animate-pulse flex items-center justify-center h-full",children:[(0,t.jsx)(g.Loader2,{className:"size-6 animate-spin"}),(0,t.jsx)("span",{className:"text-[15px]",children:"Loading analytics data..."})]});if(A||!L)return(0,t.jsx)("div",{className:"p-8 text-center text-destructive",children:"Failed to load analytics data."});let z=!L.serverTimeSeries?.length||L.serverTimeSeries.every(e=>0===e.requests),I=!L.embeddingTimeSeries?.length||L.embeddingTimeSeries.every(e=>0===e.tokens),O=!L.chatTimeSeries?.length||L.chatTimeSeries.every(e=>0===e.tokens),R=({title:e,description:s})=>(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-md",children:(0,t.jsxs)("div",{className:"flex flex-col items-center space-y-2 dark:bg-zinc-900/90 px-5 py-4 rounded-lg max-w-xl text-center",children:[(0,t.jsx)("div",{className:"p-2 border border-border/70 rounded-lg bg-white",children:(0,t.jsx)(f,{className:"size-6 text-black/80"})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-[16px] font-semibold text-foreground",children:e}),(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground",children:s})]})]})});return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Total Cost"}),(0,t.jsx)(f,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:0===(e=L.totalCost)?"$0.00":e<.01?e<1e-4?"<$0.0001":`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Across all paid models"})]})]}),(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Chat Tokens"}),(0,t.jsx)(y,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:N(L.totalChatTokens)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed in conversations"})]})]}),(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Embedding Tokens"}),(0,t.jsx)(j.Database,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:N(L.totalEmbeddingTokens)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed during indexing"})]})]}),(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,t.jsx)(u.CardTitle,{className:"text-sm font-medium",children:"Total Requests"}),(0,t.jsx)(v.Zap,{className:"size-4 text-muted-foreground"})]}),(0,t.jsxs)(u.CardContent,{children:[(0,t.jsx)("div",{className:"text-2xl font-bold",children:L.totalRequests.toLocaleString()}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"To local RAG server this week"})]})]})]}),(0,t.jsxs)(m.Tabs,{value:p,onValueChange:w,className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,t.jsxs)(m.TabsList,{className:"inline-flex bg-white/70 dark:bg-muted/70 h-9 items-center justify-center rounded-lg border border-border p-0.5 text-muted-foreground",children:[(0,t.jsxs)(m.TabsTrigger,{value:"indexing",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,t.jsx)(j.Database,{className:"size-3.5 mr-1.5"}),"Indexing Usage"]}),(0,t.jsxs)(m.TabsTrigger,{value:"chat",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,t.jsx)(y,{className:"size-3.5 mr-1.5"}),"Chat Usage"]}),(0,t.jsxs)(m.TabsTrigger,{value:"overview",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,t.jsx)(f,{className:"size-3.5 mr-1.5"}),"Server Traffic"]})]}),(0,t.jsx)("div",{className:"flex items-center",children:(0,t.jsxs)(h.Select,{value:T,onValueChange:e=>e&&S(e),children:[(0,t.jsx)(h.SelectTrigger,{className:"w-[140px] h-10! text-sm bg-white dark:bg-background focus:ring-0 focus:border-input data-[state=open]:ring-0 data-[state=open]:border-input outline-none focus:outline-none",children:(0,t.jsxs)(h.SelectValue,{placeholder:"Select timeframe",children:["7d"===T&&"Last 7 days","14d"===T&&"Last 14 days","30d"===T&&"Last 30 days","90d"===T&&"Last 90 days","all"===T&&"All time"]})}),(0,t.jsxs)(h.SelectContent,{children:[(0,t.jsx)(h.SelectItem,{value:"7d",children:"Last 7 days"}),(0,t.jsx)(h.SelectItem,{value:"14d",children:"Last 14 days"}),(0,t.jsx)(h.SelectItem,{value:"30d",children:"Last 30 days"}),(0,t.jsx)(h.SelectItem,{value:"90d",children:"Last 90 days"}),(0,t.jsx)(h.SelectItem,{value:"all",children:"All time"})]})]})})]}),(0,t.jsx)(m.TabsContent,{value:"overview",className:"space-y-4",children:(0,t.jsxs)(u.Card,{className:"shadow-none! rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{children:[(0,t.jsx)(u.CardTitle,{children:"Requests to RAG Server"}),(0,t.jsx)(u.CardDescription,{children:"Daily requests sent to your local or remote deployed RAG endpoints."})]}),(0,t.jsx)(u.CardContent,{className:"px-2 sm:p-6",children:(0,t.jsxs)("div",{className:"h-[300px] w-full relative",children:[z&&(0,t.jsx)(R,{title:"No Server Traffic Yet",description:"Once you start sending requests to the RAG server, usage will appear here."}),(0,t.jsx)(l.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,t.jsxs)(n.BarChart,{data:k(L.serverTimeSeries,T,()=>({requests:0,avgLatencyMs:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,t.jsx)(o.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,t.jsx)(c.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:e=>{if(!e.includes("-"))return e;let[t,s,a]=e.split("-");return new Date(parseInt(t,10),parseInt(s,10)-1,parseInt(a,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,t.jsx)(x.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>`${e}`}),(0,t.jsx)(d.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"},cursor:{fill:"var(--color-muted)",opacity:.4}}),(0,t.jsx)(i.Bar,{dataKey:"requests",fill:"#3b82f6",radius:[4,4,0,0],maxBarSize:40,activeBar:{className:"outline-none focus:outline-none"}})]})})]})})]})}),(0,t.jsx)(m.TabsContent,{value:"indexing",className:"space-y-4",children:(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{children:[(0,t.jsx)(u.CardTitle,{children:"Indexing Token Usage"}),(0,t.jsx)(u.CardDescription,{children:"Daily tokens processed for document indexing."})]}),(0,t.jsx)(u.CardContent,{className:"px-2 sm:p-6",children:(0,t.jsxs)("div",{className:"h-[300px] w-full relative",children:[I&&(0,t.jsx)(R,{title:"No Indexing Data Yet",description:"Add documents to your knowledge bases to see embedding token usage here."}),(0,t.jsx)(l.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,t.jsxs)(r.AreaChart,{data:k(L.embeddingTimeSeries,T,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"colorIndexing",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",stopColor:"#f97316",stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:"#f97316",stopOpacity:0})]})}),(0,t.jsx)(o.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,t.jsx)(c.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:e=>{if(!e.includes("-"))return e;let[t,s,a]=e.split("-");return new Date(parseInt(t,10),parseInt(s,10)-1,parseInt(a,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,t.jsx)(x.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>`${e>=1e3?e/1e3+"k":e}`}),(0,t.jsx)(d.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,t.jsx)(a.Area,{type:"monotone",dataKey:"tokens",stroke:"#f97316",strokeWidth:2,fillOpacity:1,fill:"url(#colorIndexing)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})}),(0,t.jsx)(m.TabsContent,{value:"chat",className:"space-y-4",children:(0,t.jsxs)(u.Card,{className:"shadow-none rounded-xl",children:[(0,t.jsxs)(u.CardHeader,{children:[(0,t.jsx)(u.CardTitle,{children:"Chat Token Usage"}),(0,t.jsx)(u.CardDescription,{children:"Daily tokens processed for chat completions."})]}),(0,t.jsx)(u.CardContent,{className:"px-2 sm:p-6",children:(0,t.jsxs)("div",{className:"h-[300px] w-full relative",children:[O&&(0,t.jsx)(R,{title:"No Chat Data Yet",description:"Chat with the AI to see your token usage metrics here."}),(0,t.jsx)(l.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,t.jsxs)(r.AreaChart,{data:k(L.chatTimeSeries,T,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"colorChat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.3}),(0,t.jsx)("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),(0,t.jsx)(o.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,t.jsx)(c.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:e=>{if(!e.includes("-"))return e;let[t,s,a]=e.split("-");return new Date(parseInt(t,10),parseInt(s,10)-1,parseInt(a,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,t.jsx)(x.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:e=>`${e>=1e3?e/1e3+"k":e}`}),(0,t.jsx)(d.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,t.jsx)(a.Area,{type:"monotone",dataKey:"tokens",stroke:"#3b82f6",strokeWidth:2,fillOpacity:1,fill:"url(#colorChat)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})})]})]})}],1717)}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,385290,t=>{"use strict";var e=t.i(410386);async function a(t){e.GlobalWorkerOptions.workerSrc=`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${e.version}/pdf.worker.mjs`;let a=await t.arrayBuffer(),r=await e.getDocument({data:new Uint8Array(a)}).promise,i=r.numPages,n=[],h=0,o=t=>{let e=Math.min(1,1600/Math.max(t.width,t.height));if(1===e)return t.toDataURL("image/jpeg",.86);let a=document.createElement("canvas");return a.width=Math.max(1,Math.round(t.width*e)),a.height=Math.max(1,Math.round(t.height*e)),a.getContext("2d")?.drawImage(t,0,0,a.width,a.height),a.toDataURL("image/jpeg",.86)};for(let t=1;t<=i;t++)try{let a=await r.getPage(t),i=await a.getOperatorList(),g=[];for(let t=0;t<i.fnArray.length;t++)(i.fnArray[t]===e.OPS.paintImageXObject||i.fnArray[t]===e.OPS.paintInlineImageXObject)&&g.push(i.argsArray[t][0]);for(let e of g)try{let r=await new Promise(t=>{try{a.objs.get(e,e=>t(e))}catch(e){t(null)}});if(r&&r.bitmap){let e=document.createElement("canvas");e.width=r.bitmap.width||r.width,e.height=r.bitmap.height||r.height;let a=e.getContext("2d");a&&(a.drawImage(r.bitmap,0,0),n.push({base64:o(e),pageNumber:t,index:h++}))}else if(r&&r.data&&r.width&&r.height){let e=document.createElement("canvas");e.width=r.width,e.height=r.height;let a=e.getContext("2d");if(a){let i=new ImageData(new Uint8ClampedArray(r.data),r.width,r.height);a.putImageData(i,0,0),n.push({base64:o(e),pageNumber:t,index:h++})}}}catch(a){console.error(`Error extracting image ${e} on page ${t}`,a)}}catch(e){console.error(`Error processing page ${t}`,e)}return n}t.s(["extractImagesFromPDF",0,a])}]);
|