import{c as fe,u as ne,r as d,j as n,R as gr,t as ee,_ as qe,K as Kt,b as xr,L as Gt}from"./index-qMrAuFFG.js";import{I as te,B as Z,S as zt,a as Nt,b as Pt,c as It,d as tt,U as yr,k as kr,E as ln,g as on,G as cn,r as Ve,j as un,x as br,q as vr,o as ue,l as At,i as dn,R as Cr,n as fn,A as jr,m as wr,y as Er,D as Sr,C as zr,V as Nr,W as Pr,L as Ir,P as Tr,e as Rr,f as Mr}from"./loading-PETOxw4W.js";import{c as Pe,u as Lt,F as U,R as Ee,a as he,L as ce,g as Fr,r as Ar,B as $e,d as Lr,e as _r,h as Dr,S as $r}from"./badge-BOFxe4_3.js";import{S as ye,C as Or,B as Br,A as Hr}from"./MineruConfig-Bd9buqsB.js";import{c as J,l as Vr,i as Ur,m as qt,n as Kr,C as Gr,o as qr,p as Wr}from"./queries-B0q6a4VE.js";import{a as mn,b as hn,S as Yr,I as Jr,p as xt,B as Xr}from"./phase-bar-Cra2ethh.js";import{A as pn,T as Zr}from"./alert-message-DBiN770l.js";import{D as Xe,e as Qr,a as Ze,b as yt,c as kt,d as bt,H as es}from"./dialog-DlDaQf4g.js";import{R as ts}from"./refresh-cw-BtfCr9OP.js";import"./clock-Dmcvs345.js";/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ns=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],gn=fe("ExternalLink",ns);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rs=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],ss=fe("GripVertical",rs);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const as=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],ls=fe("Maximize2",as);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const os=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],xn=fe("Pencil",os);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const is=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],cs=fe("RefreshCcw",is);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const us=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ds=fe("RotateCcw",us);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fs=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],yn=fe("RotateCw",fs);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ms=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],hs=fe("ZoomIn",ms);/**
 * @license lucide-react v0.476.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ps=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],gs=fe("ZoomOut",ps),Qe={shouldChunk:!1,chunkStrategy:Pe.enum.HYBRID,chunkSize:1e3,chunkOverlap:200};function xs(e){return e?{shouldChunk:!0,chunkStrategy:e.strategy??Pe.enum.HYBRID,chunkSize:e.chunk_size??Qe.chunkSize,chunkOverlap:e.chunk_overlap??Qe.chunkOverlap}:{...Qe}}function ys(e){return e.shouldChunk?Fr.parse({strategy:e.chunkStrategy??Pe.enum.HYBRID,chunk_size:Number(e.chunkSize),chunk_overlap:Number(e.chunkOverlap)}):null}function ks({initialConfig:e,onSubmit:t,onCancel:r,isSubmitting:l=!1}){const{t:s}=ne(),i=d.useMemo(()=>xs(e),[e]),o=d.useMemo(()=>[{value:Pe.enum.HYBRID,label:s("tasks.detail.chunkEditor.strategies.hybrid.label"),description:s("tasks.detail.chunkEditor.strategies.hybrid.description")},{value:Pe.enum.MERGE,label:s("tasks.detail.chunkEditor.strategies.merge.label"),description:s("tasks.detail.chunkEditor.strategies.merge.description")},{value:Pe.enum.RECURSIVE,label:s("tasks.detail.chunkEditor.strategies.recursive.label"),description:s("tasks.detail.chunkEditor.strategies.recursive.description")}],[s]),c=Lt({defaultValues:i,onSubmit:async({value:a})=>{const u=ys(a);await t(u)}});return n.jsxs("form",{onSubmit:a=>{a.preventDefault(),c.handleSubmit()},className:"space-y-6 min-h-0 overflow-auto",children:[n.jsx(c.Field,{name:"shouldChunk",children:a=>n.jsx(U,{label:s("tasks.detail.chunkEditor.enable.label"),htmlFor:"chunk-editor-should-chunk",required:!0,help:s("tasks.detail.chunkEditor.enable.help"),children:n.jsxs(Ee,{id:"chunk-editor-should-chunk",value:a.state.value?"true":"false",onValueChange:u=>a.handleChange(u==="true"),className:"flex items-center space-x-6 mt-2",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{value:"true",id:"chunk-editor-enabled"}),n.jsx(ce,{htmlFor:"chunk-editor-enabled",children:s("tasks.detail.chunkEditor.enable.options.enabled")})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{value:"false",id:"chunk-editor-disabled"}),n.jsx(ce,{htmlFor:"chunk-editor-disabled",children:s("tasks.detail.chunkEditor.enable.options.disabled")})]})]})})}),n.jsx(c.Subscribe,{selector:a=>a.values.shouldChunk,children:a=>a?n.jsxs("div",{className:"space-y-4 rounded-lg border p-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-700",children:s("tasks.detail.chunkEditor.sectionTitle")}),n.jsx(c.Field,{name:"chunkStrategy",validators:{onChange:({value:u})=>{if(!u)return s("tasks.detail.chunkEditor.errors.strategy")}},children:u=>n.jsx(U,{label:s("tasks.detail.chunkEditor.fields.strategy"),htmlFor:"chunk-editor-strategy",required:!0,error:u.state.meta.errors[0],help:s("tasks.detail.chunkEditor.fields.strategyHelp"),children:n.jsx(Ee,{id:"chunk-editor-strategy",value:u.state.value||"",onValueChange:m=>u.handleChange(m),children:o.map(m=>n.jsx(ce,{htmlFor:`chunk-editor-strategy-${m.value.toLowerCase()}`,className:"flex cursor-pointer flex-col items-start gap-3 rounded-lg border p-3 text-left has-[[data-state=checked]]:border-blue-600 dark:has-[[data-state=checked]]:border-blue-900 dark:has-[[data-state=checked]]:bg-blue-950",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(he,{value:m.value,className:"mt-0.5",id:`chunk-editor-strategy-${m.value.toLowerCase()}`}),n.jsxs("div",{className:"flex flex-col text-sm font-medium text-gray-900",children:[m.label,n.jsx("span",{className:"text-xs leading-relaxed text-gray-500",children:m.description})]})]})},m.value))})})}),n.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[n.jsx(c.Field,{name:"chunkSize",validators:{onChange:({value:u})=>{if(u==null||Number.isNaN(u)||u<=0)return s("tasks.detail.chunkEditor.errors.size")}},children:u=>n.jsx(U,{label:s("tasks.detail.chunkEditor.fields.size"),htmlFor:"chunk-editor-size",required:!0,error:u.state.meta.errors[0],help:s("tasks.detail.chunkEditor.fields.sizeHelp"),children:n.jsx(te,{id:"chunk-editor-size",type:"number",min:1,max:8192,value:u.state.value===void 0?"":String(u.state.value),onChange:m=>{const f=m.target.value;u.handleChange(f===""?void 0:Number.parseInt(f,10)),c.validateField("chunkOverlap","change")},onBlur:u.handleBlur})})}),n.jsx(c.Field,{name:"chunkOverlap",validators:{onChange:({value:u})=>{if(u==null||Number.isNaN(u)||u<0)return s("tasks.detail.chunkEditor.errors.overlap");const m=c.state.values.chunkSize??Qe.chunkSize;if(u>=m)return s("tasks.detail.chunkEditor.errors.overlapRange")}},children:u=>n.jsx(U,{label:s("tasks.detail.chunkEditor.fields.overlap"),htmlFor:"chunk-editor-overlap",required:!0,error:u.state.meta.errors[0],help:s("tasks.detail.chunkEditor.fields.overlapHelp"),children:n.jsx(te,{id:"chunk-editor-overlap",type:"number",min:0,max:4096,value:u.state.value===void 0?"":String(u.state.value),onChange:m=>{const f=m.target.value;u.handleChange(f===""?void 0:Number.parseInt(f,10))},onBlur:u.handleBlur})})})]})]}):n.jsx("p",{className:"text-sm text-gray-500",children:s("tasks.detail.chunkEditor.disabledHint")})}),n.jsxs("div",{className:"flex justify-end gap-3",children:[r&&n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:l,children:s("common.cancel")}),n.jsx(Z,{type:"submit",disabled:l,children:s(l?"common.saving":"common.save")})]})]})}function Wt(){return{type:"ragflow",baseUrl:"",apiKey:"",datasetId:"",importAsChunk:!1}}function bs(e){return e?{shouldImport:!0,knowledgeBase:{...Wt(),...e}}:{shouldImport:!1,knowledgeBase:Wt()}}function vs(e){return e.shouldImport?Ar.parse(e.knowledgeBase):null}function Cs({initialConfig:e,onSubmit:t,onCancel:r,isSubmitting:l=!1}){const{t:s}=ne(),i=d.useMemo(()=>bs(e),[e]),o=Lt({defaultValues:i,onSubmit:async({value:c})=>{const a=vs(c);await t(a)}});return n.jsxs("form",{onSubmit:c=>{c.preventDefault(),o.handleSubmit()},className:"space-y-6 min-h-0 overflow-auto",children:[n.jsx(o.Field,{name:"shouldImport",children:c=>n.jsx(U,{label:s("tasks.detail.knowledgeEditor.import.label"),htmlFor:"kb-should-import",required:!0,help:s("tasks.detail.knowledgeEditor.import.help"),children:n.jsxs(zt,{value:c.state.value.toString(),onValueChange:a=>c.handleChange(a==="true"),children:[n.jsx(Nt,{children:n.jsx(Pt,{placeholder:s("common.select")})}),n.jsxs(It,{children:[n.jsx(tt,{value:"true",children:s("tasks.detail.knowledgeEditor.import.options.enabled")}),n.jsx(tt,{value:"false",children:s("tasks.detail.knowledgeEditor.import.options.disabled")})]})]})})}),n.jsx(o.Subscribe,{selector:c=>c.values,children:c=>c.shouldImport?n.jsxs("div",{className:"space-y-4 rounded-lg border p-4",children:[n.jsx(ce,{className:"text-sm font-medium text-gray-700",children:s("tasks.detail.knowledgeEditor.sectionTitle")}),n.jsx(o.Field,{name:"knowledgeBase.type",validators:{onChange:({value:a})=>a?void 0:s("tasks.detail.knowledgeEditor.errors.typeRequired")},children:a=>n.jsx(U,{label:s("tasks.detail.knowledgeEditor.fields.type"),htmlFor:"kb-type",required:!0,error:a.state.meta.errors[0],children:n.jsx(te,{id:"kb-type",placeholder:"ragflow",value:a.state.value||"",onChange:u=>a.handleChange(u.target.value),onBlur:a.handleBlur})})}),n.jsx(o.Field,{name:"knowledgeBase.baseUrl",validators:{onChange:({value:a})=>{if(!a||a.trim().length===0)return s("tasks.detail.knowledgeEditor.errors.baseUrlRequired");try{new URL(a);return}catch{return s("tasks.detail.knowledgeEditor.errors.baseUrlInvalid")}}},children:a=>n.jsx(U,{label:s("tasks.detail.knowledgeEditor.fields.baseUrl"),htmlFor:"kb-base-url",required:!0,error:a.state.meta.errors[0],help:s("tasks.detail.knowledgeEditor.help.baseUrl"),children:n.jsx(te,{id:"kb-base-url",placeholder:"https://ragflow.example.com",value:a.state.value||"",onChange:u=>a.handleChange(u.target.value),onBlur:a.handleBlur})})}),n.jsx(o.Field,{name:"knowledgeBase.apiKey",validators:{onChange:({value:a})=>!a||a.trim().length===0?s("tasks.detail.knowledgeEditor.errors.apiKeyRequired"):void 0},children:a=>n.jsx(U,{label:s("tasks.detail.knowledgeEditor.fields.apiKey"),htmlFor:"kb-api-key",required:!0,error:a.state.meta.errors[0],children:n.jsx(te,{id:"kb-api-key",placeholder:s("tasks.detail.knowledgeEditor.placeholders.apiKey"),value:a.state.value||"",onChange:u=>a.handleChange(u.target.value),onBlur:a.handleBlur})})}),n.jsx(o.Field,{name:"knowledgeBase.datasetId",validators:{onChange:({value:a})=>!a||a.trim().length===0?s("tasks.detail.knowledgeEditor.errors.datasetIdRequired"):void 0},children:a=>n.jsx(U,{label:s("tasks.detail.knowledgeEditor.fields.datasetId"),htmlFor:"kb-dataset-id",required:!0,error:a.state.meta.errors[0],children:n.jsx(te,{id:"kb-dataset-id",placeholder:s("tasks.detail.knowledgeEditor.placeholders.datasetId"),value:a.state.value||"",onChange:u=>a.handleChange(u.target.value),onBlur:a.handleBlur})})}),n.jsx(o.Field,{name:"knowledgeBase.importAsChunk",children:a=>n.jsx(U,{label:s("tasks.detail.knowledgeEditor.fields.importAsChunk"),htmlFor:"kb-should-chunk",inline:!0,help:s("tasks.detail.knowledgeEditor.help.importAsChunk"),children:n.jsx(ye,{id:"kb-should-chunk",checked:!!a.state.value,onCheckedChange:a.handleChange})})})]}):n.jsx("p",{className:"text-sm text-gray-500",children:s("tasks.detail.knowledgeEditor.disabledHint")})}),n.jsxs("div",{className:"flex justify-end gap-3",children:[r&&n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:l,children:s("common.cancel")}),n.jsx(Z,{type:"submit",disabled:l,children:s(l?"common.saving":"common.save")})]})]})}const Yt=yr("type",[Lr,_r]),Se={type:"saas",baseUrl:"",apiKey:"",enableFormula:!0,enableTable:!0,language:"ch",enableOcr:!1,extraFormats:[],modelVersion:"pipeline"},ke={type:"selfhost",baseUrl:"",enableFormula:!0,enableTable:!0,language:"ch",parseMethod:"auto",backendType:"pipeline",serverUrl:"",returnContentList:!0,returnImages:!0,returnMd:!0},js=[{value:"pipeline",labelKey:"tasks.detail.mineruEditor.modelVersions.pipeline"},{value:"vlm",labelKey:"tasks.detail.mineruEditor.modelVersions.vlm"}],ws=["docx","html","latex"];function Es(e){return e?e.type==="selfhost"?{...ke,...e}:{...Se,...e}:Se}function Ss(e){if(e.type==="saas"){const{backendType:i,parseMethod:o,returnContentList:c,returnImages:a,returnMd:u,serverUrl:m,...f}=e;return Yt.parse(f)}const{enableOcr:t,extraFormats:r,modelVersion:l,...s}=e;return Yt.parse(s)}function zs({initialConfig:e,onSubmit:t,onCancel:r,isSubmitting:l=!1}){const{t:s}=ne(),i=d.useMemo(()=>Es(e),[e]),o=Lt({defaultValues:i,onSubmit:async({value:c})=>{const a=Ss(c);await t(a)}});return n.jsxs("form",{onSubmit:c=>{c.preventDefault(),o.handleSubmit()},className:"space-y-6 min-h-0 overflow-auto",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx(o.Field,{name:"type",children:c=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.type"),htmlFor:"mineru-type",required:!0,children:n.jsxs(Ee,{id:"mineru-type",value:c.state.value,onValueChange:a=>{c.handleChange(a),a==="saas"?(o.setFieldValue("apiKey",Se.apiKey),o.setFieldValue("modelVersion",Se.modelVersion),o.setFieldValue("enableOcr",Se.enableOcr??!1),o.setFieldValue("extraFormats",Se.extraFormats??[]),o.setFieldValue("backendType",void 0),o.setFieldValue("parseMethod",void 0),o.setFieldValue("serverUrl",void 0),o.setFieldValue("returnContentList",void 0),o.setFieldValue("returnImages",void 0),o.setFieldValue("returnMd",void 0)):(o.setFieldValue("backendType",ke.backendType),o.setFieldValue("parseMethod",ke.parseMethod),o.setFieldValue("returnContentList",ke.returnContentList),o.setFieldValue("returnImages",ke.returnImages),o.setFieldValue("returnMd",ke.returnMd),o.setFieldValue("serverUrl",ke.serverUrl),o.setFieldValue("modelVersion",void 0),o.setFieldValue("enableOcr",void 0),o.setFieldValue("extraFormats",void 0))},className:"flex gap-6",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{value:"saas",id:"mineru-type-saas"}),n.jsx(ce,{htmlFor:"mineru-type-saas",children:s("tasks.detail.mineruEditor.typeOptions.saas")})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{value:"selfhost",id:"mineru-type-selfhost"}),n.jsx(ce,{htmlFor:"mineru-type-selfhost",children:s("tasks.detail.mineruEditor.typeOptions.selfhost")})]})]})})}),n.jsx(o.Field,{name:"baseUrl",validators:{onChange:({value:c})=>{if(!c||c.trim().length===0)return s("tasks.detail.mineruEditor.errors.baseUrlRequired");try{new URL(c);return}catch{return s("tasks.detail.mineruEditor.errors.baseUrlInvalid")}}},children:c=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.baseUrl"),htmlFor:"mineru-base-url",required:!0,error:c.state.meta.errors[0],help:s("tasks.detail.mineruEditor.help.baseUrl"),children:n.jsx(te,{id:"mineru-base-url",type:"url",placeholder:s("tasks.detail.mineruEditor.placeholders.baseUrl"),value:c.state.value,onChange:a=>c.handleChange(a.target.value),onBlur:c.handleBlur})})})]}),n.jsx(o.Subscribe,{selector:c=>c.values.type,children:c=>n.jsxs(n.Fragment,{children:[n.jsx(o.Field,{name:"apiKey",validators:{onChange:({value:a})=>{if(c==="saas"&&(!a||a.trim().length===0))return s("tasks.detail.mineruEditor.errors.apiKeyRequired")}},children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.apiKey"),htmlFor:"mineru-api-key",required:c==="saas",error:a.state.meta.errors[0],help:s(c==="saas"?"tasks.detail.mineruEditor.help.apiKeySaas":"tasks.detail.mineruEditor.help.apiKeySelfhost"),children:n.jsx(te,{id:"mineru-api-key",type:"password",placeholder:s("tasks.detail.mineruEditor.placeholders.apiKey"),value:a.state.value||"",onChange:u=>a.handleChange(u.target.value),onBlur:a.handleBlur})})}),n.jsx(o.Field,{name:"enableFormula",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.enableFormula"),htmlFor:"mineru-enable-formula",inline:!0,help:s("tasks.detail.mineruEditor.help.enableFormula"),children:n.jsx(ye,{id:"mineru-enable-formula",checked:!!a.state.value,onCheckedChange:a.handleChange})})}),n.jsx(o.Field,{name:"enableTable",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.enableTable"),htmlFor:"mineru-enable-table",inline:!0,help:s("tasks.detail.mineruEditor.help.enableTable"),children:n.jsx(ye,{id:"mineru-enable-table",checked:!!a.state.value,onCheckedChange:a.handleChange})})}),n.jsx(o.Field,{name:"language",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.language"),htmlFor:"mineru-language",help:n.jsxs("span",{children:[c==="selfhost"&&n.jsxs(n.Fragment,{children:[s("tasks.detail.mineruEditor.help.languageSelfhostPrefix")," "]}),s("tasks.detail.mineruEditor.help.languageMore")," ",n.jsx("a",{className:"text-blue-500",href:"https://www.paddleocr.ai/latest/en/version3.x/algorithm/PP-OCRv5/PP-OCRv5_multi_languages.html#4-supported-languages-and-abbreviations",target:"_blank",rel:"noopener noreferrer",children:s("tasks.detail.mineruEditor.help.languageLinkText")})]}),children:n.jsx(te,{id:"mineru-language",placeholder:s(c==="saas"?"tasks.detail.mineruEditor.placeholders.languageSaas":"tasks.detail.mineruEditor.placeholders.languageSelfhost"),value:a.state.value||"",onChange:u=>a.handleChange(u.target.value),onBlur:a.handleBlur})})}),c==="saas"?n.jsxs(n.Fragment,{children:[n.jsx(o.Field,{name:"enableOcr",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.enableOcr"),htmlFor:"mineru-enable-ocr",inline:!0,help:s("tasks.detail.mineruEditor.help.enableOcr"),children:n.jsx(ye,{id:"mineru-enable-ocr",checked:!!a.state.value,onCheckedChange:a.handleChange})})}),n.jsx(o.Field,{name:"modelVersion",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.modelVersion"),htmlFor:"mineru-model-version",children:n.jsx(Ee,{id:"mineru-model-version",value:a.state.value,onValueChange:a.handleChange,className:"flex items-center gap-6",children:js.map(u=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{value:u.value,id:`mineru-model-${u.value}`}),n.jsx(ce,{htmlFor:`mineru-model-${u.value}`,children:s(u.labelKey)})]},u.value))})})}),n.jsx(o.Field,{name:"extraFormats",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.extraFormats"),htmlFor:"mineru-extra-formats",help:s("tasks.detail.mineruEditor.help.extraFormats"),children:n.jsx("div",{className:"flex gap-4",children:ws.map(u=>{var m;return n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(Or,{id:`mineru-extra-${u}`,checked:(m=a.state.value)==null?void 0:m.includes(u),onCheckedChange:f=>{const h=a.state.value||[];a.handleChange(f?[...h,u]:h.filter(g=>g!==u))}}),n.jsx(ce,{htmlFor:`mineru-extra-${u}`,children:u})]},u)})})})})]}):n.jsxs(n.Fragment,{children:[n.jsx(o.Field,{name:"backendType",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.backendType"),htmlFor:"mineru-backend",children:n.jsx(Ee,{id:"mineru-backend",value:a.state.value,onValueChange:a.handleChange,className:"flex flex-col gap-2",children:Br.map(u=>n.jsxs("div",{className:"flex items-center space-x-2 rounded border p-2",children:[n.jsx(he,{value:u.value,id:`mineru-backend-${u.value}`}),n.jsxs(ce,{htmlFor:`mineru-backend-${u.value}`,className:"flex items-center gap-2",children:[n.jsx("span",{children:u.label}),u.badge&&n.jsx($e,{variant:"outline",children:u.badge})]})]},u.value))})})}),n.jsx(o.Field,{name:"parseMethod",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.parseMethod"),htmlFor:"mineru-parse-method",children:n.jsx(Ee,{id:"mineru-parse-method",value:a.state.value,onValueChange:a.handleChange,className:"flex gap-6",children:[{value:"auto",label:s("tasks.detail.mineruEditor.parseMethods.auto")},{value:"ocr",label:s("tasks.detail.mineruEditor.parseMethods.ocr")},{value:"txt",label:s("tasks.detail.mineruEditor.parseMethods.txt")}].map(u=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{value:u.value,id:`mineru-parse-${u.value}`}),n.jsx(ce,{htmlFor:`mineru-parse-${u.value}`,children:u.label})]},u.value))})})}),n.jsx(o.Subscribe,{selector:a=>a.values.backendType,children:a=>a&&["vlm-sglang-client","vlm-vllm-http-client"].includes(a)?n.jsx(o.Field,{name:"serverUrl",validators:{onChange:({value:u})=>{if(!u||u.trim().length===0)return s("tasks.detail.mineruEditor.errors.serverUrlRequired");try{new URL(u);return}catch{return s("tasks.detail.mineruEditor.errors.serverUrlInvalid")}}},children:u=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.serverUrl"),htmlFor:"server-url",required:!0,help:s("tasks.detail.mineruEditor.help.serverUrl"),error:u.state.meta.errors[0],children:n.jsx(te,{id:"server-url",placeholder:"http://localhost:30000",value:u.state.value||"",onChange:m=>u.handleChange(m.target.value),onBlur:u.handleBlur})})}):null}),n.jsx(o.Field,{name:"returnContentList",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.returnContentList"),htmlFor:"mineru-return-content-list",inline:!0,help:s("tasks.detail.mineruEditor.help.returnContentList"),children:n.jsx(ye,{id:"mineru-return-content-list",checked:a.state.value!==!1,onCheckedChange:a.handleChange})})}),n.jsx(o.Field,{name:"returnImages",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.returnImages"),htmlFor:"mineru-return-images",inline:!0,help:s("tasks.detail.mineruEditor.help.returnImages"),children:n.jsx(ye,{id:"mineru-return-images",checked:a.state.value!==!1,onCheckedChange:a.handleChange})})}),n.jsx(o.Field,{name:"returnMd",children:a=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.returnMd"),htmlFor:"mineru-return-md",inline:!0,help:s("tasks.detail.mineruEditor.help.returnMd"),children:n.jsx(ye,{id:"mineru-return-md",checked:a.state.value!==!1,onCheckedChange:a.handleChange})})})]})]})}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.jsx(o.Field,{name:"startPage",children:c=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.startPage"),htmlFor:"mineru-start-page",children:n.jsx(te,{id:"mineru-start-page",type:"number",min:"1",placeholder:s("tasks.detail.mineruEditor.placeholders.startPage"),value:c.state.value??"",onChange:a=>c.handleChange(a.target.value?Number(a.target.value):void 0)})})}),n.jsx(o.Field,{name:"endPage",children:c=>n.jsx(U,{label:s("tasks.detail.mineruEditor.fields.endPage"),htmlFor:"mineru-end-page",children:n.jsx(te,{id:"mineru-end-page",type:"number",min:"1",placeholder:s("tasks.detail.mineruEditor.placeholders.endPage"),value:c.state.value??"",onChange:a=>c.handleChange(a.target.value?Number(a.target.value):void 0)})})})]}),n.jsxs("div",{className:"flex justify-end gap-3",children:[r&&n.jsx(Z,{type:"button",variant:"outline",onClick:r,disabled:l,children:s("common.cancel")}),n.jsx(Z,{type:"submit",disabled:l,children:s(l?"common.saving":"common.save")})]})]})}function kn({className:e,...t}){return n.jsx("div",{"data-slot":"empty",className:J("flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12",e),...t})}function bn({className:e,...t}){return n.jsx("div",{"data-slot":"empty-header",className:J("flex max-w-sm flex-col items-center gap-2 text-center",e),...t})}const Ns=Vr("flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6"}},defaultVariants:{variant:"default"}});function vn({className:e,variant:t="default",...r}){return n.jsx("div",{"data-slot":"empty-icon","data-variant":t,className:J(Ns({variant:t,className:e})),...r})}function Cn({className:e,...t}){return n.jsx("div",{"data-slot":"empty-title",className:J("text-lg font-medium tracking-tight",e),...t})}function Ue({columns:e,data:t}){return n.jsx("div",{className:"space-y-3",children:e.map(r=>n.jsxs("div",{className:"flex flex-col gap-1 text-sm sm:flex-row sm:items-center sm:gap-3",children:[n.jsx("span",{className:"shrink-0 text-xs font-medium text-gray-500",children:r.label}),n.jsx("span",{className:"break-all text-sm text-gray-900",children:r.render?r.render(t[r.key]):t[r.key]??"-"})]},r.key))})}function Ps(e){return[{label:e("tasks.detail.chunk.columns.strategy"),key:"strategy",render:t=>e(`tasks.detail.chunk.strategy.${t}`,{defaultValue:Dr[t]??t})},{label:e("tasks.detail.chunk.columns.size"),key:"chunk_size"},{label:e("tasks.detail.chunk.columns.overlap"),key:"chunk_overlap"}]}function Is({data:e}){const{t}=ne();return e?n.jsx(Ue,{data:e,columns:Ps(t)}):n.jsx(kn,{children:n.jsxs(bn,{children:[n.jsx(vn,{variant:"icon",children:n.jsx(mn,{})}),n.jsx(Cn,{children:t("tasks.detail.chunk.empty")})]})})}function st({ref:e,className:t,...r}){return n.jsx("div",{ref:e,className:J("rounded-lg border bg-card text-card-foreground shadow-sm",t),...r})}st.displayName="Card";function at({ref:e,className:t,...r}){return n.jsx("div",{ref:e,className:J("flex flex-col space-y-1.5 p-6",t),...r})}at.displayName="CardHeader";function lt({ref:e,className:t,...r}){return n.jsx("h3",{ref:e,className:J("text-2xl font-semibold leading-none tracking-tight",t),...r})}lt.displayName="CardTitle";function ot({ref:e,className:t,...r}){return n.jsx("div",{ref:e,className:J("p-6 pt-0",t),...r})}ot.displayName="CardContent";const Fe=.5,Ae=4;function We(e,t,r){return Math.min(r,Math.max(t,e))}function Ce(e){const t=e%360;return t<0?t+360:t}function Ts({src:e,alt:t,trigger:r,caption:l,open:s,onOpenChange:i,imageClassName:o,initialRotation:c=0}){const[a,u]=d.useState(!1),[m,f]=d.useState(1),[h,g]=d.useState(()=>Ce(c)),[x,b]=d.useState(()=>Ce(c)),[y,k]=d.useState({x:0,y:0}),[P,D]=d.useState(!1),p=d.useRef(null),F=d.useRef({pointerId:null,moved:!1,onImage:!1,ignoreClick:!1}),R=s!==void 0,j=R?s:a,H=d.useCallback(z=>{R||u(z),i==null||i(z)},[R,i]),O=d.useCallback(z=>{f($=>{const K=typeof z=="function"?z($):z,se=Number.isNaN(K)?$:K,me=We(se,Fe,Ae);return Number(me.toFixed(2))})},[]),B=d.useCallback(z=>{const $=.2*z;O(K=>K+$)},[O]),v=d.useCallback(z=>{z.preventDefault();const $=z.deltaY<0?1:-1;B($)},[B]),w=d.useCallback(()=>{O(z=>{const $=We(1.2,Fe,Ae);return Math.abs(z-1)<.01?We(z+$,Fe,Ae):We(1,Fe,Ae)}),k({x:0,y:0})},[O]),N=d.useCallback(z=>{g($=>Ce($+z))},[]);d.useEffect(()=>{b(z=>{const $=Ce(z);let K=h-$;return K>180?K-=360:K<-180&&(K+=360),z+K})},[h]);const S=d.useCallback(()=>{O(1),g(Ce(c)),k({x:0,y:0})},[c,O]);d.useEffect(()=>{j||(O(1),g(Ce(c)),k({x:0,y:0}),D(!1),p.current=null,F.current={pointerId:null,moved:!1,onImage:!1,ignoreClick:!1})},[j,c,O]);const M=d.useCallback(z=>{if(z.button!==0)return;z.preventDefault(),z.currentTarget.setPointerCapture(z.pointerId);const $=z.target;F.current={pointerId:z.pointerId,moved:!1,onImage:($==null?void 0:$.tagName)==="IMG",ignoreClick:z.detail>1},p.current={pointerId:z.pointerId,origin:{x:z.clientX,y:z.clientY},start:y},D(!0)},[y]),Y=d.useCallback(z=>{const $=p.current;if(!$||$.pointerId!==z.pointerId)return;z.preventDefault();const K=z.clientX-$.origin.x,se=z.clientY-$.origin.y;F.current.moved||(Math.abs(K)>2||Math.abs(se)>2)&&(F.current.moved=!0),k({x:$.start.x+K,y:$.start.y+se})},[]),re=d.useCallback(z=>{const $=p.current;if(!$||$.pointerId!==z.pointerId)return;z.preventDefault(),z.currentTarget.hasPointerCapture(z.pointerId)&&z.currentTarget.releasePointerCapture(z.pointerId),p.current=null,D(!1);const K=F.current;K.pointerId===z.pointerId&&!K.moved&&!K.onImage&&!K.ignoreClick&&H(!1),F.current={pointerId:null,moved:!1,onImage:!1,ignoreClick:!1}},[H]);return n.jsxs(Xe,{open:j,onOpenChange:H,children:[n.jsx(Qr,{asChild:!0,children:r??n.jsxs(Z,{variant:"ghost",size:"icon",children:[n.jsx(ls,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:"查看图片"})]})}),n.jsx(Ze,{showCloseButton:!0,className:"border-transparent sm:max-w-[100vw] max-w-[00vw] h-[100vh] w-full bg-transparent backdrop-blur-lg !p-0 !rounded-none shadow-none !flex flex-col overflow-hidden",children:n.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-hidden",children:[n.jsx("div",{onWheel:v,onDoubleClick:w,onPointerDown:M,onPointerMove:Y,onPointerUp:re,onPointerLeave:re,onPointerCancel:re,className:J("relative flex min-h-[18rem] w-full flex-1 items-center justify-center overflow-hidden bg-transparent",P?"cursor-grabbing":"cursor-grab"),children:n.jsx("div",{className:"transform-gpu",style:{transform:`translate3d(${y.x}px, ${y.y}px, 0)`},children:n.jsx("img",{src:e,alt:t,className:J("max-h-full max-w-full select-none object-contain transition-transform duration-200 ease-out will-change-transform",o),style:{transform:`rotate(${x}deg) scale(${m})`,transformOrigin:"center"},draggable:!1})})}),n.jsxs("div",{className:"flex shrink-0 flex-col items-center gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[n.jsx(Le,{label:"缩小",onClick:()=>B(-1),disabled:m<=Fe,children:n.jsx(gs,{})}),n.jsx(Le,{label:"放大",onClick:()=>B(1),disabled:m>=Ae,children:n.jsx(hs,{})}),n.jsx(Le,{label:"左旋转",onClick:()=>N(-90),children:n.jsx(ds,{})}),n.jsx(Le,{label:"右旋转",onClick:()=>N(90),children:n.jsx(yn,{})}),n.jsx(Le,{label:"重置",onClick:S,children:n.jsx(cs,{})})]}),n.jsxs("span",{className:"text-muted-foreground text-sm font-medium tabular-nums",children:[Math.round(m*100),"%"]})]}),l?n.jsx("div",{className:"text-muted-foreground text-sm",children:l}):null]})})]})}function Le({disabled:e,onClick:t,children:r}){return n.jsx(Z,{type:"button",className:"[--radius:9999rem] bg-transparent border-0",variant:"outline",size:"icon-sm",onClick:t,disabled:e,children:r})}const it=d.createContext(null);it.displayName="PanelGroupContext";const q={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},_t=10,be=d.useLayoutEffect,Jt=gr.useId,Rs=typeof Jt=="function"?Jt:()=>null;let Ms=0;function Dt(e=null){const t=Rs(),r=d.useRef(e||t||null);return r.current===null&&(r.current=""+Ms++),e??r.current}function jn({children:e,className:t="",collapsedSize:r,collapsible:l,defaultSize:s,forwardedRef:i,id:o,maxSize:c,minSize:a,onCollapse:u,onExpand:m,onResize:f,order:h,style:g,tagName:x="div",...b}){const y=d.useContext(it);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:k,expandPanel:P,getPanelSize:D,getPanelStyle:p,groupId:F,isPanelCollapsed:R,reevaluatePanelConstraints:j,registerPanel:H,resizePanel:O,unregisterPanel:B}=y,v=Dt(o),w=d.useRef({callbacks:{onCollapse:u,onExpand:m,onResize:f},constraints:{collapsedSize:r,collapsible:l,defaultSize:s,maxSize:c,minSize:a},id:v,idIsFromProps:o!==void 0,order:h});d.useRef({didLogMissingDefaultSizeWarning:!1}),be(()=>{const{callbacks:S,constraints:M}=w.current,Y={...M};w.current.id=v,w.current.idIsFromProps=o!==void 0,w.current.order=h,S.onCollapse=u,S.onExpand=m,S.onResize=f,M.collapsedSize=r,M.collapsible=l,M.defaultSize=s,M.maxSize=c,M.minSize=a,(Y.collapsedSize!==M.collapsedSize||Y.collapsible!==M.collapsible||Y.maxSize!==M.maxSize||Y.minSize!==M.minSize)&&j(w.current,Y)}),be(()=>{const S=w.current;return H(S),()=>{B(S)}},[h,v,H,B]),d.useImperativeHandle(i,()=>({collapse:()=>{k(w.current)},expand:S=>{P(w.current,S)},getId(){return v},getSize(){return D(w.current)},isCollapsed(){return R(w.current)},isExpanded(){return!R(w.current)},resize:S=>{O(w.current,S)}}),[k,P,D,R,v,O]);const N=p(w.current,s);return d.createElement(x,{...b,children:e,className:t,id:v,style:{...N,...g},[q.groupId]:F,[q.panel]:"",[q.panelCollapsible]:l||void 0,[q.panelId]:v,[q.panelSize]:parseFloat(""+N.flexGrow).toFixed(1)})}const wn=d.forwardRef((e,t)=>d.createElement(jn,{...e,forwardedRef:t}));jn.displayName="Panel";wn.displayName="forwardRef(Panel)";let Tt=null,et=-1,pe=null;function Fs(e,t,r){const l=(t&Pn)!==0,s=(t&In)!==0,i=(t&Tn)!==0,o=(t&Rn)!==0;if(t){if(l)return i?"se-resize":o?"ne-resize":"e-resize";if(s)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function As(){pe!==null&&(document.head.removeChild(pe),Tt=null,pe=null,et=-1)}function vt(e,t,r){var l,s;const i=Fs(e,t);if(Tt!==i){if(Tt=i,pe===null&&(pe=document.createElement("style"),document.head.appendChild(pe)),et>=0){var o;(o=pe.sheet)===null||o===void 0||o.removeRule(et)}et=(l=(s=pe.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${i} !important;}`))!==null&&l!==void 0?l:-1}}function En(e){return e.type==="keydown"}function Sn(e){return e.type.startsWith("pointer")}function zn(e){return e.type.startsWith("mouse")}function ct(e){if(Sn(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(zn(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Ls(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function _s(e,t,r){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Ds(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:Qt(e),b:Qt(t)};let l;for(;r.a.at(-1)===r.b.at(-1);)e=r.a.pop(),t=r.b.pop(),l=e;L(l,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Zt(Xt(r.a)),b:Zt(Xt(r.b))};if(s.a===s.b){const i=l.childNodes,o={a:r.a.at(-1),b:r.b.at(-1)};let c=i.length;for(;c--;){const a=i[c];if(a===o.a)return 1;if(a===o.b)return-1}}return Math.sign(s.a-s.b)}const $s=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Os(e){var t;const r=getComputedStyle((t=Nn(e))!==null&&t!==void 0?t:e).display;return r==="flex"||r==="inline-flex"}function Bs(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Os(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||$s.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Xt(e){let t=e.length;for(;t--;){const r=e[t];if(L(r,"Missing node"),Bs(r))return r}return null}function Zt(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Qt(e){const t=[];for(;e;)t.push(e),e=Nn(e);return t}function Nn(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Pn=1,In=2,Tn=4,Rn=8,Hs=Ls()==="coarse";let le=[],Ie=!1,ge=new Map,ut=new Map;const Oe=new Set;function Vs(e,t,r,l,s){var i;const{ownerDocument:o}=t,c={direction:r,element:t,hitAreaMargins:l,setResizeHandlerState:s},a=(i=ge.get(o))!==null&&i!==void 0?i:0;return ge.set(o,a+1),Oe.add(c),nt(),function(){var m;ut.delete(e),Oe.delete(c);const f=(m=ge.get(o))!==null&&m!==void 0?m:1;if(ge.set(o,f-1),nt(),f===1&&ge.delete(o),le.includes(c)){const h=le.indexOf(c);h>=0&&le.splice(h,1),dt(),s("up",!0,null)}}}function Us(e){const{target:t}=e,{x:r,y:l}=ct(e);Ie=!0,$t({target:t,x:r,y:l}),nt(),le.length>0&&(rt("down",e),dt(),e.preventDefault(),Mn(t)||e.stopImmediatePropagation())}function Ct(e){const{x:t,y:r}=ct(e);if(Ie&&e.type!=="pointerleave"&&e.buttons===0&&(Ie=!1,rt("up",e)),!Ie){const{target:l}=e;$t({target:l,x:t,y:r})}rt("move",e),dt(),le.length>0&&e.preventDefault()}function jt(e){const{target:t}=e,{x:r,y:l}=ct(e);ut.clear(),Ie=!1,le.length>0&&(e.preventDefault(),Mn(t)||e.stopImmediatePropagation()),rt("up",e),$t({target:t,x:r,y:l}),dt(),nt()}function Mn(e){let t=e;for(;t;){if(t.hasAttribute(q.resizeHandle))return!0;t=t.parentElement}return!1}function $t({target:e,x:t,y:r}){le.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Oe.forEach(s=>{const{element:i,hitAreaMargins:o}=s,c=i.getBoundingClientRect(),{bottom:a,left:u,right:m,top:f}=c,h=Hs?o.coarse:o.fine;if(t>=u-h&&t<=m+h&&r>=f-h&&r<=a+h){if(l!==null&&document.contains(l)&&i!==l&&!i.contains(l)&&!l.contains(i)&&Ds(l,i)>0){let x=l,b=!1;for(;x&&!x.contains(i);){if(_s(x.getBoundingClientRect(),c)){b=!0;break}x=x.parentElement}if(b)return}le.push(s)}})}function wt(e,t){ut.set(e,t)}function dt(){let e=!1,t=!1;le.forEach(l=>{const{direction:s}=l;s==="horizontal"?e=!0:t=!0});let r=0;ut.forEach(l=>{r|=l}),e&&t?vt("intersection",r):e?vt("horizontal",r):t?vt("vertical",r):As()}let Et;function nt(){var e;(e=Et)===null||e===void 0||e.abort(),Et=new AbortController;const t={capture:!0,signal:Et.signal};Oe.size&&(Ie?(le.length>0&&ge.forEach((r,l)=>{const{body:s}=l;r>0&&(s.addEventListener("contextmenu",jt,t),s.addEventListener("pointerleave",Ct,t),s.addEventListener("pointermove",Ct,t))}),ge.forEach((r,l)=>{const{body:s}=l;s.addEventListener("pointerup",jt,t),s.addEventListener("pointercancel",jt,t)})):ge.forEach((r,l)=>{const{body:s}=l;r>0&&(s.addEventListener("pointerdown",Us,t),s.addEventListener("pointermove",Ct,t))}))}function rt(e,t){Oe.forEach(r=>{const{setResizeHandlerState:l}=r,s=le.includes(r);l(e,s,t)})}function Ks(){const[e,t]=d.useState(0);return d.useCallback(()=>t(r=>r+1),[])}function L(e,t){if(!e)throw console.error(t),Error(t)}function ve(e,t,r=_t){return e.toFixed(r)===t.toFixed(r)?0:e>t?1:-1}function de(e,t,r=_t){return ve(e,t,r)===0}function Q(e,t,r){return ve(e,t,r)===0}function Gs(e,t,r){if(e.length!==t.length)return!1;for(let l=0;l<e.length;l++){const s=e[l],i=t[l];if(!Q(s,i,r))return!1}return!0}function ze({panelConstraints:e,panelIndex:t,size:r}){const l=e[t];L(l!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:i,maxSize:o=100,minSize:c=0}=l;if(ve(r,c)<0)if(i){const a=(s+c)/2;ve(r,a)<0?r=s:r=c}else r=c;return r=Math.min(o,r),r=parseFloat(r.toFixed(_t)),r}function _e({delta:e,initialLayout:t,panelConstraints:r,pivotIndices:l,prevLayout:s,trigger:i}){if(Q(e,0))return t;const o=[...t],[c,a]=l;L(c!=null,"Invalid first pivot index"),L(a!=null,"Invalid second pivot index");let u=0;if(i==="keyboard"){{const f=e<0?a:c,h=r[f];L(h,`Panel constraints not found for index ${f}`);const{collapsedSize:g=0,collapsible:x,minSize:b=0}=h;if(x){const y=t[f];if(L(y!=null,`Previous layout not found for panel index ${f}`),Q(y,g)){const k=b-y;ve(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}{const f=e<0?c:a,h=r[f];L(h,`No panel constraints found for index ${f}`);const{collapsedSize:g=0,collapsible:x,minSize:b=0}=h;if(x){const y=t[f];if(L(y!=null,`Previous layout not found for panel index ${f}`),Q(y,b)){const k=y-g;ve(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}}{const f=e<0?1:-1;let h=e<0?a:c,g=0;for(;;){const b=t[h];L(b!=null,`Previous layout not found for panel index ${h}`);const k=ze({panelConstraints:r,panelIndex:h,size:100})-b;if(g+=k,h+=f,h<0||h>=r.length)break}const x=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-x:x}{let h=e<0?c:a;for(;h>=0&&h<r.length;){const g=Math.abs(e)-Math.abs(u),x=t[h];L(x!=null,`Previous layout not found for panel index ${h}`);const b=x-g,y=ze({panelConstraints:r,panelIndex:h,size:b});if(!Q(x,y)&&(u+=x-y,o[h]=y,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?h--:h++}}if(Gs(s,o))return s;{const f=e<0?a:c,h=t[f];L(h!=null,`Previous layout not found for panel index ${f}`);const g=h+u,x=ze({panelConstraints:r,panelIndex:f,size:g});if(o[f]=x,!Q(x,g)){let b=g-x,k=e<0?a:c;for(;k>=0&&k<r.length;){const P=o[k];L(P!=null,`Previous layout not found for panel index ${k}`);const D=P+b,p=ze({panelConstraints:r,panelIndex:k,size:D});if(Q(P,p)||(b-=p-P,o[k]=p),Q(b,0))break;e>0?k--:k++}}}const m=o.reduce((f,h)=>h+f,0);return Q(m,100)?o:s}function qs({layout:e,panelsArray:t,pivotIndices:r}){let l=0,s=100,i=0,o=0;const c=r[0];L(c!=null,"No pivot index found"),t.forEach((f,h)=>{const{constraints:g}=f,{maxSize:x=100,minSize:b=0}=g;h===c?(l=b,s=x):(i+=b,o+=x)});const a=Math.min(s,100-i),u=Math.max(l,100-o),m=e[c];return{valueMax:a,valueMin:u,valueNow:m}}function Be(e,t=document){return Array.from(t.querySelectorAll(`[${q.resizeHandleId}][data-panel-group-id="${e}"]`))}function Fn(e,t,r=document){const s=Be(e,r).findIndex(i=>i.getAttribute(q.resizeHandleId)===t);return s??null}function An(e,t,r){const l=Fn(e,t,r);return l!=null?[l,l+1]:[-1,-1]}function Ws(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Ln(e,t=document){if(Ws(t)&&t.dataset.panelGroupId==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function ft(e,t=document){const r=t.querySelector(`[${q.resizeHandleId}="${e}"]`);return r||null}function Ys(e,t,r,l=document){var s,i,o,c;const a=ft(t,l),u=Be(e,l),m=a?u.indexOf(a):-1,f=(s=(i=r[m])===null||i===void 0?void 0:i.id)!==null&&s!==void 0?s:null,h=(o=(c=r[m+1])===null||c===void 0?void 0:c.id)!==null&&o!==void 0?o:null;return[f,h]}function Js({committedValuesRef:e,eagerValuesRef:t,groupId:r,layout:l,panelDataArray:s,panelGroupElement:i,setLayout:o}){d.useRef({didWarnAboutMissingResizeHandle:!1}),be(()=>{if(!i)return;const c=Be(r,i);for(let a=0;a<s.length-1;a++){const{valueMax:u,valueMin:m,valueNow:f}=qs({layout:l,panelsArray:s,pivotIndices:[a,a+1]}),h=c[a];if(h!=null){const g=s[a];L(g,`No panel data found for index "${a}"`),h.setAttribute("aria-controls",g.id),h.setAttribute("aria-valuemax",""+Math.round(u)),h.setAttribute("aria-valuemin",""+Math.round(m)),h.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{c.forEach((a,u)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[r,l,s,i]),d.useEffect(()=>{if(!i)return;const c=t.current;L(c,"Eager values not found");const{panelDataArray:a}=c,u=Ln(r,i);L(u!=null,`No group found for id "${r}"`);const m=Be(r,i);L(m,`No resize handles found for group id "${r}"`);const f=m.map(h=>{const g=h.getAttribute(q.resizeHandleId);L(g,"Resize handle element has no handle id attribute");const[x,b]=Ys(r,g,a,i);if(x==null||b==null)return()=>{};const y=k=>{if(!k.defaultPrevented)switch(k.key){case"Enter":{k.preventDefault();const P=a.findIndex(D=>D.id===x);if(P>=0){const D=a[P];L(D,`No panel data found for index ${P}`);const p=l[P],{collapsedSize:F=0,collapsible:R,minSize:j=0}=D.constraints;if(p!=null&&R){const H=_e({delta:Q(p,F)?j-F:F-p,initialLayout:l,panelConstraints:a.map(O=>O.constraints),pivotIndices:An(r,g,i),prevLayout:l,trigger:"keyboard"});l!==H&&o(H)}}break}}};return h.addEventListener("keydown",y),()=>{h.removeEventListener("keydown",y)}});return()=>{f.forEach(h=>h())}},[i,e,t,r,l,s,o])}function en(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function _n(e,t){const r=e==="horizontal",{x:l,y:s}=ct(t);return r?l:s}function Xs(e,t,r,l,s){const i=r==="horizontal",o=ft(t,s);L(o,`No resize handle element found for id "${t}"`);const c=o.getAttribute(q.groupId);L(c,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=l;const u=_n(r,e),m=Ln(c,s);L(m,`No group element found for id "${c}"`);const f=m.getBoundingClientRect(),h=i?f.width:f.height;return(u-a)/h*100}function Zs(e,t,r,l,s,i){if(En(e)){const o=r==="horizontal";let c=0;e.shiftKey?c=100:s!=null?c=s:c=10;let a=0;switch(e.key){case"ArrowDown":a=o?0:c;break;case"ArrowLeft":a=o?-c:0;break;case"ArrowRight":a=o?c:0;break;case"ArrowUp":a=o?0:-c;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return l==null?0:Xs(e,t,r,l,i)}function Qs({panelDataArray:e}){const t=Array(e.length),r=e.map(i=>i.constraints);let l=0,s=100;for(let i=0;i<e.length;i++){const o=r[i];L(o,`Panel constraints not found for index ${i}`);const{defaultSize:c}=o;c!=null&&(l++,t[i]=c,s-=c)}for(let i=0;i<e.length;i++){const o=r[i];L(o,`Panel constraints not found for index ${i}`);const{defaultSize:c}=o;if(c!=null)continue;const a=e.length-l,u=s/a;l++,t[i]=u,s-=u}return t}function je(e,t,r){t.forEach((l,s)=>{const i=e[s];L(i,`Panel data not found for index ${s}`);const{callbacks:o,constraints:c,id:a}=i,{collapsedSize:u=0,collapsible:m}=c,f=r[a];if(f==null||l!==f){r[a]=l;const{onCollapse:h,onExpand:g,onResize:x}=o;x&&x(l,f),m&&(h||g)&&(g&&(f==null||de(f,u))&&!de(l,u)&&g(),h&&(f==null||!de(f,u))&&de(l,u)&&h())}})}function Ye(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!=t[r])return!1;return!0}function ea({defaultSize:e,dragState:t,layout:r,panelData:l,panelIndex:s,precision:i=3}){const o=r[s];let c;return o==null?c=e!=null?e.toFixed(i):"1":l.length===1?c="1":c=o.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function ta(e,t=10){let r=null;return(...s)=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{e(...s)},t)}}function tn(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,r)=>{localStorage.setItem(t,r)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Dn(e){return`react-resizable-panels:${e}`}function $n(e){return e.map(t=>{const{constraints:r,id:l,idIsFromProps:s,order:i}=t;return s?l:i?`${i}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((t,r)=>t.localeCompare(r)).join(",")}function On(e,t){try{const r=Dn(e),l=t.getItem(r);if(l){const s=JSON.parse(l);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function na(e,t,r){var l,s;const i=(l=On(e,r))!==null&&l!==void 0?l:{},o=$n(t);return(s=i[o])!==null&&s!==void 0?s:null}function ra(e,t,r,l,s){var i;const o=Dn(e),c=$n(t),a=(i=On(e,s))!==null&&i!==void 0?i:{};a[c]={expandToSizes:Object.fromEntries(r.entries()),layout:l};try{s.setItem(o,JSON.stringify(a))}catch(u){console.error(u)}}function nn({layout:e,panelConstraints:t}){const r=[...e],l=r.reduce((i,o)=>i+o,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(i=>`${i}%`).join(", ")}`);if(!Q(l,100)&&r.length>0)for(let i=0;i<t.length;i++){const o=r[i];L(o!=null,`No layout data found for index ${i}`);const c=100/l*o;r[i]=c}let s=0;for(let i=0;i<t.length;i++){const o=r[i];L(o!=null,`No layout data found for index ${i}`);const c=ze({panelConstraints:t,panelIndex:i,size:o});o!=c&&(s+=o-c,r[i]=c)}if(!Q(s,0))for(let i=0;i<t.length;i++){const o=r[i];L(o!=null,`No layout data found for index ${i}`);const c=o+s,a=ze({panelConstraints:t,panelIndex:i,size:c});if(o!==a&&(s-=a-o,r[i]=a,Q(s,0)))break}return r}const sa=100,De={getItem:e=>(tn(De),De.getItem(e)),setItem:(e,t)=>{tn(De),De.setItem(e,t)}},rn={};function Bn({autoSaveId:e=null,children:t,className:r="",direction:l,forwardedRef:s,id:i=null,onLayout:o=null,keyboardResizeBy:c=null,storage:a=De,style:u,tagName:m="div",...f}){const h=Dt(i),g=d.useRef(null),[x,b]=d.useState(null),[y,k]=d.useState([]),P=Ks(),D=d.useRef({}),p=d.useRef(new Map),F=d.useRef(0),R=d.useRef({autoSaveId:e,direction:l,dragState:x,id:h,keyboardResizeBy:c,onLayout:o,storage:a}),j=d.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});d.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),d.useImperativeHandle(s,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:C}=j.current;return C},setLayout:C=>{const{onLayout:T}=R.current,{layout:_,panelDataArray:I}=j.current,E=nn({layout:C,panelConstraints:I.map(A=>A.constraints)});en(_,E)||(k(E),j.current.layout=E,T&&T(E),je(I,E,D.current))}}),[]),be(()=>{R.current.autoSaveId=e,R.current.direction=l,R.current.dragState=x,R.current.id=h,R.current.onLayout=o,R.current.storage=a}),Js({committedValuesRef:R,eagerValuesRef:j,groupId:h,layout:y,panelDataArray:j.current.panelDataArray,setLayout:k,panelGroupElement:g.current}),d.useEffect(()=>{const{panelDataArray:C}=j.current;if(e){if(y.length===0||y.length!==C.length)return;let T=rn[e];T==null&&(T=ta(ra,sa),rn[e]=T);const _=[...C],I=new Map(p.current);T(e,_,I,y,a)}},[e,y,a]),d.useEffect(()=>{});const H=d.useCallback(C=>{const{onLayout:T}=R.current,{layout:_,panelDataArray:I}=j.current;if(C.constraints.collapsible){const E=I.map(oe=>oe.constraints),{collapsedSize:A=0,panelSize:V,pivotIndices:W}=xe(I,C,_);if(L(V!=null,`Panel size not found for panel "${C.id}"`),!de(V,A)){p.current.set(C.id,V);const ie=we(I,C)===I.length-1?V-A:A-V,G=_e({delta:ie,initialLayout:_,panelConstraints:E,pivotIndices:W,prevLayout:_,trigger:"imperative-api"});Ye(_,G)||(k(G),j.current.layout=G,T&&T(G),je(I,G,D.current))}}},[]),O=d.useCallback((C,T)=>{const{onLayout:_}=R.current,{layout:I,panelDataArray:E}=j.current;if(C.constraints.collapsible){const A=E.map(ae=>ae.constraints),{collapsedSize:V=0,panelSize:W=0,minSize:oe=0,pivotIndices:ie}=xe(E,C,I),G=T??oe;if(de(W,V)){const ae=p.current.get(C.id),Re=ae!=null&&ae>=G?ae:G,gt=we(E,C)===E.length-1?W-Re:Re-W,X=_e({delta:gt,initialLayout:I,panelConstraints:A,pivotIndices:ie,prevLayout:I,trigger:"imperative-api"});Ye(I,X)||(k(X),j.current.layout=X,_&&_(X),je(E,X,D.current))}}},[]),B=d.useCallback(C=>{const{layout:T,panelDataArray:_}=j.current,{panelSize:I}=xe(_,C,T);return L(I!=null,`Panel size not found for panel "${C.id}"`),I},[]),v=d.useCallback((C,T)=>{const{panelDataArray:_}=j.current,I=we(_,C);return ea({defaultSize:T,dragState:x,layout:y,panelData:_,panelIndex:I})},[x,y]),w=d.useCallback(C=>{const{layout:T,panelDataArray:_}=j.current,{collapsedSize:I=0,collapsible:E,panelSize:A}=xe(_,C,T);return L(A!=null,`Panel size not found for panel "${C.id}"`),E===!0&&de(A,I)},[]),N=d.useCallback(C=>{const{layout:T,panelDataArray:_}=j.current,{collapsedSize:I=0,collapsible:E,panelSize:A}=xe(_,C,T);return L(A!=null,`Panel size not found for panel "${C.id}"`),!E||ve(A,I)>0},[]),S=d.useCallback(C=>{const{panelDataArray:T}=j.current;T.push(C),T.sort((_,I)=>{const E=_.order,A=I.order;return E==null&&A==null?0:E==null?-1:A==null?1:E-A}),j.current.panelDataArrayChanged=!0,P()},[P]);be(()=>{if(j.current.panelDataArrayChanged){j.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:T,storage:_}=R.current,{layout:I,panelDataArray:E}=j.current;let A=null;if(C){const W=na(C,E,_);W&&(p.current=new Map(Object.entries(W.expandToSizes)),A=W.layout)}A==null&&(A=Qs({panelDataArray:E}));const V=nn({layout:A,panelConstraints:E.map(W=>W.constraints)});en(I,V)||(k(V),j.current.layout=V,T&&T(V),je(E,V,D.current))}}),be(()=>{const C=j.current;return()=>{C.layout=[]}},[]);const M=d.useCallback(C=>{let T=!1;const _=g.current;return _&&window.getComputedStyle(_,null).getPropertyValue("direction")==="rtl"&&(T=!0),function(E){E.preventDefault();const A=g.current;if(!A)return()=>null;const{direction:V,dragState:W,id:oe,keyboardResizeBy:ie,onLayout:G}=R.current,{layout:ae,panelDataArray:Re}=j.current,{initialLayout:Ge}=W??{},gt=An(oe,C,A);let X=Zs(E,C,V,W,ie,A);const Vt=V==="horizontal";Vt&&T&&(X=-X);const hr=Re.map(pr=>pr.constraints),Me=_e({delta:X,initialLayout:Ge??ae,panelConstraints:hr,pivotIndices:gt,prevLayout:ae,trigger:En(E)?"keyboard":"mouse-or-touch"}),Ut=!Ye(ae,Me);(Sn(E)||zn(E))&&F.current!=X&&(F.current=X,!Ut&&X!==0?Vt?wt(C,X<0?Pn:In):wt(C,X<0?Tn:Rn):wt(C,0)),Ut&&(k(Me),j.current.layout=Me,G&&G(Me),je(Re,Me,D.current))}},[]),Y=d.useCallback((C,T)=>{const{onLayout:_}=R.current,{layout:I,panelDataArray:E}=j.current,A=E.map(ae=>ae.constraints),{panelSize:V,pivotIndices:W}=xe(E,C,I);L(V!=null,`Panel size not found for panel "${C.id}"`);const ie=we(E,C)===E.length-1?V-T:T-V,G=_e({delta:ie,initialLayout:I,panelConstraints:A,pivotIndices:W,prevLayout:I,trigger:"imperative-api"});Ye(I,G)||(k(G),j.current.layout=G,_&&_(G),je(E,G,D.current))},[]),re=d.useCallback((C,T)=>{const{layout:_,panelDataArray:I}=j.current,{collapsedSize:E=0,collapsible:A}=T,{collapsedSize:V=0,collapsible:W,maxSize:oe=100,minSize:ie=0}=C.constraints,{panelSize:G}=xe(I,C,_);G!=null&&(A&&W&&de(G,E)?de(E,V)||Y(C,V):G<ie?Y(C,ie):G>oe&&Y(C,oe))},[Y]),z=d.useCallback((C,T)=>{const{direction:_}=R.current,{layout:I}=j.current;if(!g.current)return;const E=ft(C,g.current);L(E,`Drag handle element not found for id "${C}"`);const A=_n(_,T);b({dragHandleId:C,dragHandleRect:E.getBoundingClientRect(),initialCursorPosition:A,initialLayout:I})},[]),$=d.useCallback(()=>{b(null)},[]),K=d.useCallback(C=>{const{panelDataArray:T}=j.current,_=we(T,C);_>=0&&(T.splice(_,1),delete D.current[C.id],j.current.panelDataArrayChanged=!0,P())},[P]),se=d.useMemo(()=>({collapsePanel:H,direction:l,dragState:x,expandPanel:O,getPanelSize:B,getPanelStyle:v,groupId:h,isPanelCollapsed:w,isPanelExpanded:N,reevaluatePanelConstraints:re,registerPanel:S,registerResizeHandle:M,resizePanel:Y,startDragging:z,stopDragging:$,unregisterPanel:K,panelGroupElement:g.current}),[H,x,l,O,B,v,h,w,N,re,S,M,Y,z,$,K]),me={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return d.createElement(it.Provider,{value:se},d.createElement(m,{...f,children:t,className:r,id:i,ref:g,style:{...me,...u},[q.group]:"",[q.groupDirection]:l,[q.groupId]:h}))}const Hn=d.forwardRef((e,t)=>d.createElement(Bn,{...e,forwardedRef:t}));Bn.displayName="PanelGroup";Hn.displayName="forwardRef(PanelGroup)";function we(e,t){return e.findIndex(r=>r===t||r.id===t.id)}function xe(e,t,r){const l=we(e,t),i=l===e.length-1?[l-1,l]:[l,l+1],o=r[l];return{...t.constraints,panelSize:o,pivotIndices:i}}function aa({disabled:e,handleId:t,resizeHandler:r,panelGroupElement:l}){d.useEffect(()=>{if(e||r==null||l==null)return;const s=ft(t,l);if(s==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),r(o);break}case"F6":{o.preventDefault();const c=s.getAttribute(q.groupId);L(c,`No group element found for id "${c}"`);const a=Be(c,l),u=Fn(c,t,l);L(u!==null,`No resize element found for id "${t}"`);const m=o.shiftKey?u>0?u-1:a.length-1:u+1<a.length?u+1:0;a[m].focus();break}}};return s.addEventListener("keydown",i),()=>{s.removeEventListener("keydown",i)}},[l,e,t,r])}function Vn({children:e=null,className:t="",disabled:r=!1,hitAreaMargins:l,id:s,onBlur:i,onClick:o,onDragging:c,onFocus:a,onPointerDown:u,onPointerUp:m,style:f={},tabIndex:h=0,tagName:g="div",...x}){var b,y;const k=d.useRef(null),P=d.useRef({onClick:o,onDragging:c,onPointerDown:u,onPointerUp:m});d.useEffect(()=>{P.current.onClick=o,P.current.onDragging=c,P.current.onPointerDown=u,P.current.onPointerUp=m});const D=d.useContext(it);if(D===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,groupId:F,registerResizeHandle:R,startDragging:j,stopDragging:H,panelGroupElement:O}=D,B=Dt(s),[v,w]=d.useState("inactive"),[N,S]=d.useState(!1),[M,Y]=d.useState(null),re=d.useRef({state:v});be(()=>{re.current.state=v}),d.useEffect(()=>{if(r)Y(null);else{const se=R(B);Y(()=>se)}},[r,B,R]);const z=(b=l==null?void 0:l.coarse)!==null&&b!==void 0?b:15,$=(y=l==null?void 0:l.fine)!==null&&y!==void 0?y:5;d.useEffect(()=>{if(r||M==null)return;const se=k.current;L(se,"Element ref not attached");let me=!1;return Vs(B,se,p,{coarse:z,fine:$},(T,_,I)=>{if(!_){w("inactive");return}switch(T){case"down":{w("drag"),me=!1,L(I,'Expected event to be defined for "down" action'),j(B,I);const{onDragging:E,onPointerDown:A}=P.current;E==null||E(!0),A==null||A();break}case"move":{const{state:E}=re.current;me=!0,E!=="drag"&&w("hover"),L(I,'Expected event to be defined for "move" action'),M(I);break}case"up":{w("hover"),H();const{onClick:E,onDragging:A,onPointerUp:V}=P.current;A==null||A(!1),V==null||V(),me||E==null||E();break}}})},[z,p,r,$,R,B,M,j,H]),aa({disabled:r,handleId:B,resizeHandler:M,panelGroupElement:O});const K={touchAction:"none",userSelect:"none"};return d.createElement(g,{...x,children:e,className:t,id:s,onBlur:()=>{S(!1),i==null||i()},onFocus:()=>{S(!0),a==null||a()},ref:k,role:"separator",style:{...K,...f},tabIndex:h,[q.groupDirection]:p,[q.groupId]:F,[q.resizeHandle]:"",[q.resizeHandleActive]:v==="drag"?"pointer":N?"keyboard":void 0,[q.resizeHandleEnabled]:!r,[q.resizeHandleId]:B,[q.resizeHandleState]:v})}Vn.displayName="PanelResizeHandle";function la({className:e,...t}){return n.jsx(Hn,{"data-slot":"resizable-panel-group",className:J("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Je({...e}){return n.jsx(wn,{"data-slot":"resizable-panel",...e})}function St({withHandle:e,className:t,...r}){return n.jsx(Vn,{"data-slot":"resizable-handle",className:J("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...r,children:e&&n.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:n.jsx(ss,{className:"size-2.5"})})})}var mt="Tabs",[oa]=on(mt,[un]),Un=un(),[ia,Ot]=oa(mt),Kn=d.forwardRef((e,t)=>{const{__scopeTabs:r,value:l,onValueChange:s,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:a="automatic",...u}=e,m=kr(c),[f,h]=ln({prop:l,onChange:s,defaultProp:i??"",caller:mt});return n.jsx(ia,{scope:r,baseId:cn(),value:f,onValueChange:h,orientation:o,dir:m,activationMode:a,children:n.jsx(Ve.div,{dir:m,"data-orientation":o,...u,ref:t})})});Kn.displayName=mt;var Gn="TabsList",qn=d.forwardRef((e,t)=>{const{__scopeTabs:r,loop:l=!0,...s}=e,i=Ot(Gn,r),o=Un(r);return n.jsx(br,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:l,children:n.jsx(Ve.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:t})})});qn.displayName=Gn;var Wn="TabsTrigger",Yn=d.forwardRef((e,t)=>{const{__scopeTabs:r,value:l,disabled:s=!1,...i}=e,o=Ot(Wn,r),c=Un(r),a=Zn(o.baseId,l),u=Qn(o.baseId,l),m=l===o.value;return n.jsx(vr,{asChild:!0,...c,focusable:!s,active:m,children:n.jsx(Ve.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:a,...i,ref:t,onMouseDown:ue(e.onMouseDown,f=>{!s&&f.button===0&&f.ctrlKey===!1?o.onValueChange(l):f.preventDefault()}),onKeyDown:ue(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&o.onValueChange(l)}),onFocus:ue(e.onFocus,()=>{const f=o.activationMode!=="manual";!m&&!s&&f&&o.onValueChange(l)})})})});Yn.displayName=Wn;var Jn="TabsContent",Xn=d.forwardRef((e,t)=>{const{__scopeTabs:r,value:l,forceMount:s,children:i,...o}=e,c=Ot(Jn,r),a=Zn(c.baseId,l),u=Qn(c.baseId,l),m=l===c.value,f=d.useRef(m);return d.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),n.jsx(At,{present:s||m,children:({present:h})=>n.jsx(Ve.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":a,hidden:!h,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:h&&i})})});Xn.displayName=Jn;function Zn(e,t){return`${e}-trigger-${t}`}function Qn(e,t){return`${e}-content-${t}`}var ca=Kn,ua=qn,da=Yn,fa=Xn;function er({className:e,...t}){return n.jsx(ca,{"data-slot":"tabs",className:J("flex flex-col gap-2",e),...t})}function tr({className:e,...t}){return n.jsx(ua,{"data-slot":"tabs-list",className:J("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function nr({className:e,...t}){return n.jsx(da,{"data-slot":"tabs-trigger",className:J("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer",e),...t})}function rr({className:e,...t}){return n.jsx(fa,{"data-slot":"tabs-content",className:J("flex-1 outline-none",e),...t})}var[ht]=on("Tooltip",[dn]),pt=dn(),sr="TooltipProvider",ma=700,Rt="tooltip.open",[ha,Bt]=ht(sr),ar=e=>{const{__scopeTooltip:t,delayDuration:r=ma,skipDelayDuration:l=300,disableHoverableContent:s=!1,children:i}=e,o=d.useRef(!0),c=d.useRef(!1),a=d.useRef(0);return d.useEffect(()=>{const u=a.current;return()=>window.clearTimeout(u)},[]),n.jsx(ha,{scope:t,isOpenDelayedRef:o,delayDuration:r,onOpen:d.useCallback(()=>{window.clearTimeout(a.current),o.current=!1},[]),onClose:d.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.current=!0,l)},[l]),isPointerInTransitRef:c,onPointerInTransitChange:d.useCallback(u=>{c.current=u},[]),disableHoverableContent:s,children:i})};ar.displayName=sr;var He="Tooltip",[pa,Ke]=ht(He),lr=e=>{const{__scopeTooltip:t,children:r,open:l,defaultOpen:s,onOpenChange:i,disableHoverableContent:o,delayDuration:c}=e,a=Bt(He,e.__scopeTooltip),u=pt(t),[m,f]=d.useState(null),h=cn(),g=d.useRef(0),x=o??a.disableHoverableContent,b=c??a.delayDuration,y=d.useRef(!1),[k,P]=ln({prop:l,defaultProp:s??!1,onChange:j=>{j?(a.onOpen(),document.dispatchEvent(new CustomEvent(Rt))):a.onClose(),i==null||i(j)},caller:He}),D=d.useMemo(()=>k?y.current?"delayed-open":"instant-open":"closed",[k]),p=d.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,P(!0)},[P]),F=d.useCallback(()=>{window.clearTimeout(g.current),g.current=0,P(!1)},[P]),R=d.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,P(!0),g.current=0},b)},[b,P]);return d.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),n.jsx(Cr,{...u,children:n.jsx(pa,{scope:t,contentId:h,open:k,stateAttribute:D,trigger:m,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{a.isOpenDelayedRef.current?R():p()},[a.isOpenDelayedRef,R,p]),onTriggerLeave:d.useCallback(()=>{x?F():(window.clearTimeout(g.current),g.current=0)},[F,x]),onOpen:p,onClose:F,disableHoverableContent:x,children:r})})};lr.displayName=He;var Mt="TooltipTrigger",or=d.forwardRef((e,t)=>{const{__scopeTooltip:r,...l}=e,s=Ke(Mt,r),i=Bt(Mt,r),o=pt(r),c=d.useRef(null),a=fn(t,c,s.onTriggerChange),u=d.useRef(!1),m=d.useRef(!1),f=d.useCallback(()=>u.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),n.jsx(jr,{asChild:!0,...o,children:n.jsx(Ve.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...l,ref:a,onPointerMove:ue(e.onPointerMove,h=>{h.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(s.onTriggerEnter(),m.current=!0)}),onPointerLeave:ue(e.onPointerLeave,()=>{s.onTriggerLeave(),m.current=!1}),onPointerDown:ue(e.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ue(e.onFocus,()=>{u.current||s.onOpen()}),onBlur:ue(e.onBlur,s.onClose),onClick:ue(e.onClick,s.onClose)})})});or.displayName=Mt;var Ht="TooltipPortal",[ga,xa]=ht(Ht,{forceMount:void 0}),ir=e=>{const{__scopeTooltip:t,forceMount:r,children:l,container:s}=e,i=Ke(Ht,t);return n.jsx(ga,{scope:t,forceMount:r,children:n.jsx(At,{present:r||i.open,children:n.jsx(wr,{asChild:!0,container:s,children:l})})})};ir.displayName=Ht;var Te="TooltipContent",cr=d.forwardRef((e,t)=>{const r=xa(Te,e.__scopeTooltip),{forceMount:l=r.forceMount,side:s="top",...i}=e,o=Ke(Te,e.__scopeTooltip);return n.jsx(At,{present:l||o.open,children:o.disableHoverableContent?n.jsx(ur,{side:s,...i,ref:t}):n.jsx(ya,{side:s,...i,ref:t})})}),ya=d.forwardRef((e,t)=>{const r=Ke(Te,e.__scopeTooltip),l=Bt(Te,e.__scopeTooltip),s=d.useRef(null),i=fn(t,s),[o,c]=d.useState(null),{trigger:a,onClose:u}=r,m=s.current,{onPointerInTransitChange:f}=l,h=d.useCallback(()=>{c(null),f(!1)},[f]),g=d.useCallback((x,b)=>{const y=x.currentTarget,k={x:x.clientX,y:x.clientY},P=Ca(k,y.getBoundingClientRect()),D=ja(k,P),p=wa(b.getBoundingClientRect()),F=Sa([...D,...p]);c(F),f(!0)},[f]);return d.useEffect(()=>()=>h(),[h]),d.useEffect(()=>{if(a&&m){const x=y=>g(y,m),b=y=>g(y,a);return a.addEventListener("pointerleave",x),m.addEventListener("pointerleave",b),()=>{a.removeEventListener("pointerleave",x),m.removeEventListener("pointerleave",b)}}},[a,m,g,h]),d.useEffect(()=>{if(o){const x=b=>{const y=b.target,k={x:b.clientX,y:b.clientY},P=(a==null?void 0:a.contains(y))||(m==null?void 0:m.contains(y)),D=!Ea(k,o);P?h():D&&(h(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[a,m,o,u,h]),n.jsx(ur,{...e,ref:i})}),[ka,ba]=ht(He,{isInside:!1}),va=Nr("TooltipContent"),ur=d.forwardRef((e,t)=>{const{__scopeTooltip:r,children:l,"aria-label":s,onEscapeKeyDown:i,onPointerDownOutside:o,...c}=e,a=Ke(Te,r),u=pt(r),{onClose:m}=a;return d.useEffect(()=>(document.addEventListener(Rt,m),()=>document.removeEventListener(Rt,m)),[m]),d.useEffect(()=>{if(a.trigger){const f=h=>{const g=h.target;g!=null&&g.contains(a.trigger)&&m()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[a.trigger,m]),n.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:m,children:n.jsxs(zr,{"data-state":a.stateAttribute,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[n.jsx(va,{children:l}),n.jsx(ka,{scope:r,isInside:!0,children:n.jsx(Pr,{id:a.contentId,role:"tooltip",children:s||l})})]})})});cr.displayName=Te;var dr="TooltipArrow",fr=d.forwardRef((e,t)=>{const{__scopeTooltip:r,...l}=e,s=pt(r);return ba(dr,r).isInside?null:n.jsx(Er,{...s,...l,ref:t})});fr.displayName=dr;function Ca(e,t){const r=Math.abs(t.top-e.y),l=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,l,s,i)){case i:return"left";case s:return"right";case r:return"top";case l:return"bottom";default:throw new Error("unreachable")}}function ja(e,t,r=5){const l=[];switch(t){case"top":l.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":l.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":l.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":l.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return l}function wa(e){const{top:t,right:r,bottom:l,left:s}=e;return[{x:s,y:t},{x:r,y:t},{x:r,y:l},{x:s,y:l}]}function Ea(e,t){const{x:r,y:l}=e;let s=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const c=t[i],a=t[o],u=c.x,m=c.y,f=a.x,h=a.y;m>l!=h>l&&r<(f-u)*(l-m)/(h-m)+u&&(s=!s)}return s}function Sa(e){const t=e.slice();return t.sort((r,l)=>r.x<l.x?-1:r.x>l.x?1:r.y<l.y?-1:r.y>l.y?1:0),za(t)}function za(e){if(e.length<=1)return e.slice();const t=[];for(let l=0;l<e.length;l++){const s=e[l];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))t.pop();else break}t.push(s)}t.pop();const r=[];for(let l=e.length-1;l>=0;l--){const s=e[l];for(;r.length>=2;){const i=r[r.length-1],o=r[r.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))r.pop();else break}r.push(s)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var Na=ar,Pa=lr,Ia=or,Ta=ir,Ra=cr,Ma=fr;function Fa({delayDuration:e=0,...t}){return n.jsx(Na,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Aa({...e}){return n.jsx(Fa,{children:n.jsx(Pa,{"data-slot":"tooltip",...e})})}function La({...e}){return n.jsx(Ia,{"data-slot":"tooltip-trigger",...e})}function _a({className:e,sideOffset:t=0,children:r,...l}){return n.jsx(Ta,{children:n.jsxs(Ra,{"data-slot":"tooltip-content",sideOffset:t,className:J("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...l,children:[r,n.jsx(Ma,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Da=["failed","success","timeout","cancelled"];function $a(e){return hn.reduce((t,r)=>(t[r.key]=r.labelKey?e(r.labelKey):r.key,t),{})}function Ne(e,t=-3){return e?e.split("/").slice(t).join("/"):""}function Oa({result:e,job:t,phase:r,fileIndex:l=0}){var F,R;const{t:s}=ne(),i=e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0,o=d.useMemo(()=>e==null?void 0:e.output[l],[e,l]),{data:c}=qt(t==null?void 0:t.id,o),a=e!=null&&e.input&&(e==null?void 0:e.input.length)>0?e.input[l]:null,{data:u}=qt(t==null?void 0:t.id,a==null?void 0:a.path),{data:m}=Kr(t==null?void 0:t.id,a==null?void 0:a.path),[f,h]=d.useState(!1),g=d.useMemo(()=>{var H,O,B,v;const j=(O=(H=t==null?void 0:t.config)==null?void 0:H.source)==null?void 0:O.type;return j?j==="s3"?m:j==="url"?(v=(B=t==null?void 0:t.config)==null?void 0:B.source)==null?void 0:v.storagePath:a?`/api/v1/tasks/${t==null?void 0:t.id}/file?path=${a.path}`:"":""},[t,m,a]),x=d.useCallback(()=>{h(!0)},[]),b=d.useMemo(()=>c!=null&&c.data?JSON.stringify(c.data):"",[c==null?void 0:c.data]),y=d.useMemo(()=>u!=null&&u.data?JSON.stringify(u.data):"",[u==null?void 0:u.data]),k=d.useMemo(()=>n.jsx(Kt,{className:"result-container !h-[90vh]",id:"output",dataSource:{type:"file",content:b,size:c==null?void 0:c.size,path:o},path:`local://${o}`,title:Ne(o),showPagination:!1,showDownload:!1,showSegmentSwitch:!1,showFileInfo:!1}),[b,c==null?void 0:c.size,o]);if((t==null?void 0:t.status)==="failed"&&t.phase===r&&t.errorMessage)return n.jsx(pn,{className:"border-0",title:s("tasks.detail.job.phaseErrorTitle"),content:n.jsx("p",{children:s("tasks.detail.job.phaseErrorContent",{phase:t.phase,message:t.errorMessage})}),icon:n.jsx(Gr,{})});if(!e||i)return n.jsx("div",{className:"rounded-md p-4 text-sm text-gray-500",children:(t==null?void 0:t.status)==="running"?s("tasks.detail.job.phaseInProgress"):s("tasks.detail.job.phaseNoResult")});const P=a&&(a==null?void 0:a.mime_type)==="application/pdf",D=a&&((F=a==null?void 0:a.mime_type)==null?void 0:F.startsWith("image/")),p=a&&((R=a.filename)==null?void 0:R.endsWith(".json"));return r==="import"?k:n.jsxs(la,{direction:"horizontal",children:[P&&n.jsxs(n.Fragment,{children:[n.jsx(Je,{className:"max-h-[90vh]",children:n.jsx(Ir,{loading:!f,className:"h-full",innerClassName:"h-full",children:n.jsx("iframe",{className:"border-0 w-full h-full",src:g,onLoad:x})})}),n.jsx(St,{className:"result-resizer"})]}),D&&n.jsxs(n.Fragment,{children:[n.jsx(Je,{className:"max-h-[90vh]",children:n.jsx(Ts,{src:g,alt:a==null?void 0:a.filename,trigger:n.jsx("img",{src:g,alt:a==null?void 0:a.filename,className:"object-contain w-full h-full cursor-pointer"})})}),n.jsx(St,{className:"result-resizer"})]}),p&&n.jsxs(n.Fragment,{children:[n.jsx(Je,{className:"max-h-[90vh]",children:n.jsx(Kt,{id:"input",dataSource:{type:"file",content:y,size:u==null?void 0:u.size,path:a.path},className:"result-container",path:`local://${a.path}`,title:Ne(a.path),showPagination:!1,showDownload:!1,showSegmentSwitch:!1,showFileInfo:!1})}),n.jsx(St,{className:"result-resizer"})]}),n.jsx(Je,{className:"h-[90vh]",children:k})]})}function Ba({job:e}){var D;const{t}=ne(),[r,l]=d.useState(),[s,i]=d.useState(0),o=Ur(),c=e==null?void 0:e.id,a=e==null?void 0:e.status,u=d.useMemo(()=>$a(t),[t]),m=d.useMemo(()=>{var j;if(!e)return[];const p=e.results??{},F=e.phases??[],R=e!=null&&e.phase?F.indexOf(e==null?void 0:e.phase):-1;return((j=e==null?void 0:e.phases)==null?void 0:j.map(H=>{var v;const O=F.indexOf(H);let B="waiting";return O!==-1&&O<R?B="success":O===R?B=e.status:B="waiting",{key:H,label:u[H]??H,icon:((v=hn.find(w=>w.key===H))==null?void 0:v.icon)??null,status:B,value:p==null?void 0:p[H]}}))??[]},[e,u]);d.useEffect(()=>{if(m.length===0){l(void 0);return}l(p=>{var F;return p&&m.some(R=>R.key===p)?p:(F=m[0])==null?void 0:F.key})},[m]);const f=d.useMemo(()=>m.find(p=>p.key===r),[r,m]),h=d.useMemo(()=>{var p;return!((p=f==null?void 0:f.value)!=null&&p.input)||(f==null?void 0:f.value.input.length)===0?[]:f==null?void 0:f.value.input},[f]),g=d.useMemo(()=>{var p;return!((p=f==null?void 0:f.value)!=null&&p.output)||(f==null?void 0:f.value.output.length)===0?[]:f==null?void 0:f.value.output},[f]),x=d.useCallback(p=>{i(Number(p))},[]),b=d.useMemo(()=>m.find(p=>p.key===r&&p.status==="success"),[m,r]),y=d.useMemo(()=>{if(!c||!r)return t("tasks.detail.job.retryDisabled.noPhaseSelected");if(!a)return t("tasks.detail.job.retryDisabled.unknownStatus");if(!Da.includes(a))return t(a==="running"?"tasks.detail.job.retryDisabled.running":"tasks.detail.job.retryDisabled.unsupported")},[c,a,r,t]),k=!y,P=d.useCallback(async()=>{if(y){ee.info(y);return}if(!(!c||!r))try{await o.mutateAsync({id:c,phase:r});const p=u[r]??r;ee.success(t("tasks.detail.job.retrySuccess",{phase:p}))}catch(p){const F=p instanceof Error?p.message:t("tasks.detail.job.retryFailed");ee.error(F)}},[r,c,y,o,t]);return n.jsx(er,{value:r,onValueChange:l,children:n.jsxs(st,{children:[n.jsx(at,{className:"border-b",children:n.jsxs(lt,{className:"text-lg flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[t("tasks.detail.job.title"),n.jsx(tr,{className:"overflow-x-auto",children:m.map(p=>n.jsxs(nr,{value:p.key,onClick:()=>{p.key===xt.enum.import&&i(0)},children:[p.icon,p.label,n.jsx("span",{className:Jr[p.status],children:Yr[p.status]})]},p.key))}),r&&n.jsxs(Aa,{children:[n.jsx(La,{asChild:!0,children:n.jsx(Z,{size:"icon",variant:"outline",title:y??t("tasks.detail.job.retryButton"),onClick:P,disabled:!k||o.isPending,children:n.jsx(ts,{className:o.isPending?"animate-spin":""})})}),n.jsx(_a,{children:t("tasks.detail.job.retryTooltip",{phase:u[r]})})]})]}),b&&r&&r!==xt.enum.import&&n.jsxs(zt,{onValueChange:x,children:[n.jsx(Nt,{className:"min-w-[180px]",children:n.jsx(Pt,{placeholder:n.jsxs(n.Fragment,{children:[n.jsx(qe,{path:(D=h[s])==null?void 0:D.path}),h[s]&&Ne(h[s].path,-2)]})})}),n.jsx(It,{children:h.map((p,F)=>n.jsxs(tt,{value:String(F),children:[n.jsx(qe,{path:p.path}),Ne(p.path,-2)]},p.path))})]}),b&&r===xt.enum.import&&n.jsxs(zt,{onValueChange:x,children:[n.jsx(Nt,{className:"min-w-[180px]",children:n.jsx(Pt,{placeholder:n.jsxs(n.Fragment,{children:[n.jsx(qe,{path:g[s]}),g[s]&&Ne(g[s],-2)]})})}),n.jsx(It,{children:g.map((p,F)=>n.jsxs(tt,{value:String(F),children:[n.jsx(qe,{path:p}),Ne(p,-2)]},p))})]})]})}),n.jsx(ot,{className:"p-0",children:m.length>0&&r?m.map(p=>n.jsx(rr,{value:p.key,children:n.jsx(Oa,{phase:p.key,result:p.value,job:e,fileIndex:s})},p.key)):n.jsx("div",{className:"text-sm text-gray-500",children:t("tasks.detail.job.emptyState")})})]})})}function Ha(e){return[{label:e("tasks.detail.knowledge.columns.baseUrl"),key:"baseUrl",render:t=>n.jsxs("a",{href:t,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline break-all",children:[t," ",n.jsx(gn,{className:"w-4 h-4 inline-block"})]})},{label:e("tasks.detail.knowledge.columns.apiKey"),key:"apiKey",render:t=>!t||t.length<=8?"****":`${t.slice(0,4)}****${t.slice(-4)}`},{label:e("tasks.detail.knowledge.columns.datasetId"),key:"datasetId"},{label:e("tasks.detail.knowledge.columns.importAsChunk"),key:"importAsChunk",render:t=>e(t?"common.boolean.true":"common.boolean.false")}]}const Va={ragflow:({data:e,t})=>n.jsx(Ue,{data:e,columns:Ha(t)})};function Ua({data:e,onEdit:t}){const{t:r}=ne();return!e||e.length===0?n.jsx(kn,{children:n.jsxs(bn,{children:[n.jsx(vn,{variant:"icon",children:n.jsx(mn,{})}),n.jsx(Cn,{children:r("tasks.detail.knowledge.empty")})]})}):n.jsx("div",{className:"space-y-4",children:e.map((l,s)=>{const i=l,o=i.type,c=Va[o];return c?n.jsxs("div",{className:"rounded-lg border p-4",children:[n.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[n.jsx("h3",{className:"text-lg font-semibold text-gray-900 flex items-center gap-2",children:i.type?r(`tasks.detail.knowledge.types.${String(i.type)}`,{defaultValue:String(i.type)}):r("common.unknownType")}),t&&n.jsxs(Z,{size:"sm",variant:"outline",onClick:()=>t(i,s),children:[n.jsx(xn,{className:"mr-1 h-4 w-4"}),r("common.edit")]})]}),n.jsx(c,{data:i,t:r})]},s):null})})}function mr(e,t="******"){return e?e.length<=8?t:`${e.slice(0,4)}${t}${e.slice(-4)}`:"-"}function Ft(e){return e?n.jsxs("a",{href:e,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline break-all",children:[e," ",n.jsx(gn,{className:"w-4 h-4 inline-block"})]}):"-"}function Ka(e){return[{label:e("tasks.detail.mineru.columns.type"),key:"type",render:()=>n.jsx($e,{className:"bg-green-100 text-green-800",children:e("tasks.detail.mineru.badges.saas")})},{label:e("tasks.detail.mineru.columns.baseUrl"),key:"baseUrl",render:t=>Ft(t)},{label:e("tasks.detail.mineru.columns.apiKey"),key:"apiKey",render:t=>mr(t)},{label:e("tasks.detail.mineru.columns.enableFormula"),key:"enableFormula",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.enableTable"),key:"enableTable",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.language"),key:"language"},{label:e("tasks.detail.mineru.columns.enableOcr"),key:"enableOcr",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.extraFormats"),key:"extraFormats",render:t=>Array.isArray(t)&&t.length>0?t.join(", "):"-"},{label:e("tasks.detail.mineru.columns.modelVersion"),key:"modelVersion"},{label:e("tasks.detail.mineru.columns.startPage"),key:"startPage"},{label:e("tasks.detail.mineru.columns.endPage"),key:"endPage"}]}function Ga(e){return[{label:e("tasks.detail.mineru.columns.type"),key:"type",render:()=>n.jsx($e,{className:"bg-yellow-100 text-yellow-800",children:e("tasks.detail.mineru.badges.selfhost")})},{label:e("tasks.detail.mineru.columns.baseUrl"),key:"baseUrl",render:t=>Ft(t)},{label:e("tasks.detail.mineru.columns.apiKey"),key:"apiKey",render:t=>mr(t,"****")},{label:e("tasks.detail.mineru.columns.enableFormula"),key:"enableFormula",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.enableTable"),key:"enableTable",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.language"),key:"language"},{label:e("tasks.detail.mineru.columns.parseMethod"),key:"parseMethod"},{label:e("tasks.detail.mineru.columns.serverUrl"),key:"serverUrl",render:t=>Ft(t)},{label:e("tasks.detail.mineru.columns.backendType"),key:"backendType"},{label:e("tasks.detail.mineru.columns.returnContentList"),key:"returnContentList",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.returnImages"),key:"returnImages",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.returnMd"),key:"returnMd",render:t=>e(t?"common.boolean.true":"common.boolean.false")},{label:e("tasks.detail.mineru.columns.startPage"),key:"startPage"},{label:e("tasks.detail.mineru.columns.endPage"),key:"endPage"}]}function qa({data:e}){const{t}=ne();return n.jsx(Ue,{columns:Ka(t),data:e})}function Wa({data:e}){const{t}=ne();return n.jsx(Ue,{columns:Ga(t),data:e})}function Ya({data:e}){return e.type==="saas"?n.jsx(qa,{data:e}):n.jsx(Wa,{data:e})}const Ja={local:"bg-blue-100 text-blue-800",url:"bg-green-100 text-green-800",s3:"bg-purple-100 text-purple-800"};function Xa({data:e}){const{t}=ne(),r=e.type,l=()=>[{label:t("tasks.detail.source.columns.type"),key:"type",render:i=>{const o=t(`tasks.detail.source.types.${i}`,{defaultValue:$r[i]??i});return o?n.jsx($e,{className:Ja[i]??"bg-gray-100 text-gray-800",children:o}):n.jsx($e,{className:"bg-gray-100 text-gray-800",children:t("common.unknownType")})}},{label:t("tasks.detail.source.columns.storagePath"),key:"storagePath"}],s=(()=>{const i=l();return r==="s3"?[...i,{label:t("tasks.detail.source.columns.endpoint"),key:"endpoint"},{label:t("tasks.detail.source.columns.accessKeyId"),key:"accessKeyId"},{label:t("tasks.detail.source.columns.secretKeyId"),key:"secretKeyId",render:()=>n.jsx("span",{children:"******"})},{label:t("tasks.detail.source.columns.region"),key:"region"}]:i})();return n.jsx(Ue,{columns:s,data:e})}const sn={source:{labelKey:"tasks.detail.tabs.source",icon:n.jsx(es,{}),order:1},mineru:{labelKey:"tasks.detail.tabs.mineru",icon:n.jsx(Mr,{}),order:2,editable:!0},chunk:{labelKey:"tasks.detail.tabs.chunk",icon:n.jsx(Xr,{}),order:3,editable:!0,alwaysShow:!0},knowledgeBases:{labelKey:"tasks.detail.tabs.knowledgeBases",icon:n.jsx(Rr,{}),order:4,editable:!0}},an=99;function Za({task:e}){const{t}=ne(),r=e==null?void 0:e.job,[l,s]=d.useState(()=>(r==null?void 0:r.config)??null),[i,o]=d.useState(),[c,a]=d.useState(!1),[u,m]=d.useState(!1),[f,h]=d.useState(!1),[g,x]=d.useState(null),b=Wr(),y=d.useCallback(()=>{a(!0)},[]),k=d.useCallback(()=>{m(!0)},[]);d.useEffect(()=>{s((r==null?void 0:r.config)??null)},[r]);const P=d.useMemo(()=>{if(!l||typeof l!="object"||Array.isArray(l))return[];const v=l.knowledgeBases;return Array.isArray(v)?v:[]},[l]),D=d.useCallback(async v=>{var N;if(!(e!=null&&e.id)){ee.error(t("tasks.detail.notifications.mineruMissingTask"));return}const w={...l??{},mineru:v};try{const S=await b.mutateAsync({id:e.id,data:{config:w}}),M=((N=S==null?void 0:S.job)==null?void 0:N.config)??w;s(M),ee.success(t("tasks.detail.notifications.mineruUpdated")),a(!1)}catch(S){console.error("Failed to update MinerU configuration:",S),ee.error(t("tasks.detail.notifications.mineruUpdateFailed"))}},[l,e==null?void 0:e.id,t,b]),p=d.useCallback(async v=>{var N;if(!(e!=null&&e.id)){ee.error(t("tasks.detail.notifications.chunkMissingTask"));return}const w={...l??{}};v?w.chunk=v:delete w.chunk;try{const S=await b.mutateAsync({id:e.id,data:{config:w}}),M=((N=S==null?void 0:S.job)==null?void 0:N.config)??w;s(M),ee.success(t("tasks.detail.notifications.chunkUpdated")),m(!1)}catch(S){console.error("Failed to update chunk configuration:",S),ee.error(t("tasks.detail.notifications.chunkUpdateFailed"))}},[l,e==null?void 0:e.id,t,b]),F=d.useCallback((v,w)=>{const N=v??P[0]??null;x(N),h(!0)},[P]),R=d.useCallback(async v=>{var N;if(!(e!=null&&e.id)){ee.error(t("tasks.detail.notifications.knowledgeMissingTask"));return}const w={...l??{},knowledgeBases:v?[v]:[]};try{const S=await b.mutateAsync({id:e.id,data:{config:w}}),M=((N=S==null?void 0:S.job)==null?void 0:N.config)??w;s(M),ee.success(t("tasks.detail.notifications.knowledgeUpdated")),h(!1),x(v)}catch(S){console.error("Failed to update knowledge base configuration:",S),ee.error(t("tasks.detail.notifications.knowledgeUpdateFailed"))}},[l,e==null?void 0:e.id,t,b]),j=d.useMemo(()=>{const v=l&&typeof l=="object"&&!Array.isArray(l)?l:{},w=Object.entries(v).filter(([,N])=>Array.isArray(N)?N.length>0:N!=null).map(([N,S])=>{const M=sn[N],Y=M!=null&&M.labelKey?t(M.labelKey):N,re=(M==null?void 0:M.order)??an;return{key:N,label:Y,order:re,editable:!!(M!=null&&M.editable),icon:(M==null?void 0:M.icon)??null,value:S}});return Object.entries(sn).forEach(([N,S])=>{S.alwaysShow&&(w.some(M=>M.key===N)||w.push({key:N,label:S.labelKey?t(S.labelKey):N,order:S.order??an,editable:!!S.editable,icon:S.icon??null,value:v[N]}))}),w.sort((N,S)=>N.order===S.order?N.key.localeCompare(S.key):N.order-S.order)},[l,t]);d.useEffect(()=>{if(j.length===0){o(void 0);return}o(v=>{var w;return v&&j.some(N=>N.key===v)?v:(w=j[0])==null?void 0:w.key})},[j]);const H=d.useMemo(()=>({mineru:{label:t("tasks.detail.config.editMineru"),onClick:y},chunk:{label:t("tasks.detail.config.editChunk"),onClick:k}}),[k,y,t]),O=i?H[i]:void 0,B=d.useCallback((v,w)=>{if(v==="source"&&w&&typeof w=="object"&&!Array.isArray(w))return n.jsx(Xa,{data:w});if(v==="mineru")return!w||typeof w!="object"?n.jsx("div",{className:"text-sm text-gray-500",children:t("tasks.detail.config.noMineru")}):n.jsx(Ya,{data:w});if(v==="knowledgeBases"){const N=Array.isArray(w)?w:[];return n.jsx(Ua,{data:N,onEdit:F})}if(v==="chunk"){const N=w&&typeof w=="object"&&!Array.isArray(w)?w:null;return n.jsx(Is,{data:N,onEdit:k})}return null},[k,F,t]);return n.jsxs("div",{className:"space-y-4",children:[n.jsx(er,{value:i,onValueChange:o,children:n.jsxs(st,{children:[n.jsx(at,{children:n.jsxs(lt,{className:"text-lg flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[t("tasks.detail.config.title"),n.jsx(tr,{className:"overflow-x-auto",children:j.map(v=>n.jsxs(nr,{value:v.key,children:[v.icon,v.label]},v.key))})]}),O&&n.jsxs(Z,{size:"sm",variant:"outline",onClick:O.onClick,children:[n.jsx(xn,{className:"mr-1 h-4 w-4"}),O.label]})]})}),n.jsx(ot,{children:j.length>0&&i?j.map(v=>n.jsx(rr,{value:v.key,children:B(v.key,v.value)},v.key)):n.jsx("div",{className:"text-sm text-gray-500",children:t("tasks.detail.config.empty")})})]})}),n.jsx(Ba,{job:r}),n.jsx(Xe,{open:c,onOpenChange:a,children:n.jsxs(Ze,{className:"max-w-3xl flex flex-col max-h-[90vh]",children:[n.jsxs(yt,{children:[n.jsx(kt,{children:t("tasks.detail.dialogs.mineru.title")}),n.jsx(bt,{children:t("tasks.detail.dialogs.mineru.description")})]}),n.jsx(zs,{initialConfig:l==null?void 0:l.mineru,onSubmit:D,onCancel:()=>a(!1),isSubmitting:b.isPending},JSON.stringify((l==null?void 0:l.mineru)??{}))]})}),n.jsx(Xe,{open:u,onOpenChange:m,children:n.jsxs(Ze,{className:"max-w-2xl flex flex-col max-h-[90vh]",children:[n.jsxs(yt,{children:[n.jsx(kt,{children:t("tasks.detail.dialogs.chunk.title")}),n.jsx(bt,{children:t("tasks.detail.dialogs.chunk.description")})]}),n.jsx(ks,{initialConfig:l==null?void 0:l.chunk,onSubmit:p,onCancel:()=>m(!1),isSubmitting:b.isPending},JSON.stringify((l==null?void 0:l.chunk)??{}))]})}),n.jsx(Xe,{open:f,onOpenChange:h,children:n.jsxs(Ze,{className:"max-w-2xl",children:[n.jsxs(yt,{children:[n.jsx(kt,{children:t("tasks.detail.dialogs.knowledge.title")}),n.jsx(bt,{children:t("tasks.detail.dialogs.knowledge.description")})]}),n.jsx(Cs,{initialConfig:g,onSubmit:R,onCancel:()=>h(!1),isSubmitting:b.isPending},JSON.stringify(g??{}))]})})]})}function cl(){const{t:e}=ne(),{taskId:t}=xr.useParams(),{data:r,isLoading:l,error:s,isError:i}=qr(Number(t));return n.jsxs(Tr,{loading:l,loadingText:e("tasks.detail.loading"),children:[n.jsx("div",{className:"flex items-center mb-4",children:n.jsx(Z,{variant:"ghost",asChild:!0,children:n.jsxs(Gt,{to:"/tasks",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),e("tasks.detail.backToList")]})})}),i&&n.jsx(pn,{title:e("tasks.detail.error.title"),type:"warning",content:n.jsxs("div",{children:[n.jsx("p",{className:"mb-2",children:e("tasks.detail.error.description")}),n.jsx("p",{className:"text-sm mb-4",children:e("tasks.detail.error.detail",{message:(s==null?void 0:s.message)||e("common.unknownError")})}),n.jsx("div",{className:"flex gap-2",children:n.jsxs(Z,{variant:"outline",onClick:()=>window.location.reload(),children:[n.jsx(yn,{}),e("common.reload")]})})]})}),!r&&!l&&!i&&n.jsxs(st,{children:[n.jsx(at,{children:n.jsxs(lt,{className:"text-lg flex items-center",children:[n.jsx(Zr,{className:"w-5 h-5 mr-2"}),e("tasks.detail.notFound.title")]})}),n.jsxs(ot,{children:[n.jsx("p",{className:"text-gray-600 mb-4",children:e("tasks.detail.notFound.description",{id:t})}),n.jsx(Z,{variant:"ghost",asChild:!0,children:n.jsx(Gt,{to:"/tasks",children:e("tasks.detail.backToList")})})]})]}),!i&&n.jsx(Za,{task:r})]})}export{cl as component};
