UNPKG

copper-ui

Version:

Modern React UI components library with TypeScript support, built on top of Ant Design

1 lines 102 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react"),n=require("react/jsx-runtime"),$t=require("clsx"),y=require("antd"),L=require("@ant-design/icons"),R=require("nuqs"),U=require("dayjs"),Te=require("date-fns"),te=require("@tanstack/react-table");function Yt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const z=Yt(j),gt=j.createContext(null);function re(){return j.useContext(gt)}function K(){const e=re();if(!e)throw new Error("useAppShell must be used inside AppShellProvider");return e}function _(...e){return $t.clsx(e)}const xt="223px",vt="64px",zt="b";function Gt(e){return e?"expanded":"collapsed"}function Vt({defaultOpen:e,persistenceAdapter:t}){var s;const r=(s=t==null?void 0:t.read)==null?void 0:s.call(t);return typeof r=="boolean"?r:e??!0}function Ht({sidebarWidth:e,width:t=xt,collapsedWidth:r=vt,style:s}){return{"--cu-sidebar-width":e??t,"--cu-sidebar-collapsed-width":r,...s}}function Ut({children:e,defaultOpen:t,open:r,onOpenChange:s,keyboardShortcut:l=zt,sidebarWidth:c,width:a,collapsedWidth:i=vt,persistenceAdapter:o,className:f,style:u,...d}){const[h,p]=j.useState(()=>Vt({defaultOpen:t,persistenceAdapter:o})),g=r??h,v=Gt(g),x=r!==void 0,m=c??a??xt,b=j.useCallback(M=>{var k;const D=typeof M=="function"?M(g):M;x||p(D),(k=o==null?void 0:o.write)==null||k.call(o,D),s==null||s(D)},[x,s,g,o]),w=j.useCallback(()=>{b(M=>!M)},[b]);j.useEffect(()=>{if(!l)return;const M=l.toLowerCase(),D=k=>{(k.metaKey||k.ctrlKey)&&k.key.toLowerCase()===M&&(k.preventDefault(),w())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[l,w]);const C=j.useMemo(()=>({open:g,state:v,width:m,collapsedWidth:i,setOpen:b,toggleOpen:w}),[i,g,m,b,v,w]);return n.jsx(gt.Provider,{value:C,children:n.jsx("div",{...d,"data-cu-app-shell-provider":"","data-state":v,"data-open":g,className:_("cu-app-shell-provider",f),style:Ht({sidebarWidth:c,width:a,collapsedWidth:i,style:u}),children:e})})}function Kt({className:e,onClick:t,type:r="button","aria-label":s="Toggle sidebar",...l}){const{state:c,toggleOpen:a}=K();return n.jsx("button",{...l,type:r,"aria-label":s,"data-cu-sidebar-rail":"","data-state":c,className:_("cu-sidebar-rail",e),onClick:i=>{t==null||t(i),i.defaultPrevented||a()}})}function Qt({sidebar:e,side:t="left",className:r,style:s,children:l,...c}){const{open:a,state:i}=K(),o=a?"var(--cu-sidebar-width)":"var(--cu-sidebar-collapsed-width)",f=e?n.jsx("div",{"aria-hidden":"true","data-cu-app-shell-gap":"",className:"cu-app-shell__gap",style:{width:o,transitionDuration:"var(--cu-sidebar-transition-duration, 200ms)"}}):null,u=e?n.jsxs("aside",{"data-cu-app-shell-sidebar":"","data-state":i,"data-side":t,className:"cu-app-shell__sidebar",style:{width:o,transitionDuration:"var(--cu-sidebar-transition-duration, 200ms)"},children:[e,n.jsx(Kt,{"aria-label":"Toggle sidebar"})]}):null;return n.jsxs("div",{...c,"data-state":i,"data-side":t,className:_("cu-app-shell",r),style:s,children:[f,u,l]})}function Zt({className:e,...t}){const r=re();return n.jsx("main",{"data-state":r==null?void 0:r.state,className:_("cu-sidebar-inset",e),...t})}function Ie(e,t={}){const{context:r,guard:s}=t,l=(c,a,i,o)=>{var g;const f=[...o,c.id],u=((g=c.children)==null?void 0:g.map(v=>l(v,a+1,c.id,f)).filter(v=>v!==null))??[],d=s?s({item:c,context:r,depth:a,parentId:i,parentIds:o}):!0,h=u.length>0,p=!!c.href;return!d&&!h||!p&&!h?null:{...c,children:h?u:void 0}};return e.map(c=>l(c,0,null,[])).filter(c=>c!==null)}function yt(e){const t=[],r=(s,l,c,a)=>{var i;t.push({item:s,depth:l,parentId:c,parentIds:a}),(i=s.children)==null||i.forEach(o=>{r(o,l+1,s.id,[...a,s.id])})};return e.forEach(s=>r(s,0,null,[])),t}function Jt(e,t,r){return e.href?typeof e.match=="function"?e.match({pathname:t,item:e,context:r})?"custom":null:e.match==="prefix"?t.startsWith(e.href)?"prefix":null:t===e.href?"exact":null:null}function Ve(e){return e==="exact"?3:e==="custom"?2:e==="prefix"?1:0}function De(e,t,r={}){const s=Ie(e,r),l=yt(s),c=l.map(u=>({...u,matchedBy:Jt(u.item,t,r.context)})).filter(u=>u.matchedBy!==null),a=[...c].sort((u,d)=>d.depth!==u.depth?d.depth-u.depth:Ve(d.matchedBy)-Ve(u.matchedBy))[0]??null,i=c.map(u=>u.item.id),o=Array.from(new Set(c.flatMap(u=>u.parentIds))),f=l.reduce((u,d)=>{const h=c.find(g=>g.item.id===d.item.id),p=d.item.id;return u[p]={...d,id:p,isActive:i.includes(p),isAncestorActive:o.includes(p),matchedBy:(h==null?void 0:h.matchedBy)??null},u},{});return{activeItemId:(a==null?void 0:a.item.id)??null,activeItemIds:i,ancestorItemIds:o,expandedItemIds:o,itemsById:f}}function Xt(e,t={}){const r=[],s=new Set,l=(c,a)=>{var i;c.id?s.has(c.id)?r.push({code:"duplicate-id",itemId:c.id,message:`Duplicate navigation item id "${c.id}"`,parentIds:a}):s.add(c.id):r.push({code:"missing-id",itemId:"",message:"Navigation item is missing an id",parentIds:a}),(i=c.children)==null||i.forEach(o=>l(o,[...a,c.id]))};if(e.forEach(c=>l(c,[])),r.length>0&&t.throwOnError)throw new Error(r.map(c=>c.message).join("; "));return{valid:r.length===0,issues:r}}function qt(){return n.jsxs("div",{className:"cu-sidebar-collapse-shortcut",children:[n.jsx("span",{className:"cu-sidebar-collapse-shortcut__key",children:"ctrl"}),n.jsx("span",{className:"cu-sidebar-collapse-shortcut__plus",children:"+"}),n.jsx("span",{className:"cu-sidebar-collapse-shortcut__key",children:"b"})]})}function en(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",children:n.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m11.25 4.5 7.5 7.5-7.5 7.5m-6-15 7.5 7.5-7.5 7.5"})})}function tn(){return n.jsxs(n.Fragment,{children:["Свернуть",n.jsx("br",{}),"боковое меню"]})}function nn({label:e=n.jsx(tn,{}),tooltip:t=n.jsx(qt,{}),className:r,onClick:s,...l}){const{open:c,toggleOpen:a}=K(),i=n.jsxs("button",{type:"button","data-open":c,className:_("cu-sidebar-collapse-button",r),onClick:o=>{s==null||s(o),o.defaultPrevented||a()},...l,children:[n.jsx("div",{className:"cu-sidebar-collapse-button__icon-wrap",children:n.jsx("span",{className:"cu-sidebar-collapse-button__icon",children:n.jsx(en,{})})}),c?n.jsx("span",{className:"cu-sidebar-collapse-button__label",children:e}):null]});return t?n.jsx(y.Tooltip,{title:t,placement:"top",children:i}):i}function rn({className:e,...t}){return n.jsx("div",{"data-cu-sidebar-content":"",className:_("cu-sidebar-content",e),...t})}function sn({className:e,...t}){return n.jsx("div",{"data-cu-sidebar-footer":"",className:_("cu-sidebar-footer",e),...t})}function ln({className:e,...t}){return n.jsx("div",{"data-cu-sidebar-header":"",className:_("cu-sidebar-header",e),...t})}function He({className:e,...t}){return n.jsx("div",{role:"separator",className:_("cu-sidebar-separator",e),...t})}function an(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",children:n.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M10.7 7.29a.98.98 0 0 0-1.41 0c-.4.39-.4 1.02 0 1.41l3.29 3.29-3.29 3.29c-.4.4-.4 1.02 0 1.41.39.4 1.02.4 1.41 0l4-3.99c.2-.2.3-.43.3-.71s-.1-.51-.3-.71z",clipRule:"evenodd"})})}function cn(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"4",height:"4",fill:"none",viewBox:"0 0 4 4",children:n.jsx("circle",{cx:"2",cy:"2",r:"2",fill:"currentColor"})})}function on(e){return typeof e.label=="string"&&e.label.length>0?e.label.slice(0,1).toUpperCase():"•"}function un(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!j.isValidElement(e)&&"value"in e}function Ue(e){return e==null||e===!1||e===""||e===0||e==="0"}function dn(e="neutral"){return e==="attention"||e==="danger"?"cu-nav-badge--danger":e==="warning"?"cu-nav-badge--warning":e==="success"?"cu-nav-badge--success":"cu-nav-badge--neutral"}function Ce(e){return un(e)?(e.hideWhenZero??!0)&&Ue(e.value)?null:n.jsx("span",{"aria-label":e.ariaLabel??e.label,title:e.label,className:_("cu-nav-badge",dn(e.tone)),children:e.value}):Ue(e)?null:e}function fn({item:e,depth:t,hasChildren:r,isActive:s,isAncestorActive:l,open:c,expanded:a}){const i=t===0,o=t>0,f=!e.icon&&i,u=Ce(e.badge);return n.jsxs("div",{className:_("cu-primary-nav-item",i&&"cu-primary-nav-item--root",o&&"cu-primary-nav-item--child",s&&"cu-primary-nav-item--active",l&&"cu-primary-nav-item--ancestor"),children:[e.icon?n.jsx("span",{className:_("cu-primary-nav-item__icon",i?"cu-primary-nav-item__icon--root":"cu-primary-nav-item__icon--child"),children:e.icon}):f?n.jsx("span",{className:"cu-primary-nav-item__fallback",children:on(e)}):null,c&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"cu-primary-nav-item__label",children:e.label}),u?n.jsx("span",{className:"cu-primary-nav-item__badge",children:u}):null,r?n.jsx("span",{"aria-hidden":"true",className:"cu-primary-nav-item__chevron","data-expanded":a,children:n.jsx(an,{})}):null]}),!c&&r?n.jsx("span",{"aria-hidden":"true",className:"cu-primary-nav-item__corner",children:n.jsx(cn,{})}):null]})}function hn({item:e,renderLink:t,itemState:r}){var a;const s=i=>({marginInlineStart:`${Math.min(Math.max(i-1,0),9)*16}px`}),l=(i,o)=>i.map(f=>{var m;const u=!!((m=f.children)!=null&&m.length),d=(r==null?void 0:r.id)===f.id,h=(r==null?void 0:r.parentIds.includes(f.id))??!1,p=Ce(f.badge),g=_("cu-primary-nav-overlay__row",(d||h)&&"cu-primary-nav-overlay__row--active"),v=s(o),x=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"cu-primary-nav-overlay__label",children:f.label}),p?n.jsx("span",{className:"cu-primary-nav-overlay__badge",children:p}):null]});return u?n.jsxs("div",{className:"cu-primary-nav-overlay__group",children:[n.jsx("div",{style:v,className:_(g,"cu-primary-nav-overlay__row--group"),children:x}),n.jsx("div",{className:"cu-primary-nav-overlay__list",children:l(f.children??[],o+1)})]},f.id):n.jsx(j.Fragment,{children:t({href:f.href??"#",itemId:f.id,depth:o,disabled:f.disabled,isActive:d,isAncestorActive:!1,children:n.jsx("div",{style:v,className:_(g,"cu-primary-nav-overlay__row--link"),children:x})})},f.id)});if(!((a=e.children)!=null&&a.length))return e.tooltip??e.label;const c=Ce(e.badge);return n.jsxs("div",{className:"cu-primary-nav-overlay",children:[n.jsxs("div",{className:"cu-primary-nav-overlay__header",children:[n.jsx("span",{className:"cu-primary-nav-overlay__label",children:e.label}),c?n.jsx("span",{className:"cu-primary-nav-overlay__badge",children:c}):null]}),n.jsx("div",{className:"cu-primary-nav-overlay__separator"}),n.jsx("div",{className:"cu-primary-nav-overlay__list",children:l(e.children,1)})]})}function mn({item:e,depth:t,open:r,expanded:s,itemState:l,renderLink:c,renderItemContent:a,onToggle:i}){var v;const o=!!((v=e.children)!=null&&v.length),f=(l==null?void 0:l.isActive)??!1,u=(l==null?void 0:l.isAncestorActive)??!1,d=(a==null?void 0:a({item:e,depth:t,hasChildren:o,isActive:f,isAncestorActive:u,open:r,expanded:s}))??n.jsx(fn,{item:e,depth:t,hasChildren:o,isActive:f,isAncestorActive:u,open:r,expanded:s}),h=_("cu-primary-nav__trigger",t===0&&"cu-primary-nav__trigger--root",t>0&&"cu-primary-nav__trigger--child");if(r&&o)return n.jsx("button",{type:"button","data-cu-primary-nav-item":e.id,"aria-expanded":s,className:h,onClick:()=>i(e.id),children:d});if(r)return c({href:e.href??"#",itemId:e.id,depth:t,disabled:e.disabled,isActive:f,isAncestorActive:u,children:n.jsx("div",{"data-cu-primary-nav-item":e.id,className:h,children:d})});const p=n.jsx(hn,{item:e,renderLink:c,itemState:l});return o?n.jsx(y.Popover,{placement:"rightTop",content:p,trigger:"hover",children:n.jsx("button",{type:"button","data-cu-primary-nav-item":e.id,"aria-expanded":s,className:h,onClick:()=>i(e.id),children:d})}):n.jsx(y.Tooltip,{placement:"right",title:p,children:n.jsx("div",{children:c({href:e.href??"#",itemId:e.id,depth:t,disabled:e.disabled,isActive:f,isAncestorActive:u,children:n.jsx("div",{"data-cu-primary-nav-item":e.id,className:h,children:d})})})})}function pn(e,t){return t?De(e,t).expandedItemIds:[]}function bt({items:e,pathname:t="",context:r,guard:s,renderLink:l,renderItemContent:c,renderChildren:a,expandedItemIds:i,defaultExpandedItemIds:o,expandActiveAncestors:f=!0,mountCollapsedBranches:u=!0,onExpandedItemIdsChange:d,className:h,...p}){const g=re(),[v,x]=j.useState(()=>{const k=f?pn(e,t):[];return Array.from(new Set([...o??[],...k]))}),m=Ie(e,{context:r,guard:s}),b=De(m,t,{context:r,guard:s}),w=(g==null?void 0:g.open)??!0,C=i??v,M=k=>{const S=C.includes(k)?C.filter(T=>T!==k):[...C,k];i===void 0&&x(S),d==null||d(S)},D=(k,S)=>k.map(T=>{var P;const O=b.itemsById[T.id],F=C.includes(T.id)||f&&b.expandedItemIds.includes(T.id),N=!!((P=T.children)!=null&&P.length),I=N&&w&&(F||u)?n.jsx("div",{"data-cu-primary-nav-children":"","data-state":F?"open":"closed","aria-hidden":!F,className:"cu-primary-nav__children",children:n.jsx("div",{className:"cu-primary-nav__children-inner",children:D(T.children??[],S+1)})}):null;return n.jsxs("div",{"data-cu-primary-nav-branch":T.id,className:"cu-primary-nav__branch",children:[n.jsx(mn,{item:T,depth:S,open:w,expanded:F,itemState:O,renderLink:l,renderItemContent:c,onToggle:M}),N&&I?(a==null?void 0:a({item:T,depth:S,children:I}))??I:null]},T.id)});return n.jsx("div",{...p,"data-cu-primary-navigation-tree":"","data-cu-primary-nav":"","data-state":w?"expanded":"collapsed",className:_("cu-primary-nav",h),children:D(m,0)})}const jt="var(--cu-color-neutral-0)",gn="var(--cu-color-neutral-40)",Ke="var(--cu-color-blue-50)",Qe="var(--cu-color-red-50)",Ze="var(--cu-color-green-50)",xn=e=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",...e,children:[n.jsx("defs",{children:n.jsx("clipPath",{id:"workspace-chevron-right-a",children:n.jsx("path",{fill:jt,fillOpacity:"0",d:"M0 0h24v24H0z"})})}),n.jsx("g",{clipPath:"url(#workspace-chevron-right-a)",children:n.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M10.7 7.29a.98.98 0 0 0-1.41 0c-.4.39-.4 1.02 0 1.41l3.29 3.29-3.29 3.29c-.4.4-.4 1.02 0 1.41.39.4 1.02.4 1.41 0l4-3.99c.2-.2.3-.43.3-.71s-.1-.51-.3-.71z"})})]}),vn=e=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",...e,children:[n.jsx("defs",{children:n.jsx("clipPath",{id:"workspace-overflow-list-a",children:n.jsx("path",{fill:jt,fillOpacity:"0",d:"M0 0h24v24H0z"})})}),n.jsx("g",{clipPath:"url(#workspace-overflow-list-a)",children:n.jsx("path",{stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"2",d:"M11 18c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm-6 0c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm6-6c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm-6 0c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm6-6c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1ZM5 6c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm12 12c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm0-6c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Zm0-6c0-.56.44-1 1-1 .55 0 1 .44 1 1 0 .55-.45 1-1 1-.56 0-1-.45-1-1Z"})})]}),yn=e=>n.jsx("svg",{width:"6",height:"6",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:n.jsx("path",{d:"M5 1L5 5L1 5",stroke:gn,strokeOpacity:"1",strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})}),bn=e=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 32 32",...e,children:[n.jsx("path",{fill:Ke,d:"M6.905 17.857c-1.052-1.026-.987-2.752.146-3.857l9.23-9c1.134-1.105 2.905-1.169 3.957-.143l2.857 2.786c1.052 1.026.986 2.752-.147 3.857l-9.23 9c-1.133 1.105-2.904 1.169-3.956.143z",opacity:".8"}),n.jsx("path",{fill:Ke,d:"M9.762 11.357c1.052-1.025 2.823-.962 3.956.143l9.23 9c1.133 1.105 1.2 2.831.147 3.857l-2.857 2.786c-1.052 1.026-2.823.962-3.956-.143l-9.23-9c-1.133-1.105-1.199-2.831-.147-3.857z",opacity:".4"})]}),jn=e=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",...e,children:[n.jsx("path",{fill:Qe,d:"M5.179 13.393c-.79-.77-.74-2.065.11-2.893l6.922-6.75c.85-.828 2.178-.876 2.967-.107l2.143 2.09c.789.768.74 2.064-.11 2.892l-6.923 6.75c-.85.828-2.178.876-2.967.107z",opacity:".8"}),n.jsx("path",{fill:Qe,d:"M7.322 8.518c.789-.77 2.117-.721 2.967.107l6.923 6.75c.85.828.898 2.124.11 2.893l-2.143 2.09c-.79.768-2.118.72-2.967-.108L5.289 13.5c-.85-.828-.899-2.124-.11-2.893z",opacity:".4"})]}),_n=e=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",...e,children:[n.jsx("path",{fill:Ze,d:"M5.179 13.393c-.79-.77-.74-2.065.11-2.893l6.922-6.75c.85-.828 2.178-.876 2.967-.107l2.143 2.09c.789.768.74 2.064-.11 2.892l-6.923 6.75c-.85.828-2.178.876-2.967.107z",opacity:".8"}),n.jsx("path",{fill:Ze,d:"M7.322 8.518c.789-.77 2.117-.721 2.967.107l6.923 6.75c.85.828.898 2.124.11 2.893l-2.143 2.09c-.79.768-2.118.72-2.967-.108L5.289 13.5c-.85-.828-.899-2.124-.11-2.893z",opacity:".4"})]}),wn={dev:jn,prod:bn,test:_n};function _t({env:e="prod",logo:t,brandName:r="Workspace",versionSlot:s,buildDate:l}){const{open:c}=K(),a=wn[e];return n.jsxs("div",{className:"cu-workspace-logo",children:[n.jsxs("div",{className:"cu-workspace-logo__mark",children:[t??n.jsx(a,{className:"cu-workspace-logo__default-icon",width:"44px",height:"44px"}),e!=="prod"?n.jsxs("div",{className:"cu-workspace-logo__env",children:["[",e,"]"]}):null]}),c?n.jsxs("div",{className:"cu-workspace-logo__body",children:[n.jsx("span",{className:"cu-workspace-logo__brand",children:r}),s?n.jsx("span",{className:"cu-workspace-logo__version",children:s}):null,e!=="prod"&&l?n.jsx("span",{className:"cu-workspace-logo__build-date",children:l}):null]}):null]})}function wt({label:e="Техподдержка",icon:t,onClick:r,disabled:s,ariaLabel:l}){const{open:c}=K();return n.jsxs("button",{type:"button","aria-label":l,disabled:s,className:"cu-workspace-support-button",onClick:r,children:[n.jsx("span",{className:"cu-workspace-support-button__icon",children:t??n.jsx(L.CustomerServiceOutlined,{})}),c?n.jsx("span",{className:"cu-workspace-support-button__label",children:e}):null]})}function Nt({name:e,email:t,avatar:r,unreadIndicator:s,menuItems:l,renderMenuLink:c,menuOpen:a,onMenuOpenChange:i}){const{open:o}=K(),[f,u]=j.useState(!1),d=a??f,h=v=>{a===void 0&&u(v),i==null||i(v)},p=l!=null&&l.length?n.jsx(Nn,{items:l,renderMenuLink:c,closeMenu:()=>h(!1)}):null,g=n.jsxs("button",{type:"button","aria-haspopup":p?"menu":void 0,"aria-expanded":p?d:void 0,className:"cu-workspace-user-button",children:[n.jsxs("div",{className:"cu-workspace-user-button__avatar",children:[s?n.jsx("span",{className:"cu-workspace-user-button__unread",children:s}):null,r]}),o?n.jsxs("div",{className:"cu-workspace-user-button__body",children:[n.jsx("span",{className:"cu-workspace-user-button__name",children:e}),t?n.jsx("span",{className:"cu-workspace-user-button__email",children:t}):null]}):null]});return p?n.jsx(y.Popover,{open:d,onOpenChange:h,trigger:"click",placement:"rightBottom",content:p,classNames:{root:"cu-workspace-user-popover"},arrow:!0,children:g}):g}function Nn({items:e,renderMenuLink:t,closeMenu:r}){return n.jsx("div",{className:"cu-workspace-user-menu",role:"menu","aria-label":"Меню пользователя",children:n.jsx("div",{className:"cu-workspace-user-menu__list",children:e.map(s=>n.jsx(kn,{item:s,renderMenuLink:t,closeMenu:r},s.id))})})}function kn({item:e,renderMenuLink:t,closeMenu:r}){const s=_("cu-workspace-user-menu__item",e.disabled&&"cu-workspace-user-menu__item--disabled"),l=n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"cu-workspace-user-menu__item-main",children:[e.icon?n.jsx("span",{className:"cu-workspace-user-menu__item-icon",children:e.icon}):null,n.jsx("span",{className:"cu-workspace-user-menu__item-label",children:e.label})]}),e.trailingIcon?n.jsx("span",{className:"cu-workspace-user-menu__item-trailing",children:e.trailingIcon}):null]}),c=a=>{var i;if(e.disabled){a.preventDefault(),a.stopPropagation();return}(i=e.onSelect)==null||i.call(e,a),a.defaultPrevented||r==null||r()};return e.href&&t?t({item:e,className:s,children:l,href:e.href,role:"menuitem",ariaDisabled:e.disabled||void 0,disabled:e.disabled,onClick:c}):e.href?n.jsx("a",{href:e.href,className:s,role:"menuitem","aria-disabled":e.disabled||void 0,onClick:c,children:l}):n.jsx("button",{type:"button",className:s,role:"menuitem",disabled:e.disabled,onClick:c,children:l})}function Sn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!j.isValidElement(e)&&"value"in e}function Je(e){return e==null||e===!1||e===""||e===0||e==="0"}function Tn(e="neutral"){return e==="attention"||e==="danger"?"cu-nav-badge--danger":e==="warning"?"cu-nav-badge--warning":e==="success"?"cu-nav-badge--success":"cu-nav-badge--neutral"}function Cn(e){return typeof e.label=="string"&&e.label.length>0?e.label.slice(0,1).toUpperCase():"•"}function Pn(e){return Sn(e)?(e.hideWhenZero??!0)&&Je(e.value)?null:n.jsx("span",{"aria-label":e.ariaLabel??e.label,title:e.label,className:_("cu-nav-badge",Tn(e.tone)),children:e.value}):Je(e)?null:n.jsx("span",{className:"cu-workspace-nav-item__badge-custom",children:e})}function An(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!j.isValidElement(e)}function Mn({item:e,depth:t,hasChildren:r,isActive:s,isAncestorActive:l,expanded:c}){const a=re(),i=(a==null?void 0:a.open)??!0,o=t===0,f=e.icon!=null,u=r&&(s||l),d=o&&r&&!i,h=i?Pn(e.badge):null,p=i&&!o?{marginInlineStart:`${Math.min(t,10)*12}px`}:void 0;return n.jsxs("div",{style:p,className:_("cu-workspace-nav-item",i?"cu-workspace-nav-item--open":"cu-workspace-nav-item--collapsed",o?"cu-workspace-nav-item--root":"cu-workspace-nav-item--child",f?"cu-workspace-nav-item--has-icon":"cu-workspace-nav-item--no-icon",o&&u&&"cu-workspace-nav-item--highlighted",!o&&s&&"cu-workspace-nav-item--active"),children:[f||!i?n.jsxs("div",{className:"cu-workspace-nav-item__icon-wrap",children:[n.jsx("span",{className:_("cu-workspace-nav-item__icon",o?"cu-workspace-nav-item__icon--root":"cu-workspace-nav-item__icon--child",!f&&"cu-workspace-nav-item__fallback"),children:e.icon??Cn(e)}),d?n.jsx("span",{className:"cu-workspace-nav-item__corner",children:n.jsx(yn,{"aria-hidden":"true"})}):null]}):null,i?n.jsx("span",{className:"cu-workspace-nav-item__label",children:e.label}):null,i?n.jsx("span",{className:"cu-workspace-nav-item__badge",children:h}):null,i?n.jsx("span",{"aria-hidden":"true",className:_("cu-workspace-nav-item__chevron",!r&&"cu-workspace-nav-item__chevron--empty"),"data-expanded":c,children:r?n.jsx(xn,{}):null}):null]})}function In({logo:e,support:t,user:r,...s}){const l={...s},c=l.mountCollapsedBranches??!0;delete l.collapseButton,delete l.expandActiveAncestors,delete l.footerSlot,delete l.headerSlot,delete l.logoSlot,delete l.renderChildren,delete l.renderItemContent,delete l.supportSlot,delete l.userSlot;const a=t?An(t)?n.jsx(wt,{...t}):t:null,i=r?n.jsx(Nt,{...r}):null,o=n.jsx(nn,{});return n.jsxs(n.Fragment,{children:[n.jsx(ln,{children:e?n.jsx(_t,{...e}):null}),n.jsx(rn,{children:n.jsx(bt,{...l,expandActiveAncestors:!1,mountCollapsedBranches:c,renderItemContent:f=>n.jsx(Mn,{...f})})}),n.jsxs(sn,{children:[a,a?n.jsx(He,{}):null,o,i||a?n.jsx(He,{}):null,i]})]})}const Dn=1;function On(e,t,r=0,s=Dn){if(t<=0)return 0;let l=0;for(let c=0;c<e.length;c+=1){const i=(e[c]??0)+(c>0?r:0);if(l+i>t+s)return c;l+=i}return e.length}function Oe(e){const t=j.useRef(null),r=j.useRef([]),[s,l]=j.useState(e);return j.useLayoutEffect(()=>{var f;const c=()=>{const u=t.current;if(!u){l(e);return}const d=Array.from(u.children).slice(0,e),h=u.clientWidth;if(h<=0){l(e);return}const p=[...r.current];d.forEach((m,b)=>{const w=m.offsetWidth||m.getBoundingClientRect().width;w>0&&(p[b]=w)});const g=p.slice(0,e);if(r.current=g,g.length<e||g.some(m=>!Number.isFinite(m)||m<=0)){l(e);return}const v=Number.parseFloat(window.getComputedStyle(u).columnGap||window.getComputedStyle(u).gap||"0"),x=On(g,h,Number.isNaN(v)?0:v);l(x)};c();const a=window.requestAnimationFrame(()=>{window.requestAnimationFrame(c)}),i=window.setTimeout(c,120);"fonts"in document&&document.fonts.ready.then(c).catch(()=>{});const o=new ResizeObserver(c);return t.current&&o.observe(t.current),Array.from(((f=t.current)==null?void 0:f.children)??[]).forEach(u=>{u&&o.observe(u)}),window.addEventListener("resize",c),()=>{window.cancelAnimationFrame(a),window.clearTimeout(i),o.disconnect(),window.removeEventListener("resize",c)}},[e]),{containerRef:t,firstHiddenIndex:s,hasOverflow:s<e,setItemRef:c=>a=>{}}}function oe({item:e,isActive:t,orientation:r,renderLink:s}){const l=n.jsx("span",{className:_("cu-local-navigation-link",r==="vertical"&&"cu-local-navigation-link--vertical",r==="horizontal"&&"cu-local-navigation-link--horizontal",t&&"cu-local-navigation-link--active",e.disabled&&"cu-local-navigation-link--disabled"),children:e.label});return e.disabled?l:s({href:e.href,itemId:e.id,depth:0,disabled:e.disabled,isActive:t,isAncestorActive:!1,children:l})}function ue(e,t){return typeof e.match=="function"?e.match(t,e.href):e.match==="prefix"?t.startsWith(e.href):t===e.href}function Fn({header:e,items:t,pathname:r="",actionSlot:s,overflowTriggerSlot:l,renderLink:c,sticky:a=!1,orientation:i="vertical",className:o,...f}){const u=i==="horizontal",{containerRef:d,firstHiddenIndex:h,hasOverflow:p,setItemRef:g}=Oe(u?t.length:0),v=u&&p?t.slice(0,h):t,x=u&&p?t.slice(h):[],m=n.jsx(y.Button,{size:"small","aria-label":"Show overflow local navigation items",icon:n.jsx(L.AppstoreOutlined,{})});return n.jsxs("nav",{...f,"aria-label":"Local navigation","data-orientation":i,className:_("cu-local-navigation",i==="vertical"&&"cu-local-navigation--vertical",i==="horizontal"&&"cu-local-navigation--horizontal",a&&"cu-local-navigation--sticky",o),children:[e?n.jsx("div",{className:_("cu-local-navigation__header",i==="vertical"&&"cu-local-navigation__header--vertical"),children:n.jsx(oe,{item:e,isActive:ue(e,r),orientation:i,renderLink:c})}):null,u?n.jsxs("div",{className:"cu-local-navigation__bar",children:[n.jsx("ul",{ref:d,className:"cu-local-navigation__list",children:v.map((b,w)=>n.jsx("li",{ref:g(w),className:"cu-local-navigation__item",children:n.jsx(oe,{item:b,isActive:ue(b,r),orientation:i,renderLink:c})},b.id))}),n.jsx("div",{className:_("cu-local-navigation__overflow",!p&&"cu-local-navigation__overflow--hidden"),children:n.jsx(y.Popover,{trigger:"click",placement:"bottomRight",content:n.jsx("div",{className:"cu-local-navigation__overflow-panel",children:n.jsx("ul",{className:"cu-local-navigation__overflow-list",children:x.map(b=>n.jsx("li",{children:n.jsx(oe,{item:b,isActive:ue(b,r),orientation:"vertical",renderLink:c})},b.id))})}),children:n.jsx("div",{className:"cu-local-navigation__overflow-trigger",children:l??m})})}),s?n.jsx("div",{className:"cu-local-navigation__action",children:s}):null]}):n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"cu-local-navigation__list",children:t.map(b=>n.jsx("li",{children:n.jsx(oe,{item:b,isActive:ue(b,r),orientation:i,renderLink:c})},b.id))}),s?n.jsx("div",{className:"cu-local-navigation__action",children:s}):null]})]})}function ke({item:e,isActive:t,renderLink:r,className:s}){const l=n.jsx("span",{className:_("cu-section-shell-link",t&&"cu-section-shell-link--active",e.disabled&&"cu-section-shell-link--disabled",s),children:e.label});return e.disabled?l:r({href:e.href,itemId:e.id,depth:0,disabled:e.disabled,isActive:t,isAncestorActive:!1,children:l})}function Xe(e,t){return typeof e.match=="function"?e.match(t,e.href):e.match==="prefix"?t.startsWith(e.href):t===e.href}function kt({header:e,items:t,pathname:r="",actionSlot:s,overflowTriggerSlot:l,renderLink:c,sticky:a=!0,className:i,...o}){const{containerRef:f,firstHiddenIndex:u,hasOverflow:d,setItemRef:h}=Oe(t.length),p=d?t.slice(0,u):t,g=d?t.slice(u):[],v=n.jsx(y.Button,{size:"small","aria-label":"Show overflow navigation items",icon:n.jsx(L.AppstoreOutlined,{})});return n.jsx("div",{...o,className:_("cu-section-shell",a&&"cu-section-shell--sticky",i),children:n.jsxs("div",{className:"cu-section-shell__inner",children:[e?n.jsx(ke,{item:e,isActive:!1,renderLink:c,className:"cu-section-shell-link--header"}):null,e&&t.length>0?n.jsx("div",{className:"cu-section-shell__separator"}):null,n.jsx("ul",{ref:f,className:"cu-section-shell__list",children:p.map((x,m)=>n.jsx("li",{ref:h(m),className:"cu-section-shell__item",children:n.jsx(ke,{item:x,isActive:Xe(x,r),renderLink:c})},x.id))}),n.jsx("div",{className:_("cu-section-shell__overflow",!d&&"cu-section-shell__overflow--hidden"),children:n.jsx(y.Popover,{trigger:"click",placement:"bottomRight",content:n.jsx("div",{className:"cu-section-shell__overflow-panel",children:n.jsx("ul",{className:"cu-section-shell__overflow-list",children:g.map(x=>n.jsx("li",{children:n.jsx(ke,{item:x,isActive:Xe(x,r),renderLink:c})},x.id))})}),children:n.jsx("div",{className:"cu-section-shell__overflow-trigger",children:l??v})})}),s?n.jsx("div",{className:"cu-section-shell__action",children:s}):null]})})}function Rn(e){return n.jsx(kt,{...e,overflowTriggerSlot:n.jsx(y.Button,{size:"small","aria-label":"Show overflow navigation items",icon:n.jsx(vn,{"aria-hidden":"true"})})})}const B=({when:e,children:t,elseComponent:r})=>e?t:r||null,Ln={headingText:{default:"cu-list-item__text--heading-default",small:"cu-list-item__text--heading-small"},baseText:{default:"cu-list-item__text--base-default",small:"cu-list-item__text--base-small"},helperText:{default:"cu-list-item__text--helper-default",small:"cu-list-item__text--helper-small"}},Fe=e=>{const{token:t}=y.theme.useToken(),{size:r="default",order:s=["baseText","headingText","helperText"],disabled:l,prefix:c,suffix:a,className:i,skeletonClassName:o,isLoading:f,isCenter:u,style:d,headingText:h,baseText:p,helperText:g,...v}=e,x=u??s.map(m=>e[m]).filter(m=>!m).length>1;return f?n.jsx("div",{className:_("cu-list-item-skeleton",o),style:{backgroundColor:t.colorFillSecondary}}):n.jsxs("div",{...v,className:_("cu-list-item",!l&&"cu-list-item--interactive",x&&"cu-list-item--center",i),style:{"--cu-hover-bg":t.colorBgTextHover,"--cu-active-bg":t.colorFillSecondary,...d},children:[c&&n.jsx("div",{className:_("cu-list-item__prefix",x&&"cu-list-item__slot--center"),children:c}),n.jsx("div",{className:"cu-list-item__content",children:s.map(m=>n.jsx("div",{style:{color:t.colorText},className:_("cu-list-item__text",Ln[m][r]),children:e[m]},m))}),a&&n.jsx("div",{className:_("cu-list-item__suffix",x&&"cu-list-item__slot--center"),children:a})]})},me=({children:e,className:t,disabled:r})=>{const[s,l]=j.useState(!1),c=j.useRef(null),a=i=>{var u,d;if(i&&r)return;const o=(u=c.current)==null?void 0:u.clientWidth,f=(d=c.current)==null?void 0:d.scrollWidth;o&&f&&o<f&&l(i)};return n.jsx(y.Tooltip,{title:e,placement:"bottomLeft",open:s,onOpenChange:a,children:n.jsx("p",{ref:c,className:_("cu-text-container",t),children:e})})},Bn=e=>{var t,r;return n.jsxs("div",{className:"cu-select-company-group-details",children:[n.jsxs("div",{className:"cu-select-company-group-details__title",children:["ГК «",e==null?void 0:e.name,"»"]}),n.jsxs("div",{className:"cu-select-company-group-details__companies",children:[n.jsx("span",{className:"cu-select-company-group-details__label",children:"Топ 3 компании:"}),n.jsx(me,{children:n.jsx(B,{when:Array.isArray(e==null?void 0:e.companies)&&((t=e==null?void 0:e.companies)==null?void 0:t.length)>0,elseComponent:"-",children:(r=e==null?void 0:e.companies)==null?void 0:r.map((s,l)=>l<3?`${s==null?void 0:s.opfShort} «${s==null?void 0:s.fullName}»${l<2?", ":""}`:null)})})]})]})},En=({option:e,isSelected:t,handleSelect:r,fullOption:s})=>{const{token:l}=y.theme.useToken(),c=Bn(s);return n.jsx("div",{className:"cu-select-company-option cu-select-company-option--group",children:n.jsx(Fe,{onClick:()=>r(e.value),disabled:!0,className:"cu-select-company-option__item",style:t?{backgroundColor:l.colorFillSecondary}:void 0,isCenter:!1,order:["headingText","baseText","helperText"],headingText:c})})},qe={DPGS:"rating?.pgsRating",ИНН:"inn",КПП:"kpp",Город:"city",Руководитель:"managerFIO",ОГРН:"ogrn"},Wn=["DPGS","ИНН","Руководитель"],$n=e=>Object.fromEntries(e?Object.entries(qe).filter(([t])=>e.includes(t)):Object.entries(qe).filter(([t])=>Wn.includes(t))),Yn=(e,t)=>{var r;return n.jsxs("div",{className:"cu-select-company-details",children:[n.jsx("div",{className:"cu-select-company-details__title",children:`${e==null?void 0:e.opfShort} «${e==null?void 0:e.fullName}»`}),n.jsxs("div",{className:"cu-select-company-details__meta",children:[n.jsx("div",{className:"cu-select-company-details__fields",children:(r=Object.entries(t))==null?void 0:r.map(([s,l],c)=>{var i;const a=l==="rating?.pgsRating"?(i=e==null?void 0:e.rating)==null?void 0:i.pgsRating:e==null?void 0:e[l];return n.jsxs("div",{className:"cu-select-company-details__field",children:[n.jsxs("span",{className:"cu-select-company-details__label",children:[s,":"]}),n.jsx(me,{className:"cu-select-company-details__value",children:a??"-"})]},c)})}),(e==null?void 0:e.address)&&n.jsxs("div",{className:"cu-select-company-details__field cu-select-company-details__field--address",children:[n.jsx("span",{className:"cu-select-company-details__label",children:"Адрес:"}),n.jsx(me,{className:"cu-select-company-details__value",children:typeof(e==null?void 0:e.address)=="string"?e==null?void 0:e.address:(e==null?void 0:e.address.value)??"-"})]})]})]})},zn=({option:e,isSelected:t,handleSelect:r,fullOption:s,optionalFields:l})=>{const{token:c}=y.theme.useToken(),a=$n(l),i=Yn(s,a);return i?n.jsx("div",{className:"cu-select-company-option",children:n.jsx(Fe,{onClick:()=>r(e.value),disabled:!0,className:"cu-select-company-option__item",style:t?{backgroundColor:c.colorFillSecondary}:void 0,isCenter:!1,order:["headingText","baseText","helperText"],headingText:i})}):null},Gn=e=>{const{isLoading:t=!1}=e;return n.jsx("div",{className:"cu-select-not-found",children:t?n.jsx(y.Spin,{className:"cu-select-not-found__spinner",indicator:n.jsx(L.LoadingOutlined,{spin:!0}),size:"large"}):"Нет результатов или запрос ещё не введён"})},Vn=e=>{const{subTitle:t}=e;return n.jsx(n.Fragment,{children:t&&n.jsx("div",{className:"cu-select-subtitle",children:n.jsx(y.Typography.Text,{type:"secondary",children:t})})})},Hn=e=>{const{title:t}=e;return n.jsx(n.Fragment,{children:t&&n.jsx("div",{className:"cu-select-title",children:t})})};function St(e,t){const[r,s]=j.useState(e);return j.useEffect(()=>{const l=setTimeout(()=>{s(e)},t);return()=>{clearTimeout(l)}},[e]),r}const Re=e=>"columns"in e&&Array.isArray(e.columns),G=e=>{const t=[];for(const r of e)Re(r)?t.push(...G(r.columns)):t.push(r);return t},Un=e=>R.createParser({parse:t=>t===""?null:t,serialize:t=>t??""}).withDefault(e),Kn=(e,t)=>R.createParser({parse:r=>r===""?[]:e.parse(r),serialize:r=>r===null||Array.isArray(r)&&r.length===0?"":e.serialize(r)}).withDefault(t),Qn=R.createParser({parse:e=>{try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&"value"in t&&"label"in t?t:null}catch{return null}},serialize:e=>typeof e=="object"&&e!==null&&"value"in e&&"label"in e?JSON.stringify(e):JSON.stringify(null)}),Zn=R.createParser({parse:e=>{try{const t=JSON.parse(e);return Array.isArray(t)&&t.every(s=>typeof s=="object"&&s!==null&&"value"in s&&"label"in s)?t:null}catch{return null}},serialize:e=>Array.isArray(e)&&e.every(r=>typeof r=="object"&&r!==null&&"value"in r&&"label"in r)?JSON.stringify(e):JSON.stringify(null)}),Jn=(e,t)=>{const r={},s=(l,c,a,i)=>{switch(l){case"boolean":r[c]=R.parseAsBoolean;break;case"multiselect":r[c]=R.parseAsArrayOf(R.parseAsString);break;case"date-range":r[c]=R.parseAsArrayOf(R.parseAsString);break;case"date":r[c]=R.parseAsString;break;case"select":r[c]=R.parseAsString;break;case"radio":i!=null?r[c]=Un(String(i)):r[c]=R.parseAsString;break;case"checkbox":r[c]=R.parseAsArrayOf(R.parseAsString);break;case"custom":r[c]=a?Zn:Qn;break;default:r[c]=R.parseAsString}};for(const l of G(e))if(l.filter){const c=l.filter.id??l.definition.id,a=l.filter.type==="custom"&&"isMultiple"in l.filter&&l.filter.isMultiple;s(l.filter.type,c,a)}for(const l of t)if(!r[l.id])s(l.type,l.id,void 0,l.default);else if(l.default!=null)try{const c=JSON.parse(String(l.default));if(typeof c=="object"&&c!==null){const a=Object.values(c).map(String);l.type==="radio"?r[l.id]=Kn(r[l.id],a):r[l.id]=r[l.id].withDefault(a)}}catch(c){console.warn(`[copper-ui] Не удалось распарсить default быстрого фильтра "${l.id}":`,c)}return r},et=(e,t="")=>t+e,Xn=({columns:e,quickFilters:t,filtersDebounceDelay:r=300,debounceFields:s,prefix:l})=>{const[c,a]=j.useState({field:"",order:"asc"}),[i,o]=R.useQueryState(et("pageIndex",l),R.parseAsInteger.withDefault(0)),[f,u]=R.useQueryState(et("pageSize",l),R.parseAsInteger.withDefault(10)),d=j.useCallback(S=>{o(S.pageIndex),u(S.pageSize)},[o,u]),h=j.useMemo(()=>({pageIndex:i,pageSize:f}),[i,f]),[p,g]=j.useState(0),v=j.useCallback(S=>{S&&p!==S&&g(S)},[p]),x=j.useMemo(()=>Jn(e,(t==null?void 0:t.filters)??[]),[e,t]),[m,b]=R.useQueryStates(x),w=j.useCallback(S=>{b(S),o(0)},[b,o]),C=j.useMemo(()=>s||G(e).filter(T=>{var O,F;return((O=T.filter)==null?void 0:O.type)==="input"||((F=T.filter)==null?void 0:F.type)==="input-number"}).map(T=>{var O;return((O=T.filter)==null?void 0:O.id)??T.definition.id}),[e,s]),M=j.useMemo(()=>{const S={};return C.forEach(T=>{S[T]=m[T]}),S},[m,C]),D=St(M,r),k=j.useMemo(()=>{const S={...m};return C.forEach(T=>{const O=T;O in D&&(S[O]=D[O])}),S},[m,D,C]);return j.useMemo(()=>({sort:c,setSort:a,pagination:h,setPagination:d,totalPages:p,filters:m,debouncedFilters:k,filterParsers:x,setFilters:w,quickFilters:t,setTotalPages:v}),[c,a,h,d,p,m,k,x,t,v,w])},Tt=j.createContext(void 0),Le=()=>{const e=j.useContext(Tt);if(!e)throw new Error("useTableContext must be used within a TableProvider");return e},qn=(e,t=[],r=[])=>Object.entries(e).filter(([s,l])=>l!=null&&l!==""&&(Array.isArray(l)?l.length>0:!0)&&!!Ct(s,t,r,l)),Ct=(e,t=[],r=[],s)=>{const l=r.find(i=>i.id===e);if(l&&(()=>{var o,f;if(l.type==="checkbox"&&Array.isArray(s))return s.length>0&&s.every(u=>{var d;return(d=l.options)==null?void 0:d.some(h=>String(h.value)===String(u))});if(l.type==="radio"&&Array.isArray(s)&&s.length===2){const[u,d]=s;return(o=l.options)==null?void 0:o.some(h=>typeof h.value=="string"&&h.value===JSON.stringify({from:u,to:d}))}return(f=l.options)==null?void 0:f.some(u=>u.value===s)})())return;const a=G(t).find(i=>{var o;return(((o=i.filter)==null?void 0:o.id)??i.definition.id)===e});return a&&typeof a.definition.header=="string"?a.definition.header:e},er=(e,t)=>{if(t&&t.definition.mapping){const r=t.definition.mapping.find(s=>s.value===e);if(r)return String(r.label)}return isNaN(new Date(e).getTime())?String(e):Pt(e)},Pt=e=>{try{return new Date(e).toLocaleDateString("ru-RU")}catch{return e}},tr=(e,t,r=[],s=[])=>{var f,u;const l=G(r);if(typeof t=="object"&&t!==null&&"label"in t)return String(t.label);if(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&t[0]!==null&&"label"in t[0]&&"value"in t[0])return t.map(d=>d.label).join(", ");const c=s.find(d=>d.id===e);if(c&&c.options){if(Array.isArray(t)&&c.type==="checkbox")return t.map(h=>{const p=c.options.find(g=>String(g.value)===String(h));return String(p?p.label:h)}).filter(Boolean).join(", ");if(Array.isArray(t)){const d=c.options.find(h=>typeof h.value=="string"&&h.value===JSON.stringify(t));if(d)return String(d.label)}else{const d=c.options.find(h=>h.value===t);if(d)return String(d.label)}}const a=l.find(d=>{var h;return(((h=d.filter)==null?void 0:h.id)??d.definition.id)===e});if(a&&a.filter&&(a.filter.type==="select"||a.filter.type==="multiselect")&&"options"in a.filter&&Array.isArray(a.filter.options)){const d=a.filter.options;if(Array.isArray(t))if(a.filter.type==="multiselect"){const h=t.map(p=>{var g;return(g=d.find(v=>v.value===p))==null?void 0:g.label}).filter(Boolean);if(h.length)return h.join(", ")}else{const h=d.find(p=>typeof p.value=="string"&&p.value===JSON.stringify(t));if(h)return String(h.label)}else{const h=d.find(p=>p.value===t);if(h)return String(h.label)}}const i=a==null?void 0:a.definition;if(i&&i.mapping){const d=i.mapping.find(h=>h.value===t);if(d)return String(d.label)}const o=(f=a==null?void 0:a.filter)!=null&&f.props&&"format"in a.filter.props?(u=a==null?void 0:a.filter)==null?void 0:u.props.format:void 0;return Array.isArray(t)&&t.some(d=>!isNaN(U(d,o).valueOf()))&&t.length===2?t.join(" - "):Array.isArray(t)?t.map(h=>er(h,a)).join(", "):typeof t=="string"&&t.includes("T")&&!(t.includes("[")||t.includes("]")||t.includes("{")||t.includes("}"))?Pt(t):typeof t=="boolean"?t?"Да":"Нет":String(t)},nr=({columns:e=[],quickFilters:t=[]})=>{const{filters:r,setFilters:s}=Le(),l=j.useMemo(()=>qn(r,e,t),[r,e,t]),c=o=>{const f=r[o];s({[o]:Array.isArray(f)?[]:null})},a=()=>{const o=Object.keys(r).reduce((f,u)=>{const d=r[u];return f[u]=Array.isArray(d)?[]:null,f},{});s(o)},i=j.useMemo(()=>l.map(([o,f])=>({fieldName:o,value:f,label:Ct(o,e,t,f),displayValue:tr(o,f,e,t)})),[l,e,t]);return{filters:r,activeFilters:l,processedFilters:i,resetFilter:c,resetAllFilters:a,hasActiveFilters:l.length>0}},At=({columns:e=[],quickFilters:t=[]})=>{const{token:r}=y.theme.useToken(),{processedFilters:s,resetFilter:l,resetAllFilters:c,hasActiveFilters:a}=nr({columns:e,quickFilters:t});return a?n.jsx("div",{className:"cu-table-filter-tags",children:n.jsxs("div",{className:"cu-table-filter-tags__list",children:[s.map(({fieldName:i,label:o,displayValue:f})=>n.jsx(n.Fragment,{children:n.jsx(B,{when:o,children:n.jsxs("div",{className:"cu-table-filter-tags__item",children:[n.jsxs("span",{children:[o,":"]}),n.jsx(y.Tooltip,{title:f,children:n.jsx(y.Tag,{closable:!0,className:"cu-table-filter-tags__tag",closeIcon:n.jsx(L.CloseOutlined,{style:{fontSize:"12px",color:r.colorTextQuaternary}}),onClose:()=>l(i),children:n.jsx("span",{className:"cu-table-filter-tags__value",style:{color:r.colorText},children:f})})})]})})},i)),n.jsx(B,{when:s.find(i=>i.label),children:n.jsx(y.Button,{type:"link",size:"small",className:"cu-table-filter-tags__reset",onClick:c,icon:n.jsx(L.CloseCircleFilled,{}),children:"Сбросить все"})})]})}):null};var rr={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0};function ne(e){"@babel/helpers - typeof";return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(e)}function tt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),r.push.apply(r,s)}return r}function nt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?tt(Object(r),!0).forEach(function(s){sr(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function sr(e,t,r){return t=lr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function lr(e){var t=ir(e,"string");return ne(t)=="symbol"?t:String(t)}function ir(e,t){if(ne(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(ne(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ar=nt(nt({},rr),{},{locale:"ru_RU",today:"Сегодня",now:"Сейчас",backToToday:"Текущая дата",ok:"ОК",clear:"Очистить",week:"Неделя",month:"Месяц",year:"Год",timeSelect:"Выбрать время",dateSelect:"Выбрать дату",monthSelect:"Выбрать месяц",yearSelect:"Выбрать год",decadeSelect:"Выбрать десятилетие",previousMonth:"Предыдущий месяц (PageUp)",nextMonth:"Следующий месяц (PageDown)",previousYear:"Предыдущий год (Control + left)",nextYear:"Следующий год (Control + right)",previousDecade:"Предыдущее десятилетие",nextDecade:"Следущее десятилетие",previousCentury:"Предыдущий век",nextCentury:"Следующий век"});const Mt={placeholder:"Выберите время",rangePlaceholder:["Время начала","Время окончания"]},pe={lang:{placeholder:"Выберите дату",yearPlaceholder:"Выберите год",quarterPlaceholder:"Выберите квартал",monthPlaceholder:"Выберите месяц",weekPlaceholder:"Выберите неделю",rangePlaceholder:["Начальная дата","Конечная дата"],rangeYearPlaceholder:["Начальный год","Год окончания"],rangeMonthPlaceholder:["Начальный месяц","Конечный месяц"],rangeWeekPlaceholder:["Начальная неделя","Конечная неделя"],shortWeekDays:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],shortMonths:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],...ar},timePickerLocale:{...Mt}},cr={items_per_page:"/ стр.",jump_to:"Перейти",jump_to_confirm:"подтвердить",page:"Страница",prev_page:"Назад",next_page:"Вперед",prev_5:"Предыдущие 5",next_5:"Следующие 5",prev_3:"Предыдущие 3",next_3:"Следующие 3",page_size:"размер страницы"},W="${label} не является типом ${type}",rt={locale:"ru",Pagination:cr,DatePicker:pe,TimePicker:Mt,Calendar:pe,global:{placeholder:"Пожалуйста выберите",close:"Закрыть"},Table:{filterTitle:"Фильтр",filterConfirm:"OK",filterReset:"Сбросить",filterEmptyText:"Без фильтров",filterCheckAll:"Выбрать все элементы",filterSearchPlaceholder:"Поиск в фильтрах",emptyText:"Нет данных",selectAll:"Выбрать всё",selectInvert:"Инвертировать выбор",selectNone:"Очистить все данные",selectionAll:"Выбрать все данные",sortTitle:"Сортировка",expand:"Развернуть строку",collapse:"Свернуть строку",triggerDesc:"Нажмите для сортировки по убыванию",triggerAsc:"Нажмите для сортировки по возрастанию",cancelSort:"Нажмите, чтобы отменить сортировку"},Tour:{Next:"Далее",Previous:"Назад",Finish:"Завершить"},Modal:{okText:"OK",cancelText:"Отмена",justOkText:"OK"},Popconfirm:{okText:"OK",cancelText:"Отмена"},Transfer:{titles:["",""],searchPlaceholder:"Поиск",itemUnit:"элем.",itemsUnit:"элем.",remove:"Удалить",selectAll:"Выбрать все данные",deselectAll:"Очистить все данные",selectCurrent:"Выбрать текущую страницу",selectInvert:"Инвертировать выбор",removeAll:"Удалить все данные",removeCurrent:"Удалить текущую страницу"},Upload:{uploading:"Загрузка...",removeFile:"Удалить файл",uploadError:"При загрузке произошла ошибка",previewFile:"Предпросмотр файла",downloadFile:"Загрузить файл"},Empty:{description:"Нет данных"},Icon:{icon:"иконка"},Text:{edit:"Редактировать",copy:"Копировать",copied:"Скопировано",expand:"Раскрыть",collapse:"Свернуть"},Form:{optional:"(необязательно)",defaultValidateMessages:{default:"Ошибка проверки поля ${label}",required:"Пожалуйста, введите ${label}",enum:"${label} должен быть одним из [${enum}]",whitespace:"${label} не может быть пустым",date:{format:"${label} не правильный формат даты",parse:"${label} не может быть преобразовано в дату",invalid:"${label} не является корректной датой"},types:{string:W,method:W,array:W,object:W,number:W,date:W,boolean:W,integer:W,float:W,regexp:W,email:W,url:W,hex:W},string:{len:"${label} должна быть ${len} символов",min:"${label} должна быть больше или равна ${min} символов",max:"${label} должна быть меньше или равна ${max} символов",range:"Длина ${label} должна быть между ${min}-${max} символами"},number:{len:"${label} должна быть равна ${len}",min:"${label} должна быть больше или равна ${min}",max:"${label} должна быть меньше или равна ${max}",range:"${label} должна быть между ${min}-${max}"},array:{len:"Количество элементов ${label} должно быть равно ${len}",min:"Количество элементов ${label} должно быть больше или равно ${min}",max:"Количество элементов ${label} должно быть меньше или равно ${max}",range:"Количество элементов ${label} должно быть между ${min} и ${max}"},pattern:{mismatch:"${label} не соответствует шаблону ${pattern}"}}},QRCode:{expired:"QR-код устарел",refresh:"Обновить"},ColorPicker:{presetEmpty:"Пустой",transparent:"Прозрачный",singleColor:"Один цвет",gradientColor:"Градиент"}},or=({value:e,onChange:t,options:r,className:s,style:l,...c})=>{const a=Array.isArray(e)?e:[],i=f=>{const u=String(f),d=a.includes(u)?a.filter(h=>h!==u):[...a,u];t(d)},o={className:_("cu-table-quick-filter-control",s),style:l,...c};return n.jsx(y.Button.Group,{...o,children:r==null?void 0:r.map(f=>{const u=a.includes(String(f.value));return n.jsx(y.Button,{size:"middle",type:u?"primary":"default",onClick:()=>i(f.value),children:f.label},f.value)})})},ur=({value:e,onChange:t,options:r,className:s,style:l,...c})=>{const a=o=>{t(o)},i={className:_("cu-table-quick-filter-control",s),style:l,...c};return n.jsx(y.Radio.Group,{block:!0,optionType:"button",value:e,...i,children:r==null?void 0:r.map(o=>n.jsx(y.Radio.Button,{value:o.value,onClick:()=>a(e===o.value?null:o.value),children:o.label},o.value))})};function It(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var de={exports:{}},dr=de.exports,st;function fr(){return st||(st=1,function(e,t){(function(r,s){e.exports=s()})(dr,function(){var r={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},s=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,l=/\d/,c=/\d\d/,a=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},f=function(x){return(x=+x)+(x>68?1900:2e3)},u=function(x){return function(m){this[x]=+m}},d=[/[+-]\d\d:?(\d\d)?|Z/,function(x){(this.zone||(this.zone={})).offset=function(m){if(!m||m==="Z")return 0;var b=m.match(/([+-]|\d\d)/g),w=60*b[1]+(+b[2]||0);return w===0?0:b[0]==="+"?-w:w}(x)}],h=function(x){var m=o[x];return m&&(m.indexOf?m:m.s.concat(m.f))},p=function(x,m){var b,w=o.meridiem;if(w){for(var C=1;C<=24;C+=1)if(x.indexOf(w(C,0,m))>-1){b=C>12;break}}else b=x===(m?"pm":"PM");return b},g={A:[i,function(x){this.af