import{o as e,r as a}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as s,ki as l}from"./vendor-frame-CwiylG4Y.js";import{Bf as n,Qf as t,Rf as i}from"./shared-1-3-6x7RKF.js";import{nn as o,rn as d}from"./vendor-all-2-BJdkbLSj.js";import{a as r,i as f}from"./shared-5-UQAFGbWu.js";var u=a({EncodingPickerModal:()=>c}),g=e(s()),m=l();function c({isOpen:e,attachment:a,onConfirm:s,onClose:l}){const u=d(),[c,b]=(0,g.useState)("utf-8"),M=(0,g.useMemo)(()=>function(e){return[{value:"utf-8",label:e.formatMessage({defaultMessage:"Default (UTF-8)",id:"QJ0ownoZRd"})},{value:"windows-1252",label:e.formatMessage({defaultMessage:"Western European (Windows-1252)",id:"uMZxG9zGvp"})},{value:"windows-1250",label:e.formatMessage({defaultMessage:"Central European (Windows-1250)",id:"Q4V+DsnBh+"})},{value:"windows-1251",label:e.formatMessage({defaultMessage:"Cyrillic (Windows-1251)",id:"q1BWaIlpbN"})},{value:"iso-8859-1",label:e.formatMessage({defaultMessage:"Latin-1 (ISO-8859-1)",id:"oNp1waFarV"})},{value:"shift_jis",label:e.formatMessage({defaultMessage:"Japanese (Shift_JIS)",id:"k4+9F0xUH9"})},{value:"gb18030",label:e.formatMessage({defaultMessage:"Chinese (GB18030)",id:"ILxlzNXiro"})},{value:"euc-kr",label:e.formatMessage({defaultMessage:"Korean (EUC-KR)",id:"qphPEQ/z5U"})},{value:"windows-1256",label:e.formatMessage({defaultMessage:"Arabic (Windows-1256)",id:"X5tUyXfqsl"})},{value:"windows-1254",label:e.formatMessage({defaultMessage:"Turkish (Windows-1254)",id:"2epHWDjRXo"})},{value:"windows-1253",label:e.formatMessage({defaultMessage:"Greek (Windows-1253)",id:"4VcUGIGtNu"})},{value:"tis-620",label:e.formatMessage({defaultMessage:"Thai (TIS-620)",id:"Vuh/a7xjtE"})}]}(u),[u]),x=(0,g.useCallback)(()=>{b("utf-8"),l()},[l]),p=(0,g.useMemo)(()=>a?.encodingPending?new TextDecoder(c,{fatal:!1}).decode(a.encodingPending.buffer).slice(0,500):"",[a?.encodingPending,c]),h=(0,g.useCallback)(e=>{e.preventDefault(),a?.encodingPending&&(s(new TextDecoder(c,{fatal:!1}).decode(a.encodingPending.buffer)),b("utf-8"))},[a?.encodingPending,c,s]);return(0,m.jsx)(i,{isOpen:e,onClose:x,modalSize:"md",hasCloseButton:!0,title:u.formatMessage({defaultMessage:"Select file encoding",id:"Duoty8G6d7"}),children:(0,m.jsxs)("form",{onSubmit:h,className:"flex flex-col gap-4 mt-4",children:[(0,m.jsx)("p",{className:"text-sm text-text-300",children:(0,m.jsx)(o,{defaultMessage:"The text encoding for <b>{fileName}</b> could not be determined. Choose an encoding and verify with the preview.",id:"ysZbg4a2QH",values:{fileName:a?.file_name,b:e=>(0,m.jsx)("strong",{children:e})}})}),(0,m.jsx)(f,{size:"sm",value:c,onValueChange:e=>b(e),children:M.map(e=>(0,m.jsx)(r,{value:e.value,children:e.label},e.value))}),p&&(0,m.jsx)("pre",{className:"overflow-auto max-h-64 rounded border border-border-400 bg-bg-000 p-3 text-xs text-text-200 whitespace-pre-wrap",children:p}),(0,m.jsxs)(n,{children:[(0,m.jsx)(t,{type:"button",variant:"secondary",onClick:x,children:(0,m.jsx)(o,{defaultMessage:"Cancel",id:"47FYwba+bI"})}),(0,m.jsx)(t,{type:"submit",variant:"primary",children:(0,m.jsx)(o,{defaultMessage:"Confirm",id:"N2IrpMDHDB"})})]})]})})}export{u as n,c as t};