tabularium 0.3.0__py3-none-any.whl
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.
- app/__init__.py +1 -0
- app/_bundle/VERSION +1 -0
- app/_bundle/conf/profiles/lloyds-list-1900s.json +36 -0
- app/_bundle/frontend/dist/assets/AcceptInvitePage-mmfgf6m1.js +1 -0
- app/_bundle/frontend/dist/assets/AnnotationEntry-BwG_saxU.js +2 -0
- app/_bundle/frontend/dist/assets/AnnotationPage-DH-87aUG.js +40 -0
- app/_bundle/frontend/dist/assets/BenchmarkPage-qjFgbXPG.js +1 -0
- app/_bundle/frontend/dist/assets/ContentPane-DPwsshn8.js +7 -0
- app/_bundle/frontend/dist/assets/DatasetPage-DFRTWXF0.js +1 -0
- app/_bundle/frontend/dist/assets/EvaluationPage-BTn5VHpn.js +1 -0
- app/_bundle/frontend/dist/assets/FineTuningPage-B09T-w0T.js +1 -0
- app/_bundle/frontend/dist/assets/HomePage-Buvrl10l.js +1 -0
- app/_bundle/frontend/dist/assets/LoginPage-BacwEFgw.js +1 -0
- app/_bundle/frontend/dist/assets/ModelsHubPage-i-JlXvoV.js +3 -0
- app/_bundle/frontend/dist/assets/PipelineView-B61UZ5RU.js +1 -0
- app/_bundle/frontend/dist/assets/PlaygroundPage-DdLbW7Cz.js +3 -0
- app/_bundle/frontend/dist/assets/ProjectDetailPage-CmSNb4G_.js +1 -0
- app/_bundle/frontend/dist/assets/ProjectReader-fMmVHqkV.js +1 -0
- app/_bundle/frontend/dist/assets/ProjectsPage-DitX5ysq.js +1 -0
- app/_bundle/frontend/dist/assets/RecognizePage-VVw2Z-Qw.js +1 -0
- app/_bundle/frontend/dist/assets/ResultsPage-BIjY0LGg.js +1 -0
- app/_bundle/frontend/dist/assets/SetPasswordPage-CWb7kbIn.js +1 -0
- app/_bundle/frontend/dist/assets/SettingsPage-CaJbnPc9.js +2 -0
- app/_bundle/frontend/dist/assets/SetupPage-3w2m35t_.js +1 -0
- app/_bundle/frontend/dist/assets/ShareDialog-CNF0oznE.js +1 -0
- app/_bundle/frontend/dist/assets/TableEntry-DdlC3pJj.js +2 -0
- app/_bundle/frontend/dist/assets/TableWorkspacePage-DYqW4eXA.js +1 -0
- app/_bundle/frontend/dist/assets/TrainingPage-xnyPwDG9.js +57 -0
- app/_bundle/frontend/dist/assets/UniverSheet-BwKQUIYP.js +495 -0
- app/_bundle/frontend/dist/assets/UniverSheet-DbvMtUcB.css +1 -0
- app/_bundle/frontend/dist/assets/UsersPage-BgEmi8o1.js +1 -0
- app/_bundle/frontend/dist/assets/af-DK_CjRn6-CZxsvT2y.js +1 -0
- app/_bundle/frontend/dist/assets/as-BPtSu6VN-F6qyW8uH.js +1 -0
- app/_bundle/frontend/dist/assets/avatar-CNaispuS.js +1 -0
- app/_bundle/frontend/dist/assets/be-CrQ0smca-BYVdQd18.js +1 -0
- app/_bundle/frontend/dist/assets/bg-CrQqGwni-B5xv6TfF.js +1 -0
- app/_bundle/frontend/dist/assets/bn-NCLZcWHi-BGS6_hxH.js +1 -0
- app/_bundle/frontend/dist/assets/ca-SUf6Y2Om-DrduLk3W.js +1 -0
- app/_bundle/frontend/dist/assets/clsx-DB0hHKMi.js +1 -0
- app/_bundle/frontend/dist/assets/cop-C3sk0IUo-Dw82IjCr.js +1 -0
- app/_bundle/frontend/dist/assets/cs-CmAteokq-BI5q4aVA.js +1 -0
- app/_bundle/frontend/dist/assets/cu-CBUlrW6Y-BRCy0UAr.js +1 -0
- app/_bundle/frontend/dist/assets/cy-BBPa6z2x-Cag4snSk.js +1 -0
- app/_bundle/frontend/dist/assets/da-CCDXfXtG-BWliw5hZ.js +1 -0
- app/_bundle/frontend/dist/assets/dates-8UlpNJqU.js +1 -0
- app/_bundle/frontend/dist/assets/de-1901-CWoAOigE-BlgpCKr2.js +1 -0
- app/_bundle/frontend/dist/assets/de-1996-BL6awyxG-BjfWxQKM.js +1 -0
- app/_bundle/frontend/dist/assets/de-ch-1901-hVThVHVb-_Xg3_np3.js +1 -0
- app/_bundle/frontend/dist/assets/el-monoton-D3aKqTz2-CuqNQIvE.js +1 -0
- app/_bundle/frontend/dist/assets/el-polyton-ogVWcTzh-B5J5pGHR.js +1 -0
- app/_bundle/frontend/dist/assets/en-gb-B7Al27b_-COWGBqwJ.js +1 -0
- app/_bundle/frontend/dist/assets/es-DcaaHPU_-CnHE1eri.js +1 -0
- app/_bundle/frontend/dist/assets/et-B_spaleu-H7jVbiHv.js +1 -0
- app/_bundle/frontend/dist/assets/eu-Ctv_kq9Z-D1jw9zt8.js +1 -0
- app/_bundle/frontend/dist/assets/fi-RW5VB8Yp-mParSSSy.js +1 -0
- app/_bundle/frontend/dist/assets/fr-BC2onEz9-Dc1KqFHa.js +1 -0
- app/_bundle/frontend/dist/assets/fur-AC12wySk-tJv2icDr.js +1 -0
- app/_bundle/frontend/dist/assets/ga-Cn6LkudM-CDuqe3gr.js +1 -0
- app/_bundle/frontend/dist/assets/gl-DZGc-K_G-D9_oxkqv.js +1 -0
- app/_bundle/frontend/dist/assets/grc-DOlGgO8T-DANBReIg.js +1 -0
- app/_bundle/frontend/dist/assets/gu-Bjl0l-cf-COW9d1dt.js +1 -0
- app/_bundle/frontend/dist/assets/hi-DsAaTPCC-CiihDo6Q.js +1 -0
- app/_bundle/frontend/dist/assets/hr-DT1SBBes-D_vEJhf2.js +1 -0
- app/_bundle/frontend/dist/assets/hsb-DC_ITc1e-kb5QeNH1.js +1 -0
- app/_bundle/frontend/dist/assets/hu-DVk7Y_ka-Ct1fysVO.js +1 -0
- app/_bundle/frontend/dist/assets/hy-e995ysyO-Cjfrs2ZM.js +1 -0
- app/_bundle/frontend/dist/assets/ia-Cr4TJH0c-B1i9kDPT.js +1 -0
- app/_bundle/frontend/dist/assets/id-DifDyWg9-C3Hzl2m4.js +1 -0
- app/_bundle/frontend/dist/assets/index-Bu1kTJtO.css +2 -0
- app/_bundle/frontend/dist/assets/index-DVWuV1Ff.js +12 -0
- app/_bundle/frontend/dist/assets/is-BT8UVRze-DWEBuJpb.js +1 -0
- app/_bundle/frontend/dist/assets/it-Bt_Meacx-HiFRunf5.js +1 -0
- app/_bundle/frontend/dist/assets/ka-jyoLzyDE-BU45urC7.js +1 -0
- app/_bundle/frontend/dist/assets/kmr-Cfwhwuff-DfPyPgkK.js +1 -0
- app/_bundle/frontend/dist/assets/kn-C6Lov-DP-BuXzi7S-.js +1 -0
- app/_bundle/frontend/dist/assets/la-DuvHjUWw-Bwiuou7l.js +1 -0
- app/_bundle/frontend/dist/assets/la-x-classic-yTyAOQEt-aO_2QO0y.js +1 -0
- app/_bundle/frontend/dist/assets/la-x-liturgic-CXeQb4FY-BpDOy20C.js +1 -0
- app/_bundle/frontend/dist/assets/live-CFfryZUM.js +1 -0
- app/_bundle/frontend/dist/assets/lt-BBe8DlDF-B3cgXplB.js +1 -0
- app/_bundle/frontend/dist/assets/lv-Q2BBHnzp-CLjYDJHB.js +1 -0
- app/_bundle/frontend/dist/assets/ml-2xLVYkVY-Ct0js8Am.js +1 -0
- app/_bundle/frontend/dist/assets/mn-cyrl-lHM4n0oC-DN6sz9R4.js +1 -0
- app/_bundle/frontend/dist/assets/mn-cyrl-x-lmc-3aetruI8-BJqn49ay.js +1 -0
- app/_bundle/frontend/dist/assets/mr-CjWJPVmH-DGtESPcG.js +1 -0
- app/_bundle/frontend/dist/assets/mul-ethi-D_CMSMEq-D6ioGuYP.js +1 -0
- app/_bundle/frontend/dist/assets/nb-DI8u59ch-BfDSp4tN.js +1 -0
- app/_bundle/frontend/dist/assets/nl-BHQJ6Gvn-8_OIBsy0.js +1 -0
- app/_bundle/frontend/dist/assets/nn-ntZvarUK-BWT83oy8.js +1 -0
- app/_bundle/frontend/dist/assets/no-B8ItS0F3-Cjg1mxae.js +1 -0
- app/_bundle/frontend/dist/assets/oc-P_i3-xLA-W5_I63nO.js +1 -0
- app/_bundle/frontend/dist/assets/or-50rxpoq4-Cf5-bcl5.js +1 -0
- app/_bundle/frontend/dist/assets/pa-C54UG8eN-Bj-XExX_.js +1 -0
- app/_bundle/frontend/dist/assets/pi-B9cgjyG1-o9084kBf.js +1 -0
- app/_bundle/frontend/dist/assets/pipeline-CPPlVFee.js +1 -0
- app/_bundle/frontend/dist/assets/pl-9fg-ESVt-Bv_p-a9x.js +1 -0
- app/_bundle/frontend/dist/assets/pms-BRGfm5gS-DfOt2RSi.js +1 -0
- app/_bundle/frontend/dist/assets/projectAccess-D3wgwunj.js +1 -0
- app/_bundle/frontend/dist/assets/pt-Cum2_NUC-CrkeeQaZ.js +1 -0
- app/_bundle/frontend/dist/assets/rm-C0MIK9N4-CNhvXnnG.js +1 -0
- app/_bundle/frontend/dist/assets/ro-0fmdH0HA-Bov_DAVD.js +1 -0
- app/_bundle/frontend/dist/assets/ru-v4l-ayaq-DLdM0nWP.js +1 -0
- app/_bundle/frontend/dist/assets/sa-CKY9c_Vq-CvBCyoRG.js +1 -0
- app/_bundle/frontend/dist/assets/sh-cyrl-BpCRFOmq-UY09gie6.js +1 -0
- app/_bundle/frontend/dist/assets/sh-latn-sRy4Tuaj-De-tA-2J.js +1 -0
- app/_bundle/frontend/dist/assets/sk-_iOeDNrQ-DC8Al4lF.js +1 -0
- app/_bundle/frontend/dist/assets/sl-DpiklF-D-B8FnrXi1.js +1 -0
- app/_bundle/frontend/dist/assets/sr-cyrl-Dpzrbd0W-yGc0Jz1j.js +1 -0
- app/_bundle/frontend/dist/assets/sv-CFm5y56M-DeQDoAsB.js +1 -0
- app/_bundle/frontend/dist/assets/ta-BcghgTbD-B5_ztYXp.js +1 -0
- app/_bundle/frontend/dist/assets/te-B5Spl2Jk-BjTOzs5s.js +1 -0
- app/_bundle/frontend/dist/assets/th-DWX5iPSo-CFfNau1h.js +1 -0
- app/_bundle/frontend/dist/assets/tk-BMbKB10q-UHPz-lif.js +1 -0
- app/_bundle/frontend/dist/assets/tr-CIHIuzqc-DvQDK0dA.js +1 -0
- app/_bundle/frontend/dist/assets/ui-BtIxuKN2.js +13 -0
- app/_bundle/frontend/dist/assets/uk-Dir3oxLs-DGVpthWV.js +1 -0
- app/_bundle/frontend/dist/assets/vocab-C9TBNLaa.js +1 -0
- app/_bundle/frontend/dist/assets/zh-latn-pinyin-BdYb-Ey_-CW52gdb_.js +1 -0
- app/_bundle/frontend/dist/fonts/archivo-latin-ext.woff2 +0 -0
- app/_bundle/frontend/dist/fonts/archivo-latin.woff2 +0 -0
- app/_bundle/frontend/dist/fonts/chivomono-latin-ext.woff2 +0 -0
- app/_bundle/frontend/dist/fonts/chivomono-latin.woff2 +0 -0
- app/_bundle/frontend/dist/index.html +33 -0
- app/_bundle/scripts/cloud/glmocr_native_gateway.py +118 -0
- app/_bundle/scripts/cloud/mineru_native_gateway.py +154 -0
- app/_bundle/scripts/cloud/modal_deepseek_ocr.py +124 -0
- app/_bundle/scripts/cloud/modal_dots_ocr.py +121 -0
- app/_bundle/scripts/cloud/modal_glm_ocr.py +127 -0
- app/_bundle/scripts/cloud/modal_mineru.py +151 -0
- app/_bundle/scripts/cloud/modal_paddleocr_vl.py +136 -0
- app/_bundle/scripts/cloud/modal_publish_checkpoint.sh +11 -0
- app/_bundle/scripts/cloud/modal_qwen3_vl.py +124 -0
- app/_bundle/scripts/cloud/modal_teleocr.py +119 -0
- app/_bundle/scripts/cloud/modal_unlimited_ocr.py +142 -0
- app/_bundle/scripts/cloud/modal_vllm.py +222 -0
- app/_bundle/scripts/cloud/setup_cloud_train.sh +53 -0
- app/_bundle/scripts/cloud/setup_cloud_vllm.sh +765 -0
- app/_bundle/scripts/cloud/ssh_tunnel.sh +90 -0
- app/_bundle/scripts/cloud/teleocr_native_gateway.py +134 -0
- app/_bundle/scripts/cloud/test_cloud_connection.py +124 -0
- app/_bundle/scripts/cloud/vast_onstart.sh +26 -0
- app/_bundle/scripts/local/mineru_mlx_gateway.py +139 -0
- app/_bundle/scripts/serve_model.sh +79 -0
- app/api/__init__.py +54 -0
- app/api/auth.py +257 -0
- app/api/benchmark.py +111 -0
- app/api/blocks.py +712 -0
- app/api/cloud.py +622 -0
- app/api/datasets.py +213 -0
- app/api/deps.py +56 -0
- app/api/evaluate.py +68 -0
- app/api/live.py +148 -0
- app/api/models.py +206 -0
- app/api/page_work.py +66 -0
- app/api/pages.py +678 -0
- app/api/playground.py +198 -0
- app/api/prelabel.py +244 -0
- app/api/projects.py +772 -0
- app/api/recognition.py +135 -0
- app/api/settings.py +33 -0
- app/api/system.py +543 -0
- app/api/training.py +177 -0
- app/api/users.py +149 -0
- app/cli.py +69 -0
- app/config.py +188 -0
- app/db.py +513 -0
- app/main.py +134 -0
- app/schemas.py +599 -0
- app/services/__init__.py +1 -0
- app/services/alternative_training.py +236 -0
- app/services/annotation_schema.py +133 -0
- app/services/artifacts.py +52 -0
- app/services/audit.py +28 -0
- app/services/auth.py +229 -0
- app/services/backup.py +74 -0
- app/services/benchmark.py +633 -0
- app/services/blocks.py +173 -0
- app/services/cloud_manager.py +2191 -0
- app/services/compute_profiles.py +115 -0
- app/services/corpus.py +32 -0
- app/services/custom_models.py +209 -0
- app/services/dataset_builder.py +716 -0
- app/services/dewarp.py +177 -0
- app/services/domain_profiles.py +28 -0
- app/services/evaluate.py +587 -0
- app/services/export_formats.py +109 -0
- app/services/hardware.py +255 -0
- app/services/huggingface_auth.py +103 -0
- app/services/i18n.py +609 -0
- app/services/images.py +266 -0
- app/services/inference.py +1796 -0
- app/services/labeling.py +210 -0
- app/services/live.py +160 -0
- app/services/local_runtime.py +160 -0
- app/services/mineru_mlx_runtime.py +153 -0
- app/services/mlx_runtime.py +218 -0
- app/services/modal_manager.py +617 -0
- app/services/model_adapters.py +1862 -0
- app/services/model_labels.py +266 -0
- app/services/model_registry.py +609 -0
- app/services/model_settings.py +558 -0
- app/services/monkey_preprocess.py +153 -0
- app/services/native_picker.py +110 -0
- app/services/ocr.py +169 -0
- app/services/opencode_gateway.py +63 -0
- app/services/otsl.py +290 -0
- app/services/paddle_dataset.py +280 -0
- app/services/paddle_official.py +271 -0
- app/services/paddle_runtime.py +230 -0
- app/services/paddle_training.py +86 -0
- app/services/page_meta.py +74 -0
- app/services/page_work.py +138 -0
- app/services/pages.py +435 -0
- app/services/pilot.py +48 -0
- app/services/pipeline.py +73 -0
- app/services/prefill.py +1010 -0
- app/services/process_probe.py +87 -0
- app/services/rate_limit.py +21 -0
- app/services/recognition.py +653 -0
- app/services/scan.py +286 -0
- app/services/security.py +45 -0
- app/services/serve_manager.py +967 -0
- app/services/serve_recipes.py +380 -0
- app/services/settings.py +61 -0
- app/services/table_checks.py +386 -0
- app/services/table_detect.py +989 -0
- app/services/table_headers.py +102 -0
- app/services/table_hint.py +28 -0
- app/services/table_provenance.py +17 -0
- app/services/train_recipes.py +175 -0
- app/services/trainer.py +633 -0
- app/services/trainer_metrics.py +122 -0
- app/services/trainer_script.py +230 -0
- app/services/training_executor.py +305 -0
- app/services/unlimited_ocr_mlx_server.py +254 -0
- app/services/url_security.py +29 -0
- app/services/users.py +191 -0
- app/services/vault.py +142 -0
- app/services/vendor_repos.py +51 -0
- app/services/vram.py +191 -0
- tabularium-0.3.0.dist-info/METADATA +225 -0
- tabularium-0.3.0.dist-info/RECORD +245 -0
- tabularium-0.3.0.dist-info/WHEEL +4 -0
- tabularium-0.3.0.dist-info/entry_points.txt +2 -0
- tabularium-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,ct as t,d as n,dt as r,ht as i,i as a,l as o,lt as s,r as c,st as l,t as u,tt as d,u as f}from"./ui-BtIxuKN2.js";import{O as p,T as m,c as h,i as g,r as _}from"./index-DVWuV1Ff.js";var v=i(r(),1),y=s(),b=(e,t=3)=>e==null?`—`:e.toFixed(t),x=e=>e==null?`—`:`${e.toFixed(1)}%`;function S(){let{t:r}=t(),i=m(),s=h(),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)([]),[O,k]=(0,v.useState)([]),[A,j]=(0,v.useState)(new Set),[M,N]=(0,v.useState)(10),[P,F]=(0,v.useState)(!0),[I,L]=(0,v.useState)(!1),[R,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(null),[H,U]=(0,v.useState)(null),[W,G]=(0,v.useState)(null),K=e=>{C(e),g(e===``?null:e),V(null),j(new Set)},q=_(K,G);(0,v.useEffect)(()=>{e(`/models`).then(e=>T(e.items)).catch(()=>{})},[]),(0,v.useEffect)(()=>{D(e=>e.length>0?e:[{adapter_id:i.adapterId??``,url:i.url,model:i.model}])},[i.adapterId,i.url,i.model]),(0,v.useEffect)(()=>{S!==``&&e(`/projects/${S}/benchmark/pages`).then(e=>k(e.items)).catch(()=>k([]))},[S]);let J=O.filter(e=>e.ready),Y=e=>j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),X=(e,t)=>D(n=>n.map((n,r)=>r===e?{...n,...t}:n)),Z=async()=>{if(S!==``)try{let t=await e(`/projects/${S}/benchmark/status`);if(U(t),t.state===`running`)z(!0);else if(z(!1),t.state===`done`){let t=await e(`/projects/${S}/benchmark/latest`);t.available&&V(t)}else t.state===`error`&&G(t.error??`benchmark`)}catch(e){G(e),z(!1)}};(0,v.useEffect)(()=>{V(null),U(null),Z()},[S]),(0,v.useEffect)(()=>{if(S===``||!R)return;let e=window.setInterval(()=>void Z(),2e3);return()=>window.clearInterval(e)},[R,S]);let Q=async()=>{if(S===``)return;let e=E.filter(e=>e.adapter_id);if(e.length!==0){G(null),V(null);try{await d(`/projects/${S}/benchmark`,{targets:e,page_ids:A.size>0?[...A]:null,limit:M,with_text:P,table_only:I}),z(!0),U({state:`running`})}catch(e){G(e)}}};return(0,y.jsxs)(`div`,{className:`p-3`,children:[(0,y.jsx)(n,{title:r(`benchmark.title`),intro:r(`benchmark.intro`)}),W!=null&&(0,y.jsx)(`div`,{className:`mb-3`,children:(0,y.jsx)(c,{error:W,onDismiss:()=>G(null)})}),(0,y.jsx)(o,{tab:r(`benchmark.run`),children:(0,y.jsx)(a,{label:r(`benchmark.project`),children:(0,y.jsxs)(`select`,{value:S,onChange:e=>K(e.target.value===``?``:Number(e.target.value)),className:`fld`,children:[(0,y.jsx)(`option`,{value:``,children:r(`common.chooseProject`)}),q.map(e=>(0,y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})}),S!==``&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`mb-3`,children:(0,y.jsx)(o,{tab:r(`benchmark.models`),children:(0,y.jsxs)(`div`,{className:`space-y-1`,children:[w.map(e=>{let t=E.some(t=>t.adapter_id===e.adapter_id),n=!!e.local?.runnable;return(0,y.jsxs)(`div`,{className:`border-b border-[color:var(--color-rule)] py-1.5`,children:[(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>{if(t.target.checked){let t=e.served_model_name||e.local?.mlx_repo||e.adapter_id,r=e.adapter_id===i.adapterId?i.url:n?`http://127.0.0.1:8888/v1`:``;D(n=>[...n,{adapter_id:e.adapter_id,url:r,model:t}])}else D(t=>t.filter(t=>t.adapter_id!==e.adapter_id))}}),(0,y.jsx)(`span`,{className:`font-semibold`,children:e.display_name}),(0,y.jsx)(u,{tone:n?`ok`:`neutral`,children:r(n?`benchmark.local`:`benchmark.remote`)}),n&&(0,y.jsx)(`span`,{className:`text-[10px] text-[color:var(--color-ink-3)]`,children:e.local?.runtime??``})]}),t&&(0,y.jsxs)(`div`,{className:`mt-1 grid gap-2 pl-6 sm:grid-cols-2`,children:[(0,y.jsx)(`input`,{className:`fld fld-mono`,value:E.find(t=>t.adapter_id===e.adapter_id)?.url??``,onChange:t=>X(E.findIndex(t=>t.adapter_id===e.adapter_id),{url:t.target.value}),placeholder:`http://127.0.0.1:8888/v1`}),(0,y.jsx)(`input`,{className:`fld fld-mono`,value:E.find(t=>t.adapter_id===e.adapter_id)?.model??``,onChange:t=>X(E.findIndex(t=>t.adapter_id===e.adapter_id),{model:t.target.value}),placeholder:`MonkeyOCRv2`})]})]},e.adapter_id)}),E.some(e=>w.find(t=>t.adapter_id===e.adapter_id)?.local?.runnable)&&(0,y.jsx)(`p`,{className:`pt-1 text-[11px] text-[color:var(--color-ink-3)]`,children:r(`benchmark.localHint`)})]})})}),(0,y.jsx)(`div`,{className:`mb-3`,children:(0,y.jsxs)(o,{tab:r(`benchmark.pages`),aux:(0,y.jsxs)(`span`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,y.jsx)(`span`,{children:l(`benchmark.readyCount`,J.length)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>j(new Set(J.map(e=>e.page_id))),children:r(`benchmark.selectAll`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>j(new Set),children:r(`benchmark.selectNone`)})]}),children:[O.length===0?(0,y.jsx)(f,{children:r(`benchmark.noPages`)}):(0,y.jsx)(`div`,{className:`max-h-72 overflow-y-auto`,children:O.map(e=>(0,y.jsxs)(`label`,{className:`flex items-center gap-2 border-b border-[color:var(--color-rule)] py-1 text-[12px] ${e.ready?``:`opacity-50`}`,children:[(0,y.jsx)(`input`,{type:`checkbox`,disabled:!e.ready,checked:A.has(e.page_id),onChange:()=>Y(e.page_id)}),(0,y.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate`,children:e.rel_path}),(0,y.jsx)(`span`,{className:`text-[10px] text-[color:var(--color-ink-3)]`,children:e.ready?`${e.blocks} ${r(`benchmark.blocks`)}`:`${e.unconfirmed} ${r(`benchmark.unconfirmed`)}`})]},e.page_id))}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-3`,children:[(0,y.jsx)(a,{label:r(`benchmark.pages`),hint:r(`benchmark.limitHint`),children:(0,y.jsx)(`input`,{type:`number`,min:1,max:200,className:`fld !w-24`,value:M,onChange:e=>N(Math.max(1,Math.min(200,Number(e.target.value)||1)))})}),(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:P,onChange:e=>F(e.target.checked)}),r(`benchmark.withText`)]}),(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px]`,title:r(`benchmark.tableOnlyHint`),children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:I,onChange:e=>L(e.target.checked)}),r(`benchmark.tableOnly`)]}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void Q(),disabled:R,children:r(R?`benchmark.running`:`benchmark.run`)})]}),(0,y.jsx)(`p`,{className:`mt-2 max-w-[80ch] text-[11px] text-[color:var(--color-ink-3)]`,children:A.size>0?r(`benchmark.selectedHint`,{n:A.size}):r(`benchmark.limitUsedHint`,{n:M})}),R&&(0,y.jsx)(`div`,{className:`mt-2`,children:(0,y.jsxs)(f,{children:[r(`benchmark.runningNow`,{model:H?.current_adapter??`…`,i:(H?.index??0)+1,n:H?.total??`?`}),H?.page_total?` · ${r(`benchmark.pageProgress`,{i:H.page_index??0,n:H.page_total})}`:``]})}),H?.state===`error`&&H.error&&(0,y.jsx)(`div`,{className:`mt-2`,children:(0,y.jsx)(f,{tone:`warn`,children:r(`benchmark.failed`,{error:H.error})})})]})}),(()=>{let e=B?.leaderboard??H?.results??[];if(e.length===0)return null;let t=B?.gold_pages??H?.gold_pages;return(0,y.jsxs)(o,{tab:r(`benchmark.results`),aux:(0,y.jsx)(`span`,{className:`text-[11px]`,children:t==null?``:l(`benchmark.goldCount`,t)}),children:[(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-[color:var(--color-rule)] text-left`,children:[(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:`#`}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:r(`benchmark.model`)}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:`F1@0.75`}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:`F1@0.5`}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:r(`benchmark.order`)}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:r(`benchmark.tables`)}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:`TEDS`}),(0,y.jsx)(`th`,{className:`py-1 pr-3`,children:`CER`}),(0,y.jsx)(`th`,{className:`py-1`,children:r(`benchmark.seconds`)})]})}),(0,y.jsx)(`tbody`,{children:e.map((e,t)=>(0,y.jsxs)(`tr`,{className:`border-b border-[color:var(--color-rule)]`,children:[(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:t+1}),(0,y.jsxs)(`td`,{className:`py-1 pr-3`,children:[(0,y.jsx)(`span`,{className:`font-semibold`,children:s(e.adapter_id)??e.adapter_id}),(0,y.jsx)(`span`,{className:`mono block text-[10px] text-[color:var(--color-ink-3)]`,children:e.model})]}),(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:b(e.aggregates.layout_strict?.f1)}),(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:b(e.aggregates.layout.f1)}),(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:b(e.aggregates.order.mean_levenshtein_norm)}),(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:x(e.aggregates.tables.structure_ok_pct)}),(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:b(e.aggregates.tables.mean_teds)}),(0,y.jsx)(`td`,{className:`mono py-1 pr-3`,children:b(e.aggregates.text.mean_cer)}),(0,y.jsx)(`td`,{className:`mono py-1`,children:e.seconds})]},`${e.adapter_id}-${e.model}`))})]})}),(0,y.jsx)(`p`,{className:`mt-2 text-[11px] text-[color:var(--color-ink-3)]`,children:r(`benchmark.rankHint`)})]})})()]}),S===``&&(0,y.jsxs)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:[r(`benchmark.pickProject`),` `,(0,y.jsx)(p,{to:`/progetti`,className:`font-semibold underline underline-offset-2`,children:r(`nav.projects`)})]})]})}export{S as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UniverSheet-BwKQUIYP.js","assets/ui-BtIxuKN2.js","assets/index-DVWuV1Ff.js","assets/index-Bu1kTJtO.css","assets/clsx-DB0hHKMi.js","assets/UniverSheet-DbvMtUcB.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{$ as e,A as t,B as n,D as r,G as i,N as a,S as o,T as s,c,ct as l,dt as u,g as d,h as f,ht as p,i as m,l as h,lt as g,m as _,nt as v,o as y,q as b,r as x,s as S,t as C,tt as w,u as T}from"./ui-BtIxuKN2.js";import{P as E,c as D,t as O}from"./index-DVWuV1Ff.js";var k=p(u(),1),A={"1/2":`½`,"1/4":`¼`,"3/4":`¾`,"1/3":`⅓`,"2/3":`⅔`,"1/5":`⅕`,"1/8":`⅛`,"3/8":`⅜`,"5/8":`⅝`,"7/8":`⅞`},j=`⁰¹²³⁴⁵⁶⁷⁸⁹`,M=`₀₁₂₃₄₅₆₇₈₉`,N=(e,t)=>e.replace(/\d/g,e=>t[Number(e)]);function P(e){return e.replace(/(?<![\d/])(?:(\d[\d,.]*)[ ]+)?(\d+)\/(\d+)(?![\d/])/g,(e,t,n,r)=>{let i=A[`${n}/${r}`];return i?`${t??``}${i}`:!t||Number(r)===0?e:`${t}${N(n,j)}⁄${N(r,M)}`})}function F(e){let t=Array.from({length:e.rows},()=>Array(e.cols).fill(void 0));for(let n of e.cells)for(let r=n.r;r<n.r+n.rowspan;r++)for(let i=n.c;i<n.c+n.colspan;i++)r<e.rows&&i<e.cols&&(t[r][i]=n);return t}function I(e){return!!e&&e.rowspan===1&&e.colspan===1}function ee(e,t,n,r,i){let a=Math.min(t,r),o=Math.max(t,r),s=Math.min(n,i),c=Math.max(n,i),l=F(e);for(let e=a;e<=o;e++)for(let t=s;t<=c;t++){let n=l[e]?.[t];if(!I(n)||n.r!==e||n.c!==t)return null}let u=l[a][s]??{r:a,c:s,rowspan:1,colspan:1,text:``},d=e.cells.filter(e=>!(e.r>=a&&e.r<=o&&e.c>=s&&e.c<=c&&e.rowspan===1&&e.colspan===1));return d.push({r:a,c:s,rowspan:o-a+1,colspan:c-s+1,text:u.text}),{...e,cells:d}}function te(e,t,n){let r=F(e)[t]?.[n];if(!r||r.rowspan===1&&r.colspan===1)return null;let i=e.cells.filter(e=>e!==r);for(let e=r.r;e<r.r+r.rowspan;e++)for(let t=r.c;t<r.c+r.colspan;t++)i.push({r:e,c:t,rowspan:1,colspan:1,text:e===r.r&&t===r.c?r.text:``});return{...e,cells:i}}function L(e){return Array.from({length:e+1},(t,n)=>n/e)}function ne(e,t){return t<1?[]:(e&&e.length===t+1?e:L(t)).slice(1,t)}function re(e){let t=e.row_columns??[],n=Math.max(0,e.cols-1);if(!t.length||t.length!==e.rows||!t.every(e=>e.length===n))return null;let r=e.row_columns_proven??[],i=r.length===t.length&&r.every((e,n)=>e.length===t[n].length)?r:t.map(e=>e.map(()=>!1));return{columns:t.map(e=>[...e]),proven:i.map(e=>[...e])}}function R(e,t){let n=re(e);return n?t(n):{}}function z(e,t,n){return{row_columns:e.columns.map(e=>{let r=t===0?0:e[t-1],i=t===e.length?1:e[t],a=[...e];return a.splice(t,0,n(r,i)),a}),row_columns_proven:e.proven.map(e=>{let n=[...e];return n.splice(t,0,!1),n})}}function B(e,t){return{row_columns:e.columns.map(e=>e.filter((e,n)=>n!==t)),row_columns_proven:e.proven.map(e=>e.filter((e,n)=>n!==t))}}function V(e,t,n){let r=[...e.columns],i=[...e.proven];return r.splice(t,0,[...n]),i.splice(t,0,n.map(()=>!1)),{row_columns:r,row_columns_proven:i}}function H(e,t){return{row_columns:e.columns.filter((e,n)=>n!==t),row_columns_proven:e.proven.filter((e,n)=>n!==t)}}function U(e,t,n){let r=t===`row`,i=r?e.rows:e.cols;if(i<1)return e;let a=Math.max(0,Math.min(n,i)),o=e=>r?e.r:e.c,s=e=>r?e.rowspan:e.colspan,c=r?`r`:`c`,l=r?`rowspan`:`colspan`,u=e.cells.map(e=>{let t=o(e);return t>=a?{...e,[c]:t+1}:t+s(e)>a?{...e,[l]:s(e)+1}:e}),d=(r?e.hlines:e.vlines)??[],f=d.length===i+1?[...d]:L(i),p=Math.min(a+1,i);f.splice(p,0,(f[p-1]+f[p])/2);let m=r?e.rows+1:e.rows,h=r?e.cols:e.cols+1,g={...e,rows:m,cols:h,cells:u,phantom_cols:r?e.phantom_cols:e.phantom_cols.map(e=>e>=a?e+1:e),vlines:r?e.vlines:f,hlines:r?f:e.hlines,...R(e,t=>r?V(t,a,ne(e.vlines,e.cols)):z(t,p-1,(e,t)=>(e+t)/2))},_=F(g);for(let e=0;e<m;e++)for(let t=0;t<h;t++)_[e][t]||u.push({r:e,c:t,rowspan:1,colspan:1,text:``});return g}function ie(e,t,n){let r=t===`row`,i=r?e.rows:e.cols;if(n<0||n>=i||i<2)return null;let a=e=>r?e.r:e.c,o=e=>r?e.rowspan:e.colspan,s=r?`r`:`c`,c=r?`rowspan`:`colspan`,l=[];for(let t of e.cells){let e=a(t);if(e+o(t)-1<n||e>n){l.push(e>n?{...t,[s]:e-1}:t);continue}if(o(t)>1){let r=o(t)-1;if(r===0)continue;l.push({...t,[s]:e>n?e-1:e,[c]:r})}}let u=[...(r?e.hlines:e.vlines)??[]];return u.length===i+1&&u.splice(n+1,1),{...e,rows:r?e.rows-1:e.rows,cols:r?e.cols:e.cols-1,cells:l,phantom_cols:r?e.phantom_cols:e.phantom_cols.filter(e=>e!==n).map(e=>e>n?e-1:e),vlines:r?e.vlines:u,hlines:r?u:e.hlines,...R(e,e=>r?H(e,n):B(e,n))}}function ae(e,t){let n=[];for(let r=0;r<e;r++)for(let e=0;e<t;e++)n.push({r,c:e,rowspan:1,colspan:1,text:``});return{rows:e,cols:t,cells:n,phantom_cols:[],vlines:Array.from({length:t+1},(e,n)=>n/t),hlines:Array.from({length:e+1},(t,n)=>n/e)}}function W(e,t,n){let r=t===`v`?e.cols:e.rows;if(n<1||n>r-1||r<2)return null;let i=e=>t===`v`?e.c:e.r,a=e=>t===`v`?e.colspan:e.rowspan,o=e=>t===`v`?e.r:e.c,s=e=>t===`v`?e.rowspan:e.colspan,c=e=>e<n?e:e-1,l=e.cells.map(e=>{let n=c(i(e)),r=c(i(e)+a(e)-1);return{...e,[t===`v`?`c`:`r`]:n,[t===`v`?`colspan`:`rowspan`]:r-n+1}}),u=[],d=new Map;for(let e of l){if(i(e)!==n-1){u.push(e);continue}let r=`${o(e)}:${s(e)}`,c=d.get(r);if(!c){d.set(r,e);continue}let l=[c.text,e.text].map(e=>e.trim()).filter(Boolean).join(` `);d.set(r,{...c,text:l,[t===`v`?`colspan`:`rowspan`]:Math.max(a(c),a(e))})}let f=[...d.values()],p=new Set;for(let e of f){if(p.has(o(e)))return null;for(let t=o(e);t<o(e)+s(e);t++)p.add(t)}let m=((t===`v`?e.vlines:e.hlines)??[]).filter((e,t)=>t!==n);return{...e,rows:t===`h`?e.rows-1:e.rows,cols:t===`v`?e.cols-1:e.cols,cells:[...u,...f],phantom_cols:t===`v`?e.phantom_cols.filter(e=>e!==n-1).map(e=>e>=n?e-1:e):e.phantom_cols,vlines:t===`v`?m:e.vlines,hlines:t===`h`?m:e.hlines,...R(e,e=>t===`v`?B(e,n-1):H(e,n))}}var G=8;function K(e,t,n,r=!1){let i=e.trim();if(!i)return[``];if(t===` `){let e=i.split(/\s+/).filter(e=>e!==``);return r&&e.length>n?[e.slice(0,e.length-n+1).join(` `),...e.slice(e.length-n+1)]:e.length>n?[...e.slice(0,n-1),e.slice(n-1).join(` `)]:e}let a=[],o=i;for(let e=1;e<n;e++){let e=r?o.lastIndexOf(t):o.indexOf(t);if(e<0)break;r?(a.unshift(o.slice(e+t.length)),o=o.slice(0,e)):(a.push(o.slice(0,e)),o=o.slice(e+t.length))}return r?a.unshift(o):a.push(o),a.map(e=>e.trim()).filter(e=>e!==``)}function q(e,t,n){if(t<0||t>=e.cols)return null;let r=n.separator;if(!r)return null;let i=Math.max(2,Math.min(G,n.maxParts??2)),a=F(e),o=new Map,s=n.startRow??0,c=n.endRow??e.rows-1;if(!Number.isInteger(s)||!Number.isInteger(c)||s<0||c>=e.rows||s>c)return null;for(let e=s;e<=c;e++){let s=a[e]?.[t];if(s&&(s.rowspan>1||s.colspan>1))return null;o.set(e,K(s?.text??``,r,i,n.fromRight))}let l=e;for(let e=1;e<i;e++)l=U(l,`col`,t+1);let u=l.cells.map(n=>{if(n.r>=e.rows||n.c<t||n.c>=t+i)return n;let r=o.get(n.r)??[];if(r.length<2)return n;let a=n.c-t;if(a===0)return{...n,text:r[0],source:`manual`,verified:!1};let s=r[a]??``;return s?{...n,text:s,source:`manual`,verified:!1}:n});return{...l,cells:u}}function J(e,t){return(e.text??``)===t?e:{...e,text:t,source:`manual`,verified:!1}}function oe(e,t,n,r,i){let a=Math.min(t,r),o=Math.max(t,r),s=Math.min(n,i),c=Math.max(n,i);for(let t of e.cells)if(!(t.r<a||t.r>o||t.c<s||t.c>c)&&(t.r!==a||t.c!==s)&&(t.text??``).trim()!==``)return!1;return!0}function se(e,t){let n=F(e),r=[];for(let i=0;i<e.rows;i++){let e=n[i]?.[t];!e||e.rowspan>1||e.colspan>1||r.push({row:i,cell:e})}return r}function ce(e,t,n){let r=Math.max(2,Math.min(4,n.count??2));if(t<0||t+r>e.cols)return null;let i=n.separator,a=new Map;for(let n=0;n<e.rows;n++){let o=[];for(let i=0;i<r;i++){let r=(e.cells.find(e=>e.r===n&&e.c===t+i)?.text??``).trim();r&&o.push(r)}a.set(n,o.join(i))}let o=e;for(let e=1;e<r;e++){let e=W(o,`v`,t+1);if(!e)return null;o=e}let s=o.cells.map(n=>{if(n.c!==t||n.r>=e.rows)return n;let r=a.get(n.r)??``;return r===(e.cells.find(e=>e.r===n.r&&e.c===t)?.text??``)?n:{...n,text:r,source:`manual`,verified:!1}});return{...o,cells:s}}function le(e,t){if(t<0||t>=e.cols)return null;let n=e.cells.map(e=>e.c!==t||e.rowspan>1||e.colspan>1?e:J(e,(e.text??``).replace(/[^\S\n]+/g,` `).replace(/ *\n */g,`
|
|
3
|
+
`).trim()));return{...e,cells:n}}function ue(e,t){if(t<0||t>=e.cols)return null;let n=e.cells.map(e=>e.c!==t||e.rowspan>1||e.colspan>1?e:J(e,P(e.text??``)));return{...e,cells:n}}function de(e,t,n){if(t<0||t>=e.cols)return null;let r=e.cells.map(e=>{if(e.c!==t||e.rowspan>1||e.colspan>1)return e;let r=e.text??``;return J(e,n===`upper`?r.toUpperCase():n===`lower`?r.toLowerCase():r.replace(/\p{L}[\p{L}\p{N}’'-]*/gu,e=>e[0].toUpperCase()+e.slice(1).toLowerCase()))});return{...e,cells:r}}function fe(e,t,n,r){if(t<0||t>=e.cols||n<0||n>=e.rows||r<n)return null;let i=n,a=Math.min(r,e.rows-1),o=e.cells.find(e=>e.r===i&&e.c===t);if(!o||o.rowspan>1||o.colspan>1)return null;let s=o.text??``,c=new Set(se(e,t).filter(e=>e.row>i&&e.row<=a).map(e=>e.row)),l=e.cells.map(e=>c.has(e.r)&&e.c===t?J(e,s):e);return{...e,cells:l}}function pe(e,t,n){let r=e.cells.map(e=>e.r>=t.startRow&&e.r<=t.endRow&&e.c>=t.startColumn&&e.c<=t.endColumn&&(e.text??``).trim()!==``?{...e,verified:n}:e);return{...e,cells:r}}var me=1,he=1,ge=0,_e=`tabHeader`;function Y(e){return e.sheets?.tab??Object.values(e.sheets??{})[0]}function X(e,t,n){let r=e?.cellData?.[t]?.[n]?.v;return r==null?``:String(r)}function ve(e){let t=Math.max(1,e.rows),n=Math.max(1,e.cols),r=Math.min(Math.max(0,e.header_rows??0),t),i={},a=[];for(let o of e.cells){if(o.r>=t||o.c>=n)continue;let e=Math.max(1,o.rowspan??1),s=Math.max(1,o.colspan??1);(e>1||s>1)&&a.push({startRow:o.r,startColumn:o.c,endRow:o.r+e-1,endColumn:o.c+s-1});let c=o.text??``,l=o.r<r;if(!c&&!l)continue;let u={};c&&(u.v=c,u.t=me),l&&(u.s=_e),i[o.r]={...i[o.r]??{},[o.c]:u}}return{id:`tabularium-table`,name:`Table`,appVersion:`0.25.1`,locale:`enUS`,styles:{[_e]:{bl:he,bg:{rgb:`#f1f0ec`}}},sheetOrder:[`tab`],sheets:{tab:{id:`tab`,name:`Table`,tabColor:``,hidden:ge,freeze:{xSplit:0,ySplit:r,startRow:r,startColumn:0},rowCount:t,columnCount:n,zoomRatio:1,scrollTop:0,scrollLeft:0,defaultColumnWidth:96,defaultRowHeight:24,mergeData:a,cellData:i,rowData:{},columnData:{},rowHeader:{width:46},columnHeader:{height:22},showGridlines:he}}}}function Z(e,t){let n=Y(e),r=Math.max(1,n?.rowCount??t.rows),i=Math.max(1,n?.columnCount??t.cols),a=new Map,o=new Set;for(let e of n?.mergeData??[]){let t=e.endRow-e.startRow+1,n=e.endColumn-e.startColumn+1;if(!(t<1||n<1)){a.set(`${e.startRow}:${e.startColumn}`,{rs:t,cs:n});for(let t=e.startRow;t<=e.endRow;t++)for(let n=e.startColumn;n<=e.endColumn;n++)(t!==e.startRow||n!==e.startColumn)&&o.add(`${t}:${n}`)}}let s=new Map(t.cells.map(e=>[`${e.r}:${e.c}`,e])),c=[];for(let e=0;e<r;e++)for(let t=0;t<i;t++){if(o.has(`${e}:${t}`))continue;let r=X(n,e,t),i=s.get(`${e}:${t}`),l=a.get(`${e}:${t}`),u=i?(i.text??``)===r:!1;c.push({r:e,c:t,rowspan:l?.rs??1,colspan:l?.cs??1,text:r,source:u?i?.source:`manual`,verified:u?i?.verified??!1:!1})}return{...t,rows:r,cols:i,cells:c,phantom_cols:t.phantom_cols.filter(e=>e<i),vlines:(t.vlines??[]).filter((e,t)=>t<=i),hlines:(t.hlines??[]).filter((e,t)=>t<=r)}}function Q(e){return JSON.stringify([e.rows,e.cols,e.phantom_cols,e.header_rows??0,e.cells.map(e=>[e.r,e.c,e.rowspan,e.colspan,e.text,e.source??``,e.verified??!1]),e.misprints??[],e.vlines??[],e.hlines??[],e.row_columns??[],e.row_columns_proven??[]])}var $=g(),ye=[{key:`splitSpace`,value:` `},{key:`splitComma`,value:`,`},{key:`splitSemicolon`,value:`;`},{key:`splitDash`,value:`-`}],be=6;function xe({grid:e,column:t,onApply:n,onClose:r}){let{t:i}=l(),[a,o]=(0,k.useState)(` `),[s,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(2),[p,m]=(0,k.useState)(!1),[h,g]=(0,k.useState)(1),[_,v]=(0,k.useState)(e.rows),y=s===``?a:s,b=(0,k.useMemo)(()=>q(e,t,{separator:y,maxParts:d,fromRight:p,startRow:h-1,endRow:_-1}),[e,t,y,d,p,h,_]),x=(0,k.useMemo)(()=>{if(!b)return 0;let n=0;for(let r=0;r<e.rows;r++){let i=e.cells.find(e=>e.r===r&&e.c===t)?.text??``;(b.cells.find(e=>e.r===r&&e.c===t)?.text??``)!==i&&(n+=1)}return n},[e,t,b]),S=(0,k.useMemo)(()=>{let n=[];for(let r=h-1;r<_&&n.length<be;r++){let i=e.cells.find(e=>e.r===r&&e.c===t)?.text??``;if(!i)continue;let a=[];for(let e=0;e<d;e++)a.push(b?.cells.find(n=>n.r===r&&n.c===t+e)?.text??``);n.push({before:i,after:a})}return n},[e,t,d,b,h,_]);return(0,$.jsx)(c,{title:i(`table.splitTitle`),wide:!0,onClose:r,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`btn`,children:i(`common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,disabled:!b||x===0,onClick:()=>n(b,d),className:`btn btn-primary`,children:i(`table.splitRun`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 p-3`,children:[(0,$.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:i(`table.splitColumnN`,{n:t+1})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`lbl`,children:i(`table.splitSeparator`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[ye.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":s===``&&a===e.value,onClick:()=>{u(``),o(e.value)},className:`btn btn-sm ${s===``&&a===e.value?`!border-[color:var(--color-ink)] !bg-[color:var(--color-ink)] !text-white`:``}`,children:i(`table.${e.key}`)},e.key)),(0,$.jsx)(`input`,{value:s,onChange:e=>u(e.target.value),placeholder:i(`table.splitOther`),"aria-label":i(`table.splitOther`),className:`fld fld-mono w-20`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`lbl`,htmlFor:`split-parts`,children:i(`table.splitParts`)}),(0,$.jsx)(`input`,{id:`split-parts`,type:`number`,min:2,max:8,value:d,onChange:e=>f(Math.max(2,Math.min(8,Number(e.target.value)||2))),className:`fld fld-mono w-16`})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),i(`table.splitFromRight`)]}),(0,$.jsxs)(`label`,{className:`text-xs`,children:[i(`table.splitFirstRow`),(0,$.jsx)(`input`,{"aria-label":i(`table.splitFirstRow`),type:`number`,min:1,max:e.rows,value:h,onChange:t=>g(Math.max(1,Math.min(e.rows,Number(t.target.value)||1))),className:`fld fld-mono ml-2 w-20`})]}),(0,$.jsxs)(`label`,{className:`text-xs`,children:[i(`table.splitLastRow`),(0,$.jsx)(`input`,{"aria-label":i(`table.splitLastRow`),type:`number`,min:h,max:e.rows,value:_,onChange:t=>v(Math.max(1,Math.min(e.rows,Number(t.target.value)||e.rows))),className:`fld fld-mono ml-2 w-20`})]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-[color:var(--color-ink-2)]`,children:i(`table.splitRangeHint`)}),b?x===0?(0,$.jsx)(`p`,{className:`border border-[color:var(--color-warn)] px-2 py-1 text-[12px] text-[color:var(--color-warn)]`,children:i(`table.splitEmpty`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`lbl`,children:i(`table.splitPreview`)}),(0,$.jsx)(`table`,{className:`w-full border-collapse text-[12px]`,children:(0,$.jsx)(`tbody`,{children:S.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`td`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-2 py-1`,children:e.before}),(0,$.jsx)(`td`,{className:`w-6 px-1 text-center text-[color:var(--color-ink-3)]`,children:`→`}),e.after.map((e,t)=>(0,$.jsx)(`td`,{className:`border border-[color:var(--color-rule)] px-2 py-1`,style:{background:t===0?`var(--color-sig-wash)`:`var(--color-sheet)`},children:e||(0,$.jsx)(`span`,{className:`text-[color:var(--color-ink-3)]`,children:`—`})},t))]},e.before+e.after.join(`|`)))})}),(0,$.jsx)(`p`,{className:`text-[11px] text-[color:var(--color-ink-2)]`,children:i(`table.splitAffected`,{n:x})})]}):(0,$.jsx)(`p`,{className:`border border-[color:var(--color-warn)] px-2 py-1 text-[12px] text-[color:var(--color-warn)]`,children:i(`table.splitMerged`)})]})})}function Se({src:e,pageId:n,imageSize:i}){let{t:o}=l(),s=(0,k.useRef)(null),c=(0,k.useRef)(null),[u,d]=(0,k.useState)({w:0,h:0}),[f,p]=(0,k.useState)(i??{w:0,h:0}),[m,h]=(0,k.useState)({x:0,y:0,scale:1}),[g,_]=(0,k.useState)(m),[v,y]=(0,k.useState)(!1);(0,k.useEffect)(()=>{i?.w&&i.h&&p({w:i.w,h:i.h})},[i?.w,i?.h]),(0,k.useEffect)(()=>{let e=window.setTimeout(()=>_(m),120);return()=>window.clearTimeout(e)},[m]),(0,k.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>d({w:e.clientWidth,h:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let b=(0,k.useCallback)(()=>{if(!f.w||!f.h||!u.w||!u.h)return;let e=Math.min(u.w/f.w,u.h/f.h)*.96;h({scale:e,x:(u.w-f.w*e)/2,y:(u.h-f.h*e)/2})},[f,u]),x=(0,k.useRef)(``);(0,k.useEffect)(()=>{let t=`${e}:${f.w}x${f.h}`;!f.w||!f.h||!u.w||!u.h||x.current===t||(x.current=t,b())},[b,f.w,f.h,u.w,u.h,e]);let S=(0,k.useMemo)(()=>{if(!n||!f.w||!f.h||!u.w||!u.h)return[];let e=Math.max(0,Math.min(8,Math.round(Math.log2(1/Math.max(g.scale,.01))))),t=2**e,r=Math.max(0,-g.x/g.scale),i=Math.max(0,-g.y/g.scale),a=Math.min(f.w,(u.w-g.x)/g.scale),o=Math.min(f.h,(u.h-g.y)/g.scale);if(a<=r||o<=i)return[];let s=Math.ceil(f.w/t),c=Math.ceil(f.h/t),l=Math.max(0,Math.floor(r/t/512)),d=Math.max(0,Math.floor(i/t/512)),p=Math.min(Math.ceil(s/512)-1,Math.floor(a/t/512)),m=Math.min(Math.ceil(c/512)-1,Math.floor(o/t/512)),h=[];for(let r=d;r<=m;r++)for(let i=l;i<=p;i++)h.push({key:`${e}/${i}/${r}`,src:`/api/pages/${n}/tile/${e}/${i}/${r}`,x:i*512*t,y:r*512*t,w:Math.min(512,s-i*512)*t,h:Math.min(512,c-r*512)*t});return h},[f,n,u,g]),C=(e,t)=>{if(!s.current?.getBoundingClientRect())return;let n=t??{x:u.w/2,y:u.h/2};h(t=>{let r=Math.max(.06,Math.min(12,t.scale*e)),i=n.x-t.x,a=n.y-t.y;return{scale:r,x:n.x-i*(r/t.scale),y:n.y-a*(r/t.scale)}})},w=e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),c.current={pointerId:e.pointerId,x:m.x,y:m.y,startX:e.clientX,startY:e.clientY},y(!0))},T=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||h(n=>({...n,x:t.x+e.clientX-t.startX,y:t.y+e.clientY-t.startY}))},E=()=>{c.current=null,y(!1)};return(0,$.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col border border-[color:var(--color-rule)]`,"aria-label":o(`table.pageImage`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-2 py-1`,children:[(0,$.jsx)(`span`,{className:`lbl mb-0 mr-auto`,children:o(`table.pageImage`)}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,title:o(`table.zoomOut`),"aria-label":o(`table.zoomOut`),onClick:()=>C(.8),children:(0,$.jsx)(t,{size:12})}),(0,$.jsxs)(`span`,{className:`mono w-12 text-center text-[11px]`,children:[Math.round(m.scale*100),`%`]}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,title:o(`table.zoomIn`),"aria-label":o(`table.zoomIn`),onClick:()=>C(1.25),children:(0,$.jsx)(a,{size:12})}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,title:o(`table.fitTitle`),"aria-label":o(`table.fitTitle`),onClick:b,children:(0,$.jsx)(r,{size:12})})]}),(0,$.jsxs)(`div`,{ref:s,className:`relative min-h-0 flex-1 overflow-hidden bg-[color:var(--color-fill-2)] ${v?`cursor-grabbing`:`cursor-grab`}`,style:{touchAction:`none`},onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:E,onWheel:e=>{if(e.preventDefault(),e.ctrlKey||e.metaKey){let t=s.current?.getBoundingClientRect();t&&C(Math.exp(-e.deltaY*.0015),{x:e.clientX-t.left,y:e.clientY-t.top})}else h(t=>({...t,x:t.x-e.deltaX,y:t.y-e.deltaY}))},children:[(0,$.jsx)(`img`,{"data-fade":!0,src:e,alt:o(`table.pageImage`),draggable:!1,onLoad:e=>{i?.w||p({w:e.currentTarget.naturalWidth,h:e.currentTarget.naturalHeight})},className:`pointer-events-none absolute left-0 top-0 max-w-none select-none shadow-md`,style:{width:f.w||`auto`,height:f.h||`auto`,transform:`translate(${m.x}px, ${m.y}px) scale(${m.scale})`,transformOrigin:`top left`}}),S.map(e=>(0,$.jsx)(`img`,{"data-fade":!0,src:e.src,alt:``,draggable:!1,className:`pointer-events-none absolute left-0 top-0 max-w-none select-none`,style:{width:e.w,height:e.h,transform:`translate(${m.x+e.x*m.scale}px, ${m.y+e.y*m.scale}px) scale(${m.scale})`,transformOrigin:`top left`}},e.key))]})]})}var Ce=16;function we({value:e,min:t,max:n,side:r,label:i,onChange:a,onReset:o}){let s=(0,k.useRef)(null),[c,l]=(0,k.useState)(!1),u=e=>{let i=r===`left`?s.current.startValue+e:s.current.startValue-e;a(Math.min(n,Math.max(t,i)))},d=t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),s.current={startX:t.clientX,startValue:e},l(!0),document.body.style.cursor=`col-resize`)},f=e=>{s.current&&u(e.clientX-s.current.startX)},p=()=>{s.current=null,l(!1),document.body.style.cursor=``};return(0,$.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i,"aria-valuenow":Math.round(e),"aria-valuemin":t,"aria-valuemax":n,tabIndex:0,title:i,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onKeyDown:i=>{if(i.key!==`ArrowLeft`&&i.key!==`ArrowRight`)return;i.preventDefault();let o=i.key===`ArrowLeft`?-1:1,s=r===`left`?e+o*Ce:e-o*Ce;a(Math.min(n,Math.max(t,s)))},onDoubleClick:o,className:`group relative z-10 w-[5px] shrink-0 cursor-col-resize touch-none select-none`,"data-dragging":c||void 0,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 -left-1 -right-1`}),(0,$.jsx)(`div`,{className:c?`absolute inset-y-0 left-1/2 w-[3px] -translate-x-1/2 bg-[color:var(--color-sig)]`:`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-[color:var(--color-rule)] transition-colors group-hover:bg-[color:var(--color-sig)] group-focus-visible:bg-[color:var(--color-sig)]`})]})}var Te=(0,k.lazy)(()=>E(()=>import(`./UniverSheet-BwKQUIYP.js`),__vite__mapDeps([0,1,2,3,4,5])));function Ee(e,t){let n=+(e.kind===`row`),r=e.cells.map(e=>`(${e[n]+1})`),i=r.length>5?[r[0],r[1],`…`,r[r.length-1]].join(` + `):r.join(` + `);return t(e.kind===`row`?`table.checkSumErrorColumn`:`table.checkSumErrorRow`,{total:e.total[n]+1,parts:i})}function De(e){let t=e.cells.filter(e=>(e.text??``).trim()!==``);return{n:t.filter(e=>e.verified).length,total:t.length}}var Oe=`tabularium.table.otslPreview`;function ke({label:e,full:t,className:n=``,children:r}){return(0,$.jsxs)(`span`,{title:t,className:`flex items-baseline gap-1`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`span`,{className:`mono text-[color:var(--color-ink)] ${n}`,children:r})]})}function Ae({serverId:t,pageImageUrl:r,pageId:i,pageImageSize:a,onSaveTable:o,flushRef:s}){let{t:c}=l(),u=O(),[f,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(null),[g,_]=(0,k.useState)(null),[v,b]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1),[C,T]=(0,k.useState)(0),[E,D]=(0,k.useState)(!1),[A,j]=(0,k.useState)(45),M=(0,k.useRef)(Promise.resolve()),N=(0,k.useRef)(null),P=(0,k.useRef)(null),[F,I]=(0,k.useState)(800);(0,k.useEffect)(()=>{if(!f||!P.current)return;let e=P.current,t=()=>I(e.clientWidth||800);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[!!f]);let[L,ne]=(0,k.useState)(()=>{try{return localStorage.getItem(Oe)===`open`}catch{return!1}}),re=e=>{if(e!==L){ne(e);try{localStorage.setItem(Oe,e?`open`:`closed`)}catch{}}},[R,z]=(0,k.useState)(0),[B,V]=(0,k.useState)(null),[H,W]=(0,k.useState)(null),G=(0,k.useRef)(null),K=(0,k.useRef)(``),[q,J]=(0,k.useState)(null),[se,pe]=(0,k.useState)(null),[me,he]=(0,k.useState)({startRow:0,startColumn:0,endRow:0,endColumn:0});(0,k.useEffect)(()=>{if(!f)return;let e=!1,t=setTimeout(()=>{w(`/tables/checks`,f).then(t=>{e||J(Array.isArray(t?.checks)?t:null)}).catch(()=>{e||J(null)})},400);return()=>{e=!0,clearTimeout(t)}},[f]);let ge=se?(q?.checks??[]).filter(e=>!e.ok&&[...e.cells,e.total].some(([e,t])=>e===se.r&&t===se.c)):[],_e=(e,t)=>{let n=G.current;if(!n)return;let r=(n.misprints??[]).filter(t=>t!==e);Z({...n,misprints:t?[...r,e]:r})};(0,k.useEffect)(()=>{h(null),e(`/blocks/${t}/table`).then(e=>{let t=e.grid??ae(3,4);G.current=t,K.current=Q(t),p(t)}).catch(()=>h(c(`table.loadFailed`)))},[t,c]);let Y=(0,k.useCallback)(e=>{let n=Q(e);if(N.current?.signature===n)return N.current.promise;let r=M.current.catch(()=>{}).then(async()=>{S(!0);try{b(await o(t,e)),K.current=n,T(e=>e+1),_(null)}catch(e){throw _(e instanceof Error?c(`table.saveFailedWith`,{msg:e.message}):c(`table.saveFailed`)),e}finally{N.current?.promise===r&&(N.current=null),S(!1)}});return N.current={signature:n,promise:r},M.current=r,r},[o,t,c]);(0,k.useEffect)(()=>{if(!f||Q(f)===K.current)return;let e=setTimeout(()=>void Y(f).catch(()=>{}),900);return()=>clearTimeout(e)},[f,Y]);let X=()=>!!G.current&&Q(G.current)!==K.current,ve=(0,k.useRef)(async()=>{});ve.current=async()=>{for(await M.current.catch(()=>{});X();)await Y(G.current)},(0,k.useEffect)(()=>{s&&(s.current=()=>ve.current());let e=e=>{X()&&e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),s&&(s.current=null),ve.current().catch(()=>{})}},[s]);let Z=e=>{G.current=e,p(e)},ye=(e,t)=>{let n=G.current;V(null),!(!n||!e)&&(W(n),_(c(`table.splitDone`,{n:t})),Z(e),z(e=>e+1))},be=()=>{H&&(W(null),_(null),Z(H),z(e=>e+1))},Ce=(e,t)=>{let n=G.current;if(!n)return;let{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(e===`split`){V(i);return}let s=(e,t)=>{let n=t.cells.filter(t=>{let n=e.cells.find(e=>e.r===t.r&&e.c===t.c);return n?n.text!==t.text:!1}).length;W(e),_(c(`table.columnOpDone`,{n})),Z(t),z(e=>e+1)};if(e===`merge`){if(r===a&&i===o){_(c(`table.mergeNothing`));return}if(!oe(n,r,i,a,o)){_(c(`table.mergeWouldLose`));return}let e=ee(n,r,i,a,o);if(!e){_(c(`table.columnOpRefused`));return}s(n,e);return}if(e===`unmerge`){let e=te(n,r,i);if(!e){_(c(`table.notMerged`));return}s(n,e);return}let l=n,u=e===`join`?ce(n,i,{separator:` `}):e===`normalize`?le(n,i):e===`fractions`?ue(n,i):e===`fill`?fe(n,i,r,a===r?n.rows-1:a):de(n,i,e);if(!u){_(c(`table.columnOpRefused`));return}s(l,u)},Ae=async(e,t)=>{let n=G.current;if(!n)return;let{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if((e===`deleteRow`||e===`deleteCol`)&&!await u({title:c(`table.deleteTrackConfirm`),message:c(`table.deleteTrackMessage`)}))return;let s=e===`insertRowAbove`?U(n,`row`,r):e===`insertRowBelow`?U(n,`row`,a+1):e===`insertColLeft`?U(n,`col`,i):e===`insertColRight`?U(n,`col`,o+1):e===`deleteRow`?ie(n,`row`,r):ie(n,`col`,i);if(!s){_(c(`table.columnOpRefused`));return}W(n),_(null),Z(s),z(e=>e+1)};if(m&&!f)return(0,$.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:m});if(!f)return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,role:`status`,"aria-label":c(`content.tableLoading`),children:[(0,$.jsx)(`span`,{className:`load-cell h-7 w-full rounded-[var(--radius-md)]`}),(0,$.jsx)(`span`,{className:`load-cell h-7 w-3/5 rounded-[var(--radius-md)]`}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-3`,children:[r&&(0,$.jsx)(`span`,{className:`load-cell min-h-[320px] flex-1 rounded-[var(--radius-md)]`}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(y,{label:c(`content.tableLoading`),rows:10})})]})]});let je=De(f);return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-[color:var(--color-rule)] pb-2 text-[11px] text-[color:var(--color-ink-2)]`,children:[(0,$.jsxs)(ke,{label:c(`table.gridShort`),full:c(`table.workspaceSummary`,{rows:f.rows,cols:f.cols}),children:[f.rows,` × `,f.cols]}),f.phantom_cols.length>0&&(0,$.jsx)(`span`,{children:c(`table.phantomColumns`,{n:f.phantom_cols.length})}),(0,$.jsxs)(ke,{label:c(`table.verifiedShort`),full:`${c(`table.verifiedCount`,je)} — ${c(`table.verifyHint`)}`,children:[je.n,`/`,je.total]}),q&&q.checks.length>0&&(0,$.jsxs)(ke,{full:(q.failed>0?c(`table.checksSummary`,{passed:q.passed,total:q.checks.length,failed:q.failed}):c(`table.checksBalanced`,{n:q.passed}))+((q.misprints??0)>0?` ${c(`table.misprintsCount`,{n:q.misprints??0})}`:``),label:c(`table.sumsShort`),className:q.failed>0?`!text-[color:var(--color-warn)] font-semibold`:``,children:[q.passed,`/`,q.checks.length]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-1`,title:c(`table.headerRowsTitle`),children:[c(`table.headerShort`),(0,$.jsx)(`input`,{type:`number`,min:0,max:Math.min(f.rows,20),value:f.header_rows??0,onChange:e=>{let t=Math.max(0,Math.min(Math.min(f.rows,20),Number(e.target.value)||0));t!==(f.header_rows??0)&&(Z({...f,header_rows:t}),z(e=>e+1))},className:`w-12 rounded-[var(--radius-sm)] border border-[color:var(--color-rule)] bg-[color:var(--color-panel)] px-1 py-0.5 text-[11px]`})]}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>Ce(`split`,me),children:c(`table.splitTitle`)}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:!H,onClick:be,children:c(`table.undoOperation`)}),(0,$.jsxs)(`select`,{"aria-label":c(`table.quickActions`),value:``,className:`btn btn-sm max-w-48`,onChange:e=>{e.target.value&&Ce(e.target.value,me)},children:[(0,$.jsx)(`option`,{value:``,disabled:!0,children:c(`table.quickActions`)}),[`normalize`,`fill`,`join`,`upper`,`lower`,`fractions`,`merge`,`unmerge`].map(e=>(0,$.jsx)(`option`,{value:e,children:c(e===`fractions`?`table.toFractionsShort`:e===`merge`?`table.modeMerge`:e===`unmerge`?`table.splitCell`:`table.${e}Short`)},e))]}),(0,$.jsx)(`span`,{role:`status`,className:`ml-auto`,"data-save-version":C,children:x?c(`table.saving`):X()?c(`table.unsaved`):c(`table.saved`)}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Y(G.current??f).catch(()=>{}),disabled:x||!X(),className:`btn btn-sm btn-primary ml-auto`,children:[(0,$.jsx)(n,{size:11}),c(x?`table.saving`:`table.saveGrid`)]})]}),ge.length>0&&(0,$.jsx)(`p`,{className:`text-[11px] text-[color:var(--color-warn)]`,children:ge.map((e,t)=>(0,$.jsxs)(`span`,{className:`mr-2 inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mono ${e.misprint?`text-[color:var(--color-ink-2)] line-through`:`text-[color:var(--color-ink)]`}`,children:Ee(e,c)}),e.key&&(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,title:c(`table.misprintHint`),onClick:()=>_e(e.key,!e.misprint),children:e.misprint?c(`table.misprintUndo`):c(`table.misprintMark`)})]},t))}),g&&(0,$.jsx)(d,{title:c(`table.notice`),children:(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2`,children:g})}),(0,$.jsxs)(`div`,{ref:P,className:`flex min-h-0 flex-1 gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col`,style:{flex:`0 0 ${A}%`},children:[r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-1 text-[11px]`,children:[(0,$.jsx)(`button`,{className:`btn btn-sm`,"aria-pressed":!E,onClick:()=>D(!1),children:c(`table.tableCrop`)}),(0,$.jsx)(`button`,{className:`btn btn-sm`,"aria-pressed":E,onClick:()=>D(!0),children:c(`table.wholePage`)})]}),(0,$.jsx)(Se,{src:E&&r?r:`/api/blocks/${t}/crop`,pageId:E?i:null,imageSize:E?a:null},E?`page`:`crop`)]}),(0,$.jsx)(we,{value:F*A/100,min:F*.25,max:F*.65,side:`left`,label:c(`table.imageWidth`),onChange:e=>j(e/F*100),onReset:()=>j(45)}),(0,$.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,$.jsx)(k.Suspense,{fallback:(0,$.jsx)(y,{label:c(`content.tableLoading`),rows:10}),children:(0,$.jsx)(Te,{grid:f,onGridChange:e=>{W(null),Z(e)},onColumnOp:Ce,onTrackOp:Ae,suspects:q?.suspects,onSelectionChange:e=>{pe({r:e.startRow,c:e.startColumn}),he(e)},intro:!0},`${t}:${f.rows}x${f.cols}:${R}`)})})]}),v!==null&&(0,$.jsxs)(`details`,{open:L,onToggle:e=>re(e.currentTarget.open),className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`lbl !mb-0`,children:c(`table.otslNote`)}),(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),navigator.clipboard?.writeText(v)},className:`btn btn-sm`,children:c(`common.copy`)})]}),(0,$.jsx)(`pre`,{className:`mono mt-1 max-h-32 overflow-auto text-[11px] whitespace-pre-wrap`,children:v})]}),B!==null&&(0,$.jsx)(xe,{grid:G.current??f,column:B,onApply:ye,onClose:()=>V(null)})]})}var je=`cubic-bezier(0.16, 1, 0.3, 1)`,Me=260;function Ne(){return typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches}function Pe(e,t){let n=(0,k.useRef)(null),r=(0,k.useRef)(t);(0,k.useLayoutEffect)(()=>{let i=e.current;if(!i)return;let a=i.getBoundingClientRect().height,o=n.current;if(n.current=a,Object.is(r.current,t)||(r.current=t,o==null||Math.abs(o-a)<2||Ne()||!i.animate))return;i.style.overflow=`hidden`;let s=i.animate([{height:`${o}px`},{height:`${a}px`}],{duration:Me,easing:je}),c=()=>{i.style.overflow=``};s.onfinish=c,s.oncancel=c})}function Fe(e){let t=(0,k.useRef)(new Map);(0,k.useLayoutEffect)(()=>{let n=e.current;if(!n)return;let r=new Map,i=!Ne();n.querySelectorAll(`:scope > [data-block]`).forEach(e=>{let n=e.dataset.block,a=e.offsetTop;r.set(n,a);let o=t.current.get(n);i&&o!=null&&Math.abs(o-a)>1&&e.animate&&e.animate([{transform:`translateY(${o-a}px)`},{transform:`none`}],{duration:Me,easing:je})}),t.current=r})}function Ie(e){return e.split(`<nl>`).map(e=>Array.from(e.matchAll(/<(fcel|ecel|lcel|ucel|xcel)>([\s\S]*?)(?=<(?:fcel|ecel|lcel|ucel|xcel)>|$)/gi)).map(e=>e[1].toLowerCase()===`fcel`?e[2].trim():``)).filter(e=>e.length>0)}function Le(e){let t=e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.startsWith(`|`)&&e.endsWith(`|`)&&e.split(`|`).length>=3).map(e=>e.slice(1,-1).split(`|`).map(e=>e.trim())),n=t.findIndex(e=>e.length>0&&e.every(e=>/^:?-{2,}:?$/.test(e))),r=t.filter((e,t)=>t!==n);return r.length===0?null:n===1?{head:r[0],rows:r.slice(1)}:{head:null,rows:r}}function Re(e){let t=/<tr\b[^>]*>\s*<th\b/i.test(e),n=Array.from(e.matchAll(/<tr\b[^>]*>([\s\S]*?)(?=<tr\b|<\/table\b|$)/gi)).map(e=>Array.from(e[1].matchAll(/<t[dh]\b[^>]*>([\s\S]*?)(?=<t[dh]\b|<\/tr\b|$)/gi)).map(e=>e[1].replace(/<br\s*\/?\s*>/gi,`
|
|
4
|
+
`).replace(/<[^>]*>/g,``).replace(/ /gi,` `).replace(/&/gi,`&`).replace(/</gi,`<`).replace(/>/gi,`>`).trim())).filter(e=>e.length>0);return n.length===0?null:t?{head:n[0],rows:n.slice(1)}:{head:null,rows:n}}function ze(e){let t=Ie(e),n=t.length>0?{head:null,rows:t}:Le(e)??Re(e);return n&&n.rows.length>0?[{kind:`table`,table:n}]:/<\/?(?:table|fcel|ecel|lcel|ucel|xcel|nl)/i.test(e)||/^\s*[[{]/.test(e.trim())?[{kind:`code`,text:e}]:e.split(/\n{2,}/).map(e=>e.trim()).filter(Boolean).map(e=>{if(/^#{1,3}\s+/.test(e))return{kind:`heading`,text:e.replace(/^#{1,3}\s+/,``)};let t=e.split(`
|
|
5
|
+
`);return t.every(e=>/^\s*[-*]\s+/.test(e))?{kind:`list`,items:t.map(e=>e.replace(/^\s*[-*]\s+/,``))}:{kind:`text`,text:e}})}function Be(e){return e.trim()!==``&&/^[\d.,'’\s/:+-]+$/.test(e.trim())}function Ve({table:e}){let t=Math.max(e.head?.length??0,...e.rows.map(e=>e.length)),n=Array.from({length:t},(t,n)=>{let r=e.rows.map(e=>e[n]??``).filter(e=>e.trim()!==``);return r.length>0&&r.every(Be)});return(0,$.jsx)(`div`,{className:`overflow-x-auto border border-[color:var(--color-rule)] bg-[color:var(--color-sheet)]`,children:(0,$.jsxs)(`table`,{className:`dtable`,children:[e.head&&(0,$.jsx)(`thead`,{children:(0,$.jsx)(`tr`,{children:e.head.map((e,t)=>(0,$.jsx)(`th`,{scope:`col`,children:e},t))})}),(0,$.jsx)(`tbody`,{children:e.rows.map((e,r)=>(0,$.jsx)(`tr`,{className:`stream-in`,children:Array.from({length:t},(t,r)=>(0,$.jsx)(`td`,{"data-num":n[r]?`true`:void 0,children:e[r]??``},r))},r))})]})})}function He(){return(0,$.jsx)(`span`,{"aria-hidden":!0,className:`caret`})}function Ue({chunks:e,streaming:t}){let n=e.length-1;return(0,$.jsx)(`div`,{className:`space-y-2 text-[13px] leading-relaxed`,children:e.map((e,r)=>{let i=t&&r===n;switch(e.kind){case`table`:return(0,$.jsx)(`div`,{className:`stream-in`,children:(0,$.jsx)(Ve,{table:e.table})},r);case`heading`:return(0,$.jsxs)(`h4`,{className:`stream-in text-[14px] font-bold`,children:[e.text,i&&(0,$.jsx)(He,{})]},r);case`list`:return(0,$.jsxs)(`ul`,{className:`stream-in list-disc space-y-0.5 pl-5`,children:[e.items.map((e,t)=>(0,$.jsx)(`li`,{children:e},t)),i&&(0,$.jsx)(He,{})]},r);case`code`:return(0,$.jsxs)(`pre`,{className:`mono stream-in whitespace-pre-wrap break-words text-[11px] leading-relaxed`,children:[e.text,i&&(0,$.jsx)(He,{})]},r);default:return(0,$.jsxs)(`p`,{className:`stream-in m-0 whitespace-pre-wrap`,children:[e.text,i&&(0,$.jsx)(He,{})]},r)}})})}function We({startedAt:e}){let[t,n]=(0,k.useState)(()=>Date.now());(0,k.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.round((t-e)/1e3));return(0,$.jsxs)(`span`,{className:`mono text-[11px] text-[color:var(--color-ink-3)]`,children:[String(Math.floor(r/60)).padStart(2,`0`),`:`,String(r%60).padStart(2,`0`)]})}function Ge({working:e,text:t,phase:n}){let{t:r,tn:i}=l(),a=(0,k.useRef)(null),s=(0,k.useRef)(!0),[c,u]=(0,k.useState)(!1),d=e!=null,f=d||c;(0,k.useEffect)(()=>{let e=a.current;e&&s.current&&(e.scrollTop=e.scrollHeight)},[t]);let p=t?ze(t):[],m=n?`content.phase.${n}`:null,h=m&&r(m)!==m?r(m):null;return(0,$.jsxs)(`section`,{"aria-label":r(`content.streamTitle`),"aria-busy":d,className:`border-b border-[color:var(--color-rule-strong)] bg-[color:var(--color-fill)]`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-2 py-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),disabled:d,"aria-expanded":f,"aria-label":r(f?`content.streamCollapse`:`content.streamExpand`),className:`flex items-center gap-1 text-left disabled:cursor-default`,children:[d?(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-3 shrink-0 animate-spin border-[1.5px] border-[color:var(--color-rule)] border-t-[color:var(--color-sig)]`}):(0,$.jsx)(o,{size:11,className:`shrink-0 text-[color:var(--color-ink-3)] transition-transform duration-150`,style:{transform:f?`rotate(0deg)`:`rotate(-90deg)`}}),(0,$.jsx)(`span`,{className:`lbl !mb-0`,children:r(`content.streamTitle`)})]}),h&&(0,$.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:h}),e&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-2)]`,children:e.blocks>0?i(`content.blocksSoFar`,e.blocks,{last:e.last??`—`}):r(`content.blocksSoFarNone`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:e.engine}),(0,$.jsx)(We,{startedAt:e.startedAt})]})]})]}),f&&(p.length>0||e)&&(0,$.jsx)(`div`,{ref:a,onScroll:e=>{let t=e.currentTarget;s.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},className:`max-h-[38vh] overflow-y-auto border-t border-[color:var(--color-rule)] bg-[color:var(--color-sheet)] px-2.5 py-2`,children:p.length>0?(0,$.jsx)(Ue,{chunks:p,streaming:d}):(0,$.jsxs)(`p`,{className:`m-0 text-[12px] text-[color:var(--color-ink-3)]`,children:[r(`content.streamWaiting`),(0,$.jsx)(He,{})]})})]})}var Ke={soft_hyphen:`conventions.c_soft_hyphen`,sigle:`conventions.c_sigle`,corsivi:`conventions.c_corsivi`,colonne_fantasma:`conventions.c_colonne_fantasma`,filetti:`conventions.c_filetti`};function qe({projectId:t}){let{t:n}=l(),[r,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(null);(0,k.useEffect)(()=>{i(null),e(`/projects/${t}/conventions`).then(e=>i(e.conventions)).catch(o)},[t]);let s=async e=>{if(!r)return;let n=r.map(t=>t.id===e?{...t,checked:!t.checked}:t);i(n);try{await v(`/projects/${t}/conventions`,{conventions:n})}catch(e){o(e)}},c=r?.filter(e=>e.checked).length??0,u=e=>{let t=Ke[e.id];return t?n(t):e.label};return(0,$.jsxs)(h,{tab:n(`conventions.tab`),quiet:!0,aux:r?(0,$.jsx)(`span`,{children:`${c}/${r.length}`}):void 0,children:[a!=null&&(0,$.jsx)(`div`,{className:`mb-2`,children:(0,$.jsx)(x,{error:a,onDismiss:()=>o(null)})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-[11px] text-[color:var(--color-ink-3)]`,children:n(`conventions.intro`)}),(0,$.jsx)(`ul`,{className:`space-y-1`,children:r.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.checked,onChange:()=>void s(e.id),className:`mt-0.5 shrink-0`}),(0,$.jsx)(`span`,{className:e.checked?`text-[color:var(--color-ink)]`:`text-[color:var(--color-ink-2)]`,children:u(e)})]})},e.id))})]}):(0,$.jsx)(f,{lines:4,label:n(`common.loading`)})]})}var Je=[`text`,`table`,`formula`,`picture`,`structure`],Ye=[`text`,`table`,`formula`];function Xe(e){return Ye.includes(e)}function Ze(e){return!e.builtin}function Qe(e){return e.filter(Ze)}function $e(e,t){return t?e.known_models.includes(t):e.known_models.length>0}function et(e){return{name:e.name,color:e.color,short:e.short,prompt_kind:e.prompt_kind,prompt:e.prompt,aliases:e.aliases??[]}}function tt(){return{name:``,color:`#4a5560`,short:``,prompt_kind:`text`,prompt:``,aliases:[]}}function nt(e){return e.join(`, `)}function rt(e){let t=new Set,n=[];for(let r of e.split(`,`)){let e=r.trim();if(!(!e||t.has(e))&&(t.add(e),n.push(e),n.length>=20))break}return n}var it=/^[A-Za-z][A-Za-z0-9 ._-]{0,39}$/,at=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function ot(e,t,n){let r=e.name.trim();if(!it.test(r))return`name`;if(r!==n&&t.includes(r))return`duplicate`;if(!at.test(e.color.trim()))return`color`;let i=e.short.trim();return i.length<1||i.length>6?`short`:Xe(e.prompt_kind)&&!e.prompt.trim()?`prompt`:null}var st={name:`labels.errName`,duplicate:`labels.errDuplicate`,color:`labels.errColor`,short:`labels.errShort`,prompt:`labels.errPrompt`},ct={text:`labels.kindText`,table:`labels.kindTable`,formula:`labels.kindFormula`,picture:`labels.kindPicture`,structure:`labels.kindStructure`};function lt({draft:e,onDraft:t,aliasesText:n,onAliasesText:r,draftErr:i}){let{t:a}=l();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(m,{label:a(`labels.name`),error:i===`name`?a(st.name):null,children:(0,$.jsx)(`input`,{className:`fld`,value:e.name,placeholder:a(`labels.namePlaceholder`),onChange:e=>t({name:e.target.value})})}),(0,$.jsx)(m,{label:a(`labels.short`),error:i===`short`?a(st.short):null,children:(0,$.jsx)(`input`,{className:`fld`,value:e.short,placeholder:a(`labels.shortPlaceholder`),onChange:e=>t({short:e.target.value})})}),(0,$.jsx)(m,{label:a(`labels.color`),error:i===`color`?a(st.color):null,children:(0,$.jsx)(`input`,{className:`fld`,value:e.color,onChange:e=>t({color:e.target.value})})}),(0,$.jsx)(m,{label:a(`labels.kind`),children:(0,$.jsx)(`select`,{className:`fld`,value:e.prompt_kind,onChange:e=>t({prompt_kind:e.target.value}),children:Je.map(e=>(0,$.jsx)(`option`,{value:e,children:a(ct[e])},e))})})]}),(0,$.jsx)(m,{label:a(`labels.prompt`),hint:a(`labels.promptHint`),error:i===`prompt`?a(st.prompt):null,children:(0,$.jsx)(`input`,{className:`fld`,value:e.prompt,disabled:!Xe(e.prompt_kind),placeholder:a(`labels.promptPlaceholder`),onChange:e=>t({prompt:e.target.value})})}),(0,$.jsx)(m,{label:a(`labels.aliases`),hint:a(`labels.aliasesHint`),children:(0,$.jsx)(`input`,{className:`fld`,value:n,placeholder:a(`labels.aliasesPlaceholder`),onChange:e=>r(e.target.value)})}),i===`duplicate`&&(0,$.jsx)(`p`,{className:`m-0 text-[11px] text-[color:var(--color-sig-text)]`,children:a(st.duplicate)})]})}var ut=ct;function dt({projectId:e,labels:t,activeAdapterId:n,onSaved:r}){let{t:i}=l(),a=D(),[o,s]=(0,k.useState)(()=>Qe(t).map(et)),[c,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(tt),[p,m]=(0,k.useState)(``),[h,g]=(0,k.useState)(!1),[_,y]=(0,k.useState)(!1),[b,S]=(0,k.useState)(null),[w,E]=(0,k.useState)(!1);(0,k.useEffect)(()=>{s(Qe(t).map(et))},[t]);let O=(0,k.useMemo)(()=>t.filter(e=>e.builtin),[t]),A=ot(d,(0,k.useMemo)(()=>[...t.map(e=>e.name),...o.map(e=>e.name)].filter(e=>e!==c),[t,o,c]),c),j=()=>{f(tt()),m(``),u(null),g(!1)},M=()=>{if(A)return;let e={...d,name:d.name.trim(),color:d.color.trim(),short:d.short.trim(),prompt:d.prompt.trim(),aliases:rt(p)};s(t=>c?t.map(t=>t.name===c?e:t):[...t,e]),j()},N=e=>{s(t=>t.filter(t=>t.name!==e)),c===e&&j()},P=e=>{f(e),m(nt(e.aliases)),u(e.name),g(!0)},F=async()=>{y(!0),S(null),E(!1);try{let t=await v(`/projects/${e}/labels`,{labels:o});r(t.labels),s(Qe(t.labels).map(et)),E(!0)}catch(e){S(e)}finally{y(!1)}},I=e=>{let t=e.known_models.map(e=>a(e)??e);return i(`labels.knownBy`,{models:t.join(`, `)})};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 p-3 text-[13px]`,children:[(0,$.jsx)(`p`,{className:`m-0 text-[12px] text-[color:var(--color-ink-2)]`,children:i(`labels.intro`)}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`lbl`,children:i(`labels.customTitle`)}),o.length===0?(0,$.jsx)(`p`,{className:`m-0 text-[12px] text-[color:var(--color-ink-3)]`,children:i(`labels.customEmpty`)}):(0,$.jsx)(`ul`,{className:`ruled`,children:o.map(e=>{let r=t.find(t=>t.name===e.name);return(0,$.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-3 shrink-0 rounded-sm border border-[color:var(--color-rule)]`,style:{background:e.color}}),(0,$.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:i(ut[e.prompt_kind]??`labels.kindText`)}),e.aliases.length>0&&(0,$.jsxs)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:[`↔ `,e.aliases.join(`, `)]}),(0,$.jsx)(C,{tone:`warn`,children:i(`labels.originCustom`)}),r&&$e(r,n)&&(0,$.jsx)(C,{tone:`ok`,children:i(`labels.knownHere`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>P(e),children:i(`labels.edit`)}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>N(e.name),children:i(`labels.remove`)})]})]},e.name)})})]}),h?(0,$.jsxs)(`section`,{className:`flex flex-col gap-3 border-t border-[color:var(--color-rule)] pt-3`,children:[(0,$.jsx)(lt,{draft:d,onDraft:e=>f(t=>({...t,...e})),aliasesText:p,onAliasesText:m,draftErr:A}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:M,disabled:!!A,children:i(c?`labels.edit`:`labels.add`)}),(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:j,children:i(`labels.cancel`)})]})]}):(0,$.jsx)(`button`,{type:`button`,className:`btn btn-sm self-start`,onClick:()=>g(!0),children:i(`labels.add`)}),(0,$.jsxs)(`section`,{className:`border-t border-[color:var(--color-rule)] pt-3`,children:[(0,$.jsx)(`h3`,{className:`lbl`,children:i(`palette.tab`)}),(0,$.jsx)(`ul`,{className:`ruled`,children:O.map(e=>(0,$.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 px-2 py-1.5`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-3 shrink-0 rounded-sm border border-[color:var(--color-rule)]`,style:{background:e.color}}),(0,$.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,$.jsx)(C,{tone:e.origin===`public`?`ok`:`warn`,children:e.origin===`public`?i(`labels.originPublic`):i(`labels.originCustom`)}),(0,$.jsx)(C,{tone:`neutral`,children:i(`labels.builtin`)}),e.aliases.length>0&&(0,$.jsxs)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:[`↔ `,e.aliases.join(`, `)]}),(0,$.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:e.known_models.length>0?I(e):i(`labels.knownByNone`)})]},e.name))})]}),b?(0,$.jsx)(x,{error:b,onDismiss:()=>S(null)}):null,w?(0,$.jsx)(T,{tone:`ok`,children:i(`labels.saved`)}):null,(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsx)(`button`,{type:`button`,className:`btn`,onClick:F,disabled:_,children:i(_?`labels.saving`:`labels.save`)})})]})}function ft({projectId:t}){let{t:n}=l(),[r,i]=(0,k.useState)(null),[a,o]=(0,k.useState)(``),[s,c]=(0,k.useState)(null),[u,d]=(0,k.useState)(!1);(0,k.useEffect)(()=>{i(null),d(!1),e(`/projects/${t}/table-hint`).then(e=>{i(e),o(e.hint)}).catch(c)},[t]);let p=async()=>{c(null);try{let e=await v(`/projects/${t}/table-hint`,{hint:a});i(e),o(e.hint),d(!0)}catch(e){c(e)}};return(0,$.jsxs)(`div`,{className:`p-3`,children:[s!=null&&(0,$.jsx)(`div`,{className:`mb-2`,children:(0,$.jsx)(x,{error:s,onDismiss:()=>c(null)})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-[11px] text-[color:var(--color-ink-3)]`,children:n(`tableHint.intro`)}),(0,$.jsx)(`textarea`,{value:a,onChange:e=>{o(e.target.value),d(!1)},rows:6,placeholder:n(`tableHint.placeholder`),className:`fld w-full resize-y font-mono text-[12px]`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:`btn btn-sm btn-primary`,children:n(`tableHint.save`)}),u&&(0,$.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-3)]`,children:n(`tableHint.saved`)})]}),(0,$.jsx)(`p`,{className:`mt-3 text-[11px] text-[color:var(--color-ink-3)]`,children:r.active_model==null?n(`tableHint.noModel`):r.accepts_hint?n(`tableHint.accepts`,{model:r.active_model}):n(`tableHint.ignores`,{model:r.active_model})})]}):(0,$.jsx)(f,{lines:4,label:n(`common.loading`)})]})}var pt=new Set([`Picture`,`Column`]),mt=(e,t=0)=>t?`/api/blocks/${e}/crop?v=${t}`:`/api/blocks/${e}/crop`;function ht({serverId:e,pageId:t,pageImageUrl:n,pageImageSize:r,onSaveTable:i,confirmed:a,onConfirmed:o}){let{t:s}=l(),[u,d]=(0,k.useState)(!1),f=(0,k.useRef)(null),p=(0,k.useCallback)(()=>{(async()=>{try{await f.current?.(),d(!1)}catch{}})()},[]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{let n=`/tabella/${e}?page=${t}&width=${r?.w??``}&height=${r?.h??``}&confirmed=${+!!a}`,i=Math.round(window.screen.availWidth*.85),o=Math.round(window.screen.availHeight*.85);window.open(n,`tabularium-table-${e}`,`popup,width=${i},height=${o}`)?.focus()},className:`btn btn-sm`,title:s(`table.openSecondScreen`),children:s(`table.openSecondScreen`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`btn btn-sm btn-primary`,children:s(`table.openWorkspace`)})]}),u&&(0,$.jsx)(c,{title:s(`table.workspaceTitle`),extraWide:!0,onClose:p,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col p-3`,children:[(0,$.jsx)(gt,{checked:a,onChange:o,className:`mb-2`}),(0,$.jsx)(Ae,{serverId:e,flushRef:f,pageImageUrl:n??null,pageId:t??null,pageImageSize:r??null,onSaveTable:i})]})})]}):(0,$.jsx)(`p`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[11px] text-[color:var(--color-ink-2)]`,children:s(`content.cropUnsaved`)})}function gt({checked:e,onChange:t,className:n=``}){let{t:r}=l();return(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-1.5 text-[12px] text-[color:var(--color-ink-2)] ${n}`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`accent-[color:var(--color-sig)]`}),r(`content.confirmDraft`)]})}function _t({state:e,message:t,onRun:n,onDismiss:r}){let{t:i}=l();return(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 border ${e===`error`?`border-[color:var(--color-danger)] text-[color:var(--color-danger)]`:e===`stale`?`border-[color:var(--color-warn)] text-[color:var(--color-warn)]`:`border-[color:var(--color-rule-strong)] text-[color:var(--color-ink-2)]`} bg-[color:var(--color-fill)] px-2 py-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[e===`busy`&&i(`table.redetectBusy`),e===`stale`&&i(`table.redetectStale`),e===`done`&&(t??i(`table.redetectDoneShort`)),e===`error`&&i(`table.redetectFailedWith`,{msg:t??``})]}),(e===`stale`||e===`error`)&&(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`btn btn-sm`,children:i(`table.redetectRun`)}),e!==`busy`&&(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`btn btn-sm`,children:i(`common.close`)})]})}function vt({id:e,order:t,label:n,color:r,labels:a,onLabel:o,badge:c,confirmed:u,onConfirmed:d,onDelete:f,deleteTitle:p,selected:m,onSelect:h,onMove:g,canMoveUp:v,canMoveDown:y,rowAria:x,cropUrl:S,cropAlt:C,cropUnsavedHint:w,wide:T,collapsed:E,preview:D,children:O}){let{t:A}=l(),j=(0,k.useRef)(null);Pe(j,E);let M=(0,$.jsxs)(`button`,{type:`button`,onClick:h,"aria-pressed":m,"aria-label":x,onKeyDown:e=>{if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault(),g?.(e.key===`ArrowUp`?-1:1);return}e.key===`Delete`&&(e.preventDefault(),f?.())},className:`mono flex shrink-0 items-center gap-1.5 text-[11px] text-[color:var(--color-ink-3)]`,children:[(0,$.jsx)(`span`,{className:`w-5 text-right`,children:t??`—`}),r&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-3 rounded-sm border border-[color:var(--color-rule-strong)]`,style:{background:r}})]});return E?(0,$.jsxs)(`li`,{ref:j,id:`content-row-${e}`,"data-block":e,className:`stream-in flex cursor-pointer items-center gap-2 border-b border-[color:var(--color-rule)] px-2.5 py-1.5 last:border-b-0 hover:bg-[color:var(--color-fill)]`,onClick:e=>{e.target.closest(`button`)||h?.()},children:[M,(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] font-semibold`,children:n}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px] text-[color:var(--color-ink-2)]`,children:D}),(0,$.jsxs)(`span`,{className:`shrink-0 text-[11px] text-[color:var(--color-ok)]`,title:A(`content.confirmDraft`),children:[`✓ `,A(`content.confirmDraft`)]})]}):(0,$.jsxs)(`li`,{ref:j,id:`content-row-${e}`,"data-block":e,className:`stream-in relative border-b border-[color:var(--color-rule)] p-2.5 last:border-b-0 has-[details[open]]:z-40 ${m?`bg-[color:var(--color-sig-wash)]`:``}`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[M,o&&a?(0,$.jsx)(_,{value:n,onChange:o,onFocus:h,ariaLabel:A(`inspector.class`),className:`fld !w-auto text-xs`,options:a.map(e=>({value:e.name,label:e.name}))}):(0,$.jsx)(`span`,{className:`mono text-[11px] uppercase tracking-[0.04em] text-[color:var(--color-ink-3)]`,children:n}),c&&(0,$.jsx)(`span`,{className:`badge text-[color:var(--color-ink-3)]`,title:c.title,children:c.text}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-[11px] text-[color:var(--color-ink-2)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`accent-[color:var(--color-sig)]`}),A(`content.confirmDraft`)]}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[g&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(-1),disabled:!v,"aria-label":A(`layers.moveUp`,{label:n}),className:`p-1 text-[color:var(--color-ink-2)] hover:text-[color:var(--color-ink)] disabled:opacity-30`,children:(0,$.jsx)(b,{size:11})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(1),disabled:!y,"aria-label":A(`layers.moveDown`,{label:n}),className:`p-1 text-[color:var(--color-ink-2)] hover:text-[color:var(--color-ink)] disabled:opacity-30`,children:(0,$.jsx)(s,{size:11})})]}),f&&(0,$.jsx)(`button`,{type:`button`,onClick:f,title:p,"aria-label":p,className:`btn btn-sm`,children:(0,$.jsx)(i,{size:12})})]})]}),(0,$.jsxs)(`div`,{className:T?`flex min-w-0 flex-col gap-2`:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`figure`,{onClick:h,className:`m-0 shrink-0 ${T?`max-h-32 w-full overflow-hidden`:`w-1/4`} ${h?`cursor-pointer`:``}`,children:S?(0,$.jsx)(`img`,{"data-fade":!0,src:S,alt:C,loading:`lazy`,className:`w-full rounded-sm border border-[color:var(--color-rule)] bg-[color:var(--color-table)] object-contain ${T?`max-h-32 object-top`:``}`}):(0,$.jsx)(`p`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[11px] text-[color:var(--color-ink-2)]`,children:w})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:O})]})]})}function yt({blocks:e,drafts:t,labels:n,selectedId:r,onSelect:i,onContent:a,onLabel:o,onConfirmed:s,onDelete:u,onSaveTable:d,pageId:f,pageImageUrl:p,pageImageSize:m,tableVersions:g,tableRedetect:_,onDismissRedetect:v,onRedetectNow:y,onDraftContent:b,onDraftLabel:x,onDraftGrid:C,onSaveDraftGrid:w,onDraftConfirmed:T,onDraftReject:E,onMove:D,onReorderReset:O,colorFor:A,projectId:j,liveOutput:M,activeAdapterId:N,onLabelsSaved:P,working:F}){let{t:I,tn:ee}=l(),te=(0,k.useRef)(null);Fe(te);let[L,ne]=(0,k.useState)(!1),[re,R]=(0,k.useState)(!1),[z,B]=(0,k.useState)(!1),V=new Set(e.map(e=>e.serverId).filter(e=>e!=null)),H=t.filter(e=>!V.has(e.serverId)),U=[...e].sort((e,t)=>(e.orderIdx??2**53-1)-(t.orderIdx??2**53-1));(0,k.useEffect)(()=>{r&&document.getElementById(`content-row-${r}`)?.scrollIntoView?.({block:`nearest`})},[r]);let ie=U.length+H.length,ae=F?.output??M??null,W=ie===0;return(0,$.jsxs)(h,{tab:I(`content.paneTab`),flush:!0,aux:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mono text-[11px] text-[color:var(--color-ink-3)]`,title:D?I(`layers.keys`):void 0,children:ee(`content.blocksCount`,ie)}),(0,$.jsxs)(S,{label:I(`work.contentOptions`),children:[O&&!W&&(0,$.jsx)(`button`,{type:`button`,"aria-label":I(`layers.renumber`),onClick:O,className:`menu-item`,title:I(`layers.renumberTitle`),children:I(`layers.renumber`)}),j!=null&&(0,$.jsx)(`button`,{type:`button`,"aria-label":I(`content.rules`),onClick:()=>ne(!0),className:`menu-item`,children:I(`content.rules`)}),j!=null&&(0,$.jsx)(`button`,{type:`button`,"aria-label":I(`labels.tab`),onClick:()=>R(!0),className:`menu-item`,children:I(`labels.tab`)}),j!=null&&(0,$.jsx)(`button`,{type:`button`,"aria-label":I(`tableHint.tab`),onClick:()=>B(!0),className:`menu-item`,children:I(`tableHint.tab`)})]})]}),children:[(F||ae?.text)&&(0,$.jsx)(Ge,{working:F,text:ae?.text??``,phase:ae?.phase}),W?(0,$.jsx)(`p`,{className:`p-3 text-[12px] text-[color:var(--color-ink-2)]`,children:I(`content.emptyPageBody`)}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`ul`,{ref:te,className:`cascade relative flex flex-col`,children:[U.map((e,t)=>{let c=e.label===`Table`,l=pt.has(e.label);return(0,$.jsx)(vt,{id:e.id,order:e.orderIdx??t,label:e.label,color:A?.(e.label),labels:n,onLabel:t=>o(e.id,t),badge:e.prefill&&!e.confirmed?{text:`OCR`,title:I(`layers.prefillTitle`,{source:e.prefill})}:void 0,collapsed:e.confirmed&&r!==e.id&&!c,preview:l?``:e.content.replace(/\s+/g,` `),confirmed:e.confirmed,onConfirmed:t=>s(e.id,t),onDelete:()=>u(e.id),deleteTitle:I(`inspector.deleteBlock`),selected:r===e.id,onSelect:()=>i(e.id),onMove:D?t=>D(e.id,t):void 0,canMoveUp:t>0,canMoveDown:t<U.length-1,rowAria:I(`layers.blockAria`,{n:t+1,label:e.label}),cropUrl:e.serverId?mt(e.serverId,g?.[e.serverId]??0):null,cropAlt:I(`content.cropAlt`,{label:e.label}),cropUnsavedHint:I(`content.cropUnsaved`),wide:c,children:c?(0,$.jsxs)($.Fragment,{children:[_&&_.serverId===e.serverId&&(0,$.jsx)(_t,{state:_.state,message:_.message,onRun:()=>y?.(_.serverId),onDismiss:()=>v?.()}),(0,$.jsx)(ht,{serverId:e.serverId,pageId:f??null,pageImageUrl:p??null,pageImageSize:m??null,onSaveTable:d,confirmed:e.confirmed,onConfirmed:t=>s(e.id,t)})]}):l?(0,$.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:I(`content.noContentBody`)}):(0,$.jsx)(`textarea`,{value:e.content,onChange:t=>a(e.id,t.target.value),onFocus:()=>i(e.id),rows:Math.min(10,Math.max(3,e.content.split(`
|
|
6
|
+
`).length+1)),placeholder:I(`inspector.transcriptionPlaceholder`),"aria-label":I(`content.blockAria`,{label:e.label}),className:`fld resize-y font-mono text-[12px] leading-relaxed`})},e.id)}),H.map(e=>{let t=e.label===`Table`,r=pt.has(e.label);return(0,$.jsx)(vt,{id:`draft-${e.serverId}`,order:null,label:e.label,labels:n,onLabel:x?t=>x(e.serverId,t):void 0,badge:{text:`OCR`,title:I(`content.prefillDraftBody`)},confirmed:e.confirmed,onConfirmed:t=>T(e.serverId,t),onDelete:()=>E(e.serverId),deleteTitle:I(`content.rejectDraft`),selected:!1,rowAria:I(`content.draftAria`,{label:e.label}),cropUrl:mt(e.serverId),cropAlt:I(`content.cropAlt`,{label:e.label}),cropUnsavedHint:I(`content.cropUnsaved`),wide:t,children:t?(0,$.jsx)(ht,{serverId:e.serverId,pageId:f??null,pageImageUrl:p??null,pageImageSize:m??null,onSaveTable:(e,t)=>(C(e,t),w(e,t)),confirmed:e.confirmed,onConfirmed:t=>T(e.serverId,t)}):r?(0,$.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:I(`content.noContentBody`)}):(0,$.jsx)(`textarea`,{value:e.content,onChange:t=>b(e.serverId,t.target.value),rows:Math.min(10,Math.max(3,e.content.split(`
|
|
7
|
+
`).length+1)),"aria-label":I(`content.draftAria`,{label:e.label}),className:`fld resize-y font-mono text-[12px] leading-relaxed`})},`draft-${e.serverId}`)})]})}),L&&j!=null&&(0,$.jsx)(c,{title:I(`conventions.tab`),onClose:()=>ne(!1),children:(0,$.jsx)(`div`,{className:`p-3`,children:(0,$.jsx)(qe,{projectId:j})})}),re&&j!=null&&(0,$.jsx)(c,{title:I(`labels.tab`),wide:!0,onClose:()=>R(!1),children:(0,$.jsx)(dt,{projectId:j,labels:n,activeAdapterId:N,onSaved:e=>P?.(e)})}),z&&j!=null&&(0,$.jsx)(c,{title:I(`tableHint.tab`),onClose:()=>B(!1),children:(0,$.jsx)(ft,{projectId:j})})]})}export{tt as a,we as c,Z as d,pe as f,ot as i,ve as l,gt as n,rt as o,P as p,lt as r,Ae as s,yt as t,Q as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,N as t,ct as ee,d as te,dt as n,g as r,ht as i,i as a,l as o,lt as s,n as c,r as ne,st as re,t as l,tt as u,w as ie}from"./ui-BtIxuKN2.js";import{O as ae,T as oe,i as se,r as ce}from"./index-DVWuV1Ff.js";import{a as d,f as le,o as ue}from"./vocab-C9TBNLaa.js";import{t as de}from"./dates-8UlpNJqU.js";import{n as fe}from"./PipelineView-B61UZ5RU.js";import{i as pe,n as me}from"./pipeline-CPPlVFee.js";var f=i(n(),1),p=s();function he(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} kB`:`${(e/1024/1024).toFixed(2)} MB`}function m(){let{t:n,locale:i}=ee(),s=oe(),[m,ge]=(0,f.useState)(``),[h,_e]=(0,f.useState)(.9),[g,ve]=(0,f.useState)(42),[_,ye]=(0,f.useState)(`page`),[v,be]=(0,f.useState)(!0),[y,xe]=(0,f.useState)(!1),[b,x]=(0,f.useState)(`monkeyocrv2-parsing`),S=(0,f.useRef)(!1),[C,w]=(0,f.useState)([]),[T,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(!1),[k,A]=(0,f.useState)(!1),[j,M]=(0,f.useState)(null),[N,Se]=(0,f.useState)(null),[P,F]=(0,f.useState)(!1),[I,Ce]=(0,f.useState)(null),[L,R]=(0,f.useState)({built:!1,report:null}),[z,B]=(0,f.useState)(null),[V,H]=(0,f.useState)(null),we=!!(s.model&&s.adapterId&&C.length>0&&!C.some(e=>e.adapter_id===s.adapterId));(0,f.useEffect)(()=>{e(`/system/model-adapters`).then(e=>w(e.items.filter(e=>e.export_ready!==!1))).catch(()=>w([]))},[]),(0,f.useEffect)(()=>{S.current||!s.adapterId||!C.length||C.some(e=>e.adapter_id===s.adapterId)&&x(s.adapterId)},[C,s.adapterId]);let U=async t=>{if(ge(t),se(t===``?null:t),R({built:!1,report:null}),q(),t!==``)try{R(await e(`/projects/${t}/datasets`))}catch(e){H(e)}},[W,G]=(0,f.useState)(!1),K=(0,f.useRef)(null),q=()=>{G(!1),K.current&&clearTimeout(K.current)};(0,f.useEffect)(()=>()=>q(),[]);let J=ce(e=>void U(e),H),Te=async()=>{if(m!==``){if(L.built&&!W){G(!0),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(!1),5e3);return}q(),E(!0),H(null);try{let e=await u(`/projects/${m}/datasets/build`,{split_ratio:h,seed:g,split_strategy:_,approved_only:v,pilot_only:y,adapter_id:b});R({built:!0,report:e})}catch(e){H(e)}finally{E(!1)}}},Ee=async()=>{if(m!==``){O(!0),H(null);try{Ce(await u(`/projects/${m}/datasets/build-paddle`,{split_ratio:h,seed:g,approved_only:v}))}catch(e){H(e)}finally{O(!1)}}},De=async()=>{if(m!==``){A(!0),H(null);try{M(await u(`/projects/${m}/datasets/paddle-training`,{}))}catch(e){H(e)}finally{A(!1)}}},Y=async e=>{if(m!==``){F(!0),H(null);try{Se(await u(`/projects/${m}/datasets/${e}-training`,{approved_only:v}))}catch(e){H(e)}finally{F(!1)}}},Oe=J.find(e=>e.id===m)??null,{workflow:X,training:ke}=pe(m===``?null:m,{dataset:!1,runs:!1});(0,f.useEffect)(()=>{if(B(null),m===``)return;let t=!0;return e(`/projects/${m}/pages`).then(e=>t&&B(e.items.filter(e=>e.status===`new`&&(e.drafts??0)>0).length)).catch(()=>{}),()=>{t=!1}},[m]);let Ae=X?.approved_pages??0,Z=(X?.counts.annotated??0)+(X?.counts.review??0)+(X?.counts.qa??0),je=X?.next_page?`/annotazione?project=${m}&page=${X.next_page.id}`:`/annotazione`,Me=me({project:Oe,workflow:X,dataset:L,training:ke}),Q=L.report,$=v&&(X?.approved_pages??0)===0;return(0,p.jsxs)(`div`,{className:`p-3`,children:[(0,p.jsx)(te,{title:n(`dataset.title`),intro:n(`dataset.intro`)}),V!=null&&(0,p.jsx)(`div`,{className:`mb-3`,children:(0,p.jsx)(ne,{error:V,onDismiss:()=>H(null)})}),m!==``&&(0,p.jsx)(fe,{stages:Me,here:`dataset`}),m!==``&&X&&(0,p.jsx)(`div`,{className:`mb-3`,children:(0,p.jsxs)(o,{tab:n(`dataset.material.title`),quiet:!0,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2 text-[12px]`,children:[(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{className:`mono text-[18px]`,children:Ae}),` `,n(`dataset.material.approved`)]}),(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{className:`mono text-[18px]`,children:Z}),` `,n(`dataset.material.annotated`)]}),z!=null&&(0,p.jsxs)(`span`,{children:[(0,p.jsx)(`b`,{className:`mono text-[18px]`,children:z}),` `,n(`dataset.material.drafts`)]}),(0,p.jsx)(ae,{to:je,className:`btn btn-sm ml-auto no-underline`,children:n(`dataset.material.openStudio`)})]}),(0,p.jsx)(`p`,{className:`mt-2 max-w-[80ch] text-[11px] text-[color:var(--color-ink-2)]`,children:n(v?`dataset.material.hintApproved`:`dataset.material.hintAll`)})]})}),(0,p.jsx)(`div`,{className:`mb-3`,children:(0,p.jsxs)(o,{tab:n(`dataset.build`),children:[(0,p.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,p.jsx)(a,{label:n(`dataset.project`),children:(0,p.jsxs)(`select`,{value:m,onChange:e=>void U(e.target.value===``?``:Number(e.target.value)),className:`fld`,children:[(0,p.jsx)(`option`,{value:``,children:n(`common.chooseProject`)}),J.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,p.jsx)(a,{label:n(`dataset.trainShare`,{pct:(h*100).toFixed(0)}),hint:n(`dataset.trainShareHint`,{pct:(100-h*100).toFixed(0)}),children:(0,p.jsx)(`input`,{type:`range`,min:.5,max:.95,step:.05,value:h,onChange:e=>_e(Number(e.target.value)),"aria-label":n(`dataset.trainShareLabel`),className:`mt-1.5 w-full`})}),(0,p.jsx)(a,{label:n(`dataset.splitUnit`),hint:n(`dataset.splitUnitHint`),children:(0,p.jsx)(`select`,{value:_,onChange:e=>ye(e.target.value),className:`fld`,children:[`page`,`issue`,`year`,`source`,`scanner`,`collection`,`page_type`].map(e=>(0,p.jsx)(`option`,{value:e,children:le(e)},e))})}),(0,p.jsxs)(`label`,{className:`flex items-center gap-2 self-end pb-2 text-[12px]`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>be(e.target.checked)}),n(`dataset.approvedOnly`)]})]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsx)(c,{tab:n(`dataset.advanced`),quiet:!0,aux:(0,p.jsx)(`span`,{children:n(`dataset.advancedCount`)}),children:(0,p.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,p.jsx)(a,{label:n(`dataset.seed`),hint:n(`dataset.seedHint`),children:(0,p.jsx)(`input`,{type:`number`,value:g,onChange:e=>ve(Number(e.target.value)),className:`fld fld-mono`})}),(0,p.jsx)(a,{label:n(`dataset.adapter`),hint:n(`dataset.adapterHint`),children:(0,p.jsx)(`select`,{value:b,onChange:e=>{S.current=!0,x(e.target.value)},className:`fld`,children:(C.length?C:[{adapter_id:`monkeyocrv2-parsing`,display_name:`MonkeyOCRv2 Parsing`,tasks:[],training_types:[]}]).map(e=>(0,p.jsx)(`option`,{value:e.adapter_id,children:e.display_name},e.adapter_id))})}),(0,p.jsxs)(`label`,{className:`flex items-center gap-2 self-end pb-2 text-[12px]`,children:[(0,p.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>xe(e.target.checked)}),n(`dataset.pilotOnly`)]})]})})}),we&&(0,p.jsx)(r,{title:n(`dataset.inferenceAdapterNotExportableTitle`),children:n(`dataset.inferenceAdapterNotExportableBody`,{model:s.model})}),(0,p.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,p.jsxs)(`button`,{onClick:()=>void Te(),disabled:T||m===``||$,title:$?n(`dataset.buildEmptyTitle`):void 0,className:`btn btn-primary`,children:[(0,p.jsx)(t,{size:13}),n(T?`dataset.building`:W?`dataset.confirmOverwrite`:`dataset.buildBtn`)]}),W&&(0,p.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-sig-text)]`,children:n(`dataset.overwriteNote`)}),$&&!T&&(0,p.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-2)]`,children:n(`dataset.buildEmptyHint`)})]}),(0,p.jsx)(`div`,{className:`mt-3`,children:(0,p.jsxs)(c,{tab:n(`dataset.alternatives`),quiet:!0,aux:n(`dataset.optional`),children:[(0,p.jsx)(`p`,{className:`mb-2 max-w-[75ch] text-[12px] text-[color:var(--color-ink-2)]`,children:n(`dataset.alternativesHint`)}),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`button`,{onClick:()=>void Ee(),disabled:D||m===``,className:`btn`,children:n(D?`dataset.paddleBuilding`:`dataset.paddleBuild`)}),(0,p.jsx)(`button`,{onClick:()=>void De(),disabled:k||m===``||!I,className:`btn`,children:n(k?`dataset.paddleTraining`:`dataset.paddlePrepareTraining`)}),(0,p.jsx)(`button`,{onClick:()=>void Y(`glm`),disabled:P||m===``,className:`btn`,children:n(`dataset.glmPrepareTraining`)}),(0,p.jsx)(`button`,{onClick:()=>void Y(`deepseek`),disabled:P||m===``,className:`btn`,children:n(`dataset.deepseekPrepareTraining`)}),(0,p.jsx)(`button`,{onClick:()=>void Y(`dots-ocr`),disabled:P||m===``,className:`btn`,children:n(`dataset.dotsPrepareTraining`)}),(0,p.jsx)(`button`,{onClick:()=>void Y(`unlimited-ocr`),disabled:P||m===``,className:`btn`,children:n(`dataset.unlimitedPrepareTraining`)}),(0,p.jsx)(`button`,{onClick:()=>void Y(`mineru2.5`),disabled:P||m===``,className:`btn`,children:n(`dataset.mineruPrepareTraining`)})]}),I&&(0,p.jsx)(`p`,{className:`mt-2 mono text-[11px] text-[color:var(--color-ok)]`,children:n(`dataset.paddleReady`,{train:I.counts?.vlm?.train??0,val:I.counts?.vlm?.val??0})}),j&&(0,p.jsxs)(`div`,{className:`mt-2 border-l-2 border-[color:var(--color-rule-strong)] pl-2 text-[11px]`,children:[(0,p.jsx)(`p`,{className:`mono text-[color:var(--color-ok)]`,children:n(`dataset.paddleRecipeReady`)}),!j.preflight?.ready&&(0,p.jsx)(`p`,{className:`mt-1 text-[color:var(--color-sig-text)]`,children:(j.preflight?.errors??[]).join(` · `)}),j.files&&(0,p.jsx)(`p`,{className:`mt-1 mono text-[color:var(--color-ink-2)]`,children:Object.values(j.files).join(` · `)})]}),N&&(0,p.jsxs)(`p`,{className:`mt-2 mono text-[11px] text-[color:var(--color-ok)]`,children:[N.adapter_id,`: `,N.status??n(`dataset.recipeReady`)]})]})})]})}),Q?(0,p.jsxs)(`div`,{className:`space-y-3`,children:[(0,p.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,p.jsxs)(o,{tab:n(`dataset.pagesWithBlocks`),quiet:!0,children:[(0,p.jsx)(`div`,{className:`mono text-[26px] font-semibold leading-none`,children:Q.pages.with_blocks}),(0,p.jsx)(`p`,{className:`mt-1 text-[12px] text-[color:var(--color-ink-2)]`,children:n(`dataset.trainVal`,{train:Q.pages.train,val:Q.pages.val})})]}),(0,p.jsxs)(o,{tab:n(`dataset.cropsGenerated`),quiet:!0,children:[(0,p.jsx)(`div`,{className:`mono text-[26px] font-semibold leading-none`,children:Q.crops_generated}),(0,p.jsx)(`p`,{className:`mt-1 text-[12px] text-[color:var(--color-ink-2)]`,children:n(`dataset.splitSeed`,{pct:(Q.split.ratio*100).toFixed(0),seed:Q.split.seed})})]}),(0,p.jsxs)(o,{tab:n(`dataset.lastBuild`),quiet:!0,aux:Q.pages.with_blocks===0?(0,p.jsx)(l,{tone:`warn`,children:n(`dataset.emptyBuild`)}):void 0,children:[(0,p.jsx)(`div`,{className:`mono text-[17px] font-semibold leading-tight`,children:de(Q.built_at,i)}),(0,p.jsx)(`p`,{className:`mt-1 text-[12px] text-[color:var(--color-ink-2)]`,children:Q.pages.with_blocks===0?n(`dataset.emptyBuildHint`):n(`dataset.localTime`)})]})]}),(0,p.jsx)(o,{tab:n(`dataset.perFamily`),quiet:!0,flush:!0,children:(0,p.jsxs)(`table`,{className:`w-full border-collapse text-[12px]`,children:[(0,p.jsx)(`thead`,{className:`border-b border-[color:var(--color-rule)] bg-[color:var(--color-fill)]`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{className:`px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,children:n(`dataset.family`)}),(0,p.jsx)(`th`,{className:`px-2 py-1 text-right text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,children:n(`dataset.train`)}),(0,p.jsx)(`th`,{className:`px-2 py-1 text-right text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,children:n(`dataset.validation`)}),(0,p.jsx)(`th`,{className:`px-2 py-1 text-right text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,children:n(`dataset.total`)})]})}),(0,p.jsx)(`tbody`,{className:`ruled`,children:Object.entries(Q.counts).map(([e,t])=>(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`td`,{className:`px-2 py-1`,children:d(e)}),(0,p.jsx)(`td`,{className:`mono px-2 py-1 text-right`,children:t.train}),(0,p.jsx)(`td`,{className:`mono px-2 py-1 text-right`,children:t.val}),(0,p.jsx)(`td`,{className:`mono px-2 py-1 text-right font-semibold`,children:t.train+t.val})]},e))})]})}),Q.warnings.length>0&&(0,p.jsxs)(r,{title:re(`common.warningsCount`,Q.warnings.length),children:[(0,p.jsx)(`ul`,{className:`list-inside list-disc space-y-0.5`,children:Q.warnings.map((e,t)=>(0,p.jsx)(`li`,{children:e},t))}),(0,p.jsxs)(`p`,{className:`mt-1.5`,children:[(0,p.jsx)(`b`,{className:`font-semibold`,children:n(`errors.whatToDo`)}),n(`dataset.warningsBody`)]})]}),(0,p.jsx)(o,{tab:n(`dataset.generatedFiles`),quiet:!0,aux:(0,p.jsx)(`span`,{className:`mono truncate`,children:Q.dataset_dir}),flush:!0,children:(0,p.jsx)(`ul`,{className:`ruled`,children:Q.files.map(e=>(0,p.jsxs)(`li`,{className:`flex gap-3 px-2 py-1 text-[12px]`,children:[(0,p.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate`,title:e.path,children:e.path.split(`/`).pop()}),(0,p.jsx)(`span`,{className:`mono shrink-0 text-[color:var(--color-ink-2)]`,children:ue(e.lines)}),(0,p.jsx)(`span`,{className:`mono w-20 shrink-0 text-right text-[color:var(--color-ink-2)]`,children:he(e.size)})]},e.path))})}),Object.entries(Q.sample_lines).filter(([,e])=>e.length>0).map(([e,t])=>(0,p.jsxs)(c,{tab:n(`dataset.preview`,{family:d(e)}),quiet:!0,children:[(0,p.jsx)(`p`,{className:`mb-2 max-w-[80ch] text-[12px] text-[color:var(--color-ink-2)]`,children:n(`dataset.previewIntro`)}),t.map((e,t)=>(0,p.jsx)(`pre`,{className:`mono mb-2 overflow-x-auto border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[11px] leading-relaxed`,children:e.length>700?e.slice(0,700)+`…`:e},t))]},e))]}):(0,p.jsx)(o,{tab:n(`dataset.noExport`),quiet:!0,children:(0,p.jsxs)(`div`,{className:`flex flex-col items-start gap-2 py-4`,children:[(0,p.jsx)(ie,{size:22}),(0,p.jsx)(`p`,{className:`text-[13px] font-semibold`,children:n(m===``?`dataset.noExportSelect`:`dataset.noExportBuilt`)}),(0,p.jsx)(`p`,{className:`max-w-[70ch] text-[12px] text-[color:var(--color-ink-2)]`,children:n(`dataset.noExportBody`)})]})})]})}export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,M as t,a as n,ct as r,d as i,dt as a,g as o,ht as s,i as c,l,lt as u,r as d,st as f,tt as ee,u as p}from"./ui-BtIxuKN2.js";import{O as m,T as h,a as g,c as _,i as v,r as y}from"./index-DVWuV1Ff.js";import{l as b}from"./vocab-C9TBNLaa.js";import{n as x}from"./PipelineView-B61UZ5RU.js";import{i as S,n as C}from"./pipeline-CPPlVFee.js";var w=s(a(),1),T=u(),E=e=>e==null?`—`:`${(e*100).toFixed(1)}%`,D=(e,t=3)=>e==null?`—`:e.toFixed(t);function O({tab:e,value:t,sub:n,meaning:r}){return(0,T.jsxs)(l,{tab:e,quiet:!0,children:[(0,T.jsx)(`div`,{className:`mono text-[24px] font-semibold leading-none`,children:t}),n&&(0,T.jsx)(`p`,{className:`mono mt-1 text-[11px] text-[color:var(--color-ink-3)]`,children:n}),r&&(0,T.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-[color:var(--color-ink-2)]`,children:r})]})}function k(){let{t:n}=r(),[a,s]=(0,w.useState)(``),u=h(),k=_(),[j,M]=(0,w.useState)(!0),[N,P]=(0,w.useState)(!1),[F,I]=(0,w.useState)(null),[L,R]=(0,w.useState)(null),[z,B]=(0,w.useState)(null),V=e=>{s(e),v(e===``?null:e),I(null),R(null)},H=y(V,B),U=async()=>{if(a!==``){P(!0),B(null),I(null);try{let e=await ee(`/projects/${a}/evaluate`,{server_url:u.url.trim()||null,model:u.model.trim()||null,with_text:j,limit:50});I(e),R(e.pages[0]??null)}catch(e){B(e)}finally{P(!1)}}},W=H.find(e=>e.id===a)??null,{workflow:G,dataset:K,training:q}=S(a===``?null:a,{runs:!1}),J=C({project:W,workflow:G,dataset:K,training:q}),Y=q?.run?.state===`finished`,X=u.enabled&&u.available,Z=G?.approved_pages??0,Q=Z>0,$=F?.aggregates;return(0,T.jsxs)(`div`,{className:`p-3`,children:[(0,T.jsx)(i,{title:n(`evaluate.title`),intro:n(`evaluate.intro`)}),z!=null&&(0,T.jsx)(`div`,{className:`mb-3`,children:(0,T.jsx)(d,{error:z,onDismiss:()=>B(null)})}),a!==``&&Q&&(0,T.jsx)(x,{stages:J,here:`evaluate`}),!u.enabled&&(0,T.jsxs)(`div`,{className:`mb-3 flex items-center justify-between border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-3 py-2 text-[12px] text-[color:var(--color-ink-2)]`,children:[(0,T.jsx)(`span`,{children:n(`cloud.card.inferenceDisabledNotice`)}),(0,T.jsx)(m,{to:`/modelli`,className:`btn btn-sm`,children:u.model?n(`recognition.changeModel`):n(`recognition.chooseModel`)})]}),(0,T.jsx)(`div`,{className:`mb-3`,children:(0,T.jsxs)(l,{tab:n(`evaluate.run`),children:[(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,T.jsx)(c,{label:n(`evaluate.project`),children:(0,T.jsxs)(`select`,{value:a,onChange:e=>V(e.target.value===``?``:Number(e.target.value)),className:`fld`,children:[(0,T.jsx)(`option`,{value:``,children:n(`common.chooseProject`)}),H.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,T.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,T.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-[12px]`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>M(e.target.checked)}),n(`evaluate.withText`)]})})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-[color:var(--color-rule)] pt-2 text-[12px]`,children:[(0,T.jsx)(`span`,{className:`lbl !mb-0`,children:n(`recognition.computeProfile`)}),(0,T.jsx)(`strong`,{title:u.model||void 0,children:k(u.adapterId)??(u.model||`—`)}),(0,T.jsxs)(`span`,{className:`text-[color:var(--color-ink-2)]`,children:[`· `,u.provider?n(`recognition.provider.${u.provider}`):n(`recognition.locationLocal`)]}),(0,T.jsx)(m,{to:`/modelli`,className:`font-semibold no-underline`,children:u.model?n(`recognition.changeModel`):n(`recognition.chooseModel`)})]}),a!==``&&G&&!Q&&(0,T.jsxs)(p,{tone:`warn`,children:[(0,T.jsx)(`span`,{children:n(`evaluate.needsGold`)}),` `,(0,T.jsx)(m,{to:G.next_page?`/annotazione?project=${a}&page=${G.next_page.id}`:`/annotazione`,className:`font-semibold underline underline-offset-2`,children:n(`dataset.material.openStudio`)})]}),a!==``&&Q&&!Y&&(0,T.jsx)(p,{children:n(`evaluate.baselineNote`,{n:Z})}),u.enabled&&!X&&(0,T.jsxs)(p,{tone:`warn`,children:[(0,T.jsx)(`span`,{children:n(`recognition.unreachableModel`,{model:k(u.adapterId)??u.model,url:u.url})}),` `,(0,T.jsx)(m,{to:`/modelli`,className:`font-semibold underline underline-offset-2`,children:n(`recognition.changeModel`)})]}),(0,T.jsxs)(`button`,{onClick:()=>void U(),disabled:N||a===``||!Q||!X,className:`btn btn-primary mt-3`,children:[(0,T.jsx)(t,{size:13}),n(N?`evaluate.running`:`evaluate.runBtn`)]}),N&&(0,T.jsx)(`p`,{className:`mt-2 max-w-[80ch] text-[12px] text-[color:var(--color-ink-2)]`,children:n(`evaluate.runningNote`)})]})}),F&&$&&(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-5`,children:[(0,T.jsx)(O,{tab:n(`evaluate.pagesEvaluated`),value:String(F.pages_evaluated),sub:n(F.scope===`all_approved`?`evaluate.ofApproved`:`evaluate.ofVal`,{n:F.val_pages})}),(0,T.jsx)(O,{tab:n(`evaluate.precision`),value:E($.layout.precision),sub:n(`evaluate.precisionSub`,{matched:$.layout.matched,total:$.layout.n_pred}),meaning:n(`evaluate.precisionMeaning`)}),(0,T.jsx)(O,{tab:n(`evaluate.recall`),value:E($.layout.recall),sub:n(`evaluate.recallSub`,{n:$.layout.n_gt}),meaning:n(`evaluate.recallMeaning`)}),(0,T.jsx)(O,{tab:n(`evaluate.order`),value:D($.order.mean_levenshtein_norm),sub:n(`evaluate.orderSub`,{pct:E(($.order.exact_pct??0)/100)}),meaning:n(`evaluate.orderMeaning`)}),(0,T.jsx)(O,{tab:n(`evaluate.textCer`),value:D($.text.mean_cer),sub:n(`evaluate.textCerSub`,{n:$.text.n,wer:D($.text.mean_wer)}),meaning:n(`evaluate.textCerMeaning`)})]}),(0,T.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[$.layout_strict?.f1!=null&&(0,T.jsx)(O,{tab:n(`evaluate.strictF1`),value:E($.layout_strict.f1),sub:n(`evaluate.strictF1Sub`,{matched:$.layout_strict.matched,gt:$.layout_strict.n_gt,pred:$.layout_strict.n_pred}),meaning:n(`evaluate.strictF1Meaning`)}),(0,T.jsx)(O,{tab:n(`evaluate.iou`),value:D($.layout.mean_iou_of_matched),meaning:n(`evaluate.iouMeaning`)}),(0,T.jsx)(O,{tab:n(`evaluate.tablesStruct`),value:$.tables?.structure_ok_pct==null?`—`:E($.tables.structure_ok_pct/100),sub:`n=${$.tables?.n??0}`,meaning:n(`evaluate.tablesStructMeaning`)}),(0,T.jsx)(O,{tab:n(`evaluate.tablesText`),value:D($.tables?.mean_cell_cer),meaning:n(`evaluate.tablesTextMeaning`)})]}),$.layout_strict?.per_label&&Object.keys($.layout_strict.per_label).length>0&&(0,T.jsxs)(l,{tab:n(`evaluate.perLabel`),quiet:!0,flush:!0,children:[(0,T.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{className:`text-left text-[color:var(--color-ink-3)]`,children:[(0,T.jsx)(`th`,{className:`px-2 py-1 font-normal`,children:n(`evaluate.perLabelLabel`)}),(0,T.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:`F1`}),(0,T.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:n(`evaluate.perLabelFound`)}),(0,T.jsx)(`th`,{className:`px-2 py-1 text-right font-normal`,children:n(`evaluate.perLabelInvented`)})]})}),(0,T.jsx)(`tbody`,{className:`mono`,children:Object.entries($.layout_strict.per_label).sort(([,e],[,t])=>t.n_gt-e.n_gt).map(([e,t])=>(0,T.jsxs)(`tr`,{className:`border-t border-[color:var(--color-rule)]`,children:[(0,T.jsx)(`td`,{className:`px-2 py-1`,children:e}),(0,T.jsx)(`td`,{className:`px-2 py-1 text-right`,children:E(t.f1)}),(0,T.jsxs)(`td`,{className:`px-2 py-1 text-right`,children:[t.matched,`/`,t.n_gt]}),(0,T.jsx)(`td`,{className:`px-2 py-1 text-right`,children:t.n_pred-t.matched})]},e))})]}),(0,T.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-[color:var(--color-ink-2)]`,children:n(`evaluate.perLabelMeaning`)})]}),F.warnings.length>0&&(0,T.jsx)(o,{title:f(`common.warningsCount`,F.warnings.length),children:(0,T.jsx)(`ul`,{className:`list-inside list-disc space-y-0.5`,children:F.warnings.map((e,t)=>(0,T.jsx)(`li`,{children:e},t))})}),(0,T.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,T.jsx)(l,{tab:n(`evaluate.valPages`),quiet:!0,flush:!0,aux:(0,T.jsx)(`span`,{children:b(F.pages.length)}),children:(0,T.jsx)(`ul`,{className:`ruled max-h-[28rem] overflow-y-auto`,children:F.pages.map(e=>(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{onClick:()=>R(e),"aria-pressed":L?.page_id===e.page_id,className:`flex w-full items-center gap-2 px-2 py-1 text-left text-[12px] ${L?.page_id===e.page_id?`bg-[color:var(--color-sig-wash)] font-semibold`:`hover:bg-[color:var(--color-fill)]`}`,children:[(0,T.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate`,children:g(e)}),e.error?(0,T.jsx)(`span`,{className:`shrink-0 text-[color:var(--color-sig-text)]`,children:n(`evaluate.error`)}):(0,T.jsxs)(`span`,{className:`mono shrink-0 text-[color:var(--color-ink-2)]`,children:[e.layout.matched,`/`,e.layout.n_gt,` `,n(`evaluate.ordShort`,{n:e.order.levenshtein_norm.toFixed(2)})]})]})},e.page_id))})}),L&&(L.gt_items?.length||L.pred_items?.length)?(0,T.jsx)(l,{tab:n(`evaluate.overlay`),quiet:!0,aux:(0,T.jsx)(`span`,{className:`mono truncate`,children:g(L)}),children:(0,T.jsx)(A,{pageId:L.page_id,gt:L.gt_items??[],pred:L.pred_items??[]})}):(0,T.jsx)(l,{tab:n(`evaluate.overlay`),quiet:!0,children:(0,T.jsxs)(`div`,{className:`flex flex-col items-start gap-2 py-4`,children:[(0,T.jsx)(e,{size:22}),(0,T.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:n(`evaluate.overlayEmpty`)})]})})]}),L&&L.text&&L.text.length>0&&(0,T.jsx)(l,{tab:n(`evaluate.textRec`),quiet:!0,aux:(0,T.jsx)(`span`,{children:f(`evaluate.firstLines`,Math.min(10,L.text.length))}),flush:!0,children:(0,T.jsx)(`ul`,{className:`ruled`,children:L.text.slice(0,10).map((e,t)=>(0,T.jsxs)(`li`,{className:`grid gap-1 px-2 py-1.5 text-[12px] sm:grid-cols-[8rem_1fr_1fr]`,children:[(0,T.jsx)(`span`,{className:`lbl !mb-0`,children:e.label}),(0,T.jsxs)(`span`,{className:`mono`,children:[(0,T.jsx)(`span`,{className:`text-[color:var(--color-ink-3)]`,children:n(`evaluate.yours`)}),e.gt.slice(0,90)]}),(0,T.jsxs)(`span`,{className:`mono`,children:[(0,T.jsx)(`span`,{className:`text-[color:var(--color-ink-3)]`,children:n(`evaluate.predicted`)}),e.hyp.slice(0,90)]})]},t))})}),L&&L.actions&&L.actions.length>0&&(0,T.jsx)(o,{title:n(`evaluate.suggestedActions`),children:(0,T.jsx)(`ul`,{className:`list-inside list-disc space-y-0.5`,children:L.actions.map(e=>(0,T.jsx)(`li`,{children:e},e))})})]})]})}function A({pageId:e,gt:t,pred:i}){let{t:a}=r(),[o,s]=(0,w.useState)(null);if((0,w.useEffect)(()=>{s(null);let t=new Image;t.onload=()=>s({w:t.naturalWidth,h:t.naturalHeight}),t.src=`/api/pages/${e}/preview`},[e]),!o)return(0,T.jsx)(`div`,{className:`py-4`,children:(0,T.jsx)(n,{label:a(`evaluate.overlayLoading`)})});let c=e=>e/1e3*o.w,l=e=>e/1e3*o.h;return(0,T.jsxs)(`figure`,{className:`m-0`,children:[(0,T.jsxs)(`div`,{className:`lighttable relative overflow-hidden border border-[color:var(--color-rule)]`,children:[(0,T.jsx)(`img`,{src:`/api/pages/${e}/preview`,alt:a(`evaluate.overlayAlt`),className:`block w-full`}),(0,T.jsxs)(`svg`,{viewBox:`0 0 ${o.w} ${o.h}`,className:`absolute inset-0 h-full w-full`,"aria-hidden":`true`,children:[i.map((e,t)=>(0,T.jsx)(`rect`,{x:c(e.bbox[0]),y:l(e.bbox[1]),width:c(e.bbox[2]-e.bbox[0]),height:l(e.bbox[3]-e.bbox[1]),fill:`rgb(230 0 18 / 0.10)`,stroke:`#a3000e`,strokeWidth:1.4},`p${t}`)),t.map((e,t)=>(0,T.jsx)(`rect`,{x:c(e.bbox[0]),y:l(e.bbox[1]),width:c(e.bbox[2]-e.bbox[0]),height:l(e.bbox[3]-e.bbox[1]),fill:`none`,stroke:`#111111`,strokeWidth:1.2,strokeDasharray:`5 3`},`g${t}`))]})]}),(0,T.jsxs)(`figcaption`,{className:`mt-1.5 flex flex-wrap gap-4 text-[11px] text-[color:var(--color-ink-2)]`,children:[(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,T.jsx)(`span`,{className:`inline-block h-2.5 w-4 border border-[color:var(--color-sig)] bg-[rgb(230_0_18/0.10)]`}),a(`evaluate.predLegend`)]}),(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,T.jsx)(`span`,{className:`inline-block h-2.5 w-4 border border-dashed border-[color:var(--color-ink)]`}),a(`evaluate.gtLegend`)]})]})]})}export{k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,a as t,ct as n,d as r,dt as i,ht as a,i as o,l as s,lt as c,r as l,st as u,t as d}from"./ui-BtIxuKN2.js";import{O as f,i as p,r as m}from"./index-DVWuV1Ff.js";import{d as h}from"./vocab-C9TBNLaa.js";import{r as g}from"./pipeline-CPPlVFee.js";var _=a(i(),1),v=c();function y(){let{t:i}=n(),[a,c]=(0,_.useState)(``),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(0),T=e=>{c(e),p(e===``?null:e),b(null),S(null)},E=m(T,S);(0,_.useEffect)(()=>{if(a===``)return;let t=!0;return b(null),S(null),Promise.all([e(`/projects/${a}/workflow`),e(`/projects/${a}/datasets`),e(`/projects/${a}/training/status`)]).then(([e,n,r])=>{t&&b({workflow:e,dataset:n,training:r})}).catch(e=>{t&&S(e)}),()=>{t=!1}},[a,C]);let D=(y?.workflow.total_pages??0)>0,O=y?.workflow.approved_pages??0,k=y?g(y.dataset):!1,A=y?.training.active===!0,j=E.find(e=>e.id===a)?.access?.can_edit===!1,M=y?.training.run?.state===`finished`,N=y?.workflow.next_page?`/annotazione?project=${a}&page=${y.workflow.next_page.id}`:`/annotazione`,P=j?{to:N,title:`team.readerTitle`,body:`team.readerNotice`,action:`team.openReader`}:A?{to:`/training`,title:`ux.nextRunning`,body:`ux.nextRunningBody`,action:`ux.monitorTraining`}:D?!k&&O===0?{to:N,title:`ux.nextReview`,body:`ux.nextReviewBody`,action:`dataset.material.openStudio`}:k?M?{to:`/valutazione`,title:`ux.nextEvaluate`,body:`ux.nextEvaluateBody`,action:`pipeline.steps.evaluateAction`}:{to:`/training`,title:`ux.nextTrain`,body:`ux.nextTrainBody`,action:`ux.configureTraining`}:{to:`/dataset`,title:`ux.nextDataset`,body:`ux.nextDatasetBody`,action:`pipeline.steps.datasetAction`}:{to:`/progetti/${a}`,title:`ux.nextImport`,body:`ux.nextImportBody`,action:`workflow.addPages`};return(0,v.jsxs)(`div`,{className:`p-3`,children:[(0,v.jsx)(r,{title:i(`nav.training`),intro:`${i(`ux.refineIntro`)} ${i(`ux.baselineHint`)}`,aux:(0,v.jsx)(`div`,{className:`w-[min(24rem,100%)]`,children:(0,v.jsx)(o,{label:i(`training.project`),children:(0,v.jsxs)(`select`,{className:`fld`,value:a,onChange:e=>T(e.target.value?Number(e.target.value):``),children:[(0,v.jsx)(`option`,{value:``,children:i(`common.chooseProject`)}),E.map(e=>(0,v.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})})}),x!=null&&(0,v.jsxs)(`div`,{className:`mb-3`,children:[(0,v.jsx)(l,{error:x}),a!==``&&(0,v.jsx)(`button`,{className:`btn mt-2`,onClick:()=>w(e=>e+1),children:i(`ux.retryStatus`)})]}),a===``&&(0,v.jsxs)(s,{tab:i(`ux.nextStep`),quiet:!0,children:[(0,v.jsx)(`p`,{className:`mb-3 text-[13px]`,children:i(`ux.pickRefineProject`)}),(0,v.jsx)(f,{className:`btn no-underline`,to:`/progetti`,children:i(`nav.projects`)})]}),a!==``&&!y&&x==null&&(0,v.jsx)(t,{label:i(`ux.loadingStatus`)}),y&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`section`,{"aria-label":i(`ux.nextStep`),className:`mb-3 flex flex-wrap items-center gap-3 border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-3`,children:[(0,v.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64`,children:[(0,v.jsx)(`h2`,{className:`text-[18px] font-bold`,children:i(P.title)}),(0,v.jsx)(`p`,{className:`mt-1 max-w-[85ch] text-[13px] text-[color:var(--color-ink-2)]`,children:i(P.body)})]}),(0,v.jsx)(f,{to:P.to,className:`btn btn-primary no-underline`,children:i(P.action)})]}),(0,v.jsx)(`section`,{"aria-label":i(`ux.refineTools`),className:`border-y border-[color:var(--color-rule)]`,children:(0,v.jsx)(`ol`,{className:`ruled`,children:[{to:`/dataset`,title:`workflow.dataset`,status:k?i(`ux.dataReady`):u(`ux.goldCount`,O)},{to:`/training`,title:`workflow.train`,status:y.training.run?h(y.training.run.state):i(`ux.noTraining`)},{to:`/valutazione`,title:`workflow.evaluate`,status:O>0?u(`ux.goldCount`,O):i(`ux.needsGold`)}].map(e=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(f,{to:e.to,className:`flex flex-wrap items-center gap-x-5 gap-y-2 px-3 py-3 no-underline hover:bg-[color:var(--color-fill)]`,children:[(0,v.jsx)(`div`,{className:`min-w-0 flex-1 basis-64`,children:(0,v.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:i(e.title)})}),(0,v.jsx)(d,{tone:`neutral`,children:e.status}),(0,v.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})},e.to))})})]})]})}export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,b as t,ct as n,dt as r,ht as i,l as a,lt as o,r as s,t as c}from"./ui-BtIxuKN2.js";import{O as l,a as u,i as d,n as f,o as p}from"./index-DVWuV1Ff.js";import{n as m,p as h,r as g}from"./vocab-C9TBNLaa.js";import{t as _}from"./PipelineView-B61UZ5RU.js";import{i as v,t as y}from"./pipeline-CPPlVFee.js";var b=i(r(),1),x=o(),S=`__drafts`;function C({page:e}){let{t}=n();return(0,x.jsx)(`li`,{className:`relative border-b border-r border-[color:var(--color-rule)] bg-[color:var(--color-sheet)]`,children:(0,x.jsxs)(l,{to:`/annotazione?project=${e.project_id}&page=${e.id}`,className:`block text-[color:var(--color-ink)] no-underline hover:bg-[color:var(--color-fill)]`,children:[(0,x.jsx)(`div`,{className:`lighttable aspect-[3/4] overflow-hidden`,children:(0,x.jsx)(`img`,{"data-fade":!0,src:`/api/pages/${e.id}/thumbnail`,alt:t(`home.thumbnailAlt`,{path:e.rel_path}),loading:`lazy`,className:`h-full w-full bg-white object-cover object-top`})}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-[color:var(--color-rule)] px-1.5 py-1`,children:[(0,x.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-[11px] text-[color:var(--color-ink-2)]`,title:u(e),children:p(e)}),e.status===`new`&&(e.drafts??0)>0?(0,x.jsx)(c,{tone:`warn`,children:t(`home.draftsBadge`,{n:e.drafts??0})}):(0,x.jsx)(c,{tone:g[e.status]??`neutral`,children:h(e.status)})]})]})})}function w(){let{t:r}=n(),[i,o]=(0,b.useState)([]),[c,u]=(0,b.useState)(null),[p,g]=(0,b.useState)([]),[w,T]=(0,b.useState)(null),[E,D]=(0,b.useState)(!0),[O,k]=(0,b.useState)(``);(0,b.useEffect)(()=>{let t=!0;return e(`/projects`).then(e=>{t&&(o(e.items),u(f(e.items)))}).catch(e=>t&&T(e)).finally(()=>t&&D(!1)),()=>{t=!1}},[]),(0,b.useEffect)(()=>{if(c==null)return;d(c);let t=!0;return g([]),e(`/projects/${c}/pages`).then(e=>t&&g(e.items)).catch(e=>t&&T(e)),()=>{t=!1}},[c]);let A=i.find(e=>e.id===c)??null,{workflow:j,dataset:M,training:N,runs:P}=v(c),F=y({project:A,workflow:j,dataset:M,training:N,runs:P,draftPages:p.filter(e=>(e.drafts??0)>0).length}),I=(0,b.useMemo)(()=>[...p].sort((e,t)=>(m[e.status]??9)-(m[t.status]??9)||e.rel_path.localeCompare(t.rel_path)),[p]),L=p.filter(e=>(e.drafts??0)>0).length,R=O===S?I.filter(e=>(e.drafts??0)>0):O?I.filter(e=>e.status===O):I,z=p.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{}),B=p.filter(e=>e.status!==`new`).length,V=p.length?B/p.length:0,H=Object.keys(z).sort((e,t)=>(m[e]??9)-(m[t]??9));return(0,x.jsxs)(`div`,{className:`p-3`,children:[w!=null&&(0,x.jsx)(`div`,{className:`mb-3`,children:(0,x.jsx)(s,{error:w,onDismiss:()=>T(null)})}),(0,x.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-end gap-x-4 gap-y-2 border-b border-[color:var(--color-rule-strong)] pb-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`span`,{className:`lbl !mb-0.5`,children:r(`home.activeArchive`)}),i.length>1?(0,x.jsx)(`select`,{value:c??``,onChange:e=>u(Number(e.target.value)),"aria-label":r(`home.activeArchive`),className:`block max-w-full border-0 bg-transparent p-0 text-[34px] font-bold leading-[1.05] tracking-[-0.035em] focus:outline-none focus-visible:outline-2 focus-visible:outline-[color:var(--color-sig)]`,children:i.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))}):(0,x.jsx)(`h1`,{className:`truncate text-[34px] font-bold leading-[1.05] tracking-[-0.035em]`,children:A?.name??r(E?`home.loadingHeader`:`home.noArchive`)}),A?.archive_dir&&(0,x.jsx)(`p`,{className:`mono mt-1 truncate text-[11px] text-[color:var(--color-ink-3)]`,children:A.archive_dir})]}),p.length>0&&(0,x.jsxs)(`div`,{className:`ml-auto flex items-end gap-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`lbl !mb-0`,children:r(`home.pages`)}),(0,x.jsx)(`span`,{className:`mono text-[22px] font-semibold leading-none`,children:p.length})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`lbl !mb-0`,children:r(`home.worked`)}),(0,x.jsxs)(`span`,{className:`mono text-[22px] font-semibold leading-none`,children:[B,(0,x.jsxs)(`span`,{className:`text-[13px] font-normal text-[color:var(--color-ink-3)]`,children:[` `,`/ `,p.length]})]})]}),(0,x.jsxs)(`div`,{className:`w-40`,children:[(0,x.jsx)(`span`,{className:`lbl !mb-0.5`,children:r(`home.progress`,{pct:(V*100).toFixed(0)})}),(0,x.jsx)(`div`,{className:`h-2 border border-[color:var(--color-rule-strong)] bg-[color:var(--color-sheet)]`,role:`progressbar`,"aria-valuenow":Math.round(V*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":r(`home.progressLabel`),children:(0,x.jsx)(`div`,{className:`h-full bg-[color:var(--color-sig)]`,style:{width:`${V*100}%`}})})]})]})]}),(0,x.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,x.jsx)(l,{to:`/`,className:`btn btn-primary no-underline`,children:r(`home.recognizePages`)}),(0,x.jsx)(l,{to:c==null?`/progetti`:`/progetti/${c}`,className:`btn no-underline`,children:r(`home.manageArchive`)}),(0,x.jsx)(l,{to:`/progetti?nuovo=1`,className:`btn no-underline`,children:r(`projects.new`)})]}),c!=null&&(0,x.jsx)(`div`,{className:`mb-3`,children:(0,x.jsx)(_,{branches:F})}),(0,x.jsx)(a,{tab:r(`home.wall`),quiet:!0,flush:!0,aux:H.length>0&&(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>k(``),"aria-pressed":O===``,className:`btn btn-sm ${O===``?`!border-[color:var(--color-ink)] !bg-[color:var(--color-ink)] !text-white`:``}`,children:r(`home.all`,{n:p.length})}),L>0&&(0,x.jsx)(`button`,{type:`button`,onClick:()=>k(O===S?``:S),"aria-pressed":O===S,className:`btn btn-sm ${O===S?`!border-[color:var(--color-ink)] !bg-[color:var(--color-ink)] !text-white`:``}`,children:r(`home.withDrafts`,{n:L})}),H.map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>k(O===e?``:e),"aria-pressed":O===e,className:`btn btn-sm ${O===e?`!border-[color:var(--color-ink)] !bg-[color:var(--color-ink)] !text-white`:``}`,children:[h(e),` `,z[e]]},e))]}),children:R.length>0?(0,x.jsx)(`ul`,{className:`cascade grid grid-cols-2 border-l border-t border-[color:var(--color-rule)] sm:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8`,children:R.map(e=>(0,x.jsx)(C,{page:e},e.id))}):(0,x.jsxs)(`div`,{className:`flex flex-col items-start gap-2 p-6`,children:[(0,x.jsx)(t,{size:22}),(0,x.jsx)(`p`,{className:`text-[13px] font-semibold`,children:E?r(`home.emptyLoading`):i.length===0?r(`home.emptyNoArchive`):O?r(`home.emptyNoPageInState`,{state:O===S?r(`home.withDrafts`,{n:0}):h(O)}):r(`home.emptyNoPagesYet`)}),(0,x.jsx)(`p`,{className:`max-w-[60ch] text-[12px] text-[color:var(--color-ink-2)]`,children:i.length===0?r(`home.emptyNoArchiveBody`):r(O?`home.emptyFilterBody`:`home.emptyNoPagesBody`)}),O?(0,x.jsx)(`button`,{type:`button`,onClick:()=>k(``),className:`btn`,children:r(`home.showAll`)}):(0,x.jsx)(l,{to:i.length===0?`/progetti`:`/progetti/${c}`,className:`btn btn-primary no-underline`,children:i.length===0?r(`home.createArchive`):r(`home.manageArchive`)})]})})]})}export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,ct as t,dt as n,ht as r,i,lt as a}from"./ui-BtIxuKN2.js";import{E as o}from"./index-DVWuV1Ff.js";var s=r(n(),1),c=a();function l(){let{t:n}=t(),{instanceName:r,allowRegistration:a,login:l,register:u}=o(),[d,f]=(0,s.useState)(`login`),[p,m]=(0,s.useState)(``),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(null),[x,S]=(0,s.useState)(!1);return(0,c.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[color:var(--color-fill)] p-4`,children:(0,c.jsxs)(`div`,{className:`mod w-full max-w-sm border-[color:var(--color-rule-strong)]`,children:[(0,c.jsx)(`div`,{className:`mod-head border-b-[color:var(--color-rule-strong)]`,children:(0,c.jsx)(`span`,{className:`mod-tab`,children:n(d===`login`?`auth.loginTitle`:`auth.registerTitle`)})}),(0,c.jsxs)(`div`,{className:`mod-body`,children:[(0,c.jsxs)(`h1`,{className:`text-[22px] font-bold leading-tight tracking-[-0.03em]`,children:[r||`Tabularium`,(0,c.jsx)(`span`,{className:`text-[color:var(--color-sig-text)]`,children:`Lab`})]}),(0,c.jsx)(`p`,{className:`mt-1 text-[12px] text-[color:var(--color-ink-2)]`,children:n(d===`login`?`auth.loginSubtitle`:`auth.registerSubtitle`)}),(0,c.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),!p.trim()||!h){b(n(`auth.fillRequired`));return}S(!0),b(null);try{d===`login`?await l(p.trim(),h):await u(p.trim(),h,_)}catch(t){b(e(t).messaggio)}finally{S(!1)}},className:`mt-4 space-y-3`,children:[(0,c.jsx)(i,{label:n(`auth.username`),children:(0,c.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),autoComplete:`username`,autoFocus:!0,className:`fld`})}),(0,c.jsx)(i,{label:n(`auth.password`),children:(0,c.jsx)(`input`,{type:`password`,value:h,onChange:e=>g(e.target.value),autoComplete:d===`login`?`current-password`:`new-password`,className:`fld`})}),d===`register`&&(0,c.jsx)(i,{label:n(`auth.email`),hint:n(`auth.emailHint`),children:(0,c.jsx)(`input`,{type:`email`,value:_,onChange:e=>v(e.target.value),autoComplete:`email`,className:`fld`})}),y&&(0,c.jsx)(`p`,{role:`alert`,className:`text-[12px] text-[color:var(--color-sig-text)]`,children:y}),(0,c.jsx)(`button`,{type:`submit`,disabled:x,className:`btn btn-primary w-full justify-center`,children:n(x?`auth.busy`:d===`login`?`auth.login`:`auth.register`)})]}),a&&(0,c.jsx)(`div`,{className:`mt-4 border-t border-[color:var(--color-rule)] pt-3`,children:(0,c.jsx)(`button`,{type:`button`,onClick:()=>{f(d===`login`?`register`:`login`),b(null)},className:`text-[12px] font-medium text-[color:var(--color-sig-text)] hover:underline`,children:n(d===`login`?`auth.switchToRegister`:`auth.switchToLogin`)})})]})]})})}export{l as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{$ as e,C as t,Y as n,Z as r,c as i,ct as a,d as o,dt as s,ht as c,i as l,l as u,lt as d,n as f,nt as p,p as m,r as ee,t as h,tt as g,u as te}from"./ui-BtIxuKN2.js";import{C as _,D as v,N as y,O as ne,S as b,T as re,_ as ie,b as x,d as S,f as ae,g as C,h as oe,l as w,m as T,p as E,t as se,u as D,v as O,x as k,y as A}from"./index-DVWuV1Ff.js";import{s as j}from"./vocab-C9TBNLaa.js";var M=c(s(),1),N=d(),ce={done:`ok`,active:`progress`,waiting:`neutral`,failed:`warn`};function P({n:e,title:t,state:n,stateLabel:r,aux:i,children:a}){return(0,N.jsxs)(`li`,{className:`grid grid-cols-[2rem_1fr] gap-x-3 border-b border-[color:var(--color-rule)] py-3 last:border-b-0 ${n===`waiting`?`opacity-60`:``}`,"aria-current":n===`active`?`step`:void 0,children:[(0,N.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center text-[13px] font-bold ${n===`done`?`bg-[color:var(--color-ok)] text-white`:n===`active`?`bg-[color:var(--color-sig-plate)] text-white`:n===`failed`?`bg-[color:var(--color-warn)] text-white`:`border border-[color:var(--color-rule)] text-[color:var(--color-ink-3)]`}`,"aria-hidden":!0,children:n===`done`?`✓`:e}),(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-[14px] font-bold`,children:t}),(0,N.jsx)(h,{tone:ce[n],children:r}),i&&(0,N.jsx)(`span`,{className:`ml-auto`,children:i})]}),a&&(0,N.jsx)(`div`,{className:`mt-1 text-[12px] text-[color:var(--color-ink-2)]`,children:a})]})]})}function le({tab:e,aux:t,children:n}){return(0,N.jsx)(u,{tab:`3 · ${e}`,aux:t,children:n})}var F=`vast_api_key`,I=`tabularium.vast.job`;function L(){try{let e=localStorage.getItem(I);if(!e)return null;let t=JSON.parse(e);return!t.host||!t.port||!t.instanceId?null:{instanceId:String(t.instanceId),host:String(t.host),port:Number(t.port),servedName:String(t.servedName||``),adapterId:String(t.adapterId||``)}}catch{return null}}function R(e){try{e?localStorage.setItem(I,JSON.stringify(e)):localStorage.removeItem(I)}catch{}}var z=`tabularium.modal.template`,B=`tabularium.modal.keep_warm`;function ue(e,t){try{let n=localStorage.getItem(e);if(n!==null)return localStorage.getItem(t)!==null&&localStorage.removeItem(t),n;let r=localStorage.getItem(t);return r!==null&&(localStorage.setItem(e,r),localStorage.removeItem(t)),r}catch{return null}}function de(e){return e.includes(`.modal.run`)?`modal`:e.includes(`proxy.runpod.net`)||e.includes(`api.runpod.ai`)?`runpod`:e.includes(`127.0.0.1`)||e.includes(`localhost`)?`vast`:e?`manual`:`vast`}function fe(e,t,n){let r=t.trim(),i=parseInt(n.trim(),10);return r&&Number.isFinite(i)&&i>0&&i<65536?{host:r,port:i}:e.ssh_host&&e.ssh_port?{host:e.ssh_host,port:e.ssh_port}:null}function V(e){return e.includes(`paddleocr`)?`paddleocr-vl`:e.includes(`mineru`)?`mineru`:e.includes(`unlimited-ocr`)?`unlimited-ocr`:e.includes(`dots-ocr`)?`dots-ocr`:e.includes(`glm-ocr`)?`glm-ocr`:e.includes(`deepseek-ocr`)?`deepseek-ocr`:e.includes(`qwen3-vl`)?`qwen3-vl`:e.includes(`teleocr`)?`teleocr`:`monkeyocrv2`}var pe={monkeyocrv2:{model:`MonkeyOCRv2`,adapterId:`monkeyocrv2-parsing`},"paddleocr-vl":{model:`PaddleOCR-VL-1.6`,adapterId:`paddleocr-vl`},mineru:{model:`mineru2.5`,adapterId:`mineru2.5`},"unlimited-ocr":{model:`Unlimited-OCR`,adapterId:`unlimited-ocr`},"dots-ocr":{model:`dots-mocr`,adapterId:`dots-ocr`},"glm-ocr":{model:`glm-ocr`,adapterId:`glm-ocr`},"deepseek-ocr":{model:`deepseek-ocr-2`,adapterId:`deepseek-ocr`},"qwen3-vl":{model:`qwen3-vl-8b`,adapterId:`qwen3-vl-8b`},teleocr:{model:`StarDoc-AI/TeleOCR`,adapterId:`teleocr`}},me=Object.fromEntries(Object.entries(pe).map(([e,t])=>[t.adapterId,e])),he=[{id:`monkeyocrv2`,label:`MonkeyOCRv2-Parsing`},{id:`paddleocr-vl`,label:`PaddleOCR-VL-1.6`},{id:`mineru`,label:`MinerU2.5`},{id:`unlimited-ocr`,label:`Unlimited-OCR`},{id:`dots-ocr`,label:`dots.mocr`},{id:`glm-ocr`,label:`GLM-OCR`},{id:`deepseek-ocr`,label:`DeepSeek-OCR-2`},{id:`qwen3-vl`,label:`Qwen3-VL-8B`},{id:`teleocr`,label:`TeleOCR`}],ge=`https://opencode.ai/inference/go/google/v1beta`,_e=`gemini-4-argon-contributor`;function ve(e,t){navigator.clipboard?.writeText(e).then(t).catch(()=>{})}function ye({open:n,onClose:o,focusProvider:s,focusAdapterId:c,focusModelLabel:d,inline:p=!1,onlyProvider:ee=null}){let{t:v}=a(),y=se(),b=re(),ie=s??de(b.url),x=!!(n&&c&&s&&s!==`manual`),S=!!(x&&s===`modal`&&c?.startsWith(`custom-`)),ae={vast:`Vast.ai`,runpod:`RunPod`,modal:`Modal`},[C,oe]=(0,M.useState)(``),[w,T]=(0,M.useState)([]),[E,D]=(0,M.useState)(!1),[O,A]=(0,M.useState)(null),[j,ce]=(0,M.useState)([]),[I,ye]=(0,M.useState)(``),[H,be]=(0,M.useState)(``),[xe,Se]=(0,M.useState)(`80`),[Ce,we]=(0,M.useState)(`24`),[Te,Ee]=(0,M.useState)(``),[De,Oe]=(0,M.useState)(`12.9`),[ke,Ae]=(0,M.useState)(!0),[je,Me]=(0,M.useState)(null),[Ne,Pe]=(0,M.useState)(null),[Fe,Ie]=(0,M.useState)(null),[U,Le]=(0,M.useState)(null),[Re,ze]=(0,M.useState)([]),[Be,W]=(0,M.useState)(``),[G,Ve]=(0,M.useState)(!1),[He,Ue]=(0,M.useState)(!1),[We,Ge]=(0,M.useState)(!1),[Ke,qe]=(0,M.useState)([]),[K,Je]=(0,M.useState)(`monkeyocrv2-parsing`),[Ye,Xe]=(0,M.useState)(``),[Ze,Qe]=(0,M.useState)(()=>L()?.servedName||(b.provider===`vast`&&b.model?b.model:`MonkeyOCRv2`)),[$e,et]=(0,M.useState)(()=>L()?.instanceId??null),[tt,nt]=(0,M.useState)(!1),[rt,it]=(0,M.useState)(null),[at,ot]=(0,M.useState)(!1),[st,ct]=(0,M.useState)(!0),[lt,ut]=(0,M.useState)(null),dt=x&&c&&!c.startsWith(`custom-`)?c:K,ft=Ke.find(e=>e.adapter_id===dt),pt=ft?.min_free_disk_gb??22,mt=ft?Math.ceil((pt+28)/10)*10:80,ht=ft?Math.ceil(ft.min_free_vram_gb+2):24,gt=ft?.min_cuda_driver??12.9,_t=(ft?.min_free_ram_gb??8)+4;(0,M.useEffect)(()=>{Se(String(mt))},[mt]),(0,M.useEffect)(()=>{we(String(ht))},[ht]),(0,M.useEffect)(()=>{Oe(String(gt))},[gt]);let[vt,yt]=(0,M.useState)(``),[bt,xt]=(0,M.useState)(``),[St,Ct]=(0,M.useState)(``),[wt,Tt]=(0,M.useState)(`root`),[Et,Dt]=(0,M.useState)(``),[Ot,kt]=(0,M.useState)(``),[At,jt]=(0,M.useState)(!1),[q,Mt]=(0,M.useState)({running:!1}),[J,Nt]=(0,M.useState)(!1),[Pt,Ft]=(0,M.useState)(``),[It,Lt]=(0,M.useState)([]),[Rt,zt]=(0,M.useState)(!1),[Bt,Vt]=(0,M.useState)(null),[Ht,Ut]=(0,M.useState)(()=>ue(z,`lloyds.modal_template`)||V(b.url)),Wt=e=>{Ut(e);try{localStorage.setItem(z,e)}catch{}},Y=x&&s===`modal`&&c?c.startsWith(`custom-`)?`monkeyocrv2`:me[c]??`monkeyocrv2`:Ht,[X,Gt]=(0,M.useState)(null),[Kt,qt]=(0,M.useState)(``),[Jt,Yt]=(0,M.useState)(()=>ue(B,`lloyds.modal_keep_warm`)===`1`),[Xt,Zt]=(0,M.useState)(!1),[Qt,Z]=(0,M.useState)(null),$t=X?.task&&!X.task.done?X.task:null,[en,tn]=(0,M.useState)(b.url),[nn,rn]=(0,M.useState)(b.model),[an,on]=(0,M.useState)(b.apiKey),sn=K===`monkeyocrv2-parsing`||K.startsWith(`custom-`),[cn,ln]=(0,M.useState)(null),un=(e,t)=>ve(e,()=>{ln(t),setTimeout(()=>ln(null),2e3)});(0,M.useEffect)(()=>{n&&(c===`gemini-argon`?(tn(ge),rn(_e),on(``)):(tn(b.url),rn(s===`manual`&&d?d:b.model),on(b.apiKey)),pn(),bn(),_n(),yn())},[n,s,d,c]),(0,M.useEffect)(()=>{if(!(!n||!c)&&(s===`vast`&&Je(c),s===`modal`)){let e=me[c];c.startsWith(`custom-`)?Wt(`monkeyocrv2`):e&&Wt(e)}},[n,s,c]),(0,M.useEffect)(()=>{Ke.length!==0&&(Ke.some(e=>e.adapter_id===K)||Je(`monkeyocrv2-parsing`))},[Ke,K]);let dn=!!C.trim()||He;(0,M.useEffect)(()=>{!n||!dn||kn(!0)},[n,dn]),(0,M.useEffect)(()=>{if(!n)return;let t=!1,r=async()=>{try{let n=await e(`/system/cloud/modal?template=${Y}`);t||Gt(n)}catch{}};r();let i=setInterval(()=>void r(),2e3);return()=>{t=!0,clearInterval(i)}},[n,Y]),(0,M.useEffect)(()=>{if(!n||Fe===null)return;let e=!1,t=async()=>{try{let t=gn();if(!t)return;let n=await g(`/system/cloud/vast/instance`,{...t,instance_id:Fe});if(e)return;T(e=>e.some(e=>String(e.id)===String(n.id))?e.map(e=>String(e.id)===String(n.id)?{...e,...n}:e):[...e,n]),n.ssh_ready?(Ie(null),A(v(`cloud.control.instanceReady`,{id:String(n.id),host:String(n.ssh_host),port:String(n.ssh_port)}))):A(v(`cloud.control.waitingInstance`,{id:String(n.id),status:n.status}))}catch{}};t();let r=setInterval(()=>void t(),8e3);return()=>{e=!0,clearInterval(r)}},[n,Fe,C,He]),(0,M.useEffect)(()=>{if(!n||!U)return;let e=!1,t=0,r=async()=>{try{let n=await g(`/system/cloud/vast/provision/log`,{host:U.host,port:U.port,lines:60});if(e)return;if(t=0,ze(n.lines),W(n.phase),!n.present){Le(null),W(`absent`),R(null);return}if(n.failed){W(`failed`),Le(null),R(null),A(v(`cloud.control.provisionFailed`,{error:n.error}));return}n.ready&&(Le(null),W(`ready`),A(v(`cloud.control.provisionReady`)),await mn(U.host,U.port))}catch(n){t+=1,!e&&t>=3&&A(v(`cloud.control.provisionStatusError`,{error:String(n)}))}};r();let i=setInterval(()=>void r(),1e4);return()=>{e=!0,clearInterval(i)}},[n,U]),(0,M.useEffect)(()=>{if(!n)return;let e=L();e&&(e.adapterId&&e.adapterId!==dt||(e.servedName&&Qe(e.servedName),et(e.instanceId),xt(e.host),Ct(String(e.port)),Le({host:e.host,port:e.port}),A(v(`cloud.control.vastGuide.resumed`,{id:e.instanceId}))))},[n]),(0,M.useEffect)(()=>{G&&R(null)},[G]),(0,M.useEffect)(()=>{if(U||L()||Ye.trim())return;let e=Ke.find(e=>e.adapter_id===K);e?.served_model_name&&Qe(e.served_model_name)},[Ke,K]);let fn=w.some(e=>!e.is_running);(0,M.useEffect)(()=>{if(!n||!fn)return;let e=setInterval(()=>void kn(!0),1e4);return()=>clearInterval(e)},[n,fn]);let pn=async()=>{try{let t=await e(`/system/cloud/tunnel`);Mt(t),t.host&&xt(t.host),t.port&&Ct(String(t.port)),t.running||Ve(!1)}catch{}};(0,M.useEffect)(()=>{if(!n||!q.running||G)return;let e=!1,t=`http://127.0.0.1:${q.local_port||8888}/v1`,r=async()=>{try{let n=await _({url:t,model:Ze});if(e||!n.ok)return;await k({enabled:!0,url:t,model:Ze,adapterId:K}),e||(Ve(!0),A(v(`cloud.control.endpointReady`,{url:t})))}catch{}};r();let i=setInterval(()=>void r(),5e3);return()=>{e=!0,clearInterval(i)}},[n,q.running,q.local_port,G,Ze,K]);let mn=async(e,t)=>{let n=(e??bt).trim(),r=t??parseInt(St.trim(),10);if(!n||!Number.isFinite(r)){A(v(`cloud.control.missingHostPort`));return}Nt(!0),A(null);try{let e=await g(`/system/cloud/tunnel/start`,{host:n,port:r,user:wt.trim()||`root`,local_port:0,remote_port:8888,adapter_id:K});Mt(e);let t=`http://127.0.0.1:${e.local_port||8888}/v1`;A(v(`cloud.control.endpointVerifying`,{url:t}))}catch(e){A(v(`cloud.control.startError`,{error:String(e)}))}finally{Nt(!1)}},hn=async()=>{Nt(!0);try{await g(`/system/cloud/tunnel/stop`,{}),Mt({running:!1}),A(v(`cloud.control.stopped`))}catch(e){A(v(`cloud.control.stopError`,{error:String(e)}))}finally{Nt(!1)}},gn=()=>C.trim()?{api_key:C.trim()}:He?{credential_ref:`vault:${F}`}:null,_n=async()=>{try{let t=await e(`/system/secrets/${F}`);if(Ue(t.configured),!t.configured){ct(!1);return}let n=`vault:${F}`;try{Me(await g(`/system/cloud/vast/account`,{credential_ref:n}))}catch{}finally{ct(!1)}await xn(),await kn(!0)}catch{ct(!1)}},vn=async()=>{try{await r(`/system/secrets/${F}`),Ue(!1),oe(``),A(v(`cloud.control.keyForgotten`))}catch(e){A(v(`cloud.control.loadError`,{error:String(e)}))}},yn=async()=>{try{let t=await e(`/system/cloud/vast/models`);qe(t.items)}catch{}},bn=async()=>{try{Pe(await e(`/system/cloud/vast/ssh-key`))}catch{}},xn=async()=>{if(vt.trim())return vt.trim();try{let t=await e(`/system/cloud/vast/monkeyocr-ref`);return yt(t.ref),t.ref}catch(e){return A(v(`cloud.control.refResolveError`,{error:String(e)})),``}},Sn=e=>{let t=e.find(e=>e.is_running&&e.ssh_direct_port);t&&(kt(e=>e.trim()||String(t.ssh_direct_port)),t.ssh_direct_host&&Dt(e=>e.trim()||String(t.ssh_direct_host)))},Q=e=>fe(e,Et,Ot),Cn=w.some(e=>e.is_running&&e.ssh_via===`proxy`),wn=async()=>{let e=Et.trim(),t=parseInt(Ot.trim(),10);if(!e||!Number.isFinite(t)||t<=0){A(v(`cloud.control.missingHostPort`));return}jt(!0);try{await g(`/system/cloud/vast/hostkey`,{host:e,port:t});let n=await g(`/system/cloud/vast/ssh-check`,{host:e,port:t,user:wt.trim()||`root`,attempts:2});A(n.ok?v(`cloud.control.sshCheckOk`,{host:e,port:String(t)}):n.message||v(`cloud.control.sshCheckFailed`,{host:e,port:String(t)}))}catch(n){A(v(`cloud.control.sshCheckFailed`,{host:e,port:String(t)})+` ${String(n)}`)}finally{jt(!1)}},Tn=async e=>{let t=await g(`/system/cloud/vast/hostkey`,{host:e.host,port:e.port});A(v(`cloud.control.hostKeyPinned`,{host:t.host,port:String(t.port),types:t.key_types.join(`, `)}))},En=async e=>{let t=Q(e);if(!t){A(v(`cloud.control.noSsh`));return}D(!0);try{let n=gn();if(!n){A(v(`cloud.control.missingKey`));return}let r=await xn();if(!r)return;A(v(`cloud.control.attachingKey`)),await g(`/system/cloud/vast/ssh-key`,{...n,instance_id:e.id}),await bn(),await Tn(t);let i=await g(`/system/cloud/vast/provision`,{host:t.host,port:t.port,monkeyocr_ref:r,adapter_id:K,model:Ye.trim(),remote_port:8888});Qe(i.served_model_name),xt(t.host),Ct(String(t.port)),ze([]),ut(null),et(String(e.id)),Le({host:t.host,port:t.port}),R({instanceId:String(e.id),host:t.host,port:t.port,servedName:i.served_model_name,adapterId:K}),i.already_ready?(A(v(`cloud.control.serverAlreadyReady`)),await mn(t.host,t.port)):A(v(`cloud.control.provisionStarted`))}catch(e){A(v(`cloud.control.provisionError`,{error:String(e)}))}finally{D(!1)}},Dn=async e=>{if(!c||!c.startsWith(`custom-`))return;let t=Q(e);if(!t){A(v(`cloud.control.noSsh`));return}let n=gn();if(!n){A(v(`cloud.control.missingKey`));return}D(!0);try{A(v(`cloud.control.checkpointUploading`));let e=await g(`/system/cloud/vast/publish-checkpoint`,{...n,host:t.host,port:t.port,adapter_id:c,monkeyocr_ref:vt.trim(),remote_port:8888});Qe(e.served_model_name),A(v(`cloud.control.checkpointUploaded`)),await mn(t.host,t.port)}catch(e){A(v(`cloud.control.checkpointUploadError`,{error:String(e)}))}finally{D(!1)}},On=async()=>{let e=gn();if(!e){A(v(`cloud.control.missingKey`));return}D(!0),A(null);try{let t=await g(`/system/cloud/vast/account`,e);Me(t);let n=await g(`/system/cloud/vast/ssh-key`,e);if(C.trim())try{await g(`/system/secrets`,{name:F,value:C.trim()}),Ue(!0),oe(``)}catch{}await bn(),A(n.already_registered?v(`cloud.control.setupKeyAlready`):v(`cloud.control.setupKeyRegistered`)),await xn(),await kn()}catch(e){A(v(`cloud.control.setupError`,{error:String(e)}))}finally{D(!1)}},kn=async(e=!1)=>{let t=gn();if(!t){e||A(v(`cloud.control.missingKey`));return}e||(D(!0),A(null));try{let n=await g(`/system/cloud/vast/instances`,t);T(n.items),Ge(!0),Sn(n.items),e||A(n.items.length===0?v(`cloud.control.noneFound`):v(`cloud.control.found`,{count:n.items.length}))}catch(t){e||A(v(`cloud.control.loadError`,{error:String(t)}))}finally{e||D(!1)}},An=async()=>{let e=gn();if(!e){A(v(`cloud.control.missingKey`));return}D(!0),A(null);try{let t=await g(`/system/cloud/vast/offers`,{...e,gpu_name:I.trim(),max_dph:H?Number(H):null,disk_gb:Math.max(Number(xe)||40,mt),min_gpu_ram_gb:Ce?Math.max(Number(Ce),ht):ht,min_cpu_ram_gb:_t,min_compute_capability:ft?.min_compute_capability??7.5,min_inet_down:Te?Number(Te):null,min_cuda:De?Math.max(Number(De),gt):gt,verified_only:ke,num_gpus:1,min_reliability:.95,instance_type:`on-demand`});ce(t.items),A(t.items.length?v(`cloud.control.offersFound`,{count:t.items.length}):v(`cloud.control.noOffers`))}catch(e){A(v(`cloud.control.loadError`,{error:String(e)}))}finally{D(!1)}},jn=async e=>{let t=gn();if(!t){A(v(`cloud.control.missingKey`));return}let n=e.dph_total==null?v(`cloud.control.priceUnknown`):`$${e.dph_total.toFixed(3)}/h`;if(await y({title:v(`cloud.control.rentTitle`),message:v(`cloud.control.rentConfirm`,{gpu:`${e.num_gpus}× ${e.gpu_name||`GPU`}`,price:n}),acceptLabel:v(`cloud.control.rentTitle`)})){D(!0),A(null);try{let n=await g(`/system/cloud/vast/rent`,{...t,offer_id:e.id,disk_gb:Math.max(Number(xe)||40,mt),adapter_id:K,dph_total:e.dph_total,cuda_max_good:e.cuda_max_good??null,prepare_server:!1,port:8888});ce([]),A(v(`cloud.control.rentStarted`)),n.contract_id!=null&&(Ie(n.contract_id),et(String(n.contract_id))),await kn()}catch(e){A(v(`cloud.control.rentError`,{error:String(e)}))}finally{D(!1)}}},Mn=async(e,t)=>{if(t===`delete`&&!await y({title:v(`cloud.control.deleteResourceTitle`),message:v(`cloud.control.deleteResourceConfirm`,{id:String(e)}),acceptLabel:v(`cloud.control.deleteResourceTitle`)}))return;let n=gn();if(!n){A(v(`cloud.control.missingKey`));return}D(!0);try{await g(`/system/cloud/vast/control`,{...n,instance_id:e,action:t}),A(v(`cloud.control.commandSent`,{action:v(t===`start`?`cloud.control.actionStart`:t===`stop`?`cloud.control.actionPause`:`cloud.control.actionDelete`)})),await kn()}catch(e){A(v(`cloud.control.commandError`,{error:String(e)}))}finally{D(!1)}},Nn=async e=>{let t=Q(e);if(!t){A(v(`cloud.control.noSsh`));return}xt(t.host),Ct(String(t.port)),Nt(!0);try{await Tn(t)}catch(e){A(v(`cloud.control.hostKeyError`,{error:String(e)}));return}finally{Nt(!1)}await mn(t.host,t.port)},Pn=async()=>{if(!Pt.trim()){Vt(v(`cloud.control.missingKey`));return}zt(!0),Vt(null);try{let e=await g(`/system/cloud/runpod/pods`,{api_key:Pt.trim()});Lt(e.items),Vt(e.items.length===0?v(`cloud.control.noneFound`):v(`cloud.control.found`,{count:e.items.length}))}catch(e){Vt(v(`cloud.control.loadError`,{error:String(e)}))}finally{zt(!1)}},Fn=async(e,t)=>{if(!(t===`delete`&&!await y({title:v(`cloud.control.deleteResourceTitle`),message:v(`cloud.control.deleteResourceConfirm`,{id:String(e)}),acceptLabel:v(`cloud.control.deleteResourceTitle`)}))){zt(!0);try{await g(`/system/cloud/runpod/control`,{api_key:Pt.trim(),pod_id:e,action:t}),Vt(v(`cloud.control.commandSent`,{action:v(t===`start`?`cloud.control.actionStart`:t===`stop`?`cloud.control.actionPause`:`cloud.control.actionDelete`)})),await Pn()}catch(e){Vt(v(`cloud.control.commandError`,{error:String(e)}))}finally{zt(!1)}}},In=async e=>{let t=`https://${e.id}-8888.proxy.runpod.net/v1`;try{await k({enabled:!0,url:t,model:x&&d?d:void 0,apiKey:Pt.trim()||void 0,adapterId:x&&c?c:b.adapterId}),await _({url:t,apiKey:Pt.trim()||void 0}),Vt(v(`cloud.control.runpodProxySet`,{url:t}))}catch(e){Vt(v(`cloud.control.commandError`,{error:String(e)}))}},Ln=async()=>{Zt(!0),Z(null);try{await g(`/system/cloud/modal/setup`,{}),Z(v(`cloud.control.modalSetupStarted`))}catch(e){Z(v(`cloud.control.modalTaskError`,{error:String(e)}))}finally{Zt(!1)}},Rn=async()=>{Zt(!0),Z(null);try{await g(`/system/cloud/modal/deploy`,{template:Y,api_key:Kt.trim()||null,keep_warm:Jt}),Z(v(`cloud.control.modalDeployStarted`))}catch(e){Z(v(`cloud.control.modalTaskError`,{error:String(e)}))}finally{Zt(!1)}},zn=async()=>{if(c){Zt(!0),Z(null);try{await g(`/system/cloud/modal/publish-checkpoint`,{adapter_id:c,keep_warm:Jt}),Z(v(`cloud.control.modalCheckpointStarted`))}catch(e){Z(v(`cloud.control.modalTaskError`,{error:String(e)}))}finally{Zt(!1)}}},Bn=async()=>{if(await y({title:v(`cloud.control.modalStopTitle`),message:v(`cloud.control.modalStopConfirm`)})){Zt(!0),Z(null);try{await g(`/system/cloud/modal/stop`,{template:Y}),Z(v(`cloud.control.modalStopStarted`))}catch(e){Z(v(`cloud.control.modalTaskError`,{error:String(e)}))}finally{Zt(!1)}}},Vn=async()=>{let e=X?.endpoint;if(!e)return;let t=e.replace(/\/$/,``)+`/v1`,n=pe[Y]??pe.monkeyocrv2;try{let e={enabled:!0,url:t,model:x&&d&&c?.startsWith(`custom-`)?d:n.model,adapterId:x&&c?c:n.adapterId,apiKey:Kt.trim()||void 0};await _(e),await k(e),o()}catch(e){Z(v(`cloud.control.modalTaskError`,{error:String(e)}))}},Hn=async()=>{try{let e={enabled:!0,url:en,model:nn,apiKey:an,adapterId:c??void 0};await _(e),await k(e),o()}catch(e){Z(v(`cloud.control.modalTaskError`,{error:String(e)}))}},$=w.find(e=>String(e.id)===$e)??w.find(e=>q.running&&Q(e)?.host===q.host)??w.find(e=>e.is_running)??w[0]??null,Un=$?.is_running?Q($):null;if((0,M.useEffect)(()=>{if(!n||!$||!Un||U)return;let e=String($.id);rt!==e&&(it(e),ot(!0),(async()=>{try{await g(`/system/cloud/vast/hostkey`,Un);let e=await g(`/system/cloud/vast/provision/log`,{...Un,lines:60});ze(e.lines);let t=x&&s===`vast`&&!!c?.startsWith(`custom-`);e.present&&e.adapter_id&&e.adapter_id!==dt&&!t?(ut({adapterId:e.adapter_id,state:e.ready?`ready`:e.failed?`failed`:`preparing`}),W(`absent`)):e.present?e.ready?W(`ready`):e.failed?(W(`failed`),A(v(`cloud.control.provisionFailed`,{error:e.error}))):(W(e.phase||`starting`),Le(Un)):W(`absent`)}catch{W(``)}finally{ot(!1)}})())},[n,$?.id,Un?.host,Un?.port,U]),!n)return null;let Wn=(e,t)=>e?`ok`:/fail|error/i.test(t)?`warn`:`neutral`,Gn=e=>{let t={running:`statusRunning`,loading:`statusLoading`,created:`statusProvisioning`,stopped:`statusStopped`,paused:`statusStopped`,exited:`statusExited`,terminated:`statusExited`,frozen:`statusFrozen`,rebooting:`statusRebooting`,unknown:`statusNoContact`,offline:`statusNoContact`}[String(e||``).toLowerCase()];return t?v(`cloud.control.${t}`):e},Kn={absent:`phaseAbsent`,starting:`phaseStarting`,system:`phaseSystem`,clone:`phaseClone`,python:`phasePython`,weights:`phaseWeights`,serving:`phaseServing`,ready:`phaseReady`,failed:`phaseFailed`},qn=(e,t,n,r,i,a,o,s,c,l,d=!0)=>(0,N.jsxs)(u,{tab:v(`cloud.control.instancesLabel`),quiet:!0,flush:!0,aux:l&&(0,N.jsx)(`button`,{type:`button`,onClick:l,disabled:t,className:`btn btn-sm`,children:v(t?`cloud.control.loading`:`cloud.control.load`)}),children:[e.length===0&&(0,N.jsx)(`p`,{className:`p-3 text-[12px] text-[color:var(--color-ink-2)]`,children:v(d?`cloud.control.noneFound`:`cloud.control.loading`)}),(0,N.jsx)(`div`,{className:`divide-y divide-[color:var(--color-rule)]`,children:e.map(e=>{let l=s?Q(e):null,u=l?.host??e.ssh_host,d=l?.port??e.ssh_port,f=!!(s&&U?.host===u&&U?.port===d),p=!!(s&&G&&q.running&&q.host===u);return(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-3`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`font-bold`,children:e.label}),(0,N.jsx)(h,{tone:Wn(e.is_running,e.status),children:Gn(e.status)}),e.dph_total!=null&&(0,N.jsxs)(`span`,{className:`mono text-[11px] font-semibold text-[color:var(--color-sig)]`,children:[`$`,e.dph_total.toFixed(3),`/h`]}),e.cost_estimate&&(0,N.jsx)(`span`,{className:`mono text-[11px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.costSoFar`,{cost:e.cost_estimate.estimated_usd.toFixed(2)})})]}),(0,N.jsxs)(`div`,{className:`mono mt-0.5 text-[11px] text-[color:var(--color-ink-3)]`,children:[`ID: `,e.id,` `,u&&`· SSH: ${u}:${d}`,e.ssh_via===`proxy`&&` · ${v(`cloud.control.sshViaProxy`)}`,e.ssh_via===`direct`&&` · ${v(`cloud.control.sshViaDirect`)}`]}),!e.is_running&&s&&(0,N.jsx)(`div`,{className:`mt-0.5 text-[11px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.instanceStarting`,{action:v(`cloud.control.provisionRun`)})})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.is_running?(0,N.jsxs)(N.Fragment,{children:[p?(0,N.jsx)(h,{tone:`ok`,children:v(`cloud.control.instanceInUse`)}):s?(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(e),disabled:t||J||f||!u||!d,className:`btn btn-sm btn-primary`,children:v(f?`cloud.control.${Kn[Be]??`phaseStarting`}`:`cloud.control.provisionRun`)}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>n(e),disabled:t,className:`btn btn-sm`,children:r}),c&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>c(e),disabled:t||J||!u||!d,className:`btn btn-sm btn-primary`,children:v(`cloud.control.publishCheckpoint`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),disabled:t,className:`btn btn-sm`,title:v(`cloud.control.pauseTitle`),children:v(`cloud.control.pause`)})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),disabled:t,className:`btn btn-sm btn-primary`,children:v(`cloud.control.resume`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:t,className:`btn btn-sm btn-danger`,title:v(`cloud.control.deleteResource`),children:v(`cloud.control.deleteResource`)})]})]},e.id)})})]}),Jn=(e,n)=>(0,N.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 border border-[color:var(--color-rule-strong)] bg-[color:var(--color-fill)] p-2 font-mono text-[11px] text-[color:var(--color-ink)]`,children:[(0,N.jsx)(`code`,{className:`flex-1 overflow-x-auto`,children:e}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>un(e,n),className:`btn btn-sm shrink-0`,children:[(0,N.jsx)(t,{size:12}),v(cn===n?`cloud.control.copied`:`cloud.control.copy`)]})]}),Yn=b.provider??(b.url?de(b.url):null),Xn=v(Yn===`modal`?`recognition.provider.modal`:Yn===`vast`?`recognition.provider.vast`:Yn===`runpod`?`recognition.provider.runpod`:Yn===`local`?`recognition.provider.local`:`cloud.control.tabManual`),Zn=e=>!ee||ee===e,Qn=p?le:f,$n=(0,N.jsxs)(`div`,{className:p?`space-y-3`:`space-y-3 p-3`,children:[x&&!p&&(0,N.jsxs)(`div`,{className:`border border-[color:var(--color-rule-strong)] bg-[color:var(--color-fill)] p-2 text-[12px]`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`b`,{className:`font-semibold`,children:v(`cloud.control.deployGuidedTitle`,{model:d||c||``,provider:ae[s??``]??``})}),(0,N.jsx)(h,{tone:`ok`,children:d||c})]}),(0,N.jsx)(`p`,{className:`mt-0.5 text-[11px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.deployGuidedHint`)})]}),!p&&(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border border-[color:var(--color-rule-strong)] bg-[color:var(--color-panel)] p-2 text-[12px]`,children:[(0,N.jsx)(`span`,{className:`lbl !mb-0`,children:v(`cloud.control.activeNowLabel`)}),(0,N.jsx)(h,{tone:b.enabled?`ok`:`neutral`,children:b.enabled?`${b.model||`—`} · ${Xn}`:v(`cloud.control.activeNowDisabled`)})]}),Zn(`vast`)&&(0,N.jsx)(Qn,{tab:v(`cloud.control.tabVast`),defaultOpen:ie===`vast`,aux:$?.is_running&&$.dph_total!=null?(0,N.jsx)(`span`,{className:`mono text-[11px] font-semibold`,children:v(`cloud.control.vastGuide.billing`,{price:$.dph_total.toFixed(3)})}):void 0,children:(()=>{let e=x&&s===`vast`&&!!c?.startsWith(`custom-`),t=Ke.find(e=>e.adapter_id===K),n=!!(je&&Ne?.exists&&(He||C.trim())&&!tt),r=n&&!!Un,i=r&&(Be===`ready`||G),a=!!U,o=st&&He&&!je,u=n?`done`:`active`,p=n?r?`done`:`active`:`waiting`,ee=r?i?`done`:Be===`failed`?`failed`:`active`:`waiting`,g=i?G?`done`:`active`:`waiting`,_=v(`cloud.control.${Kn[Be]??`phaseStarting`}`),y=`http://127.0.0.1:${q.local_port||8888}/v1`,b=e=>{String(e.id)!==String($?.id)&&(et(String(e.id)),W(``),ze([]),ut(null))},re=(0,N.jsxs)(`div`,{className:`mt-2 border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-3`,children:[(0,N.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,N.jsx)(l,{label:v(`cloud.control.gpuFilterLabel`),hint:v(`cloud.control.gpuFilterHint`),children:(0,N.jsx)(`input`,{value:I,onChange:e=>ye(e.target.value),placeholder:`RTX 4090`,className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.vramLabel`),hint:v(`cloud.control.vramHint`),children:(0,N.jsx)(`input`,{type:`number`,min:`0`,step:`1`,value:Ce,onChange:e=>we(e.target.value),className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.maxPriceLabel`),children:(0,N.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:H,onChange:e=>be(e.target.value),placeholder:`0.50`,className:`fld fld-mono`})})]}),(0,N.jsxs)(`details`,{className:`mt-2`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.vastGuide.moreFilters`)}),(0,N.jsxs)(`div`,{className:`mt-2 grid gap-3 sm:grid-cols-3`,children:[(0,N.jsx)(l,{label:v(`cloud.control.diskLabel`),hint:v(`cloud.control.diskHint`,{recommended:mt,free:pt}),children:(0,N.jsx)(`input`,{type:`number`,min:`10`,value:xe,onChange:e=>Se(e.target.value),className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.netLabel`),hint:v(`cloud.control.netHint`),children:(0,N.jsx)(`input`,{type:`number`,min:`0`,step:`10`,value:Te,onChange:e=>Ee(e.target.value),placeholder:`100`,className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.cudaLabel`),hint:v(`cloud.control.cudaHint`),children:(0,N.jsx)(`input`,{type:`number`,min:`0`,step:`0.1`,value:De,onChange:e=>Oe(e.target.value),placeholder:`12.4`,className:`fld fld-mono`})}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] sm:col-span-3`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:ke,onChange:e=>Ae(e.target.checked)}),v(`cloud.control.verifiedOnly`)]})]})]}),(0,N.jsx)(`p`,{className:`mt-2 text-[11px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.compatibilityFilter`,{model:ft?.adapter_id??dt,vram:ht,ram:_t,disk:mt,compute:(ft?.min_compute_capability??7.5).toFixed(1),cuda:gt.toFixed(1)})}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void An(),disabled:E,className:`btn btn-primary mt-3`,children:v(E?`cloud.control.loading`:`cloud.control.findOffers`)}),j.length>0&&(0,N.jsx)(`div`,{className:`mt-3 divide-y divide-[color:var(--color-rule)] border border-[color:var(--color-rule)] bg-[color:var(--color-sheet)]`,children:j.map(e=>(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 p-2.5`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsxs)(`span`,{className:`font-bold text-[color:var(--color-ink)]`,children:[e.num_gpus,`× `,e.gpu_name||`GPU`]}),e.verified&&(0,N.jsx)(h,{tone:`ok`,children:v(`cloud.control.verified`)}),(0,N.jsx)(`span`,{className:`mono text-[12px] font-semibold text-[color:var(--color-ink)]`,children:e.dph_total==null?`—`:`$${e.dph_total.toFixed(3)}/h`})]}),(0,N.jsxs)(`div`,{className:`mono text-[11px] text-[color:var(--color-ink-2)]`,children:[v(`cloud.control.offerSpecs`,{vram:e.gpu_ram==null?`—`:String(Math.round(e.gpu_ram/1024)),disk:e.disk_space==null?`—`:String(Math.round(e.disk_space)),net:e.inet_down==null?`—`:String(Math.round(e.inet_down))}),e.cuda_max_good!=null&&` · CUDA ${e.cuda_max_good}`,e.compute_cap!=null&&` · sm_${(e.compute_cap/100).toFixed(1)}`,` · `,e.reliability==null?`—`:`${(e.reliability*100).toFixed(1)}%`,` · `,e.location||v(`cloud.control.locationUnknown`)]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void jn(e),disabled:E,className:`btn btn-sm btn-primary`,children:v(`cloud.control.rent`)})]},e.id))})]});return(0,N.jsxs)(`div`,{className:`space-y-2`,children:[O&&(0,N.jsx)(te,{tone:G?`ok`:Be===`failed`?`warn`:`neutral`,children:O}),(0,N.jsxs)(`ol`,{children:[(0,N.jsxs)(P,{n:1,title:v(`cloud.control.vastGuide.accountTitle`),state:u,stateLabel:v(n?`cloud.control.vastGuide.accountOk`:o?`cloud.control.vastGuide.checking`:`cloud.control.vastGuide.accountTodo`),aux:n?(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>nt(!0),children:v(`cloud.control.vastGuide.change`)}):void 0,children:[n?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(h,{tone:je.balance_ok?`ok`:`warn`,children:v(`cloud.control.setupAccountOk`,{email:je.email||`—`,balance:je.balance.toFixed(2)})}),(0,N.jsx)(h,{tone:`ok`,children:v(`cloud.control.setupKeyReady`,{fingerprint:`${Ne.fingerprint.slice(0,18)}…`})})]}):o?(0,N.jsx)(m,{indeterminate:!0,label:v(`cloud.control.vastGuide.checking`)}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`p`,{children:[v(`cloud.control.vastGuide.accountBody`),` `,(0,N.jsx)(`a`,{href:`https://cloud.vast.ai/manage-keys/`,target:`_blank`,rel:`noopener noreferrer`,children:v(`cloud.control.vastGuide.openConsole`)})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,N.jsx)(`div`,{className:`min-w-[16rem] flex-1`,children:(0,N.jsx)(l,{label:v(`cloud.control.apiKeyLabel`),hint:v(He?`cloud.control.keySavedHint`:`cloud.control.apiKeyHint`),children:(0,N.jsx)(`input`,{type:`password`,value:C,onChange:e=>oe(e.target.value),placeholder:v(`cloud.control.apiKeyPlaceholder`),className:`fld fld-mono`})})}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void On().then(()=>nt(!1)),disabled:E||!C.trim()&&!He,className:`btn btn-primary`,children:v(E?`cloud.control.setupRunning`:`cloud.control.setupRun`)})]}),He&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(h,{tone:`ok`,children:v(`cloud.control.keySaved`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>void vn(),children:v(`cloud.control.forgetKey`)}),tt&&(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>nt(!1),children:v(`cloud.control.vastGuide.keepKey`)})]})]}),je&&!je.balance_ok&&(0,N.jsx)(`p`,{className:`mt-1 text-[color:var(--color-warn)]`,children:v(`cloud.control.setupNoCredit`)})]}),(0,N.jsx)(P,{n:2,title:v(`cloud.control.vastGuide.gpuTitle`),state:p,stateLabel:r&&$?$.label:Fe!==null||w.some(e=>!e.is_running&&/load|creat|unknown/i.test(e.status))?v(`cloud.control.vastGuide.gpuStarting`):v(!We&&n?`cloud.control.loading`:`cloud.control.vastGuide.gpuTodo`),children:n&&(0,N.jsxs)(`div`,{className:`space-y-2`,children:[!We&&(0,N.jsx)(m,{indeterminate:!0,label:v(`cloud.control.loading`)}),Fe!==null&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(m,{indeterminate:!0,label:v(`cloud.control.vastGuide.gpuStarting`)}),(0,N.jsx)(`p`,{className:`mt-1 text-[11px]`,children:v(`cloud.control.vastGuide.gpuStartingBody`,{id:String(Fe)})})]}),w.length>0?(0,N.jsx)(`div`,{className:`divide-y divide-[color:var(--color-rule)] border border-[color:var(--color-rule)]`,children:w.map(e=>{let t=String(e.id)===String($?.id);return(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 p-2.5 ${t?`bg-[color:var(--color-sig-wash)]`:`bg-[color:var(--color-sheet)]`}`,children:[w.length>1&&(0,N.jsx)(`input`,{type:`radio`,name:`vast-instance`,checked:t,onChange:()=>b(e),"aria-label":v(`cloud.control.vastGuide.useInstance`,{id:String(e.id)})}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`font-bold text-[color:var(--color-ink)]`,children:e.label}),(0,N.jsx)(h,{tone:Wn(e.is_running,e.status),children:Gn(e.status)}),e.dph_total!=null&&(0,N.jsxs)(`span`,{className:`mono text-[11px] font-semibold text-[color:var(--color-ink)]`,children:[`$`,e.dph_total.toFixed(3),`/h`]}),e.cost_estimate&&(0,N.jsx)(`span`,{className:`mono text-[11px]`,children:v(`cloud.control.costSoFar`,{cost:e.cost_estimate.estimated_usd.toFixed(2)})})]}),(0,N.jsxs)(`div`,{className:`mono mt-0.5 text-[11px] text-[color:var(--color-ink-3)]`,children:[`ID `,e.id,Q(e)&&` · SSH ${Q(e).host}:${Q(e).port}`,e.ssh_via===`proxy`&&` · ${v(`cloud.control.sshViaProxy`)}`]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.is_running?(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Mn(e.id,`stop`),disabled:E,className:`btn btn-sm`,title:v(`cloud.control.pauseTitle`),children:v(`cloud.control.pause`)}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Mn(e.id,`start`),disabled:E,className:`btn btn-sm btn-primary`,children:v(`cloud.control.resume`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Mn(e.id,`delete`),disabled:E,className:`btn btn-sm btn-danger`,children:v(`cloud.control.deleteResource`)})]})]},e.id)})}):We&&(0,N.jsx)(`p`,{children:v(`cloud.control.vastGuide.noInstances`)}),w.length>0?(0,N.jsxs)(`details`,{children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.vastGuide.rentAnother`)}),re]}):We&&re,Cn&&(0,N.jsx)(`p`,{className:`text-[11px] text-[color:var(--color-warn)]`,children:v(`cloud.control.vastGuide.proxyHint`)})]})}),(0,N.jsx)(P,{n:3,title:v(`cloud.control.vastGuide.serverTitle`,{model:d||t?.hf_repo||K}),state:ee,stateLabel:r?i?v(`cloud.control.phaseReady`):at?v(`cloud.control.vastGuide.checking`):a?_:v(Be===`failed`?`cloud.control.phaseFailed`:`cloud.control.vastGuide.serverTodo`):v(`cloud.control.vastGuide.waitingGpu`),children:r&&$&&(0,N.jsxs)(`div`,{className:`space-y-2`,children:[!x&&(0,N.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,N.jsx)(l,{label:v(`cloud.control.modelLabel`),hint:v(`cloud.control.modelHint`),children:(0,N.jsx)(`select`,{value:K,onChange:e=>Je(e.target.value),className:`fld fld-mono`,disabled:a,children:Ke.map(e=>(0,N.jsx)(`option`,{value:e.adapter_id,children:e.hf_repo},e.adapter_id))})}),(0,N.jsx)(l,{label:v(`cloud.control.modelCustom`),hint:v(`cloud.control.modelCustomHint`),children:(0,N.jsx)(`input`,{value:Ye,onChange:e=>Xe(e.target.value),placeholder:`org/checkpoint`,className:`fld fld-mono`,disabled:a})})]}),t?.needs_own_image&&(0,N.jsx)(`p`,{className:`text-[11px]`,children:v(`cloud.control.modelOwnImage`,{image:t.docker_image})}),a?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(m,{indeterminate:!0,label:_}),(0,N.jsx)(`p`,{className:`mt-1 text-[11px]`,children:v(`cloud.control.vastGuide.preparingBody`)})]}):i?(0,N.jsx)(`p`,{children:v(`cloud.control.vastGuide.serverReadyBody`)}):(0,N.jsxs)(`div`,{children:[lt&&(0,N.jsx)(`p`,{className:`mb-1 text-[color:var(--color-warn)]`,children:v(`cloud.control.vastGuide.otherModel.${lt.state}`,{model:lt.adapterId})}),!at&&(0,N.jsx)(`p`,{children:v(e?`cloud.control.vastGuide.publishBody`:`cloud.control.vastGuide.serverBody`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-primary mt-2`,disabled:E||J||at,onClick:()=>void(e?Dn($):En($)),children:v(E?`cloud.control.setupRunning`:e?`cloud.control.publishCheckpoint`:Be===`failed`?`cloud.control.vastGuide.retry`:`cloud.control.vastGuide.prepareCta`)})]}),Re.length>0&&(0,N.jsxs)(`details`,{open:a||Be===`failed`&&!lt,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-3)]`,children:v(`cloud.control.provisionLogLabel`)}),(0,N.jsx)(`pre`,{className:`mono mt-1 max-h-56 overflow-auto whitespace-pre-wrap border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[11px] leading-[1.5]`,children:Re.join(`
|
|
2
|
+
`)})]})]})}),(0,N.jsx)(P,{n:4,title:v(`cloud.control.vastGuide.connTitle`),state:g,stateLabel:G?v(`cloud.control.inferenceOn`):q.running?v(`cloud.control.connectionChecking`):v(`cloud.control.tunnelClosed`),children:i&&(G?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`mono text-[11px]`,children:y}),(0,N.jsx)(ne,{to:`/`,className:`btn btn-primary no-underline`,children:v(`modelsHub.goRecognize`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:J,onClick:()=>void hn(),children:v(`cloud.control.vastGuide.disconnect`)})]}):q.running?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(m,{indeterminate:!0,label:v(`cloud.control.connectionChecking`)}),(0,N.jsx)(`p`,{className:`mt-1 text-[11px]`,children:v(`cloud.control.endpointVerifying`,{url:y})})]}):(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:v(`cloud.control.vastGuide.connBody`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-primary mt-2`,disabled:J||!$,onClick:()=>$&&void Nn($),children:v(J?`cloud.control.starting`:`cloud.control.connect`)})]}))})]}),(0,N.jsx)(f,{tab:v(`cloud.control.vastGuide.advanced`),quiet:!0,defaultOpen:Cn,children:(0,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,N.jsx)(`p`,{className:`text-[12px] font-semibold sm:col-span-2`,children:v(`cloud.control.directSshTitle`)}),(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)] sm:col-span-2`,children:v(`cloud.control.directSshHint`)}),(0,N.jsx)(l,{label:v(`cloud.control.directHostLabel`),hint:v(`cloud.control.directHostHint`),children:(0,N.jsx)(`input`,{value:Et,onChange:e=>Dt(e.target.value),placeholder:`173.239.92.155`,className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.directPortLabel`),hint:v(`cloud.control.directPortHint`),children:(0,N.jsx)(`input`,{value:Ot,onChange:e=>kt(e.target.value),placeholder:`41934`,className:`fld fld-mono`})}),(0,N.jsxs)(`div`,{className:`flex items-end gap-2 sm:col-span-2`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>void wn(),disabled:At||!Et.trim()||!Ot.trim(),className:`btn btn-sm`,children:v(At?`cloud.control.sshChecking`:`cloud.control.sshCheckRun`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>{Dt(``),kt(``)},disabled:At||!Et.trim()&&!Ot.trim(),className:`btn btn-sm`,children:v(`cloud.control.directSshClear`)})]})]}),(0,N.jsxs)(`div`,{className:`grid gap-3 border-t border-[color:var(--color-rule)] pt-3 sm:grid-cols-2`,children:[(0,N.jsx)(`p`,{className:`text-[12px] font-semibold sm:col-span-2`,children:v(`cloud.control.manualTunnelTitle`)}),(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)] sm:col-span-2`,children:v(`cloud.control.manualTunnelHint`)}),(0,N.jsx)(l,{label:v(`cloud.control.hostLabel`),hint:v(`cloud.control.hostHint`),children:(0,N.jsx)(`input`,{value:bt,onChange:e=>xt(e.target.value),placeholder:`ssh5.vast.ai`,disabled:q.running,className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.portLabel`),hint:v(`cloud.control.portHint`),children:(0,N.jsx)(`input`,{value:St,onChange:e=>Ct(e.target.value),placeholder:`38291`,disabled:q.running,className:`fld fld-mono`})}),(0,N.jsx)(l,{label:v(`cloud.control.userLabel`),hint:v(`cloud.control.userHint`),children:(0,N.jsx)(`input`,{value:wt,onChange:e=>Tt(e.target.value),placeholder:`root`,disabled:q.running,className:`fld fld-mono`})}),(0,N.jsx)(`div`,{className:`flex items-end`,children:q.running?(0,N.jsx)(`button`,{type:`button`,onClick:()=>void hn(),disabled:J,className:`btn btn-danger w-full`,children:v(J?`cloud.control.stopping`:`cloud.control.stop`)}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>void mn(),disabled:J,className:`btn btn-primary w-full`,children:v(J?`cloud.control.starting`:`cloud.control.start`)})})]}),sn&&(0,N.jsx)(`div`,{className:`border-t border-[color:var(--color-rule)] pt-3`,children:(0,N.jsx)(l,{label:v(`cloud.control.monkeyRefLabel`),hint:v(`cloud.control.monkeyRefHint`),children:(0,N.jsx)(`input`,{value:vt,onChange:e=>yt(e.target.value),className:`fld fld-mono`})})})]})},Cn?`adv-open`:`adv`)]})})()}),Zn(`runpod`)&&(0,N.jsx)(Qn,{tab:v(`cloud.control.tabRunpod`),defaultOpen:ie===`runpod`,children:(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.runpodBody`)}),x&&s===`runpod`&&(0,N.jsxs)(`div`,{className:`border border-[color:var(--color-rule-strong)] bg-[color:var(--color-sheet-dim)] p-2 text-[12px]`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:v(`cloud.control.modelLabel`)}),(0,N.jsx)(`div`,{className:`mt-1 font-semibold`,children:d||c}),(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.guidedModelHint`)})]}),Bt&&(0,N.jsx)(`div`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-3 py-2 text-[12px]`,children:Bt}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`div`,{className:`flex-1`,children:(0,N.jsx)(l,{label:v(`cloud.control.runpodKeyLabel`),hint:v(`cloud.control.runpodKeyHint`),children:(0,N.jsx)(`input`,{type:`password`,value:Pt,onChange:e=>Ft(e.target.value),placeholder:v(`cloud.control.apiKeyPlaceholder`),className:`fld fld-mono`})})}),(0,N.jsx)(`div`,{className:`flex items-end`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Pn(),disabled:Rt,className:`btn btn-primary`,children:v(Rt?`cloud.control.loading`:`cloud.control.load`)})})]}),It.length>0&&qn(It,Rt,e=>void In(e),v(`cloud.control.runpodUseProxy`),e=>void Fn(e,`start`),e=>void Fn(e,`stop`),e=>void Fn(e,`delete`)),(0,N.jsxs)(`details`,{children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-3)]`,children:v(`cloud.control.runpodSetupTitle`)}),(0,N.jsxs)(`div`,{className:`mt-2 space-y-2 text-[12px] text-[color:var(--color-ink-2)]`,children:[(0,N.jsx)(`p`,{children:v(`cloud.control.runpodSetupBody`)}),Jn('export MONKEYOCR_REF=COMMIT_O_TAG_MONKEYOCR_VERIFICATO; export TABULARIUM_REF=COMMIT_O_TAG_TABULARIUM_VERIFICATO; export TABULARIUM_SERVER_API_KEY=TOKEN_DEL_SERVER; curl -fsSL "https://raw.githubusercontent.com/nbadino/tabularium/${TABULARIUM_REF}/scripts/cloud/setup_cloud_vllm.sh" | bash -s -- --port 8888 --ref "$MONKEYOCR_REF"',`runpod-setup`)]})]})]})}),Zn(`modal`)&&(0,N.jsx)(Qn,{tab:v(`cloud.control.tabModal`),defaultOpen:ie===`modal`||Y!==`monkeyocrv2`,aux:(0,N.jsx)(h,{tone:X?.token?`ok`:`neutral`,children:X?.token?v(`cloud.control.modalTokenOk`):v(`cloud.control.modalTokenMissing`)}),children:(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.modalBody`)}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`lbl !mb-1`,children:v(`cloud.control.modalModelLabel`)}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(x?he.filter(e=>e.id===(me[c??``]??`monkeyocrv2`)):he).map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>Wt(e.id),disabled:!!$t||S,className:`btn btn-sm ${Y===e.id?`btn-primary`:``}`,children:e.label},e.id))})]}),Y===`paddleocr-vl`&&(0,N.jsx)(`p`,{className:`border border-[color:var(--color-warn-rule)] bg-[color:var(--color-warn-wash)] p-2 text-[12px] text-[color:var(--color-warn)]`,children:v(`cloud.control.modalPaddleCaveat`)}),Y===`monkeyocrv2`&&(0,N.jsx)(`p`,{className:`border border-[color:var(--color-ok)] bg-[color:var(--color-ok-wash)] p-2 text-[12px] text-[color:var(--color-ok)]`,children:v(`cloud.control.modalMonkeyPerformance`)}),Y===`mineru`&&(0,N.jsx)(`p`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[12px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.modalMineruCaveat`)}),Y===`unlimited-ocr`&&(0,N.jsx)(`p`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[12px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.modalUnlimitedCaveat`)}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[12px]`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:Jt,onChange:e=>{let t=e.target.checked;Yt(t);try{localStorage.setItem(B,t?`1`:`0`)}catch{}}}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`span`,{className:`block font-semibold`,children:v(`cloud.control.modalKeepWarm`)}),(0,N.jsx)(`span`,{className:`block text-[color:var(--color-ink-3)]`,children:v(`cloud.control.modalKeepWarmHint`)})]})]}),Qt&&(0,N.jsx)(`div`,{className:`border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-3 py-2 text-[12px]`,children:Qt}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!X?.token&&!$t&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Ln(),disabled:Xt||!X?.cli,className:`btn btn-primary`,children:v(`cloud.control.modalConnect`)}),X?.token&&!$t&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>void(S?zn():Rn()),disabled:Xt,className:`btn btn-primary`,children:S?v(`cloud.control.modalPublishCheckpoint`):X.endpoint?v(`cloud.control.modalRedeploy`):v(`cloud.control.modalDeploy`)}),!X.endpoint&&!S&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-ink-3)]`,children:v(`cloud.control.modalDeployHint`)}),S&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-ink-3)]`,children:v(`cloud.control.modalPublishCheckpointHint`)})]}),X?.token&&X?.endpoint&&!$t&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Bn(),disabled:Xt,className:`btn btn-sm btn-danger`,children:v(`cloud.control.modalStop`)}),$t&&(0,N.jsx)(h,{tone:`progress`,children:$t.kind===`setup`?v(`cloud.control.modalWaitingBrowser`):v(`cloud.control.modalDeploying`)}),X?.task?.done&&(0,N.jsx)(h,{tone:X.task.ok?`ok`:`warn`,children:X.task.ok?v(`cloud.control.modalTaskDone`):v(`cloud.control.modalTaskFailed`)}),!X?.cli&&(0,N.jsx)(`span`,{className:`text-[12px] text-[color:var(--color-warn)]`,children:v(`cloud.control.modalCliMissing`)})]}),X?.endpoint&&(0,N.jsxs)(`div`,{className:`space-y-2 border border-[color:var(--color-rule)] p-3`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:v(`cloud.control.modalEndpoint`)}),(0,N.jsx)(`div`,{className:`mono overflow-x-auto text-[11px] text-[color:var(--color-ink)]`,children:X.endpoint.replace(/\/$/,``)+`/v1`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Vn(),className:`btn btn-primary btn-sm`,children:v(`cloud.control.modalUseEndpoint`)})]}),(0,N.jsx)(l,{label:v(`cloud.control.modalKeyLabel`),hint:v(`cloud.control.modalKeyHint`),children:(0,N.jsx)(`input`,{type:`password`,value:Kt,onChange:e=>qt(e.target.value),className:`fld fld-mono`})}),X?.task&&X.task.log.length>0&&(0,N.jsx)(u,{tab:v(`cloud.control.modalLog`),quiet:!0,flush:!0,children:(0,N.jsx)(`pre`,{className:`mono max-h-48 overflow-auto p-2 text-[11px] leading-relaxed`,children:X.task.log.join(`
|
|
3
|
+
`)})}),(0,N.jsxs)(`details`,{children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-3)]`,children:v(`cloud.control.modalSetupTitle`)}),(0,N.jsx)(`p`,{className:`mt-2 text-[12px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.modalSetupBody`)})]})]})}),Zn(`manual`)&&(0,N.jsx)(Qn,{tab:v(`cloud.control.tabManual`),defaultOpen:ie===`manual`,children:(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:v(`cloud.control.manualBody`)}),(0,N.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,N.jsx)(`div`,{className:`sm:col-span-2`,children:(0,N.jsx)(l,{label:v(`cloud.control.urlLabel`),hint:v(`cloud.control.urlHint`),children:(0,N.jsx)(`input`,{value:en,onChange:e=>tn(e.target.value),placeholder:`https://<POD_ID>-8888.proxy.runpod.net/v1`,className:`fld fld-mono`})})}),(0,N.jsx)(`div`,{className:`sm:col-span-2`,children:(0,N.jsx)(l,{label:v(`cloud.card.modelLabel`),hint:v(`cloud.card.modelHint`),children:(0,N.jsx)(`input`,{value:nn,onChange:e=>rn(e.target.value),placeholder:`Unlimited-OCR`,className:`fld fld-mono`})})}),(0,N.jsx)(`div`,{className:`sm:col-span-2`,children:(0,N.jsx)(l,{label:v(`cloud.control.directKeyLabel`),children:(0,N.jsx)(`input`,{type:`password`,value:an,onChange:e=>on(e.target.value),placeholder:v(`cloud.control.directKeyPlaceholder`),className:`fld fld-mono`})})}),(0,N.jsx)(`div`,{className:`flex justify-end sm:col-span-2`,children:(0,N.jsx)(`button`,{type:`button`,onClick:()=>void Hn(),className:`btn btn-primary`,children:v(`cloud.control.saveApply`)})})]})]})})]});return p?$n:(0,N.jsx)(i,{title:v(`cloud.control.title`),onClose:o,wide:!0,children:$n})}var H={supported:`cloud.models.maturitySupported`,experimental:`cloud.models.maturityExperimental`,catalog:`cloud.models.maturityCatalog`,unavailable:`cloud.models.maturityUnavailable`},be={supported:`ok`,experimental:`progress`,catalog:`neutral`,unavailable:`warn`},xe=[`layout`,`text`,`table`,`formula`],Se={display_name:``,hf_repo:``,hf_revision:``,served_model_name:``,trust_remote_code:!1,max_model_len:``,gpu_memory_utilization:``,extra_args:``};function Ce({models:e,loading:t,selectedId:n,onSelect:i,onChanged:o}){let{t:s}=a(),c=re(),[l,d]=(0,M.useState)(``),[f,p]=(0,M.useState)(!1),[m,ee]=(0,M.useState)(!1),[_,v]=(0,M.useState)(Se),[y,ne]=(0,M.useState)(!1),[b,x]=(0,M.useState)(null),[S,ae]=(0,M.useState)(null),C=e.filter(e=>e.local?.runnable).length,w=l.trim().toLocaleLowerCase(),T=e.filter(e=>f&&!e.local?.runnable?!1:!w||`${e.display_name} ${e.adapter_id} ${e.hf_repo}`.toLocaleLowerCase().includes(w)),E=e=>xe.filter(t=>e.tasks.includes(t)).map(t=>t===`table`&&e.table_format?s(`modelsHub.taskTableFormat`,{format:e.table_format.toUpperCase()}):s(`modelsHub.task.${t}`)).join(` · `),se=async()=>{ne(!0),ae(null);try{await g(`/models/custom`,{display_name:_.display_name.trim()||void 0,hf_repo:_.hf_repo.trim(),hf_revision:_.hf_revision.trim()||void 0,served_model_name:_.served_model_name.trim()||void 0,trust_remote_code:_.trust_remote_code,max_model_len:_.max_model_len.trim()?Number(_.max_model_len):void 0,gpu_memory_utilization:_.gpu_memory_utilization.trim()?Number(_.gpu_memory_utilization):void 0,extra_args:_.extra_args.trim()||void 0}),v(Se),ee(!1),await o()}catch(e){ae(s(`cloud.models.addCustomError`,{error:String(e)}))}finally{ne(!1)}},D=async e=>{x(e);try{await r(`/models/custom/${e}`),await o()}catch(e){ae(s(`cloud.models.deleteError`,{error:String(e)}))}finally{x(null)}},O=(e,t,n={})=>(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-[11px] ${n.wide?`sm:col-span-2`:``}`,children:[t,(0,N.jsx)(`input`,{className:`fld fld-mono`,type:n.type??`text`,placeholder:n.placeholder,value:_[e],onChange:t=>v(n=>({...n,[e]:t.target.value}))})]});return(0,N.jsxs)(u,{tab:`1 · ${s(`modelsHub.step.model`)}`,flush:!0,aux:(0,N.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-2)]`,children:s(`modelsHub.pickModelAux`,{n:String(e.length)})}),children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 border-b border-[color:var(--color-rule)] p-3`,children:[(0,N.jsxs)(`label`,{className:`block min-w-[16rem] flex-1`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:s(`modelsHub.searchLabel`)}),(0,N.jsx)(`input`,{className:`fld`,value:l,onChange:e=>d(e.target.value),placeholder:s(`modelsHub.searchPlaceholder`)})]}),(0,N.jsxs)(`div`,{role:`group`,"aria-label":s(`modelsHub.filterLabel`),className:`flex`,children:[(0,N.jsx)(`button`,{type:`button`,"aria-pressed":!f,className:`btn btn-sm ${f?``:`!border-[color:var(--color-ink)] !bg-[color:var(--color-ink)] !text-white`}`,onClick:()=>p(!1),children:s(`modelsHub.filterAll`,{n:String(e.length)})}),(0,N.jsx)(`button`,{type:`button`,"aria-pressed":f,className:`btn btn-sm -ml-px ${f?`!border-[color:var(--color-ink)] !bg-[color:var(--color-ink)] !text-white`:``}`,onClick:()=>p(!0),children:s(`modelsHub.filterHere`,{n:String(C)})})]})]}),S&&(0,N.jsx)(`div`,{className:`px-3`,children:(0,N.jsx)(te,{tone:`warn`,children:S})}),(0,N.jsxs)(`ul`,{className:`divide-y divide-[color:var(--color-rule)]`,children:[T.map(e=>{let t=n===e.adapter_id,r=c.enabled&&c.adapterId===e.adapter_id&&!!c.provider,a=ie(e);return(0,N.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 py-2.5 pr-3 ${t?`border-l-[3px] border-l-[color:var(--color-sig)] bg-[color:var(--color-sig-wash)] pl-[9px]`:`bg-[color:var(--color-sheet)] pl-3`}`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-[14px] font-bold`,children:e.display_name}),H[e.maturity]&&(0,N.jsx)(h,{tone:be[e.maturity]??`neutral`,children:s(H[e.maturity])}),e.adapter_id===`monkeyocrv2-parsing`&&(0,N.jsx)(h,{tone:`ok`,children:s(`cloud.models.defaultBadge`)}),oe(e)&&(0,N.jsx)(h,{tone:`neutral`,children:s(`cloud.models.customBadge`)}),r&&(0,N.jsx)(h,{tone:`sig`,children:s(`cloud.models.inUseNow`)})]}),(0,N.jsxs)(`div`,{className:`mt-0.5 text-[12px] text-[color:var(--color-ink-2)]`,children:[E(e)||`—`,e.approx_size_gb!=null&&(0,N.jsxs)(`span`,{className:`mono text-[color:var(--color-ink-3)]`,children:[` · ~`,e.approx_size_gb,` GB`]})]}),(0,N.jsxs)(`details`,{className:`mt-0.5 text-[11px] text-[color:var(--color-ink-3)]`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer`,children:s(`modelsHub.showDetails`)}),(0,N.jsxs)(`div`,{className:`mt-1 space-y-0.5`,children:[(0,N.jsx)(`div`,{className:`mono`,children:e.hf_repo}),e.local?.mlx_repo&&(0,N.jsxs)(`div`,{className:`mono`,children:[`MLX: `,e.local.mlx_repo]}),e.license_note&&(0,N.jsx)(`div`,{children:e.license_note}),oe(e)&&(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm mt-1`,disabled:b===e.adapter_id,onClick:()=>void D(e.adapter_id),children:s(`cloud.models.removeCustom`)})]})]})]}),(0,N.jsx)(`div`,{className:`w-[13rem] text-[11px] leading-snug`,children:e.local?.runnable?(0,N.jsx)(`span`,{className:`font-semibold text-[color:var(--color-ok)]`,children:s(`modelsHub.runsHere`,{runtime:j(e.local.runtime)})}):a?(0,N.jsx)(`span`,{className:`text-[color:var(--color-ink-2)]`,children:s(`modelsHub.remoteOnly`)}):(0,N.jsx)(`span`,{className:`text-[color:var(--color-warn)]`,children:s(`modelsHub.notUsableYet`)})}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm w-[7.5rem] justify-center ${t||!n?`btn-primary`:``}`,disabled:!a,title:a?void 0:s(`modelsHub.notUsableYetHint`),onClick:()=>i(e),children:s(t?`modelsHub.continue`:`modelsHub.choose`)})]},e.adapter_id)}),T.length===0&&(0,N.jsx)(`li`,{className:`p-3 text-[12px] text-[color:var(--color-ink-2)]`,children:t||e.length===0?s(`cloud.models.loading`):s(`modelsHub.noMatch`)})]}),(0,N.jsxs)(`div`,{className:`border-t border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:s(`cloud.models.addCustomHint`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,"aria-expanded":m,onClick:()=>ee(e=>!e),children:s(m?`cloud.models.addCustomCollapse`:`cloud.models.addCustomOpen`)})]}),m&&(0,N.jsxs)(`div`,{className:`mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[O(`hf_repo`,s(`cloud.models.fieldHfRepo`),{placeholder:`org/model-name`}),O(`display_name`,s(`cloud.models.fieldDisplayName`)),O(`hf_revision`,s(`cloud.models.fieldHfRevision`)),O(`served_model_name`,s(`cloud.models.fieldServedName`)),O(`max_model_len`,s(`cloud.models.fieldMaxModelLen`),{type:`number`}),O(`gpu_memory_utilization`,s(`cloud.models.fieldGpuMemUtil`),{type:`number`}),O(`extra_args`,s(`cloud.models.fieldExtraArgs`),{placeholder:`--dtype bfloat16 --tensor-parallel-size 1`,wide:!0}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px] sm:col-span-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:_.trust_remote_code,onChange:e=>v(t=>({...t,trust_remote_code:e.target.checked}))}),s(`cloud.models.fieldTrustRemoteCode`)]}),(0,N.jsx)(`div`,{className:`sm:col-span-2`,children:(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,disabled:y||!_.hf_repo.trim(),onClick:()=>void se(),children:s(y?`cloud.models.downloadStarting`:`cloud.models.addCustomSubmit`)})})]})]})]})}function we({model:e,selected:t,caps:r,onSelect:i}){let{t:o}=a(),s=A(e),c=r?.local_compute;return(0,N.jsxs)(u,{tab:`2 · ${o(`modelsHub.step.destination`)}`,aux:(0,N.jsx)(`span`,{className:`text-[11px] font-semibold`,children:e.display_name}),children:[(0,N.jsx)(`p`,{className:`max-w-[72ch] text-[12px] text-[color:var(--color-ink-2)]`,children:o(`modelsHub.chooseDestinationHint`)}),c&&(0,N.jsxs)(`p`,{className:`mt-2 border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-2 py-1.5 text-[11px] text-[color:var(--color-ink-2)]`,children:[(0,N.jsx)(`span`,{className:`lbl !mb-0 mr-2 inline`,children:o(`localCompute.title`)}),o(`localCompute.machine`,{os:c.platform,arch:c.arch}),` · `,c.memory_gb?o(`localCompute.memory`,{gb:String(c.memory_gb)}):o(`localCompute.memoryUnknown`),` · `,c.usable_runtimes.length>0?c.usable_runtimes.map(e=>j(e)).join(`, `):o(`localCompute.reason.no_local_runtime`)]}),(0,N.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:w.map(r=>{let a=S(e,r),c=t===r,l=s===r;return(0,N.jsxs)(`button`,{type:`button`,disabled:!a.ok,"aria-pressed":c,onClick:()=>i(r),className:`group flex flex-col border p-3 text-left disabled:cursor-not-allowed disabled:bg-[color:var(--color-fill)] ${c?`border-[color:var(--color-sig)] bg-[color:var(--color-sig-wash)] outline outline-1 outline-[color:var(--color-sig)]`:`border-[color:var(--color-rule)] bg-[color:var(--color-sheet)] hover:border-[color:var(--color-ink)] disabled:hover:border-[color:var(--color-rule)]`}`,children:[(0,N.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-[14px] font-bold ${a.ok?``:`text-[color:var(--color-ink-3)]`}`,children:o(`recognition.provider.${r}`)}),l&&(0,N.jsx)(h,{tone:`ok`,children:o(`modelsHub.recommended`)}),a.publish&&(0,N.jsx)(h,{tone:`neutral`,children:o(`modelsHub.publishBadge`)})]}),a.ok?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`mt-1 block text-[12px] text-[color:var(--color-ink)]`,children:r===`local`?o(`modelsHub.dest.localBody`,{runtime:j(e.local.runtime)}):o(`modelsHub.dest.${r}Body`)}),(0,N.jsxs)(`span`,{className:`mt-2 block border-t border-[color:var(--color-rule)] pt-1.5 text-[11px] text-[color:var(--color-ink-2)]`,children:[(0,N.jsx)(`span`,{className:`lbl !mb-0 inline`,children:o(`modelsHub.youWillNeed`)}),` `,r===`local`&&e.local.runtime===`mlx-vlm`?o(`modelsHub.dest.localNeedsMlx`,{repo:e.local.mlx_repo??e.hf_repo}):r===`local`?o(`modelsHub.dest.localNeedsVllm`,{size:e.approx_size_gb==null?`—`:`~${e.approx_size_gb} GB`}):o(`modelsHub.dest.${r}Needs`)]}),r===`local`&&e.vram_warning&&(0,N.jsxs)(`span`,{className:`mt-1.5 flex items-start gap-1 text-[11px] text-[color:var(--color-warn)]`,children:[(0,N.jsx)(n,{size:12}),(0,N.jsx)(`span`,{children:e.vram_warning})]})]}):(0,N.jsx)(`span`,{className:`mt-1 block text-[11px] text-[color:var(--color-ink-2)]`,children:a.reasonKey?o(a.reasonKey):null})]},r)})})]})}var Te={preparing:`cloud.models.servePhasePreparing`,preparing_repo:`cloud.models.servePhasePreparingRepo`,preparing_runtime:`cloud.models.servePhasePreparingRuntime`,preparing_draft:`cloud.models.servePhasePreparingDraft`,preparing_image:`cloud.models.servePhasePreparingImage`,launching:`cloud.models.servePhaseLaunching`,loading:`cloud.models.servePhaseLoading`,ready:`cloud.models.servePhaseReady`,failed:`cloud.models.servePhaseFailed`};function Ee({text:e}){let t=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e]),(0,N.jsx)(`pre`,{ref:t,className:`mono mt-1 max-h-40 overflow-auto whitespace-pre-wrap border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] p-2 text-[11px] leading-relaxed`,children:e})}function De({model:t,onChanged:i}){let{t:o}=a(),[s,c]=(0,M.useState)({running:!1,adapter_id:null,port:null,pid:null,error:null}),[l,d]=(0,M.useState)({state:`disconnected`}),[f,ee]=(0,M.useState)(`8889`),[h,_]=(0,M.useState)(!1),[y,re]=(0,M.useState)(null),[ie,x]=(0,M.useState)(!1),[S,ae]=(0,M.useState)(null),C=(0,M.useRef)(null),oe=v(),w=t.local.runtime===`mlx-vlm`,se=t.local.mlx_repo_choices??[],[D,O]=(0,M.useState)(t.local.mlx_repo??``);(0,M.useEffect)(()=>{O(t.local.mlx_repo??``)},[t.local.mlx_repo]);let k=async()=>{try{c(await e(`/models/serve/status`))}catch{}},A=async()=>{try{d(await e(`/models/huggingface/auth`))}catch{}};(0,M.useEffect)(()=>{k(),A();let e=setInterval(()=>void k(),3e3);return()=>clearInterval(e)},[]),(0,M.useEffect)(()=>{if(l.state!==`awaiting_authorization`)return;let e=setInterval(()=>void A(),3e3);return()=>clearInterval(e)},[l.state]);let ce=t.runtime_state===`installing`;(0,M.useEffect)(()=>{if(!t.downloading&&!ce){C.current=null,ae(null);return}let e=setInterval(()=>void i(),2e3);return()=>clearInterval(e)},[t.downloading,ce]),(0,M.useEffect)(()=>{if(!t.downloading)return;let e=Date.now(),n=C.current;if(!n||t.size_bytes<n.bytes){C.current={t:e,bytes:t.size_bytes},ae(null);return}let r=(e-n.t)/1e3;r>=3&&ae((t.size_bytes-n.bytes)/r)},[t.downloading,t.size_bytes]);let le=s.adapter_id===t.adapter_id,F=le&&!!s.ready,I=le&&!F&&(!!s.starting||s.running)&&s.phase!==`failed`,L=le&&s.phase===`failed`,R=!le&&s.adapter_id&&(s.running||s.starting),z=(0,M.useRef)(!1);(0,M.useEffect)(()=>{F&&!z.current&&b().catch(()=>{}),z.current=F},[F]);let B=w||t.installed,ue=B?`done`:t.state===`failed`?`failed`:`active`,de=B?F?`done`:L?`failed`:`active`:`waiting`,fe=F?`done`:`waiting`,V=async(e,t)=>{_(!0),re(null);try{await e()}catch(e){re(o(t,{error:String(e)}))}finally{_(!1)}},pe=()=>V(async()=>{await g(`/models/${t.adapter_id}/download`,{}),await i()},`cloud.models.downloadError`),me=()=>V(async()=>{await g(`/models/${t.adapter_id}/download/cancel`,{}),await i()},`cloud.models.cancelError`),he=()=>{if(!ie){x(!0),setTimeout(()=>x(!1),5e3);return}x(!1),V(async()=>{await r(`/models/${t.adapter_id}`),await i()},`cloud.models.deleteError`)},ge=()=>V(async()=>{let e=Number(f);if(!Number.isInteger(e)||e<1024||e>65535)throw Error(o(`cloud.models.invalidPort`));c(await g(`/models/${t.adapter_id}/serve/start`,{port:e})),await k()},`cloud.models.serveError`),_e=()=>V(async()=>{await g(`/models/serve/stop`,{}),await k()},`cloud.models.serveError`),ve=n=>V(async()=>{let r=await e(`/system/model-settings/${t.adapter_id}`);await p(`/system/model-settings/${t.adapter_id}`,{...r.overrides,mlx:{...r.overrides.mlx??{},repo:n}}),await i()},`cloud.models.serveError`),ye=async()=>{let e=window.open(``,`_blank`,`noopener,noreferrer`);try{let t=await g(`/models/huggingface/auth/start`,{});d(t),t.verification_uri_complete?e?e.location.href=t.verification_uri_complete:window.open(t.verification_uri_complete,`_blank`,`noopener,noreferrer`):e?.close()}catch(t){e?.close(),re(String(t))}},H=t.expected_bytes??(t.approx_size_gb?t.approx_size_gb*1024**3:null),be=H?Math.min(99,t.size_bytes/H*100):void 0,xe=S&&S>0&&H?Math.max(0,H-t.size_bytes)/S:null,Se=(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,N.jsx)(`span`,{children:l.state===`connected`?o(`cloud.models.hfConnected`,{username:l.username||``}):l.state===`awaiting_authorization`?o(`cloud.models.hfAwaiting`,{code:l.user_code||``}):o(`cloud.models.hfNotConnected`)}),l.state===`awaiting_authorization`&&l.verification_uri_complete&&(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>window.open(l.verification_uri_complete,`_blank`,`noopener,noreferrer`),children:o(`cloud.models.hfOpenLogin`)}),l.state!==`connected`&&l.state!==`awaiting_authorization`&&(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>void ye(),children:o(`cloud.models.hfConnect`)}),l.error&&(0,N.jsx)(`span`,{className:`text-[color:var(--color-sig-text)]`,children:l.error})]});return(0,N.jsxs)(u,{tab:`3 · ${o(`modelsHub.step.configure`)}`,aux:(0,N.jsxs)(`span`,{className:`text-[11px] font-semibold`,children:[t.display_name,` · `,o(`recognition.provider.local`),` · `,j(t.local.runtime)]}),children:[y&&(0,N.jsx)(te,{tone:`warn`,children:y}),t.vram_warning&&(0,N.jsxs)(`p`,{className:`mb-2 flex items-start gap-1 text-[11px] text-[color:var(--color-warn)]`,children:[(0,N.jsx)(n,{size:12}),(0,N.jsx)(`span`,{children:t.vram_warning})]}),(0,N.jsxs)(`ol`,{children:[(0,N.jsxs)(P,{n:1,title:o(`modelsHub.local.weightsTitle`),state:ue,stateLabel:w?o(`modelsHub.local.weightsAuto`):t.installed?o(`cloud.models.installed`,{size:E(t.size_bytes)}):t.downloading?o(`cloud.models.downloading`,{size:E(t.size_bytes)}):t.state===`failed`?o(`cloud.models.failed`):o(`cloud.models.notInstalled`),children:[w?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:o(`modelsHub.local.weightsMlxBody`,{repo:t.local.mlx_repo??t.hf_repo})}),se.length>0&&(0,N.jsxs)(`label`,{className:`mt-2 block max-w-md`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:o(`settings.mlxField.repo`)}),(0,N.jsx)(`select`,{className:`fld mt-1 w-full`,value:D,disabled:!oe||h||F||I,onChange:e=>{let t=e.target.value;t&&t!==D&&ve(t)},children:se.map(e=>(0,N.jsxs)(`option`,{value:e.repo,disabled:e.fits===!1,children:[e.variant,` · `,e.repo,e.fits===!1?` — ${o(`modelsHub.variantTooBig`)}`:``]},e.repo))}),(0,N.jsx)(`span`,{className:`mt-1 block text-[10px] text-[color:var(--color-ink-3)]`,children:o(`settings.mlxRepoHint`)})]})]}):t.installed?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`mono text-[11px]`,children:t.path??t.hf_repo}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm ${ie?`text-[color:var(--color-sig-text)]`:``}`,disabled:h||I||F,onClick:he,children:o(ie?`cloud.models.confirmDelete`:`modelsHub.local.deleteWeights`)})]}):t.downloading?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(m,{value:be,indeterminate:be==null,label:o(`cloud.models.downloadProgressAria`,{name:t.display_name})}),(0,N.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-baseline gap-x-3 text-[11px]`,children:[(0,N.jsx)(`span`,{className:`mono`,children:H?o(`cloud.models.downloadedOf`,{done:E(t.size_bytes),total:E(H)}):o(`cloud.models.downloadedSoFar`,{done:E(t.size_bytes)})}),be!=null&&(0,N.jsxs)(`span`,{className:`mono`,children:[Math.round(be),`%`]}),S!=null&&(0,N.jsx)(`span`,{className:`mono`,children:o(`cloud.models.downloadRate`,{rate:E(S)})}),(0,N.jsx)(`span`,{children:xe==null?o(`cloud.models.downloadEtaUnknown`):o(`cloud.models.downloadEta`,{time:T(xe)})}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm ml-auto`,disabled:h,onClick:()=>void me(),children:o(`cloud.models.cancel`)})]})]}):(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:o(`modelsHub.local.weightsVllmBody`,{repo:t.hf_repo,size:t.approx_size_gb==null?`—`:`~${t.approx_size_gb} GB`})}),t.checkpoint_detached&&(0,N.jsx)(`p`,{className:`mt-1 text-[color:var(--color-warn)]`,children:o(`cloud.models.checkpointDetached`)}),t.downloadable!==!1&&(0,N.jsx)(`button`,{type:`button`,className:`btn btn-primary mt-2`,disabled:h,onClick:()=>void pe(),children:o(h?`cloud.models.downloadStarting`:`modelsHub.local.downloadCta`)})]}),t.error&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-sig-text)]`,children:t.error}),t.adapter_id===`paddleocr-vl`&&t.runtime_state&&t.runtime_state!==`ready`&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px]`,children:o(`cloud.models.paddleRuntime`,{state:t.runtime_state})}),t.runtime_error&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-sig-text)]`,children:t.runtime_error}),!B||w?Se:null]}),(0,N.jsxs)(P,{n:2,title:o(`modelsHub.local.serverTitle`),state:de,stateLabel:F?o(`cloud.models.serving`,{port:String(s.port)}):o(I?Te[s.phase??`preparing`]??`cloud.models.servePhasePreparing`:L?`cloud.models.servePhaseFailed`:B?`modelsHub.local.serverStopped`:`modelsHub.local.waitingWeights`),children:[R&&(0,N.jsx)(`p`,{className:`mb-2 text-[color:var(--color-warn)]`,children:o(`modelsHub.local.otherServing`,{model:s.adapter_id??``})}),F||I?(0,N.jsxs)(`div`,{children:[I&&(0,N.jsx)(m,{indeterminate:!0,label:o(`cloud.models.serveProgressAria`,{name:t.display_name})}),(0,N.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-3 text-[11px]`,children:[(0,N.jsxs)(`span`,{className:`mono`,children:[`http://127.0.0.1:`,s.port??f,`/v1`]}),s.elapsed_s!=null&&I&&(0,N.jsx)(`span`,{className:`mono text-[color:var(--color-ink-3)]`,children:o(`cloud.models.serveElapsed`,{time:T(s.elapsed_s)})}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-sm ml-auto`,disabled:h,onClick:()=>void _e(),children:o(`cloud.models.serveStop`)})]}),I&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-ink-3)]`,children:o(`cloud.models.serveProgressHint`)})]}):(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:o(w?`modelsHub.local.serverBodyMlx`:`modelsHub.local.serverBodyVllm`)}),(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-end gap-2`,children:[(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:o(`cloud.models.servePort`)}),(0,N.jsx)(`input`,{className:`fld fld-mono w-24`,type:`number`,min:1024,max:65535,value:f,disabled:!B,onChange:e=>ee(e.target.value)})]}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!B||h||!t.local_serve_ready,onClick:()=>void ge(),children:o(h?`cloud.models.serveStarting`:L?`modelsHub.local.retry`:`modelsHub.local.startCta`)})]})]}),le&&s.error&&(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-[color:var(--color-sig-text)]`,children:s.error}),le&&s.log_tail&&(I||L)&&(0,N.jsxs)(`details`,{className:`mt-1.5`,open:L,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-3)]`,children:o(`cloud.models.serveLog`)}),(0,N.jsx)(Ee,{text:s.log_tail})]})]}),(0,N.jsx)(P,{n:3,title:o(`modelsHub.local.readyTitle`),state:fe,stateLabel:o(F?`recognition.modelReady`:`modelsHub.local.notYet`),children:F?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{children:o(`modelsHub.local.readyBody`,{model:t.display_name})}),(0,N.jsx)(ne,{to:`/`,className:`btn btn-primary no-underline`,children:o(`modelsHub.goRecognize`)}),(0,N.jsx)(ne,{to:`/playground`,className:`btn no-underline`,children:o(`modelsHub.tryPlayground`)})]}):(0,N.jsx)(`p`,{children:o(`modelsHub.local.readyPending`)})})]})]})}var Oe={model:`modello`,destination:`dove`,configure:`configura`},ke={modello:`model`,dove:`destination`,configura:`configure`};function Ae(){let{t}=a(),n=re(),[r,s]=y(),[c,l]=(0,M.useState)(O),[d,f]=(0,M.useState)(!0),[m,g]=(0,M.useState)(null),[_,v]=(0,M.useState)(null),[ie,oe]=(0,M.useState)(!1),[w,T]=(0,M.useState)(!1),[E,se]=(0,M.useState)(!1),k=(0,M.useRef)(null),A=(0,M.useCallback)(async(e=!0)=>{try{l(await ae(e))}catch(e){g(e)}finally{f(!1)}},[]);(0,M.useEffect)(()=>{b().catch(g),A(!0),e(`/system/info`).then(e=>v(e.capabilities??null)).catch(()=>{})},[A]);let j=!!(n.provider&&n.adapterId),ce=r.get(`modello`),P=r.get(`dove`),le=ke[r.get(`passo`)??``]??null,F=!ce&&!P&&!le,I=ce??(F&&j?n.adapterId:null),L=P??(F&&j?D(n.provider):null),R=C(L)?L:null,z=(0,M.useMemo)(()=>c.find(e=>e.adapter_id===I)??null,[c,I]),B=x(le??(F&&j?`configure`:null),z,R),ue=e=>{let t=new URLSearchParams,n=e.model===void 0?I:e.model,r=e.dest===void 0?R:e.dest;n&&t.set(`modello`,n),r&&t.set(`dove`,r),t.set(`passo`,Oe[e.step]),oe(!1),s(t);let i=k.current?.getBoundingClientRect().top;i!=null&&i<0&&k.current?.scrollIntoView({block:`start`})},de=async t=>{if(z){se(!0),g(null);try{let n=await e(`/system/model-settings/${z.adapter_id}`);await p(`/system/model-settings/${z.adapter_id}`,{...n.overrides,mlx:{...n.overrides.mlx??{},repo:t}}),await A(!0)}catch(e){g(e)}finally{se(!1),T(!1),ue({dest:`local`,step:`configure`})}}},fe=e=>{let t=R&&S(e,R).ok?R:null;ue({model:e.adapter_id,dest:t,step:`destination`})},V=n.enabled&&j,pe=V&&n.available,me=D(n.provider),he=c.find(e=>e.adapter_id===n.adapterId)?.display_name??n.model,ge=[{id:`model`,n:1,label:t(`modelsHub.step.model`),value:z?.display_name??null,enabled:!0},{id:`destination`,n:2,label:t(`modelsHub.step.destination`),value:R&&z?t(`recognition.provider.${R}`):null,enabled:!!z},{id:`configure`,n:3,label:t(`modelsHub.step.configure`),value:z&&R?pe&&z.adapter_id===n.adapterId&&R===me?t(`modelsHub.stepReady`):t(`modelsHub.stepConfiguring`):null,enabled:!!z&&!!R}];return(0,N.jsxs)(`div`,{className:`p-3`,children:[(0,N.jsx)(o,{title:t(`nav.models`),intro:t(`modelsHub.intro`)}),m!=null&&(0,N.jsx)(`div`,{className:`mb-3`,children:(0,N.jsx)(ee,{error:m})}),(0,N.jsx)(u,{tab:t(`modelsHub.inUseTitle`),quiet:!0,aux:(0,N.jsx)(h,{tone:pe?`ok`:V?`warn`:`neutral`,children:t(pe?`recognition.modelReady`:V?`recognition.modelUnavailable`:`modelsHub.nothingInUse`)}),children:V?(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:t(`modelsHub.runningModel`)}),(0,N.jsx)(`div`,{className:`truncate text-[16px] font-bold`,children:he})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`lbl`,children:t(`cloud.models.destinationLabel`)}),(0,N.jsx)(`div`,{className:`text-[14px] font-semibold`,children:t(`recognition.provider.${me??n.provider}`)})]}),(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`lbl`,children:t(`modelsHub.endpoint`)}),(0,N.jsx)(`div`,{className:`mono truncate text-[12px]`,children:n.url||`—`})]}),(0,N.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(B!==`configure`||I!==n.adapterId||R!==me)&&(0,N.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ue({model:n.adapterId,dest:me,step:`configure`}),children:t(`modelsHub.manageInUse`)}),pe&&(0,N.jsx)(ne,{to:`/`,className:`btn btn-primary no-underline`,children:t(`modelsHub.goRecognize`)})]})]}):(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:t(`modelsHub.nothingInUseHint`)})}),(0,N.jsx)(`nav`,{ref:k,"aria-label":t(`modelsHub.stepsLabel`),className:`mt-3 scroll-mt-3`,children:(0,N.jsx)(`ol`,{className:`grid border border-[color:var(--color-rule)] sm:grid-cols-3`,children:ge.map(e=>{let n=e.id===B;return(0,N.jsx)(`li`,{className:`border-b border-[color:var(--color-rule)] last:border-b-0 sm:border-b-0 sm:border-r sm:last:border-r-0`,children:(0,N.jsxs)(`button`,{type:`button`,disabled:!e.enabled,"aria-current":n?`step`:void 0,onClick:()=>ue({step:e.id}),className:`relative flex w-full items-center gap-2.5 px-3 py-2 text-left disabled:cursor-not-allowed ${n?`bg-[color:var(--color-ink)] text-white`:`bg-[color:var(--color-sheet)] hover:bg-[color:var(--color-fill)] disabled:hover:bg-[color:var(--color-sheet)]`}`,children:[(0,N.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center text-[12px] font-bold ${n?`bg-[color:var(--color-sig-plate)] text-white`:e.value?`bg-[color:var(--color-ink)] text-white`:`border border-[color:var(--color-rule)] text-[color:var(--color-ink-3)]`}`,"aria-hidden":!0,children:e.n}),(0,N.jsxs)(`span`,{className:`min-w-0`,children:[(0,N.jsx)(`span`,{className:`block text-[11px] font-semibold uppercase tracking-[0.04em] ${n?`text-white/80`:e.enabled?`text-[color:var(--color-ink-2)]`:`text-[color:var(--color-ink-3)]`}`,children:e.label}),(0,N.jsx)(`span`,{className:`block truncate text-[13px] font-semibold ${n?`text-white`:e.enabled?``:`text-[color:var(--color-ink-3)]`}`,children:e.value??(n?t(`modelsHub.stepNow`):`—`)})]}),n&&(0,N.jsx)(`span`,{className:`absolute inset-x-0 bottom-0 h-[3px] bg-[color:var(--color-sig)]`,"aria-hidden":!0})]})},e.id)})})}),(0,N.jsxs)(`div`,{className:`mt-3`,children:[B===`model`&&(0,N.jsx)(Ce,{models:c,loading:d,selectedId:z?.adapter_id??null,onSelect:fe,onChanged:()=>A(!0)}),B===`destination`&&z&&(0,N.jsx)(we,{model:z,selected:R,caps:_,onSelect:e=>{if(e===`local`&&(z.local.mlx_repo_choices?.length??0)>1){T(!0);return}ue({dest:e,step:`configure`})}}),B===`configure`&&z&&R===`local`&&(0,N.jsx)(De,{model:z,onChanged:()=>A(!0)}),B===`configure`&&z&&R&&R!==`local`&&(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(`p`,{className:`max-w-[80ch] text-[12px] text-[color:var(--color-ink-2)]`,children:t(`modelsHub.remoteIntro`,{model:z.display_name,provider:t(`recognition.provider.${R}`)})}),ie&&(0,N.jsxs)(te,{tone:`ok`,children:[t(`modelsHub.remoteDone`,{model:z.display_name,provider:t(`recognition.provider.${R}`)}),` `,(0,N.jsx)(ne,{to:`/`,children:t(`modelsHub.goRecognize`)})]}),(0,N.jsx)(ye,{open:!0,inline:!0,onlyProvider:R,focusProvider:R,focusAdapterId:z.adapter_id,focusModelLabel:z.display_name,onClose:()=>{b().catch(()=>{}),oe(!0)}},`${R}:${z.adapter_id}`)]}),B!==`model`&&!z&&!d&&(0,N.jsx)(te,{tone:`warn`,children:t(`modelsHub.modelMissing`)})]}),w&&z&&(0,N.jsxs)(i,{title:t(`modelsHub.localVariantTitle`),onClose:()=>T(!1),children:[(0,N.jsx)(`p`,{className:`max-w-[70ch] text-[12px] text-[color:var(--color-ink-2)]`,children:t(`modelsHub.localVariantIntro`,{model:z.display_name})}),(0,N.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:(z.local.mlx_repo_choices??[]).map(e=>(0,N.jsxs)(`button`,{type:`button`,className:`btn text-left`,disabled:E||e.fits===!1,onClick:()=>void de(e.repo),children:[(0,N.jsx)(`span`,{className:`block font-semibold`,children:e.variant}),(0,N.jsx)(`span`,{className:`mono block text-[11px] text-[color:var(--color-ink-3)]`,children:e.repo}),e.fits===!1&&(0,N.jsx)(`span`,{className:`block text-[11px] text-[color:var(--color-warn)]`,children:t(`modelsHub.variantTooBig`)})]},e.repo))})]}),(0,N.jsx)(`div`,{className:`mt-3`,children:(0,N.jsxs)(u,{tab:t(`ux.modelTools`),quiet:!0,children:[(0,N.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:t(`modelsHub.toolsIntro`)}),(0,N.jsx)(`ul`,{className:`mt-3 grid border-t border-[color:var(--color-rule)] sm:grid-cols-2`,children:[{to:`/fine-tuning`,label:t(`nav.training`),hint:t(`ux.refineToolHint`)},{to:`/playground`,label:t(`nav.playground`),hint:t(`modelsHub.toolPlaygroundHint`)}].map(e=>(0,N.jsx)(`li`,{className:`border-b border-[color:var(--color-rule)]`,children:(0,N.jsxs)(ne,{to:e.to,className:`block px-1 py-1.5 no-underline hover:bg-[color:var(--color-fill)]`,children:[(0,N.jsx)(`span`,{className:`text-[13px] font-semibold text-[color:var(--color-ink)]`,children:e.label}),(0,N.jsx)(`span`,{className:`mt-0.5 block text-[13px] text-[color:var(--color-ink-2)]`,children:e.hint})]})},e.to))})]})})]})}export{Ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ct as e,j as t,l as n,lt as r,t as i}from"./ui-BtIxuKN2.js";import{O as a}from"./index-DVWuV1Ff.js";var o=r();function s({branch:n}){let{t:r}=e(),s=n.state===`blocked`,c=n.state===`active`;return(0,o.jsx)(`li`,{className:`border-b border-[color:var(--color-rule)] px-2 py-2 last:border-b-0`,children:(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,o.jsx)(`span`,{className:n.recommended?`text-[15px] font-bold tracking-[-0.02em]`:`text-[14px] font-semibold`,children:n.name}),(s||c)&&(0,o.jsx)(i,{tone:s?`warn`:`sig`,children:r(s?`pipeline.stateBlocked`:`pipeline.stateCurrent`)}),n.detail&&(0,o.jsx)(`span`,{className:`mono text-[12px] text-[color:var(--color-ink-2)]`,children:n.detail}),s&&(0,o.jsxs)(`span`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:[r(`pipeline.needs`),`: `,n.needs]}),!s&&(0,o.jsxs)(a,{to:n.action.to,className:`ml-auto shrink-0 no-underline ${n.recommended?`btn btn-primary`:`btn btn-sm`}`,children:[(0,o.jsx)(t,{size:12}),n.action.label]})]})})}function c({branches:t}){let{t:r}=e();return(0,o.jsx)(n,{tab:r(`pipeline.pathsTab`),flush:!0,aux:(0,o.jsx)(`span`,{children:r(`pipeline.pathsHint`)}),children:(0,o.jsx)(`ul`,{className:`ruled`,children:t.map(e=>(0,o.jsx)(s,{branch:e},e.id))})})}function l({stages:n,here:r}){let{t:s}=e(),c=n.findIndex(e=>e.id===r);if(c<0)return null;let l=n[c];if(l.state!==`blocked`)return null;let u=r===`train`?`dataset`:r===`evaluate`?`annotate`:null,d=u?n.find(e=>e.id===u&&e.state!==`done`):n.slice(0,c).find(e=>e.state!==`done`);return(0,o.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-x-3 gap-y-1.5 border border-[color:var(--color-warn)] bg-[color:var(--color-warn-wash)] px-2 py-1.5`,children:[(0,o.jsx)(i,{tone:`warn`,children:s(`pipeline.stateBlocked`)}),(0,o.jsxs)(`span`,{className:`text-[12px] text-[color:var(--color-ink)]`,children:[s(`pipeline.requires`),` `,l.needs]}),d&&(0,o.jsxs)(a,{to:d.action.to,className:`btn btn-sm ml-auto no-underline`,children:[(0,o.jsx)(t,{size:11}),d.action.label]})]})}export{l as n,c as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{$ as e,C as t,M as n,a as ee,ct as r,d as i,dt as a,ht as o,i as s,l as c,lt as l,r as u,st as d,tt as f,u as p}from"./ui-BtIxuKN2.js";import{O as m,T as h,a as g,c as _,i as v,r as y}from"./index-DVWuV1Ff.js";import{i as b}from"./vocab-C9TBNLaa.js";var x=o(a(),1),S=l();function C(e,t){return e&&[`local`,`ssh`,`vast`,`runpod`,`modal`,`custom`].includes(e)?t(`recognition.provider.${e}`):e||t(`recognition.locationLocal`)}function w(){let{t:a}=r(),[o,l]=(0,x.useState)(``),[w,T]=(0,x.useState)([]),[E,D]=(0,x.useState)(null),O=h(),k=_(),[A,j]=(0,x.useState)(!1),[M,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(null),[I,L]=(0,x.useState)(null),[R,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(null),[H,U]=(0,x.useState)(`model`),[W,G]=(0,x.useState)(null);(0,x.useEffect)(()=>{e(`/system/prefill-engines`).then(e=>G(e.ocr)).catch(()=>G(null))},[]);let K=async t=>{if(l(t),v(t===``?null:t),T([]),D(null),N(null),t!==``)try{let n=await e(`/projects/${t}/pages`);T(n.items)}catch(e){F(e)}},q=y(e=>void K(e),F),J=async()=>{if(!(!o||!E)){j(!0),F(null),L(null);try{let e=await f(`/playground/parse`,{project_id:o,page_id:E,engine:$});N(e);let t=new Image;t.onload=()=>L({w:t.naturalWidth,h:t.naturalHeight}),t.src=`/api/pages/${E}/preview`}catch(e){F(e)}finally{j(!1)}}},Y=async()=>{if(!M)return;let e=M.items.map(e=>e.content?`${e.label}: ${e.content}`:e.label).join(`
|
|
2
|
+
|
|
3
|
+
`);try{await navigator.clipboard.writeText(e),z(!0),setTimeout(()=>z(!1),2e3)}catch{}},X=e=>I&&I.w?e/1e3*I.w:0,Z=e=>I&&I.h?e/1e3*I.h:0,Q=O.enabled&&O.available,$=H===`model`&&!Q&&W?.available?`ocr`:H,te=$===`ocr`?!!W?.available:Q;return(0,S.jsxs)(`div`,{className:`p-3`,children:[(0,S.jsx)(i,{title:a(`playground.title`),intro:a(`playground.intro`)}),(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3 border border-[color:var(--color-rule)] p-3`,children:[(0,S.jsx)(`p`,{className:`max-w-[85ch] text-[13px] text-[color:var(--color-ink-2)]`,children:a(`workflow.tryHint`)}),(0,S.jsx)(m,{to:`/`,className:`btn no-underline`,children:a(`workflow.saveRecognition`)}),(0,S.jsx)(m,{to:`/progetti`,className:`btn btn-sm no-underline`,children:a(`workflow.addPages`)})]}),$===`model`&&!O.enabled&&(0,S.jsxs)(`div`,{className:`mb-3 flex items-center justify-between border border-[color:var(--color-rule)] bg-[color:var(--color-fill)] px-3 py-2 text-[12px] text-[color:var(--color-ink-2)]`,children:[(0,S.jsx)(`span`,{children:a(`cloud.card.inferenceDisabledNotice`)}),(0,S.jsx)(m,{to:`/modelli`,className:`btn btn-sm`,children:O.model?a(`recognition.changeModel`):a(`recognition.chooseModel`)})]}),$===`model`&&O.enabled&&!O.available&&(0,S.jsx)(`div`,{className:`mb-3`,children:(0,S.jsxs)(p,{tone:`warn`,children:[(0,S.jsx)(`span`,{children:a(`recognition.unreachableModel`,{model:k(O.adapterId)??O.model,url:O.url})}),` `,(0,S.jsx)(m,{to:`/modelli`,className:`font-semibold underline underline-offset-2`,children:a(`recognition.changeModel`)})]})}),P!=null&&(0,S.jsx)(`div`,{className:`mb-3`,children:(0,S.jsx)(u,{error:P,onDismiss:()=>F(null)})}),(0,S.jsx)(`div`,{className:`mb-3`,children:(0,S.jsxs)(c,{tab:a(`playground.run`),children:[(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsx)(s,{label:a(`playground.project`),children:(0,S.jsxs)(`select`,{value:o,disabled:A,onChange:e=>void K(e.target.value===``?``:Number(e.target.value)),className:`fld`,children:[(0,S.jsx)(`option`,{value:``,children:a(`common.chooseProject`)}),q.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,S.jsx)(s,{label:a(`playground.page`),children:(0,S.jsxs)(`select`,{value:E??``,onChange:e=>{D(e.target.value===``?null:Number(e.target.value)),N(null),L(null)},disabled:A||w.length===0,className:`fld`,children:[(0,S.jsx)(`option`,{value:``,children:a(o===``?`playground.pickProject`:`playground.pickPage`)}),w.map(e=>(0,S.jsx)(`option`,{value:e.id,children:g(e)},e.id))]})})]}),(0,S.jsx)(`div`,{className:`mt-3 max-w-md`,children:(0,S.jsx)(s,{label:a(`playground.engine`),hint:$===`ocr`?a(`playground.ocrNote`):void 0,children:(0,S.jsxs)(`select`,{value:$,onChange:e=>U(e.target.value),className:`fld`,children:[(0,S.jsxs)(`option`,{value:`model`,disabled:!Q,children:[a(`playground.engineModel`,{name:k(O.adapterId)??(O.model||`—`)}),Q?``:` — ${a(`recognition.modelUnavailable`)}`]}),(0,S.jsx)(`option`,{value:`ocr`,disabled:!W?.available,children:a(`playground.engineOcr`,{engine:W?.engine??`—`})})]})})}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(`button`,{onClick:()=>void J(),disabled:A||!E||!te,className:`btn btn-primary`,children:[(0,S.jsx)(n,{size:13}),a(A?`playground.analysing`:`playground.analyse`)]}),M?.ok&&(0,S.jsxs)(`button`,{onClick:()=>void Y(),className:`btn`,children:[(0,S.jsx)(t,{size:13}),a(R?`playground.copied`:`playground.copyMd`)]}),M&&(0,S.jsxs)(`span`,{className:`mono ml-auto text-[11px] text-[color:var(--color-ink-3)]`,children:[M.model,` · `,C(M.provider,a)]})]})]})}),M&&E?(0,S.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,S.jsx)(c,{tab:a(`playground.predLayout`),quiet:!0,children:I?(0,S.jsxs)(`figure`,{className:`m-0`,children:[(0,S.jsxs)(`div`,{className:`lighttable relative overflow-hidden border border-[color:var(--color-rule)]`,children:[(0,S.jsx)(`img`,{src:`/api/pages/${E}/preview`,alt:a(`playground.overlayAltPred`),className:`block w-full`}),(0,S.jsx)(`svg`,{viewBox:`0 0 ${I.w} ${I.h}`,className:`absolute inset-0 h-full w-full`,"aria-hidden":`true`,children:M.items.map((e,t)=>(0,S.jsx)(`rect`,{x:X(e.bbox_norm[0]),y:Z(e.bbox_norm[1]),width:X(e.bbox_norm[2]-e.bbox_norm[0]),height:Z(e.bbox_norm[3]-e.bbox_norm[1]),fill:B===t?`rgb(230 0 18 / 0.24)`:`rgb(230 0 18 / 0.09)`,stroke:`#a3000e`,strokeWidth:B===t?3:1.4},t))})]}),(0,S.jsx)(`figcaption`,{className:`mt-1.5 text-[11px] text-[color:var(--color-ink-2)]`,children:d(`playground.legend`,M.items.length)})]}):(0,S.jsx)(`div`,{className:`py-4`,children:(0,S.jsx)(ee,{label:a(`playground.previewLoading`)})})}),(0,S.jsx)(c,{tab:a(`playground.blocks`),quiet:!0,flush:!0,aux:(0,S.jsx)(`span`,{children:b(M.items.length)}),children:(0,S.jsx)(`ol`,{className:`ruled max-h-[70vh] overflow-y-auto`,children:M.items.map((e,t)=>(0,S.jsxs)(`li`,{onMouseEnter:()=>V(t),onMouseLeave:()=>V(null),className:`px-2 py-1.5 ${B===t?`bg-[color:var(--color-sig-wash)]`:``}`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`mono w-6 shrink-0 text-[11px] text-[color:var(--color-ink-3)]`,children:t+1}),(0,S.jsx)(`span`,{className:`text-[12px] font-semibold`,children:e.label}),(0,S.jsxs)(`span`,{className:`mono ml-auto shrink-0 text-[11px] text-[color:var(--color-ink-3)]`,children:[`[`,e.bbox_px.join(`, `),`]`]})]}),e.content&&(0,S.jsx)(`p`,{className:`mt-1 pl-8 text-[12px] leading-relaxed text-[color:var(--color-ink-2)]`,children:e.content})]},t))})})]}):(0,S.jsx)(c,{tab:a(`playground.noRun`),quiet:!0,children:(0,S.jsxs)(`div`,{className:`flex flex-col items-start gap-2 py-4`,children:[(0,S.jsx)(n,{size:22}),(0,S.jsx)(`p`,{className:`max-w-[70ch] text-[12px] text-[color:var(--color-ink-2)]`,children:a(`playground.noRunBody`)})]})})]})}export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,G as t,I as n,J as r,V as i,Z as ee,c as te,ct as ne,dt as a,et as re,g as ie,ht as o,i as s,l as c,lt as ae,n as l,nt as oe,r as se,s as ce,st as u,t as le,tt as d,x as ue}from"./ui-BtIxuKN2.js";import{E as de,M as fe,O as f,a as p,i as pe,j as me,t as he}from"./index-DVWuV1Ff.js";import{n as ge,t as _e}from"./projectAccess-D3wgwunj.js";import{c as ve,l as ye,p as m,r as be}from"./vocab-C9TBNLaa.js";import{n as xe,t as Se}from"./ShareDialog-CNF0oznE.js";var h=o(a(),1),Ce=[`front`,`editorial`,`shipping`,`casualties`,`adverts`,`misc`],we=[`new`,`annotated`,`qa`,`exported`,`review`,`approved`],g=ae(),_=e=>`tabularium.scanReport.${e}`;function Te(e){try{let t=sessionStorage.getItem(_(e));return t?JSON.parse(t):null}catch{return null}}function v(){let{t:a}=ne(),o=he(),{id:ae}=fe(),v=Number(ae),Ee=me(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)([]),[C,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)({current:0,total:0}),[D,O]=(0,h.useState)(()=>Te(v)),[k,A]=(0,h.useState)(null),[De,j]=(0,h.useState)(!1),[M,N]=(0,h.useState)(``),[P,F]=(0,h.useState)(!1),[I,L]=(0,h.useState)(new Set),[Oe,ke]=(0,h.useState)(!1),[Ae,je]=(0,h.useState)(!1),[Me,Ne]=(0,h.useState)(null),[R,z]=(0,h.useState)(null),[Pe,Fe]=(0,h.useState)(!1),[B,Ie]=(0,h.useState)(null),V=(0,h.useRef)(null),H=(0,h.useRef)(null),[U,Le]=(0,h.useState)(!1),[W,Re]=(0,h.useState)([]),[G,ze]=(0,h.useState)([]),[Be,Ve]=(0,h.useState)([]),[He,Ue]=(0,h.useState)(!1),We=de(),K=y?ge(y,We):null,q=K?.can_manage===!0,J=K?.can_edit===!0;(0,h.useEffect)(()=>{e(`/system/domain-profiles`).then(e=>Re(e.items)).catch(()=>Re([])),e(`/system/model-adapters`).then(e=>ze(e.items)).catch(()=>ze([]))},[]),(0,h.useEffect)(()=>{O(Te(v)),L(new Set),e(`/projects/${v}`).then(e=>{b(e),pe(e.id)}).catch(A),e(`/projects/${v}/pages`).then(e=>S(e.items)).catch(A),e(`/projects/${v}/study-protocol`).then(z).catch(()=>z(null)),e(`/projects/${v}/activity`).then(e=>Ve(e.items)).catch(()=>Ve([]))},[v]);let Ge=async()=>{w(!0),A(null);try{let t=await d(`/projects/${v}/scan/start`),n={status:`running`};for(;await new Promise(e=>window.setTimeout(e,500)),n=await e(`/projects/${v}/scan/jobs/${t.job_id}`),E({current:n.current??0,total:n.total??0,file:n.current_file}),n.status===`running`;);if(n.status===`error`)throw Error(n.error||`Scansione fallita`);let r=n.report??{found_files:0,registered:0,duplicates:0,unsupported:0,errors:[]};(r.missing??0)>0&&await o({title:a(`project.missingPagesTitle`),message:a(`project.missingPagesConfirm`,{n:r.missing??0})})&&await d(`/projects/${v}/scan?confirm_missing=true`),O(r),sessionStorage.setItem(_(v),JSON.stringify(r));let i=await e(`/projects/${v}/pages`);S(i.items),b(await e(`/projects/${v}`))}catch(e){A(e)}finally{w(!1),E({current:0,total:0})}},Ke=async t=>{if(t?.length){Le(!0),A(null);try{let n=new FormData;Array.from(t).forEach(e=>n.append(`files`,e,e.name));let r=await fetch(`/api/projects/${v}/import-upload`,{method:`POST`,body:n});if(!r.ok)throw Error(a(`project.importFailed`,{status:r.status,detail:await r.text()}));let i=await r.json();O(i),sessionStorage.setItem(_(v),JSON.stringify(i)),S((await e(`/projects/${v}/pages`)).items)}catch(e){A(e)}finally{Le(!1),H.current&&(H.current.value=``),V.current&&(V.current.value=``)}}},Y=async(e,t,n)=>{S(r=>r.map(r=>r.id===e?{...r,[t]:n}:r));try{await re(`/pages/${e}`,{[t]:n||null})}catch(e){A(e)}},X=async(e,t)=>{let n=[...I];if(!(n.length===0||!t)){S(n=>n.map(n=>I.has(n.id)?{...n,[e]:t}:n));try{await Promise.all(n.map(n=>re(`/pages/${n}`,{[e]:t})))}catch(e){A(e)}}},qe=async()=>{if(I.size)try{await d(`/projects/${v}/gold-set`,[...I])}catch(e){A(e)}},Je=async e=>{A(null);try{await d(`/pages/${e}/approve`),S(t=>t.map(t=>t.id===e?{...t,status:`approved`}:t))}catch(e){A(e)}},Ye=async()=>{let t=await e(`/projects/${v}/pages`);S(t.items)},Xe=async e=>{je(!0),A(null),Ne(null);try{let t=await d(`/projects/${v}/pages/approve`,{page_ids:e,confirm_drafts:Oe});Ne(a(`project.approveResult`,{approved:t.approved,skipped:t.skipped_count})),L(new Set),await Ye()}catch(e){A(e)}finally{je(!1)}},Ze=async()=>{if(R){Fe(!0);try{let e=await oe(`/projects/${v}/study-protocol`,R);z(e)}catch(e){A(e)}finally{Fe(!1)}}},Qe=async()=>{try{let t=await e(`/projects/${v}/pilot-sample?target=40&seed=42`);Ie(t)}catch(e){A(e)}},$e=async()=>{if(B)try{await d(`/projects/${v}/pilot-sample/save`,B.pages.map(e=>e.id))}catch(e){A(e)}},et=async()=>{if(!(!y||M!==y.name)){F(!0);try{await ee(`/projects/${v}?confirm=true`),sessionStorage.removeItem(_(v)),Ee(`/progetti`)}catch(e){A(e),F(!1),j(!1)}}},tt=x.length>0&&I.size===x.length,nt=()=>L(tt?new Set:new Set(x.map(e=>e.id))),rt=e=>L(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Z=`px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-[0.04em] text-[color:var(--color-ink-2)]`,Q=`px-2 py-1 align-middle`,$=(0,h.useMemo)(()=>D?.errors.length??0,[D]);return(0,g.jsxs)(`div`,{className:`p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-end gap-x-4 gap-y-2 border-b border-[color:var(--color-rule-strong)] pb-3`,children:[(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsxs)(f,{to:`/progetti`,className:`mb-0.5 inline-flex items-center gap-1 text-[11px] font-semibold uppercase tracking-[0.04em] no-underline`,children:[(0,g.jsx)(n,{size:11}),a(`project.back`)]}),(0,g.jsx)(`h1`,{className:`truncate text-[26px] font-bold leading-tight tracking-[-0.03em]`,children:y?.name??a(`project.fallback`)}),y?.archive_dir&&(0,g.jsx)(`p`,{className:`mono mt-0.5 truncate text-[11px] text-[color:var(--color-ink-3)]`,children:y.archive_dir})]}),(0,g.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`mono text-[12px] text-[color:var(--color-ink-2)]`,children:ye(x.length)}),(0,g.jsxs)(`button`,{type:`button`,onClick:()=>Ue(!0),className:`btn`,title:a(`share.buttonTitle`),children:[(0,g.jsx)(r,{size:13}),a(q?`share.button`:`team.peopleAccess`)]}),y?.archive_dir&&(0,g.jsxs)(`button`,{onClick:()=>y?.archive_dir?void Ge():V.current?.click(),disabled:!J||C||U,className:`btn btn-primary`,children:[(0,g.jsx)(i,{size:13}),a(C?`project.scanBusy`:`project.scan`)]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>V.current?.click(),disabled:!J||U,className:`btn btn-primary`,children:a(U?`project.uploading`:`workflow.importFiles`)}),(0,g.jsx)(`input`,{ref:V,type:`file`,multiple:!0,accept:`.jpg,.jpeg,.png,.bmp,.webp,.tif,.tiff,.pdf`,className:`hidden`,onChange:e=>void Ke(e.target.files)}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>H.current?.click(),disabled:!J||U,className:`btn`,children:a(U?`project.uploading`:`project.chooseFolder`)}),(0,g.jsx)(`input`,{ref:H,type:`file`,multiple:!0,onChange:e=>void Ke(e.target.files),className:`hidden`,webkitdirectory:``,directory:``}),q&&(0,g.jsx)(ce,{label:a(`ux.projectActions`),children:(0,g.jsxs)(`button`,{onClick:()=>{N(``),j(!0)},className:`menu-item text-[color:var(--color-sig-text)]`,children:[(0,g.jsx)(t,{size:13}),a(`project.delete`)]})})]})]}),y&&(0,g.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[13px]`,children:[(0,g.jsx)(le,{tone:`neutral`,children:_e(K)}),(0,g.jsx)(`span`,{children:a(`team.ownerLine`,{name:y.owner_name??a(We.enabled?`team.noOwner`:`team.localProject`)})})]}),J&&(0,g.jsx)(`p`,{className:`mb-3 -mt-2 text-[11px] text-[color:var(--color-ink-2)]`,children:a(y?.archive_dir?`workflow.serverImportHint`:`workflow.uploadHint`)}),k!=null&&(0,g.jsx)(`div`,{className:`mb-3`,children:(0,g.jsx)(se,{error:k,onDismiss:()=>A(null)})}),x.length>0&&(0,g.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[J&&(0,g.jsx)(f,{to:`/`,className:`btn btn-primary no-underline`,children:a(`home.recognizePages`)}),(0,g.jsx)(f,{to:`/annotazione?project=${v}`,className:`btn no-underline`,children:a(J?`pipeline.steps.annotateAction`:`team.openReader`)}),(0,g.jsx)(f,{to:`/archivio`,className:`btn no-underline`,children:a(`nav.archive`)}),J&&(0,g.jsx)(f,{to:`/fine-tuning`,className:`btn no-underline`,children:a(`nav.training`)})]}),R&&(0,g.jsx)(`div`,{className:`mb-3`,children:(0,g.jsx)(l,{tab:a(`project.protocolTab`,{version:R.version}),quiet:!0,aux:(0,g.jsx)(`span`,{children:a(Pe?`project.protocolSaving`:`project.protocolVersioned`)}),children:(0,g.jsxs)(`fieldset`,{disabled:!J,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[(0,g.jsx)(s,{label:a(`project.objective`),children:(0,g.jsx)(`textarea`,{value:R.objective,onChange:e=>z(t=>t&&{...t,objective:e.target.value}),className:`fld min-h-16`,placeholder:a(`project.objectivePlaceholder`)})}),(0,g.jsx)(s,{label:a(`project.corpusScope`),hint:a(`project.corpusScopeHint`),children:(0,g.jsx)(`input`,{value:R.corpus_scope,onChange:e=>z(t=>t&&{...t,corpus_scope:e.target.value}),className:`fld`})}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,g.jsx)(s,{label:a(`project.from`),children:(0,g.jsx)(`input`,{type:`date`,value:R.time_start??``,onChange:e=>z(t=>t&&{...t,time_start:e.target.value||null}),className:`fld`})}),(0,g.jsx)(s,{label:a(`project.to`),children:(0,g.jsx)(`input`,{type:`date`,value:R.time_end??``,onChange:e=>z(t=>t&&{...t,time_end:e.target.value||null}),className:`fld`})})]}),(0,g.jsx)(s,{label:a(`project.domainProfile`),children:(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsx)(`select`,{value:R.domain_profile,onChange:e=>z(t=>t&&{...t,domain_profile:e.target.value}),className:`fld`,children:(W.some(e=>e.id===R.domain_profile)||!R.domain_profile?W:[{id:R.domain_profile,name:R.domain_profile},...W]).map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsx)(`select`,{value:R.model_adapter,onChange:e=>z(t=>t&&{...t,model_adapter:e.target.value}),className:`fld`,children:(G.some(e=>e.adapter_id===R.model_adapter)||!R.model_adapter?G:[{adapter_id:R.model_adapter,display_name:R.model_adapter},...G]).map(e=>(0,g.jsx)(`option`,{value:e.adapter_id,children:e.display_name},e.adapter_id))})]})}),(0,g.jsx)(`div`,{className:`flex items-end justify-end`,children:(0,g.jsx)(`button`,{type:`button`,onClick:()=>void Ze(),disabled:Pe,className:`btn btn-sm btn-primary`,children:a(`project.saveProtocol`)})})]})})}),(0,g.jsx)(`div`,{className:`mb-3`,children:(0,g.jsx)(l,{tab:a(`project.activityTab`),quiet:!0,children:(0,g.jsx)(xe,{items:Be,projectId:v,pages:x})})}),(0,g.jsx)(`div`,{className:`mb-3`,children:(0,g.jsxs)(l,{tab:a(`project.pilotTab`),quiet:!0,aux:(0,g.jsx)(`span`,{children:a(`project.pilotRange`)}),children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(`button`,{type:`button`,disabled:!J,onClick:()=>void Qe(),className:`btn btn-sm`,children:a(`project.generateSample`)}),B&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`mono text-[12px]`,children:u(`project.pilotSelected`,B.pages.length)}),(0,g.jsx)(`button`,{type:`button`,disabled:!J,onClick:()=>void $e(),className:`btn btn-sm btn-primary`,children:a(`project.saveToProtocol`)})]})]}),B&&(0,g.jsxs)(`p`,{className:`mt-2 mono truncate text-[11px] text-[color:var(--color-ink-3)]`,children:[B.pages.slice(0,5).map(e=>e.rel_path).join(` · `),B.pages.length>5?` …`:``]})]})}),C&&(0,g.jsx)(`div`,{className:`mb-3`,children:(0,g.jsxs)(c,{tab:a(`project.scanningTitle`),children:[(0,g.jsx)(`p`,{className:`text-[13px]`,children:a(`project.scanningBody`)}),(0,g.jsx)(`p`,{className:`mt-1 max-w-[80ch] text-[12px] text-[color:var(--color-ink-2)]`,children:T.total>0?`File ${T.current}/${T.total}${T.file?` · ${T.file}`:``}`:a(`project.scanningHint`)}),(0,g.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden border border-[color:var(--color-rule-strong)]`,role:`progressbar`,"aria-label":a(`project.scanningLabel`),children:(0,g.jsx)(`div`,{className:`h-full animate-pulse bg-[color:var(--color-sig)] transition-[width] duration-300`,style:{width:T.total?`${Math.max(3,T.current/T.total*100)}%`:`25%`}})})]})}),D&&!C&&(0,g.jsxs)(`div`,{className:`mb-3 grid gap-3 sm:grid-cols-2`,children:[(0,g.jsx)(c,{tab:a(`project.report`),quiet:!0,aux:(0,g.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>{sessionStorage.removeItem(_(v)),O(null)},children:a(`project.archive`)}),children:(0,g.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-4`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{className:`lbl !mb-0`,children:a(`project.foundFiles`)}),(0,g.jsx)(`dd`,{className:`mono text-[17px] font-semibold leading-none`,children:D.found_files})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{className:`lbl !mb-0`,children:a(`project.registered`)}),(0,g.jsx)(`dd`,{className:`mono text-[17px] font-semibold leading-none`,children:D.registered})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{className:`lbl !mb-0`,children:a(`project.duplicates`)}),(0,g.jsx)(`dd`,{className:`mono text-[17px] font-semibold leading-none`,children:D.duplicates})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{className:`lbl !mb-0`,children:a(`project.unsupported`)}),(0,g.jsx)(`dd`,{className:`mono text-[17px] font-semibold leading-none`,children:D.unsupported})]})]})}),$>0?(0,g.jsxs)(ie,{title:u(`project.skipCount`,$),children:[(0,g.jsx)(`ul`,{className:`mono max-h-32 list-inside list-disc space-y-0.5 overflow-auto text-[11px]`,children:D.errors.map((e,t)=>(0,g.jsx)(`li`,{className:`break-all`,children:e},t))}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[12px]`,children:[(0,g.jsx)(`b`,{className:`font-semibold`,children:a(`errors.whatToDo`)}),a(`project.skippedBody`)]})]}):(0,g.jsx)(c,{tab:a(`project.noErrors`),quiet:!0,children:(0,g.jsx)(`p`,{className:`text-[12px] text-[color:var(--color-ink-2)]`,children:a(`project.noErrorsBody`)})})]}),I.size>0&&(0,g.jsx)(`div`,{className:`mb-3`,children:(0,g.jsxs)(c,{tab:u(`project.bulkTab`,I.size),aux:(0,g.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>L(new Set),children:a(`project.deselect`)}),children:[(0,g.jsx)(`p`,{className:`mb-2 max-w-[80ch] text-[12px] text-[color:var(--color-ink-2)]`,children:a(`project.bulkBody`)}),(0,g.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,g.jsx)(s,{label:a(`project.issueDate`),children:(0,g.jsx)(`input`,{type:`date`,onChange:e=>void X(`issue_date`,e.target.value),className:`fld`})}),(0,g.jsx)(s,{label:a(`project.issueYear`),hint:a(`project.tabHint`),children:(0,g.jsx)(`input`,{placeholder:a(`project.issueNoPlaceholder`),onBlur:e=>void X(`issue_no`,e.target.value),className:`fld`})}),(0,g.jsx)(s,{label:a(`project.pageType`),children:(0,g.jsxs)(`select`,{defaultValue:``,onChange:e=>void X(`page_type`,e.target.value),className:`fld`,children:[(0,g.jsx)(`option`,{value:``,children:a(`project.noChange`)}),Ce.map(e=>(0,g.jsx)(`option`,{value:e,children:ve(e)},e))]})}),(0,g.jsx)(s,{label:a(`project.status`),children:(0,g.jsxs)(`select`,{defaultValue:``,onChange:e=>void X(`status`,e.target.value),className:`fld`,children:[(0,g.jsx)(`option`,{value:``,children:a(`project.noChange`)}),we.map(e=>(0,g.jsx)(`option`,{value:e,children:m(e)},e))]})})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>void qe(),className:`btn btn-sm mt-3`,children:a(`project.protectGold`)})]})}),(0,g.jsx)(`fieldset`,{disabled:!J,className:`min-w-0`,children:(0,g.jsx)(c,{tab:a(`project.registry`),quiet:!0,flush:!0,aux:(0,g.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[Me&&(0,g.jsx)(`span`,{className:`text-[11px] text-[color:var(--color-ink-2)]`,children:Me}),(0,g.jsxs)(`label`,{className:`flex items-center gap-1 text-[11px]`,title:a(`project.approveConfirmDraftsHint`),children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:Oe,onChange:e=>ke(e.target.checked)}),a(`project.approveConfirmDrafts`)]}),I.size>0&&(0,g.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:Ae,onClick:()=>void Xe([...I]),children:u(`project.approveSelected`,I.size)}),(0,g.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,disabled:Ae||x.length===0,onClick:()=>void Xe(null),children:a(`project.approveAll`)}),(0,g.jsx)(`span`,{children:ye(x.length)})]}),children:x.length>0?(0,g.jsx)(`div`,{className:`overflow-x-auto`,children:(0,g.jsxs)(`table`,{className:`w-full border-collapse text-[12px]`,children:[(0,g.jsx)(`thead`,{className:`border-b border-[color:var(--color-rule)] bg-[color:var(--color-fill)]`,children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{className:`${Z} w-8`,children:(0,g.jsx)(`input`,{type:`checkbox`,checked:tt,onChange:nt,"aria-label":a(`project.selectAll`)})}),(0,g.jsx)(`th`,{className:`${Z} w-12`,children:a(`project.colPage`)}),(0,g.jsx)(`th`,{className:Z,children:a(`project.colFile`)}),(0,g.jsx)(`th`,{className:`${Z} w-32`,children:a(`project.colDate`)}),(0,g.jsx)(`th`,{className:`${Z} w-28`,children:a(`project.colIssue`)}),(0,g.jsx)(`th`,{className:`${Z} w-16`,children:a(`project.colNumber`)}),(0,g.jsx)(`th`,{className:`${Z} w-36`,children:a(`project.colType`)}),(0,g.jsx)(`th`,{className:`${Z} w-32`,children:a(`project.colStatus`)}),(0,g.jsx)(`th`,{className:`${Z} w-24`,children:a(`project.colAction`)})]})}),(0,g.jsx)(`tbody`,{className:`ruled`,children:x.map(e=>(0,g.jsxs)(`tr`,{className:I.has(e.id)?`bg-[color:var(--color-sig-wash)]`:`hover:bg-[color:var(--color-fill)]`,children:[(0,g.jsx)(`td`,{className:Q,children:(0,g.jsx)(`input`,{type:`checkbox`,checked:I.has(e.id),onChange:()=>rt(e.id),"aria-label":a(`project.selectPage`,{path:p(e)})})}),(0,g.jsx)(`td`,{className:Q,children:(0,g.jsx)(`img`,{"data-fade":!0,src:`/api/pages/${e.id}/thumbnail`,alt:a(`project.thumbnailAlt`,{path:p(e)}),loading:`lazy`,className:`h-10 w-8 border border-[color:var(--color-rule)] bg-white object-cover object-top`})}),(0,g.jsxs)(`td`,{className:`${Q} min-w-0`,children:[(0,g.jsx)(`span`,{className:`mono block max-w-[24rem] truncate`,title:p(e),children:p(e)}),(0,g.jsxs)(`span`,{className:`mono text-[11px] text-[color:var(--color-ink-3)]`,children:[e.width,`×`,e.height]})]}),(0,g.jsx)(`td`,{className:Q,children:(0,g.jsx)(`input`,{type:`date`,value:e.issue_date??``,onChange:t=>void Y(e.id,`issue_date`,t.target.value),"aria-label":a(`project.dateOf`,{path:e.rel_path}),className:`fld !py-0.5 !text-[12px]`})}),(0,g.jsx)(`td`,{className:Q,children:(0,g.jsx)(`input`,{value:e.issue_no??``,onChange:t=>void Y(e.id,`issue_no`,t.target.value),placeholder:a(`project.issueNoPlaceholder`),"aria-label":a(`project.issueOf`,{path:e.rel_path}),className:`fld !py-0.5 !text-[12px]`})}),(0,g.jsx)(`td`,{className:Q,children:(0,g.jsx)(`input`,{value:e.page_no??``,onChange:t=>void Y(e.id,`page_no`,t.target.value),placeholder:`1`,"aria-label":a(`project.pageNumOf`,{path:e.rel_path}),className:`fld !py-0.5 !text-[12px]`})}),(0,g.jsx)(`td`,{className:Q,children:(0,g.jsxs)(`select`,{value:e.page_type??``,onChange:t=>void Y(e.id,`page_type`,t.target.value),"aria-label":a(`project.typeOf`,{path:e.rel_path}),className:`fld !py-0.5 !text-[12px]`,children:[(0,g.jsx)(`option`,{value:``,children:`—`}),Ce.map(e=>(0,g.jsx)(`option`,{value:e,children:ve(e)},e))]})}),(0,g.jsx)(`td`,{className:Q,children:(0,g.jsx)(`select`,{value:e.status,onChange:t=>void Y(e.id,`status`,t.target.value),"aria-label":a(`project.statusOf`,{path:e.rel_path}),className:`fld !py-0.5 !text-[12px]`,children:we.map(e=>(0,g.jsx)(`option`,{value:e,children:m(e)},e))})}),(0,g.jsx)(`td`,{className:Q,children:e.status!==`approved`&&e.status!==`exported`?(0,g.jsxs)(`button`,{onClick:()=>void Je(e.id),className:`btn btn-sm`,title:a(`project.approveTitle`),children:[(0,g.jsx)(ue,{size:11}),a(`project.approve`)]}):(0,g.jsx)(le,{tone:be[e.status]??`ok`,children:m(e.status)})})]},e.id))})]})}):(0,g.jsxs)(`div`,{className:`flex flex-col items-start gap-2 p-6`,children:[(0,g.jsx)(i,{size:22}),(0,g.jsx)(`p`,{className:`text-[13px] font-semibold`,children:a(`project.emptyTitle`)})]})})}),He&&y&&(0,g.jsx)(Se,{projectId:v,projectName:y.name,canManage:q,onAccessChanged:()=>{e(`/projects/${v}`).then(b).catch(A)},onClose:()=>Ue(!1)}),De&&y&&(0,g.jsx)(te,{title:a(`project.deleteModalTitle`),onClose:()=>!P&&j(!1),footer:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{onClick:()=>j(!1),disabled:P,className:`btn`,children:a(`common.cancel`)}),(0,g.jsxs)(`button`,{onClick:()=>void et(),disabled:M!==y.name||P,className:`btn btn-primary`,children:[(0,g.jsx)(t,{size:13}),a(P?`project.deleting`:`project.deleteForever`)]})]}),children:(0,g.jsxs)(`div`,{className:`p-3`,children:[(0,g.jsx)(`p`,{className:`text-[13px]`,children:u(`project.deleteBody`,x.length)}),(0,g.jsx)(`p`,{className:`mt-2 text-[12px] text-[color:var(--color-ink-2)]`,children:a(`project.deleteBody2`,{dir:y.archive_dir??`—`})}),(0,g.jsx)(`div`,{className:`mt-3`,children:(0,g.jsx)(s,{label:a(`project.typeName`),hint:a(`project.typeNameHint`,{name:y.name}),children:(0,g.jsx)(`input`,{autoFocus:!0,value:M,onChange:e=>N(e.target.value),placeholder:y.name,className:`fld`})})})]})})]})}export{v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,a as t,ct as n,d as r,dt as i,ht as a,i as o,l as s,lt as c,r as l,t as u}from"./ui-BtIxuKN2.js";import{N as d,O as f,a as p,i as m}from"./index-DVWuV1Ff.js";import{i as h,n as g,t as _}from"./live-CFfryZUM.js";var v=a(i(),1),y=c();function b({block:r}){let{t:i}=n(),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let t=!0;return e(`/blocks/${r.id}/table`).then(e=>{t&&o(e)}).catch(e=>{t&&c(e)}),()=>{t=!1}},[r.id,r.updated_at]),s)return(0,y.jsx)(l,{error:s});if(!a)return(0,y.jsx)(t,{label:i(`common.loading`)});if(!a.grid)return(0,y.jsx)(`p`,{className:`whitespace-pre-wrap text-[13px]`,children:r.content});let u=a.grid;return(0,y.jsx)(`div`,{className:`overflow-auto`,children:(0,y.jsx)(`table`,{className:`w-full border-collapse text-[12px]`,"aria-label":i(`team.tablePreview`),children:(0,y.jsx)(`tbody`,{children:Array.from({length:u.rows},(e,t)=>(0,y.jsx)(`tr`,{children:u.cells.filter(e=>e.r===t).sort((e,t)=>e.c-t.c).map(e=>(0,y.jsx)(`td`,{rowSpan:e.rowspan,colSpan:e.colspan,className:`whitespace-pre-wrap border border-[color:var(--color-rule)] px-2 py-1`,children:e.text},e.c))},t))})})})}function x({project:i,projects:a}){let{t:c}=n(),[x,S]=d(),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),k=Number(x.get(`page`))||null,A=C?.find(e=>e.id===k)??(k?null:C?.[0]);return(0,v.useEffect)(()=>{let t=!0;return w(null),O(null),e(`/projects/${i.id}/pages`).then(e=>{t&&w(e.items)}).catch(e=>{t&&O(e)}),()=>{t=!1}},[i.id]),(0,v.useEffect)(()=>{if(E(null),!A)return;let t=!0,n=()=>e(`/pages/${A.id}/annotations`).then(e=>{t&&(E(e.items),O(null))}).catch(e=>{t&&O(e)});n(),_(A.id);let r=h(e=>{e.pageId===A.id&&n()});return()=>{t=!1,r(),g()}},[A?.id]),(0,y.jsxs)(`div`,{className:`p-3`,children:[(0,y.jsx)(r,{title:c(`team.readerTitle`),intro:`${c(`team.readerIntro`)} ${c(`team.readerNotice`)}`,aux:(0,y.jsx)(u,{tone:`neutral`,children:c(`share.roleViewer`)})}),(0,y.jsxs)(`div`,{className:`my-3 grid gap-3 sm:grid-cols-2`,children:[(0,y.jsx)(o,{label:c(`training.project`),children:(0,y.jsx)(`select`,{className:`fld`,value:i.id,onChange:e=>{m(Number(e.target.value)),S({project:e.target.value})},children:a.map(e=>(0,y.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,y.jsx)(o,{label:c(`playground.page`),children:(0,y.jsxs)(`select`,{className:`fld`,value:A?.id??``,disabled:!C?.length,onChange:e=>S({project:String(i.id),page:e.target.value}),children:[!A&&(0,y.jsx)(`option`,{value:``,children:c(`playground.pickPage`)}),C?.map(e=>(0,y.jsx)(`option`,{value:e.id,children:p(e)},e.id))]})})]}),(0,y.jsx)(f,{to:`/progetti/${i.id}`,className:`btn mb-3 no-underline`,children:c(`team.projectOverview`)}),D!=null&&(0,y.jsx)(l,{error:D}),!C&&!D&&(0,y.jsx)(t,{label:c(`common.loading`)}),C&&!A&&(0,y.jsx)(`p`,{className:`p-3 text-[13px]`,children:c(k?`team.pageUnavailable`:`project.emptyTitle`)}),A&&(0,y.jsxs)(`div`,{className:`grid items-start gap-3 lg:grid-cols-2`,children:[(0,y.jsx)(s,{tab:p(A),quiet:!0,children:(0,y.jsx)(`img`,{src:`/api/pages/${A.id}/preview`,alt:c(`team.pagePreview`,{name:p(A)}),className:`w-full`})}),(0,y.jsxs)(s,{tab:c(`team.savedContent`),quiet:!0,children:[!T&&!D&&(0,y.jsx)(t,{label:c(`common.loading`)}),T?.length===0&&(0,y.jsx)(`p`,{className:`text-[13px]`,children:c(`team.noBlocks`)}),(0,y.jsx)(`ol`,{className:`divide-y divide-[color:var(--color-rule)]`,children:T?.slice().sort((e,t)=>(e.order_idx??1e9)-(t.order_idx??1e9)).map((e,t)=>(0,y.jsxs)(`li`,{className:`py-3`,children:[(0,y.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-semibold`,children:[t+1,` · `,e.label]}),(0,y.jsx)(u,{tone:e.confirmed?`ok`:`warn`,children:c(e.confirmed?`team.verified`:`team.draft`)})]}),e.label===`Table`?(0,y.jsx)(b,{block:e}):(0,y.jsx)(`p`,{className:`whitespace-pre-wrap text-[13px] leading-relaxed`,children:e.content})]},e.id))})]})]})]})}export{x as default};
|