1import{r as c,j as s,ay as N,k as me,h as pe,B as y,dC as xe,ar as be,ec as ge}from"./index-BJsnW-wr.js";import{C as q,u as J,a as he,b as we}from"./ClampedCell-Cp2O2Cfm.js";import{A as ye}from"./index-TGCU2RQq.js";import{u as Ne,i as fe,G as W,M as ke,d as Se,a as Ie}from"./mockApplicationsStore-DLdhXASI.js";import{D as De}from"./index-DmuVq8ET.js";import{s as D}from"./index-BrUtw_S4.js";import{R as je}from"./refresh-cw-CgglY1qd.js";import{E as ve}from"./eye-B_aps21x.js";import{D as Me}from"./download-C9kXtWED.js";import"./TextLayer-BHGG73pZ.js";import"./tiny-invariant-CopsF_GD.js";import"./index-Uuhpf9jm.js";import"./chevron-left-B8frVpXD.js";import"./chevron-right-DDZdJPqh.js";const Re=(e,o)=>{const l=new Date(e);return l.setFullYear(l.getFullYear()+o),l.toISOString()},Ee=e=>{const o=fe(e);return{iinBin:e.iinBin,series:null,number:e.nikadNumber,globalUniqueNumber:e.globalUniqueNumber,nikadNumber:e.nikadNumber,reqNikadNumber:e.nikadNumber,dateIssue:o?e.submittedAt:"",validityStartDate:o?e.submittedAt:"",validityEndDate:o?Re(e.submittedAt,1):"",licensiar:{code:"MOCK",bin:e.licensiarBin,nameRu:e.licensiarName},service:{code:e.applicationType,nameRu:e.serviceName},status:o?{code:"1",nameRu:"ÐÑдан"}:{code:"2",nameRu:"Ðа ÑаÑÑмоÑÑении"},stopSuspendDuplicateDate:null,suspendingStartDate:null,suspendingEndDate:null,objectAddressRu:null,objectAddressKz:null,documentType:"PERMIT",documents:{documentContentResult:o?[{language:"ru",documentGuid:e.documentGuid}]:[]},subServices:null,attachments:null}},Ce=()=>{const e=Ne(o=>o.applications);return c.useMemo(()=>({rows:e.map(Ee),records:e}),[e])},Ae={1:{className:"bg-green-100 text-green-600 border-green-500"},2:{className:"bg-blue-100 text-blue-600 border-blue-500"},5:{className:"bg-red-100 text-red-600 border-red-500"}},Oe=({status:e,children:o})=>{const l=Ae[e]??{className:"bg-slate-100 text-slate-600 border-slate-300"};return s.jsx("span",{className:`inline-flex items-center px-2.5 py-1 rounded-[6px] font-semibold text-[11px] border ${l.className}`,children:o})},Le=[{key:"nikadNumber",title:"ÐÐÐÐÐ",dataIndex:"nikadNumber",width:120,render:e=>s.jsx("span",{className:"font-semibold text-[13px] text-slate-900 whitespace-nowrap",children:e})},{key:"globalUniqueNumber",title:"УÐÐÐ Ð",dataIndex:"globalUniqueNumber",width:130,render:e=>s.jsx("span",{className:"text-[13px] text-slate-600 whitespace-nowrap",children:e})},{key:"serviceName",title:"ÐÐÐÐÐÐÐÐÐÐÐРУСÐУÐÐ",dataIndex:["serviceName","nameRu"],width:240,render:e=>s.jsx(q,{text:e,maxWidth:"240px"})},{key:"dateIssue",title:"ÐÐТРРÐШÐÐÐЯ",dataIndex:"dateIssue",width:120,render:e=>s.jsx("span",{className:"text-[13px] text-slate-600 whitespace-nowrap",children:e?N(e).format("DD.MM.YYYY"):"â"})},{key:"validityStartDate",title:"ÐÐТРÐÐЧÐÐÐ",dataIndex:"validityStartDate",width:110,render:e=>s.jsx("span",{className:"text-[13px] text-slate-600 whitespace-nowrap",children:e?N(e).format("DD.MM.YYYY"):"â"})},{key:"validityEndDate",title:"ÐÐТРÐÐÐÐЧÐÐÐЯ",dataIndex:"validityEndDate",width:130,render:e=>s.jsx("span",{className:"text-[13px] text-slate-600 whitespace-nowrap",children:e?N(e).format("DD.MM.YYYY"):"â"})},{key:"licensiar",title:"ÐÐЦÐÐÐÐÐÐ ",dataIndex:["licensiar","nameRu"],width:200,render:e=>s.jsx(q,{text:e,maxWidth:"200px"})},{key:"applicant",title:"ÐÐЯÐÐТÐÐЬ",dataIndex:"iinBin",width:130,render:e=>s.jsx("span",{className:"text-[13px] text-slate-600 whitespace-nowrap",children:e})},{key:"iinBin",title:"ÐÐÐ",dataIndex:"iinBin",width:110,render:e=>s.jsx("span",{className:"text-[13px] text-slate-600 whitespace-nowrap",children:e})},{key:"status",title:"СТÐТУС",dataIndex:"status",width:120,render:e=>s.jsx(Oe,{status:e.code,children:e.nameRu})}],Ve=()=>{var L,G,Y,U,P,B,_,T;const e=me(),[o,l]=c.useState(null),[d,h]=c.useState(null),[j,H]=c.useState({title:""}),m=J(d),V=d?((L=m.data)==null?void 0:L.status)==="DONE"?"DONE":((G=m.data)==null?void 0:G.status)==="FAILED"?"FAILED":"LOADING":"LOADING",v=(t,i,n)=>{H({title:t.nikadNumber,subtitle:n??t.service.nameRu}),h(i)},Q=()=>
1{if(!d)return;const t=d;h(null),queueMicrotask(()=>h(t))},M=pe(t=>t.user),[p,X]=c.useState({pageIndex:0,pageSize:10}),{rows:R,records:Z}=Ce(),[ee,E]=c.useState(W),[C,A]=c.useState(null);c.useEffect(()=>{E(!0);const t=setTimeout(()=>E(!1),ke);return()=>clearTimeout(t)},[p]);const f=M.bin||M.iin,{data:a,isLoading:te}=he(f,{page:p.pageIndex,size:p.pageSize}),{mutate:se,isPending:ne,error:b}=we(f),x=J(o);c.useEffect(()=>{const t=x==null?void 0:x.data;if((t==null?void 0:t.status)==="DONE"&&(t!=null&&t.blob)){const i=URL.createObjectURL(t.blob),n=document.createElement("a");n.href=i,n.download=`document_${o}.pdf`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(i),l(null)}else(t==null?void 0:t.status)==="FAILED"&&(D.error("ÐÑибка пÑи ÑкаÑивании: "+t.errorMessage),l(null))},[x==null?void 0:x.data,o]);const ae=(t,i)=>{const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},oe=async t=>{if(t.documentUrl){A(t.documentGuid),await Se(Ie);try{const i=await fetch(t.documentUrl),n=i.headers.get("content-type")??"";if(!i.ok||n.includes("text/html"))throw new Error("not found");ae(await i.blob(),t.documentUrl.split("/").pop()),D.success("ÐокÑÐ¼ÐµÐ½Ñ ÑÑпеÑно ÑкаÑан")}catch{D.error("Ðе ÑдалоÑÑ ÑкаÑаÑÑ Ð´Ð¾ÐºÑменÑ")}finally{A(null)}}},O=(a==null?void 0:a.content)??[],ie=p.pageIndex===0?[...R,...O]:O,re=((a==null?void 0:a.totalElements)??0)+R.length,w=(Y=a==null?void 0:a.syncInfo)==null?void 0:Y.lastSyncedAt,le=(w?Date.now()-new Date(w).getTime():Number.POSITIVE_INFINITY)>=1440*60*1e3,k=((U=a==null?void 0:a.syncInfo)==null?void 0:U.lastSyncResult)==="FAILED",g=((P=a==null?void 0:a.syncInfo)==null?void 0:P.lastSyncResult)==="IN_PROGRESS",ce=ne||g,de=((B=a==null?void 0:a.syncInfo)==null?void 0:B.errorMessage)??(b instanceof Error?b.message:void 0);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"font-semibold text-2xl leading-8 text-slate-900 tracking-[-0.48px]",children:"ÐÑÑнал Ð Ð"}),s.jsx("p",{className:"text-sm leading-5 text-slate-500 mt-2",children:"Ð¡Ð²ÐµÐ´ÐµÐ½Ð¸Ñ Ð¿Ð¾ ÑазÑеÑиÑелÑнÑм докÑменÑам (лиÑензии, ÑазÑеÑÐµÐ½Ð¸Ñ Ð¸ ÑведомлениÑ) из ÐС Ð-лиÑензиÑование"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(y,{icon:s.jsx(je,{size:16}),loading:ce,disabled:!f,onClick:()=>se(),children:"ÐбновиÑÑ Ð´Ð°Ð½Ð½Ñе"}),s.jsx(y,{type:"primary",onClick:()=>e("/gov"),icon:s.jsx(xe,{}),style:{backgroundColor:"#00a6f4",borderColor:"#00a6f4"},className:"!flex !items-center !gap-2 !px-5 !h-10 !rounded-xl !text-sm !font-semibold shadow-md shadow-blue-500/20 hover:shadow-blue-500/40 transition-all",children:"Ðовое заÑвление"})]})]}),(le||k||b||g)&&s.jsx(be,{className:"!mb-4",type:k||b?"error":g?"info":"warning",showIcon:!0,message:k||b?"Ðе ÑдалоÑÑ ÑинÑ
ÑонизиÑоваÑÑ ÑазÑеÑиÑелÑнÑе докÑменÑÑ":g?"СинÑ
ÑонизаÑÐ¸Ñ ÑазÑеÑиÑелÑнÑÑ
докÑменÑов вÑполнÑеÑÑÑ":"ÐаннÑе жÑÑнала могÑÑ Ð±ÑÑÑ Ð½ÐµÐ°ÐºÑÑалÑнÑ",description:de??(g?"ÐÑÑнал бÑÐ´ÐµÑ Ð¾Ð±Ð½Ð¾Ð²Ð»Ñн авÑомаÑиÑеÑки поÑле завеÑÑÐµÐ½Ð¸Ñ ÑинÑ
ÑонизаÑии.":w?`ÐоÑледнÑÑ ÑÑпеÑÐ½Ð°Ñ ÑинÑ
ÑонизаÑиÑ: ${N(w).format("DD.MM.YYYY, HH:mm")}. ÐбновиÑе даннÑе пеÑед ÑабоÑой Ñ Ð¶ÑÑналом.`:"СинÑ
ÑонизаÑÐ¸Ñ ÐµÑÑ Ð½Ðµ вÑполнÑлаÑÑ. ÐбновиÑе даннÑе, ÑÑÐ¾Ð±Ñ Ð·Ð°Ð³ÑÑзиÑÑ ÑазÑеÑиÑелÑнÑе докÑменÑÑ.")}),s.jsx(ye,{dataSource:ie,columns:[...Le,{key:"actions",title:"ÐÐÐСТÐÐЯ",width:100,render:(t,i)=>{var K,$;const n=((K=i.documents)==null?void 0:K.documentContentResult)??[],r=($=n[0])==null?void 0:$.documentGuid,z=!!(r!=null&&r.startsWith("mock-doc-")),S=z?C===r:o===r,ue=n.map((u,I)=>({key:u.documentGuid,label:u.documentName??`ÐокÑÐ¼ÐµÐ½Ñ ${I+1}`,onClick:()=>v(i,u.documentGuid,u.documentName)})),F=s.jsx(y,{className:"!p-2 !border-sky-300 !text-sky-600 !hover:bg-sky-200",disabled:n.length===0,onClick:()=>{n.length===1&&v(i,n[0].documentGuid)},children:s.jsx(ve,{size:16})});return s.jsxs("div",{className:"flex items-center gap-2",children:[n.length>1&&!W?s.jsx(ge,{menu:{items:ue},trigger:["click"],children:F}):F,s.jsx(y,{className:"!p-2 !border-sky-300 !text-sky-600 !hover:bg-sky-200",onClick:()=>{const u=Z.find(I=>I.documentGuid===r);z&&u?oe(u):l(r??null)},loading:S,disabled:!r||!!o&&!S||!!C&&!S,children:s.jsx(Me,{size:16})})]})}}],rowKey:"nikadNumber",loading:te||ee,hideHeader:!1,pagination:{current:p.pageIndex+1,pageSize:p.pageSize,total:re,showSizeChanger:!0,onChange:(t,i)=>X(n=>({...n,pageIndex:t-1,pageSize:i}))}}),s.jsx(De,{open:!!d,onClose:()=>h(null),externalSource:{status:V,blob:((_=m.data)==null?void 0:_.status)==="DONE"?m.data.blob:void 0,ext:"pdf",errorMessage:((T=m.data)==null?void 0:T.status)==="FAILED"?m.data.errorMessage:void 0},onRetry:Q,title:j.title,subtitle:j.subtitle,downloadFileName:d?`document_${d}`:"document"})]})};export{Le as COLUMNS,Ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.