@ehfuse/taskbox 0.11.11 → 0.11.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import{a as Mi,b as Mp,c as dm,d as NL,e as FL,f as HL,g as WL,h as $L}from"./ch
2
2
  `).replace(/<\/(p|div|li|h[1-6]|blockquote)>/gi,`
3
3
  `),o=document.createElement("div");return o.innerHTML=t,(o.textContent??"").replace(/\n{3,}/g,`
4
4
 
5
- `).trim()}var Iw={...yx,left:(yx.left??[]).map(e=>e.filter(t=>t!=="undo"&&t!=="redo")).filter(e=>e.length>0).flatMap(e=>e.includes("indent")?[["bulletList","numberList"],e]:[e])};function cc({syncKey:e,value:t,onChange:o,readOnly:a=!1,viewFirst:r=!1,onTranslate:i,minHeight:l=180,editing:s,onEditingChange:c}){M();let{uploadContentImage:u,openExternalUrl:m,openContentImage:d}=ie(),f=v=>{m?m(v):window.open(v,"_blank","noopener,noreferrer")},[p,g]=hx(()=>!r||!_a(t).trim()),x=s!==void 0,b=x?s:p,_=Ba(c);_.current=c;let h=v=>{x||g(v),_.current?.(v)};bx(()=>{r&&h(!_a(t).trim())},[e,r]);let B=Ba(null),C=Ba(new _w),z=Ba(null),y=Ba(Date.now()+800),S=$e(),D=Cw(),K=yw(D.breakpoints.down("sm")),[P,k]=hx(!1),T=()=>{let v=_a(t);v&&navigator.clipboard.writeText(v).then(()=>{k(!0),window.setTimeout(()=>k(!1),1500)})},I=(v,H=!1)=>v instanceof Element?v.closest(H?".taskbox-content-readview a[href]":".ehfuse-editor-content a[href]"):null,E=v=>S||v.ctrlKey||v.metaKey;bx(()=>{if(a)return;let v=md(t);z.current===v||z.current===t||(z.current=v,y.current=Date.now()+800,B.current?.setHtml(v))},[e,t,a]);let L=md(t),R=Ba(null),A=Ba({el:null,html:""});return Tw(()=>{let v=R.current;v&&(A.current.el===v&&A.current.html===L||(v.innerHTML=L,A.current={el:v,html:L}))}),a||!b?sc(sl,{sx:{position:"relative",mt:1},children:[ro(sl,{onClickCapture:v=>{let H=v.target;if(H?.tagName==="IMG"&&H.src){v.preventDefault(),v.stopPropagation();let U=Array.from(v.currentTarget.querySelectorAll("img")).filter(le=>le.src),ee=U.map((le,$)=>({src:le.src,name:le.alt||decodeURIComponent(le.src.split("/").pop()||"")||`image-${$+1}`})),re=Math.max(0,U.indexOf(H));d?d(ee,re):f(ee[re].src);return}let te=I(v.target,!0);te&&(v.preventDefault(),v.stopPropagation(),f(te.href))},ref:R,className:"taskbox-content-readview","data-drag-scroll":"off",sx:{border:"1px solid #e0e0e0",borderRadius:1,p:"12px",pr:K?"12px":"52px",pb:"28px",minHeight:l,fontSize:16,lineHeight:1.6,color:"#37352f",wordBreak:"break-word",userSelect:"text","& > p:first-of-type":{mt:0},"& > p:last-of-type":{mb:0},"& a[href]":{color:"#2563eb",textDecoration:"underline",cursor:"pointer"},"& img":{maxWidth:"100%",cursor:"zoom-in"},"& ul, & ol":{pl:"1.5em",my:.5},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li > p":{my:0}}}),K?sc(sl,{sx:{display:"flex",gap:1,mt:1},children:[ro(ld,{variant:"outlined",color:"inherit",startIcon:ro(vw,{sx:{fontSize:18}}),onClick:T,sx:{flex:1,fontSize:15,color:"#37352f",borderColor:"#d9d9d6"},children:P?n("section.copied"):n("common.copy")}),a?null:ro(ld,{variant:"outlined",color:"inherit",startIcon:ro(kx,{sx:{fontSize:18}}),onClick:()=>h(!0),sx:{flex:1,fontSize:15,color:"#37352f",borderColor:"#d9d9d6"},children:n("common.edit")}),i?ro(ld,{variant:"outlined",color:"inherit",startIcon:ro(Tx,{sx:{fontSize:18}}),onClick:i,sx:{flex:1,fontSize:15,color:"#37352f",borderColor:"#d9d9d6"},children:n("section.translate")}):null]}):sc(sl,{sx:{position:"absolute",top:6,right:6,display:"flex",flexDirection:"column",gap:.25},children:[a?null:ro(cd,{title:n("section.editContent"),arrow:!0,placement:"left",children:ro(sd,{size:"small","aria-label":n("section.editContent"),onClick:()=>h(!0),sx:{color:"#9a9a97"},children:ro(kx,{sx:{fontSize:17}})})}),i?ro(cd,{title:n("section.translate"),arrow:!0,placement:"left",children:ro(sd,{size:"small","aria-label":n("section.translate"),onClick:i,sx:{color:"#9a9a97"},children:ro(Tx,{sx:{fontSize:17}})})}):null]})]}):sc(sl,{onDragOver:v=>v.stopPropagation(),onDrop:v=>v.stopPropagation(),onMouseDownCapture:v=>{E(v)&&I(v.target)&&v.preventDefault()},onClickCapture:v=>{let H=E(v)?I(v.target):null;H&&(v.preventDefault(),v.stopPropagation(),f(H.href))},sx:{mt:1,"& .ehfuse-editor-content > p:first-of-type":{mt:0},"& .ehfuse-editor-content > p:last-of-type":{mb:0},"& .ehfuse-editor-content.ehfuse-editor-empty::before":{top:"12px",left:"12px"},...S?{"& .ehfuse-editor-content a[href]":{cursor:"pointer"}}:{},position:"relative"},children:[r&&!x?ro(cd,{title:n("section.finishEditingTooltip"),arrow:!0,children:ro(sd,{size:"small","aria-label":n("section.finishEditing"),onMouseDown:v=>v.preventDefault(),onClick:()=>h(!1),sx:{position:"absolute",top:4,right:6,zIndex:2,color:"#2f9e5b"},children:ro(Sw,{sx:{fontSize:19}})})}):null,ro(Bw,{ref:B,defaultValue:md(t),autoHeight:!0,showToolbar:!S,focusBorder:!0,styles:{focusBorderColor:"var(--primary)"},toolbarOptions:Iw,plugins:[C.current],locale:ua(),minHeight:l,placeholder:n("section.contentPlaceholder"),onImageUpload:u,contentStyle:{padding:"12px"},onChange:v=>{let H=Date.now()<y.current,te=v===z.current;z.current=v,!(H||te)&&o(v)}})]})}import{Fragment as qw,jsx as Do,jsxs as uc}from"react/jsx-runtime";function pd(e){return String(e??"").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").trim().length>0}function dc({content:e,templates:t,onApply:o,onSave:a,onRemove:r,readOnly:i=!1}){M();let[l,s]=ud(null),[c,u]=ud(!1),[m,d]=ud(""),f=async g=>{s(null),!(pd(e)&&!await Pw({title:n("section.loadTemplate"),message:n("section.loadTemplateConfirm",{name:g.name})}))&&o(g.content)},p=()=>{s(null);let g=_a(e);g&&navigator.clipboard.writeText(g).then(()=>Ow(n("section.contentCopied"))).catch(()=>Mw(n("section.contentCopyFailed")))};return uc(qw,{children:[Do(Ew,{title:n("section.contentMenu"),arrow:!0,disableInteractive:!0,children:Do(Sx,{size:"small","aria-label":n("section.contentMenu"),onClick:g=>s(g.currentTarget),sx:{ml:"auto",color:"#9a9a97"},children:Do(Rw,{sx:{fontSize:18}})})}),uc(Dw,{anchorEl:l,open:!!l,onClose:()=>s(null),transitionDuration:0,children:[Do(mc,{disabled:!pd(e),onClick:p,sx:{fontSize:14,minWidth:220},children:n("menu.copyContent")}),i?null:Do(Cx,{sx:{my:.5}}),!i&&a?Do(mc,{disabled:!pd(e),onClick:()=>{s(null),d(""),u(!0)},sx:{fontSize:14,minWidth:220},children:n("section.saveAsTemplate")}):null,!i&&a?Do(Cx,{sx:{my:.5}}):null,i?null:t.length===0?Do(mc,{disabled:!0,sx:{fontSize:14,minWidth:220},children:n("section.noSavedTemplates")}):t.map(g=>uc(mc,{onClick:()=>{f(g)},sx:{fontSize:14,minWidth:220,gap:1},children:[Do(dd,{sx:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.name}),r?Do(Sx,{size:"small","aria-label":n("section.deleteTemplateAria",{name:g.name}),onClick:x=>{x.stopPropagation(),r(g.seq)},sx:{color:"#9a9a97"},children:Do(Xt,{sx:{fontSize:16}})}):null]},g.seq))]}),Do(Lw,{open:c,onClose:()=>u(!1),maxWidth:"xs",title:n("section.saveTemplateTitle"),locale:ye(),backdropClick:!1,titleIcons:{delete:{visible:!1},print:{visible:!1},share:{visible:!1}},tabs:{visible:!1},actions:{showCancelButton:!0,right:Do(ww,{variant:"contained",disabled:!m.trim(),onClick:()=>{a?.(m.trim(),e),u(!1)},children:n("common.save")})},sections:[{id:"template-name",title:"",showTitle:!1,children:uc(dd,{sx:{display:"flex",flexDirection:"column",gap:1},children:[Do(dd,{sx:{fontSize:15,color:"#37352f"},children:n("section.saveTemplateHint")}),Do(Aw,{size:"medium",fullWidth:!0,autoFocus:!0,placeholder:n("section.templateNamePlaceholder"),value:m,onChange:g=>d(g.target.value)})]})}]})]})}import{useState as ml}from"react";import{Box as Ht,Button as _x,Dialog as Qw,IconButton as li,Switch as Jw,TextField as Zw,Tooltip as fd}from"@mui/material";import{DndContext as eD,PointerSensor as tD,closestCenter as oD,useSensor as nD,useSensors as rD}from"@dnd-kit/core";import{restrictToParentElement as aD,restrictToVerticalAxis as iD}from"@dnd-kit/modifiers";import{SortableContext as lD,arrayMove as sD,useSortable as cD,verticalListSortingStrategy as mD}from"@dnd-kit/sortable";import{CSS as uD}from"@dnd-kit/utilities";import Ix from"@mui/icons-material/Close";import dD from"@mui/icons-material/AddCircle";import wx from"@mui/icons-material/AddTask";import pD from"@mui/icons-material/Checklist";import fD from"@mui/icons-material/CheckCircle";import gD from"@mui/icons-material/DragIndicator";import xD from"@mui/icons-material/Launch";import bD from"@mui/icons-material/LinkOutlined";import hD from"@mui/icons-material/RadioButtonUnchecked";import{useMemo as Ww}from"react";import{Box as Kn,Button as $w,Tab as Vw,Tabs as Uw}from"@mui/material";import{FormDialog as Kw}from"@ehfuse/mui-form-dialog";import{ClearTextField as Gw}from"@ehfuse/mui-form-controls";import jw from"@mui/icons-material/CheckCircle";import Yw from"@mui/icons-material/RadioButtonUnchecked";import{OverlayScrollbar as Xw}from"@ehfuse/overlay-scrollbar";import{useRef as zw}from"react";import{useGlobalForm as Nw,useModal as Fw}from"@ehfuse/forma";import{ErrorAlert as Hw}from"@ehfuse/alerts";var vx={type:"related",search:"",selectedSeqs:[]};function cl(e){M();let t=zw(e);t.current=e;let o={link:Fw({modalId:ve("taskbox-task-link")})},a=Nw({formId:ve("taskbox-task-link-form"),initialValues:vx,onValidate:l=>l.selectedSeqs.length===0?(Hw(n("link.selectTask")),!1):!0,onSubmit:l=>{for(let s of l.selectedSeqs)t.current.onSubmit(s,l.type);return o.link.close(),!0}});return{form:a,modals:o,openDialog:()=>{a.setFormValues({...vx,selectedSeqs:[]}),o.link.open()},toggleSelected:l=>{let s=a.getFormValue("selectedSeqs")??[];if(s.includes(l)){a.setFormValue("selectedSeqs",s.filter(c=>c!==l));return}a.setFormValue("selectedSeqs",t.current.multiSelect?[...s,l]:[l])}}}import{jsx as xo,jsxs as pc}from"react/jsx-runtime";var Bx=[{type:"related",get label(){return n("link.related")},get hint(){return n("link.relatedHint")}},{type:"follow_up",get label(){return n("link.previous")},get hint(){return n("link.previousHint")}},{type:"duplicate_of",get label(){return n("link.duplicate")},get hint(){return n("link.duplicateHint")}}];function fc({controller:e,task:t,tasks:o,excludeSeqs:a=[],hideRelationType:r=!1,title:i=n("link.title"),confirmLabel:l=n("link.confirm")}){M();let s=$e(),{form:c}=e,u=e.modals.link,m=c.useValue("type")??"related",d=String(c.useValue("search")??""),f=c.useValue("selectedSeqs")??[],p=Ww(()=>{let b=new Set([t.seq,...a]),_=d.trim().toLowerCase();return o.filter(h=>b.has(h.seq)||h.is_event||h.is_notice||h.linked_only?!1:_?h.title.toLowerCase().includes(_)||(h.ticket_no??"").toLowerCase().includes(_):!0).sort((h,B)=>!!h.completed!=!!B.completed?h.completed?1:-1:B.seq-h.seq)},[o,t.seq,a,d]),g=Bx.find(b=>b.type===m)?.hint??"",x=pc(Kn,{sx:{display:"flex",flexDirection:"column",minHeight:0,height:s?"100%":"auto"},children:[r?null:xo(Uw,{value:m,onChange:(b,_)=>c.setFormValue("type",_),sx:{minHeight:38,flexShrink:0,borderBottom:"1px solid #ededeb","& .MuiTab-root":{minHeight:38,py:.5,fontSize:16,color:"#333333"}},children:Bx.map(b=>xo(Vw,{value:b.type,label:b.label},b.type))}),r?null:xo(Kn,{sx:{mt:1,mb:1.5,fontSize:14,flexShrink:0},children:g}),pc(Kn,{sx:{...s?{height:"100%",minHeight:0}:{height:560},display:"flex",flexDirection:"column",...s?{}:{border:"1px solid #cccccc",borderRadius:1},overflow:"hidden",userSelect:"none"},children:[xo(Kn,{sx:{px:1.5,py:1,borderBottom:"1px solid #cccccc",flexShrink:0},children:xo(Gw,{placeholder:n("link.searchPlaceholder"),name:"search",form:c,fullWidth:!0,autoFocus:!0,size:"small",sx:{"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiInputBase-root":{px:0}}})}),xo(Kn,{sx:{flex:1,minHeight:0},children:xo(Xw,{style:{height:"100%"},contentStyle:{paddingTop:0},children:xo(Kn,{sx:{display:"flex",flexDirection:"column"},children:p.length===0?xo(Kn,{sx:{py:4,textAlign:"center",fontSize:13.5,color:"#9a9a97"},children:n("link.empty")}):p.map(b=>{let _=b.is_notice||b.is_event?Oe(b.icon||(b.is_notice?vt:zt)):null,h=f.includes(b.seq);return pc(Kn,{onClick:()=>e.toggleSelected(b.seq),sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:1.25,flexShrink:0,cursor:"pointer",borderBottom:"1px solid #ededeb","&:last-of-type":{borderBottom:"none"},bgcolor:h?"#e3eefb":"transparent","&:hover":{bgcolor:h?"#e3eefb":"#f7f7f5"}},children:[h?xo(jw,{sx:{fontSize:20,flexShrink:0,color:"#2f6fd0"}}):xo(Yw,{sx:{fontSize:20,flexShrink:0,color:"#c9c8c5"}}),_?xo(_,{sx:{fontSize:17,flexShrink:0,color:b.icon_color||"#1e3a8a"}}):null,pc(Kn,{component:"span",sx:{flex:1,minWidth:0,fontSize:15,color:"#37352f",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:3,overflow:"hidden",lineHeight:1.5,wordBreak:"break-word"},children:[b.ticket_no?`${b.ticket_no} `:"",b.title]}),xo(Kn,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:xo(Ke,{option:Nt(b)})})]},b.seq)})})})})]})]});return xo(Kw,{open:u.isOpen,onClose:u.close,maxWidth:"sm",fullScreen:s,mobilePresentation:s?"slide":"dialog",...s?{contentPaddingX:0,contentTopPadding:0,sectionsPaddingTop:0}:{},sx:s?{DialogContent:{pb:0,"& .os-content > div":{height:"100%",boxSizing:"border-box",paddingBottom:0,marginBottom:0},"& .FormSection-content, & .section-content":{height:"100%",paddingBottom:0,marginBottom:0}}}:void 0,title:i,locale:ye(),tabs:{visible:!1},titleIcons:{delete:{visible:!1}},fontScale:{enabled:!0},fontScaleKey:"taskbox-task-link",sections:[{id:"task-link",showTitle:!1,children:x}],scrollPastLastSection:!1,sectionContentPaddingTop:0,contentTopPadding:12,actions:{showCancelButton:!0,right:xo($w,{variant:"contained",disabled:f.length===0,onClick:()=>{c.submit()},children:l})}})}import{ConfirmActionPopper as kD}from"@ehfuse/mui-confirm-action";import{Fragment as CD,jsx as Se,jsxs as Gn}from"react/jsx-runtime";var Dx="taskbox.checklist.hideCompleted";function TD({id:e,children:t}){let{attributes:o,listeners:a,setNodeRef:r,transform:i,transition:l,isDragging:s}=cD({id:e});return Se(Ht,{ref:r,sx:{transform:uD.Transform.toString(i),transition:l,...s?{opacity:.6,position:"relative",zIndex:1}:{}},children:t({handleProps:{...o,...a},dragging:s})})}function yD({sortable:e,sensors:t,rowIds:o,onDragEnd:a,compact:r,children:i}){let l=Se(Ht,{sx:{display:"flex",flexDirection:"column",mt:.5,pl:r?0:3.25},children:i});return e?Se(eD,{sensors:t,collisionDetection:oD,modifiers:[iD,aD],onDragEnd:a,children:Se(lD,{items:o,strategy:mD,children:l})}):l}function gc({taskSeq:e,checklist:t,onAdd:o,onToggle:a,confirmOnToggle:r=!1,onRemove:i,onUpdate:l,onReorder:s,removeLocked:c=!1,onConvertToTask:u,onOpenLinkedTask:m,linkCandidates:d,linkBaseTask:f,onLinkExistingTask:p,resolveLinkedTask:g,myAccountSeq:x=0}){M();let[b,_]=ml(""),h=cl({multiSelect:!0,onSubmit:$=>{if(!p)return;let Z=d?.find(W=>W.seq===$);p(e,$,String(Z?.title??"").trim())}}),[B,C]=ml(null),z=$e(),[y,S]=ml(null),[D,K]=ml(null),P=$=>{let Z=$.task_seq?g?.($.task_seq):void 0;return Z?Z.completed:$.checked},k=$=>{if(!$.task_seq||x<=0)return!1;let Z=g?.($.task_seq);return Z?!Wf(Z,x):!1},T=$=>!!$.task_seq&&!!g&&!g?.($.task_seq),I=t.filter($=>!T($)),E=I.filter(P).length,[L,R]=ml(()=>{try{return localStorage.getItem(Dx)==="1"}catch{return!1}}),A=$=>{R($);try{localStorage.setItem(Dx,$?"1":"0")}catch{}},v=!!s&&!z&&!c,H=rD(nD(tD,{activationConstraint:{distance:5}})),te=($,Z)=>$.task_seq?`linked-${$.task_seq}`:`row-${Z}`,U=t.map(te),ee=U.filter(($,Z)=>{let W=t[Z];return T(W)?!1:!(L&&P(W))}),re=$=>{let{active:Z,over:W}=$;if(!W||Z.id===W.id)return;let V=U.indexOf(String(Z.id)),fe=U.indexOf(String(W.id));V<0||fe<0||s?.(e,sD(t,V,fe))},le=()=>{b.trim()&&(o(e,b),_(""))};return Gn(zo,{icon:Se(pD,{sx:{fontSize:19,display:"block"}}),title:Gn(CD,{children:[n("section.todo"),t.length>0?Gn(Ht,{component:"span",sx:{fontSize:12.5,color:"#9a9a97"},children:[E," / ",t.length]}):null]}),titleExtra:I.length>0?Gn(Ht,{sx:{flex:1,minWidth:0,ml:1,display:"flex",alignItems:"center",gap:1},children:[Se(Ht,{sx:{flex:1,minWidth:0,height:6,borderRadius:3,bgcolor:"#ececea"},children:Se(Ht,{sx:{height:"100%",borderRadius:3,width:`${Math.round(E/I.length*100)}%`,bgcolor:"#2f80ed",transition:"width 0.2s"}})}),E>0?Gn(Ht,{component:"label",sx:{display:"inline-flex",alignItems:"center",gap:.25,flexShrink:0,cursor:"pointer",fontSize:13.5,fontWeight:400,color:"#57564f",userSelect:"none"},children:[Se(Jw,{size:"small",checked:L,onChange:($,Z)=>A(Z)}),n("section.hideDone")]}):null]}):null,children:[Se(yD,{sortable:v,sensors:H,rowIds:ee,onDragEnd:re,compact:z,children:t.map(($,Z)=>{let W=$.task_seq?g?.($.task_seq):void 0,V=P($);if(L&&V||T($))return null;let fe=!!$.task_seq,Ee=k($),nt=se=>Gn(Ht,{sx:{display:"flex",alignItems:z?"flex-start":"center",gap:1,px:1.25,...v?{ml:-3,pl:.5}:{},py:.5,borderRadius:1,"&:hover":{bgcolor:"#f7f7f5"},"&:hover .taskbox-checklist-remove":{opacity:1},"&:hover .taskbox-checklist-convert":{opacity:1},"&:hover .taskbox-checklist-handle":{opacity:1}},children:[se?Se(Ht,{className:"taskbox-checklist-handle",...se,sx:{display:"inline-flex",flexShrink:0,alignItems:"center",color:"#c9c8c5",opacity:0,transition:"opacity 0.15s",cursor:"grab","&:active":{cursor:"grabbing"},touchAction:"none",userSelect:"none"},children:Se(gD,{sx:{fontSize:16}})}):null,Se(fd,{title:Ee?n("section.toggleLocked"):"",arrow:!0,disableInteractive:!0,children:Se(Ht,{component:"span",onClick:Ee?void 0:Q=>r?K({anchorEl:Q.currentTarget,index:Z,checked:!V}):a(e,Z,!V),sx:{display:"inline-flex",flexShrink:0,cursor:Ee?"default":"pointer",...z?{mt:"1px"}:{}},children:V?Se(fD,{sx:{fontSize:18,color:Ee?"#a9c6ec":"#2f80ed"}}):Se(hD,{sx:{fontSize:18,color:Ee?"#d6d5d1":"#9a9a97"}})})}),B?.index===Z?Se(Ht,{component:"input",autoFocus:!0,spellCheck:!1,value:B.label,enterKeyHint:"done",onChange:Q=>C({index:Z,label:Q.target.value}),onBlur:()=>{B.label.trim()&&B.label.trim()!==$.label&&l?.(e,Z,B.label),C(null)},onKeyDown:Q=>{Q.key==="Enter"&&Q.target.blur(),Q.key==="Escape"&&C(null)},sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:14,color:"#37352f",bgcolor:"transparent",p:0}}):Se(Ht,{component:"span",onClick:fe?$.task_seq&&m?()=>m($.task_seq):void 0:c||!l?void 0:z?()=>S({index:Z,label:$.label}):()=>C({index:Z,label:$.label}),sx:{flex:1,minWidth:0,fontSize:14.5,color:"#37352f",textDecoration:V?"line-through":"none",overflow:"hidden",textOverflow:"ellipsis",...z?{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:3,lineHeight:1.4,wordBreak:"break-word"}:{whiteSpace:"nowrap"},...fe?m?{cursor:"pointer","&:hover":{color:"#2f80ed"}}:{}:c||!l?{}:{cursor:"text"}},children:$.label}),fe?Gn(Ht,{component:"span",onClick:$.task_seq&&m?()=>m($.task_seq):void 0,sx:{display:"inline-flex",alignItems:"center",gap:.4,flexShrink:0,...z?{mt:"1px"}:{},px:.75,py:.2,borderRadius:1,fontSize:12,fontWeight:500,color:"#1d4f91",bgcolor:"#e3eefb",whiteSpace:"nowrap",...m?{cursor:"pointer"}:{}},children:[Se(xD,{sx:{fontSize:12}}),W?.manager_name?.trim()||n("template.task")]}):null,!c&&!fe&&u?Se(fd,{title:n("section.makeTask"),arrow:!0,enterDelay:300,disableInteractive:!0,children:Se(li,{className:"taskbox-checklist-convert",size:"small","aria-label":n("section.makeTask"),onClick:()=>u(e,Z,$.label),sx:{display:z?"none":"inline-flex",opacity:0,transition:"opacity 0.15s",color:"#9a9a97"},children:Se(wx,{sx:{fontSize:16}})})}):null,c?null:Se(li,{className:"taskbox-checklist-remove",size:"small","aria-label":n("section.deleteTodo"),onClick:()=>i(e,Z),sx:{display:z?"none":"inline-flex",opacity:0,transition:"opacity 0.15s",color:"#9a9a97"},children:Se(Ix,{sx:{fontSize:15}})})]});return v?Se(TD,{id:U[Z],children:({handleProps:se})=>nt(se)},U[Z]):Se(Ht,{children:nt(null)},U[Z])})}),Gn(Ht,{sx:{mt:.5,ml:z?0:3.25,display:"flex",alignItems:"center",gap:.5},children:[Se(Ht,{component:"input",spellCheck:!1,value:b,placeholder:n("section.addTodoPlaceholder"),enterKeyHint:"done",onChange:$=>_($.target.value),onKeyDown:$=>{$.key==="Enter"&&le()},sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:14,color:"#37352f",bgcolor:"transparent",px:1.25,py:.75,"&::placeholder":{color:"#9a9a97"}}}),d&&f&&p?Se(fd,{title:n("section.attachExisting"),arrow:!0,children:Se(li,{size:"small","aria-label":n("section.attachExisting"),onMouseDown:$=>$.preventDefault(),onClick:h.openDialog,sx:{flexShrink:0,color:"#9a9a97"},children:Se(bD,{sx:{fontSize:20}})})}):null,Se(li,{size:"small","aria-label":n("section.addTodo"),disabled:!b.trim(),onMouseDown:$=>$.preventDefault(),onClick:le,sx:{flexShrink:0,color:b.trim()?"#2f80ed":"#c9c8c5"},children:Se(dD,{sx:{fontSize:20}})})]}),d&&f&&p?Se(fc,{controller:h,task:f,tasks:d,excludeSeqs:t.map($=>Number($.task_seq??0)).filter($=>$>0),hideRelationType:!0,title:n("section.attachExisting"),confirmLabel:n("section.attach")}):null,Se(kD,{open:!!D,anchorEl:D?.anchorEl??null,title:D?.checked?n("calendar.checklistCompleteConfirm"):n("task.uncompleteConfirm"),confirmText:D?.checked?n("common.done"):n("task.unmark"),onCancel:()=>K(null),onConfirm:()=>{D&&a(e,D.index,D.checked),K(null)}}),Se(Qw,{open:!!y,onClose:()=>S(null),maxWidth:"xs",fullWidth:!0,slotProps:{paper:{sx:{borderRadius:2,m:2}}},children:Gn(Ht,{sx:{p:2,display:"flex",flexDirection:"column",gap:1.5},children:[Se(Ht,{sx:{fontSize:15.5,fontWeight:600,color:"#37352f"},children:n("section.editTodo")}),Se(Zw,{autoFocus:!0,fullWidth:!0,size:"medium",value:y?.label??"",onChange:$=>S(Z=>Z&&{...Z,label:$.target.value}),onKeyDown:$=>{if($.key!=="Enter")return;let Z=y;Z&&Z.label.trim()&&l?.(e,Z.index,Z.label.trim()),S(null)}}),Gn(Ht,{sx:{display:"flex",alignItems:"center",gap:1},children:[!c&&u&&y&&!t[y.index]?.task_seq?Se(li,{"aria-label":n("section.makeTask"),onClick:()=>{u(e,y.index,t[y.index]?.label??""),S(null)},sx:{color:"#57564f"},children:Se(wx,{sx:{fontSize:20}})}):null,!c&&y?Se(li,{"aria-label":n("section.deleteTodo"),onClick:()=>{i(e,y.index),S(null)},sx:{color:"#e5484d"},children:Se(Ix,{sx:{fontSize:19}})}):null,Se(Ht,{sx:{flex:1}}),Se(_x,{color:"inherit",onClick:()=>S(null),children:n("common.cancel")}),Se(_x,{variant:"contained",disabled:!y?.label.trim(),onClick:()=>{y&&y.label.trim()&&l?.(e,y.index,y.label.trim()),S(null)},children:n("common.confirm")})]})]})})]})}import{useRef as wD,useState as DD}from"react";import{Box as sn,IconButton as ED}from"@mui/material";import{DndContext as RD,PointerSensor as PD,closestCenter as MD,useSensor as OD,useSensors as LD}from"@dnd-kit/core";import{restrictToParentElement as AD,restrictToVerticalAxis as qD}from"@dnd-kit/modifiers";import{SortableContext as zD,useSortable as ND,verticalListSortingStrategy as FD}from"@dnd-kit/sortable";import{CSS as HD}from"@dnd-kit/utilities";import WD from"@mui/icons-material/DragIndicator";import $D from"@mui/icons-material/Close";import Px from"@mui/icons-material/AttachFileOutlined";var SD=new Set(["jpg","jpeg","png","gif","bmp","webp","svg","pdf","txt","json","xml","log","md","markdown","csv","xls","xlsx","html","htm","js","jsx","ts","tsx","css","scss","sass","less","php","py","java","c","cpp","h","hpp","cs","go","rs","rb","swift","kt","scala","sql","sh","bash","bat","ps1","yml","yaml","toml","ini","conf","mp4","avi","mov","wmv","flv","webm","mp3","wav","ogg","m4a","aac"]),xc=e=>{let t=e?.split(".").pop()?.toLowerCase()??"";return SD.has(t)};import{LinearProgress as vD}from"@mui/material";import{Fragment as BD,jsx as ID,jsxs as _D}from"react/jsx-runtime";function Ex(e){let t=xn(),o=t.useValue("attachmentUpload.taskSeq"),a=t.useValue("attachmentUpload.index"),r=t.useValue("attachmentUpload.total"),i=t.useValue("attachmentUpload.queue"),l=a??0;return!l||e>0&&(o??0)!==e?null:{index:l,total:r??0,queue:i??[]}}function gd(){let t=xn().useValue("attachmentUpload.progress");return _D(BD,{children:[t??0,"%"]})}function Rx(){let t=xn().useValue("attachmentUpload.progress");return ID(vD,{variant:"determinate",value:t??0,sx:{height:4,borderRadius:2,bgcolor:"#dbe9fb",mt:.75}})}import{Fragment as Mx,jsx as It,jsxs as dl}from"react/jsx-runtime";function VD({id:e,children:t}){let{attributes:o,listeners:a,setNodeRef:r,transform:i,transition:l,isDragging:s}=ND({id:e});return It(sn,{ref:r,sx:{transform:HD.Transform.toString(i),transition:l,...s?{opacity:.6,position:"relative",zIndex:1}:{}},children:t({...o,...a})})}function ul(e){return e>=1048576?`${(e/1048576).toFixed(1)}MB`:`${Math.max(1,Math.round(e/1024))}KB`}var bc={flex:1,minWidth:0,fontSize:13.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function hc({taskSeq:e,attachments:t,onAdd:o,onRemove:a,removeLocked:r=!1,onPreview:i,onDownload:l,onReorder:s}){M();let[c,u]=DD(!1),m=wD(null),d=$e(),f=Ai(),p=Li(),g=Ex(e),x=e===0,b=!!s&&!x&&!d&&!r&&!g&&t.length>1,_=LD(OD(PD,{activationConstraint:{distance:5}})),h=(P,k)=>P.uuid?`file-${P.uuid}`:`file-${k}`,B=t.map(h),C=P=>{let{active:k,over:T}=P;if(!T||k.id===T.id)return;let I=B.indexOf(String(k.id)),E=B.indexOf(String(T.id));I<0||E<0||s?.(e,I,E)},z=P=>{if(i){i(P);return}window.open(p(P.uuid??""),"_blank","noopener,noreferrer")},y=P=>{if(l){l(P);return}window.open(p(P.uuid??"",{download:!0}),"_blank","noopener,noreferrer")},S=P=>g?P+1<g.index?"done":P+1===g.index?"uploading":"waiting":"waiting",D=(P,k,T,I={})=>dl(sn,{sx:{px:1,py:.5,borderRadius:1,border:"1px solid",borderColor:I.uploading?"#d5e6fb":"#e6e6e3",bgcolor:I.uploading?"#f4f9ff":"transparent","&:hover .taskbox-file-remove":{opacity:1},"&:hover .taskbox-file-handle":{opacity:1}},children:[dl(sn,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:0},children:[I.handleProps?It(sn,{className:"taskbox-file-handle","aria-label":n("section.reorder"),...I.handleProps,sx:{display:"inline-flex",flexShrink:0,alignItems:"center",ml:-.5,mr:-.5,color:"#c9c8c5",opacity:0,transition:"opacity 0.15s",cursor:"grab","&:active":{cursor:"grabbing"},touchAction:"none",userSelect:"none"},children:It(WD,{sx:{fontSize:16}})}):null,It(Px,{sx:{fontSize:16,color:"#9a9a97"}}),k,It(sn,{component:"span",sx:{fontSize:12,color:I.uploading?"#2f80ed":"#9a9a97",flexShrink:0},children:T}),I.removeIndex!==void 0?It(ED,{className:"taskbox-file-remove",size:"small","aria-label":n("section.deleteAttachment"),onClick:()=>a(e,I.removeIndex),sx:{opacity:0,transition:"opacity 0.15s",color:"#9a9a97"},children:It($D,{sx:{fontSize:15}})}):null]}),I.uploading?It(Rx,{}):null]},P),K=P=>{let k=xc(P.name);return It(sn,{component:"button",type:"button",onClick:()=>k?z(P):y(P),title:n("section.fileAction",{name:P.name,value:k?n("section.preview"):n("section.download")}),sx:{...bc,color:"#37352f",textAlign:"left",p:0,border:"none",background:"none",font:"inherit",fontSize:13.5,cursor:"pointer",outline:"none","&:focus-visible":{textDecoration:"underline",color:"#2f80ed"},"&:hover":{textDecoration:"underline",color:"#2f80ed"}},children:P.name})};return dl(zo,{icon:It(Px,{sx:{fontSize:18,display:"block"}}),title:dl(Mx,{children:[n("section.files")," ",t.length>0?t.length:""]}),children:[It(UD,{sortable:b,sensors:_,rowIds:B,onDragEnd:C,children:dl(sn,{sx:{display:"flex",flexDirection:"column",gap:.5,mt:1},children:[t.map((P,k)=>{let T=`${P.uuid||P.name}-${k}`;if(x){let I=S(k),E=I==="uploading";return D(T,It(sn,{component:"span",sx:{...bc,color:I==="done"?"#37352f":"#9a9a97"},children:P.name}),E?It(gd,{}):ul(P.size),{uploading:E,removeIndex:!r&&!g?k:void 0})}return P.uuid?b?It(VD,{id:h(P,k),children:I=>D(T,K(P),ul(P.size),{removeIndex:r?void 0:k,handleProps:I})},h(P,k)):D(T,K(P),ul(P.size),{removeIndex:r?void 0:k}):D(T,It(sn,{component:"span",title:n("section.legacyAttachment"),sx:{...bc,color:"#9a9a97"},children:P.name}),ul(P.size),{removeIndex:r?void 0:k})}),!x&&g?g.queue.slice(g.index-1).map((P,k)=>{let T=k===0;return D(`uploading-${g.index+k}-${P.name}`,It(sn,{component:"span",sx:{...bc,color:"#9a9a97"},children:P.name}),T?It(gd,{}):ul(P.size),{uploading:T})}):null]})}),It(sn,{onClick:()=>m.current?.click(),onDragOver:P=>{P.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:P=>{P.preventDefault(),u(!1);let k=Array.from(P.dataTransfer.files);k.length>0&&o(e,k)},sx:{mt:1,py:2.5,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,border:"1.5px dashed",borderColor:c?"#2f80ed":"#cfcfcc",borderRadius:1,bgcolor:c?"#eef6ff":"transparent",color:"#787774",fontSize:13.5,cursor:"pointer",transition:"background-color 0.15s, border-color 0.15s","&:hover":{bgcolor:"#fafaf9",borderColor:"#9a9a97"}},children:d?n("section.attachHint",{uploadMaxMb:f}):n("section.attachHintDrag",{uploadMaxMb:f})}),It(sn,{component:"input",ref:m,type:"file",multiple:!0,onChange:P=>{let k=Array.from(P.target.files??[]);k.length>0&&o(e,k),P.target.value=""},sx:{display:"none"}})]})}function UD({sortable:e,sensors:t,rowIds:o,onDragEnd:a,children:r}){return e?It(RD,{sensors:t,collisionDetection:MD,modifiers:[qD,AD],onDragEnd:a,children:It(zD,{items:o,strategy:FD,children:r})}):It(Mx,{children:r})}import{useState as JD}from"react";import{Checkbox as ZD,Divider as eE,ListItemIcon as tE,Menu as oE,MenuItem as qx}from"@mui/material";import nE from"@mui/icons-material/Add";import{Box as xd,Button as jD}from"@mui/material";import{FormDialog as YD}from"@ehfuse/mui-form-dialog";import{ClearTextField as XD}from"@ehfuse/mui-form-controls";import{ColorPicker as QD}from"@ehfuse/mui-color-picker";import{useGlobalForm as KD}from"@ehfuse/forma";import{ErrorAlert as GD}from"@ehfuse/alerts";var Ox="#2f80ed";function Lx({open:e,onClose:t,onSubmit:o}){M();let a=KD({formId:ve("taskbox-add-label-form"),initialValues:{name:"",color:Ox},onValidate:i=>String(i.name??"").trim()?!0:(GD(n("dialog.enterLabelName")),!1),onSubmit:i=>(o(String(i.name).trim(),i.color),r.form.close(),!0)}),r={form:to({modalIdPrefix:"taskbox-add-label-dialog",open:e,onClose:t,onOpen:()=>a.setFormValues({name:"",color:Ox})})};return{form:a,modals:r}}import{jsx as pl,jsxs as bd}from"react/jsx-runtime";function Ax({open:e,onClose:t,onSubmit:o}){M();let{form:a,modals:r}=Lx({open:e,onClose:t,onSubmit:o}),i=String(a.useFormValue("name")??""),l=String(a.useFormValue("color")??""),s=ff(l),c=bd(xd,{children:[bd(xd,{sx:{display:"flex",alignItems:"center",gap:1.5,mt:.5},children:[pl(XD,{form:a,name:"name",label:n("dialog.labelName"),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),a.submit())},fullWidth:!0,autoFocus:!0}),pl(QD,{value:l,onChange:u=>a.setFormValue("color",u),shape:"circle",colorSize:28})]}),bd(xd,{sx:{mt:2,display:"flex",alignItems:"center",gap:1,fontSize:13,color:"#787774"},children:[n("dialog.preview"),pl(Ke,{option:{key:"__preview__",name:i.trim()||n("dialog.label"),...s}})]})]});return pl(YD,{open:r.form.isOpen,onClose:r.form.close,maxWidth:"xs",title:n("dialog.addLabelTitle"),locale:ye(),tabs:{visible:!1},titleIcons:{delete:{visible:!1}},fontScale:{enabled:!0},fontScaleKey:"taskbox-add-label",sections:[{id:"add-label",showTitle:!1,children:c}],actions:{showCancelButton:!0,right:pl(jD,{variant:"contained",onClick:()=>{a.submit()},children:n("common.add")})}})}import{Fragment as rE,jsx as si,jsxs as kc}from"react/jsx-runtime";function Tc({anchorEl:e,selectedKeys:t,labelOptions:o,onToggle:a,onAddLabel:r,onClose:i}){M();let[l,s]=JD(!1),c=Ln();return kc(rE,{children:[kc(oE,{anchorEl:e,open:!!e,onClose:i,transitionDuration:0,...c,children:[o.map(u=>{let m=t.includes(u.key);return kc(qx,{onClick:()=>a(u.key),sx:{fontSize:14,minWidth:170,gap:1},children:[si(ZD,{size:"small",checked:m,sx:{p:0}}),si(Ke,{option:u})]},u.key)}),si(eE,{}),kc(qx,{onClick:()=>s(!0),sx:{fontSize:14,color:"#787774"},children:[si(tE,{children:si(nE,{sx:{fontSize:18,color:"#787774"}})}),n("menu.addLabel")]})]}),si(Ax,{open:l,onClose:()=>s(!1),onSubmit:r})]})}function zx(e,t){let o=Number(e.author_account_seq??0);return t.filter(a=>{let r=Number(a.account_seq??0);return r>0&&r!==o})}function Nx(e,t){let o=(e.target_account_seqs??[]).filter(d=>d>0);if(o.length===0)return null;let a=new Set(o),r=zx(e,t),i=new Map;for(let d of r){let f=String(d.department??"").trim();if(!f)continue;let p=i.get(f)??[];p.push(d),i.set(f,p)}let l=[],s=new Set;for(let[d,f]of i)if(f.every(g=>a.has(Number(g.account_seq??0)))){l.push(d);for(let g of f)s.add(Number(g.account_seq??0))}let c=new Map(r.map(d=>[Number(d.account_seq??0),d.name])),u=e.target_names??[],m=[];return o.forEach((d,f)=>{s.has(d)||m.push(c.get(d)??u[f]??n("dialog.noName"))}),{teamNames:l,individualNames:m}}function yc(e,t){let o=Nx(e,t);return o?[...o.teamNames,...o.individualNames].join(", "):n("col.allEmployees")}function xK(e,t){let o=Nx(e,t);return o?{kind:"members",teamNames:o.teamNames,individualNames:o.individualNames}:{kind:"everyone"}}function Fx(e,t,o){let a=(e.target_account_seqs??[]).filter(p=>p>0),r=zx(e,t),i=a.length>0?a.length:r.length,l=e.acks??[],s=o>0&&l.some(p=>p.account_seq===o),c=o>0&&Number(e.author_account_seq??0)===o,u=a.length===0||a.includes(o),m=new Set(l.map(p=>p.account_seq)),f=(a.length>0?r.filter(p=>a.includes(Number(p.account_seq??0))):r).filter(p=>!m.has(Number(p.account_seq??0))).map(p=>String(p.name??"").trim()).filter(p=>p.length>0);return{count:l.length,total:i,acked:s,pendingNames:f,canAck:o>0&&!c&&u&&!s&&!e.completed}}import{DatePicker as xE}from"@ehfuse/mui-datetime-picker";import{Fragment as Ia,jsx as pe,jsxs as vn}from"react/jsx-runtime";var Ux="taskbox:create-expanded";function bE(){try{return window.localStorage.getItem(Ux)==="1"}catch{return!1}}function Td({form:e,statusOptions:t,customTabs:o,sprints:a=[],avatarSrcByName:r,isNotice:i=!1,hideProject:l=!1,hideBug:s=!1,hideTypeToggle:c=!1,leadingRow:u,extraRows:m,hideLabel:d=!1,simple:f=!1,hideMembers:p=!1,templateItem:g=!1,postMode:x=!1,employees:b=[],workspaceName:_="",workspaceSlot:h,myAccountSeq:B=0,departments:C=[],myGroupSeq:z=0,onMemberEdit:y,onAddProject:S,onAddLabelOption:D,contentSyncKey:K="create",contentTemplates:P,contentTitleExtra:k,onSaveContentTemplate:T,onRemoveContentTemplate:I}){M();let E=xn(),L=Ai(),R=e.useFormValue("manager_name"),A=e.useFormValue("receiver_names"),v=e.useFormValue("start_date"),H=!!e.useFormValue("is_event"),te=!!e.useFormValue("is_bug"),U=e.useFormValue("bug_repro")??"",ee=e.useFormValue("bug_device")??"",re=e.useFormValue("bug_where")??"",le=e.useFormValue("bug_version")??"",$=e.useFormValue("event_time")??"",Z=e.useFormValue("event_place")??"",W=e.useFormValue("event_address")??"",V=e.useFormValue("due_date"),fe=e.useFormValue("reminders")??[],Ee=e.useFormValue("priority"),nt=e.useFormValue("content"),se=e.useFormValue("note")??"",N=e.useFormValue("checklist")??[],j=e.useFormValue("tab_key"),ae=e.useFormValue("sprint_seq")??0,me=e.useFormValue("story_points")??0,we=o.find(w=>w.key===j&&w.useSprints),Ce=we?a.filter(w=>`custom-${w.group_seq}`===j):[],[Ct,Ne]=ci(null),Re=e.useFormValue("label_keys"),[Pt,Ve]=ci(null),gt=e.useFormValue("visibility")||"involved",io=Number(e.useFormValue("visibility_group_seq")??0),[J,Be]=ci(null),qe=e.useFormValue("repeat_rule")||"",Ye=e.useFormValue("repeat_until")||"",[Jn,Zn]=ci(null),[Co,Dn]=ci(null),er=e.useFormValue("target_names"),pn=e.useFormValue("target_account_seqs"),En=E.useValue("createAttachmentFiles")??[],Vt=i?yc({author_account_seq:B,target_names:er,target_account_seqs:pn},b):"",[lt,Wo]=ci(bE),fn=f&&!H&&!i&&!x,Mt=fn&&!lt,Oo=()=>{let w=!lt;Wo(w);try{window.localStorage.setItem(Ux,w?"1":"0")}catch{}},lo=!x,Me=p?1:2;return vn(Ia,{children:[u,!i&&!c?vn(hr,{sx:{display:"flex",gap:1.25,px:2,pt:1.5,pb:1.5,flexShrink:0},children:[h?pe(hr,{sx:{alignSelf:"center",mr:"6px",minWidth:0,display:"flex"},children:h}):_?pe(hr,{sx:{alignSelf:"center",fontSize:13.5,fontWeight:600,color:"#37352f",mr:"6px",maxWidth:160,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_,children:_}):null,[{value:"task",label:n("kind.task")},{value:"event",label:n("kind.event")},...s?[]:[{value:"bug",label:n("kind.bug")}]].map(w=>{let ue=(te?"bug":H?"event":"task")===w.value;return pe(Hx,{onClick:()=>Lm(e,w.value),sx:{px:1.75,lineHeight:1,pt:"8px",pb:"10px",borderRadius:99,fontSize:13.5,fontWeight:ue?600:400,color:ue?"#ffffff":"#787774",bgcolor:ue?"#2563eb":"#f4f4f2"},children:w.label},w.label)})]}):null,pe(fl,{sx:{borderColor:"#e6e6e3"}}),vn(hr,{sx:{pt:1.5,pb:2,display:"flex",flexDirection:"column",gap:.25},children:[pe(ic,{hideProject:l||x||Mt&&!j,hideManager:p||Mt&&!R,hideReceivers:g||p||Mt&&A.length===0,hideStartDate:Mt||x,hideReminder:g||x||Mt&&fe.length===0,hidePriority:x,hideDueDate:x||!H&&!!qe,values:{tabKey:j,managerName:R,receiverNames:A,startDate:v,dueDate:V,reminders:fe,priority:Ee,eventTime:$,eventPlace:Z,eventAddress:W},customTabs:o,avatarSrcByName:r,notice:i,event:H,onChangeEventTime:w=>e.setFormValue("event_time",w),onChangeEventPlace:w=>e.setFormValue("event_place",w),onChangeEventAddress:w=>e.setFormValue("event_address",w),targetSummary:Vt,onChangeProject:w=>e.setFormValue("tab_key",w),onAddProject:S,onChangeStartDate:w=>e.setFormValue("start_date",w),onClearStartDate:()=>e.setFormValue("start_date",""),onChangeDueDate:w=>e.setFormValue("due_date",w),onChangeReminder:w=>e.setFormValue("reminders",w),onChangePriority:w=>e.setFormValue("priority",w),onMemberEdit:y,pinColumns:lo,beforeStart:vn(Ia,{children:[!g&&!te&&!x&&!(Mt&&!qe)?pe(he,{icon:pe(dE,{sx:{fontSize:17,...qe?{color:"#2f80ed"}:{}}}),label:n("create.repeat"),onClick:w=>Zn(w),sx:H||!lo?void 0:pt(Me),children:qe?ss(qe):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("common.none")})}):null,!g&&!te&&!x&&qe?pe(he,{icon:pe(pE,{sx:{fontSize:17}}),label:n("create.repeatUntil"),onClick:w=>Dn(w),sx:H||!lo?void 0:pt(Me),children:Ye?Vo(Ye):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("create.auto")})}):null]}),trailing:vn(Ia,{children:[!i&&!p&&!(Mt&&gt==="involved")?pe(he,{icon:gt==="all"?pe($x,{sx:{fontSize:17,color:"#2f80ed"}}):gt==="group"?pe(Vx,{sx:{fontSize:17,color:"#d9730d"}}):pe(Wx,{sx:{fontSize:17}}),label:n("create.visibility"),onClick:w=>Be(w),sx:H||!lo?void 0:pt(1),children:gt==="all"?n("create.visibilityPublic"):gt==="group"?n("create.visibilityDept",{value:C.find(w=>w.seq===io)?.name??n("create.department")}):n("create.visibilityPrivate")}):null,we&&!H&&!i&&!x&&!(Mt&&ae===0&&me===0)?vn(Ia,{children:[pe(he,{icon:pe(uE,{sx:{fontSize:17}}),label:n("col.goal"),onClick:w=>Ne(w),sx:lo?pt(1):void 0,children:ae>0?Ce.find(w=>w.seq===ae)?.name??n("create.deletedGoal"):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("board.unassigned")})}),pe(he,{icon:pe(fE,{sx:{fontSize:17}}),label:"\uD3EC\uC778\uD2B8",sx:lo?pt(1):void 0,children:pe(xr,{value:me>0?String(me):"",placeholder:n("create.notEstimated"),onCommit:w=>e.setFormValue("story_points",Number(w.replace(/[^0-9.]/g,""))||0)})})]}):null,te?pe(lc,{values:{repro:U,device:ee,where:re,version:le},onChangeRepro:w=>e.setFormValue("bug_repro",w),onChangeDevice:w=>e.setFormValue("bug_device",w),onChangeWhere:w=>e.setFormValue("bug_where",w),onChangeVersion:w=>e.setFormValue("bug_version",w)}):null,!g&&!x&&!i?(m??[]).filter(w=>!(Mt&&!w.filled)).map(w=>pe(he,{icon:w.icon,label:w.label,onClick:w.onClick,sx:H||!lo?void 0:pt(Me),children:w.value},w.key)):null]}),leading:H||d?null:pe(hr,{sx:{gridColumn:"1 / -1"},children:pe(he,{icon:pe(mE,{sx:{fontSize:17}}),label:n("dialog.label"),onClick:w=>Ve(w),children:(Re??[]).length>0?pe(Nr,{labelKeys:Re??[],labelOptions:t}):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("menu.empty")})})})}),fn?vn(Hx,{onClick:Oo,"aria-expanded":lt,sx:{alignSelf:"flex-start",display:"flex",alignItems:"center",gap:.5,minHeight:32,mx:2,pr:1,borderRadius:1,fontSize:14,color:"#2563eb","&:hover":{bgcolor:"#f2f2f0"}},children:[lt?pe(aE,{sx:{fontSize:17}}):pe(iE,{sx:{fontSize:17}}),lt?n("create.collapseFields"):n("create.expandFields")]}):null,pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),pe(zo,{icon:pe(sE,{sx:{fontSize:18,display:"block"}}),title:n("common.content"),titleExtra:k||P?vn(Ia,{children:[k,P?pe(dc,{content:nt,templates:P,onApply:w=>e.setFormValue("content",w),onSave:T,onRemove:I}):null]}):void 0,children:pe(cc,{syncKey:K,value:nt,onChange:w=>e.setFormValue("content",w)})}),te||x||Mt&&!se?null:vn(Ia,{children:[pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),pe(zo,{icon:pe(cE,{sx:{fontSize:18,display:"block"}}),title:n("col.note"),children:pe(gE,{form:e,name:"note",placeholder:n("create.notePlaceholder"),fullWidth:!0,size:"medium",sx:{mt:1}})})]}),H||x||Mt&&N.length===0?null:pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),H||x||Mt&&N.length===0?null:pe(gc,{taskSeq:0,checklist:N,onAdd:(w,Y)=>zm(e,Y),onToggle:(w,Y,ue)=>Nm(e,Y,ue),onRemove:(w,Y)=>Fm(e,Y),onUpdate:(w,Y,ue)=>Hm(e,Y,ue)}),g?null:vn(Ia,{children:[pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),pe(hc,{taskSeq:0,attachments:En.map(w=>({name:w.name,size:w.size})),onAdd:(w,Y)=>Wm(E,Y,L),onRemove:(w,Y)=>$m(E,Y)})]})]}),pe(hd,{transitionDuration:0,anchorEl:Ct,open:!!Ct,onClose:()=>Ne(null),children:[{seq:0,label:n("board.unassigned")},...Ce.map(w=>({seq:w.seq,label:nn(w)}))].map(w=>pe(kd,{onClick:()=>{e.setFormValue("sprint_seq",w.seq),Ne(null)},sx:{fontSize:14,minWidth:170},children:w.label},w.seq))}),pe(hd,{transitionDuration:0,anchorEl:Jn,open:!!Jn,onClose:()=>Zn(null),children:[{value:"",label:n("common.none")},...Wi].map(w=>pe(kd,{selected:qe===w.value,onClick:()=>{Zn(null),Am(e,w.value)},sx:{fontSize:14,minWidth:140},children:w.label},w.value||"none"))}),pe(xE,{anchorEl:Co,open:!!Co,onClose:()=>Dn(null),selectedDate:Ye?new Date(`${Ye}T00:00:00`):new Date,onDateChange:w=>{qm(e,w),Dn(null)}}),pe(hd,{transitionDuration:0,anchorEl:J,open:!!J,onClose:()=>Be(null),children:[{key:"involved",label:n("create.visibilityPrivate"),tip:n("create.privateTip"),icon:pe(Wx,{sx:{fontSize:17,color:"#57564f"}}),selected:gt==="involved",onPick:()=>$i(e,"involved")},{key:"all",label:n("create.visibilityPublic"),tip:n("create.publicTip"),icon:pe($x,{sx:{fontSize:17,color:"#2f80ed"}}),selected:gt==="all",onPick:()=>$i(e,"all")},...[...C].sort((w,Y)=>w.seq===z?-1:Y.seq===z?1:0).map(w=>({key:`group-${w.seq}`,label:n("create.visibilityDeptName",{name:w.name}),tip:n("create.deptTip",{name:w.name}),icon:pe(Vx,{sx:{fontSize:17,color:"#d9730d"}}),selected:gt==="group"&&io===w.seq,onPick:()=>$i(e,"group",w.seq)}))].map(w=>pe(lE,{title:w.tip,arrow:!0,disableInteractive:!0,placement:"right",children:vn(kd,{selected:w.selected,onClick:()=>{w.onPick(),Be(null)},sx:{fontSize:14,minWidth:170,gap:1},children:[w.icon,w.label]})},w.key))}),pe(Tc,{anchorEl:Pt,selectedKeys:Re??[],labelOptions:t,onToggle:w=>e.setFormValue("label_keys",bs(Re??[],w)),onAddLabel:(w,Y)=>D?.(w,Y),onClose:()=>Ve(null)})]})}import{Fragment as jx,jsx as kt,jsxs as gl}from"react/jsx-runtime";var IE={gap:"0.75rem !important","& .left-actions, & .right-actions":{display:"contents"},"& .left-actions > span:empty":{display:"none"},"& .left-actions:not(:has(*:not(:empty)))":{display:"none"},"& .left-actions .MuiButton-root, & .right-actions .MuiButton-root":{flex:"1 1 0",minWidth:0,margin:"0 !important",paddingLeft:"8px !important",paddingRight:"8px !important",whiteSpace:"nowrap"},"& .right-actions .MuiButton-text":{border:"1px solid rgba(0, 0, 0, 0.23)"},"& .right-actions .MuiButton-contained":{border:"1px solid transparent"}};function Yx({open:e,onClose:t,desktopPresentation:o="drawer",submitLabel:a,...r}){M();let{form:i,presetTitle:l="",presetContent:s="",presetVisibility:c,presetVisibilityGroupSeq:u=0,presetDueDate:m="",presetTabKey:d="",presetManager:f=null,isNotice:p=!1,defaultBug:g=!1}=r,x=xn(),b=kE(!1),[_,h]=Kx(0),B=i.useFormValue("title"),C=i.useFormValue("icon"),z=i.useFormValue("icon_color"),y=!!i.useFormValue("is_event"),S=!!i.useFormValue("is_bug"),D=$e(),P=x.useValue("createSubmitting")??!1,k=p||y?Oe(C||(p?vt:zt)):null,T=p?n("create.titleNotice"):y?n("create.titleEvent"):S?n("task.createBug"):n("task.createTask"),I=p?n("create.noticeTitlePlaceholder"):y?n("create.eventTitlePlaceholder"):S?n("create.bugTitlePlaceholder"):n("create.taskTitlePlaceholder");hE(()=>{let v=b.current;b.current=e,!(!e||v)&&(Om(i,x,{presetTitle:l,presetContent:s,presetVisibility:c,presetVisibilityGroupSeq:u,presetDueDate:m,presetTabKey:d,presetManager:f,isNotice:p,defaultBug:g}),h(H=>H+1))},[e]);let[E,L]=Kx(null),R=v=>k?y?kt(SE,{title:n("col.changeIcon"),arrow:!0,enterDelay:400,disableInteractive:!0,children:kt(TE,{onClick:H=>L(H.currentTarget),sx:{display:"flex",p:.5,borderRadius:1,color:z||"#1e3a8a","&:hover":{bgcolor:"#f2f2f0"}},children:kt(k,{sx:{fontSize:20}})})}):kt(kr,{sx:[{display:"flex",color:z||"#1e3a8a"},v],children:kt(k,{sx:{fontSize:20}})}):null,A=gl(kr,{sx:{display:"flex",alignItems:"center",gap:1,px:2,pt:2,pb:1},children:[R({p:0}),kt(kr,{component:"input",autoFocus:!0,spellCheck:!1,value:B,placeholder:I,onChange:v=>i.setFormValue("title",v.target.value),sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:19,fontWeight:600,color:"#37352f",p:0,m:0,"&::placeholder":{color:"#c9c8c5",fontWeight:400}}})]});return D||o==="dialog"?kt(jx,{children:kt(_E,{open:e,onClose:t,backdropClick:!1,locale:ye(),fontScale:D?{enabled:!0,default:1.1,min:.6}:{enabled:!0},title:T,titleIcons:{delete:{visible:!1},print:{visible:!1},share:{visible:!1}},fullScreen:D,mobilePresentation:D?"slide":"dialog",maxWidth:"md",actions:{showCancelButton:!0,right:kt(yd,{variant:"contained",disableElevation:!0,disabled:P,onClick:P?void 0:i.submit,children:P?n("create.saving"):a??n("create.saveButton")})},dialogActionSx:D?IE:void 0,tabs:{visible:!1},contentTopPadding:0,contentPaddingX:0,sectionsPaddingTop:0,sectionContentPaddingTop:0,contentBottomPadding:0,scrollPastLastSection:!1,overlayScrollbar:{enabled:!0,contentStyle:{minWidth:0}},sections:[{id:"task-create",title:"",showTitle:!1,children:kt(kr,{sx:{width:"100%",minWidth:0,display:"flex",flexDirection:"column",gap:0},children:kt(Td,{...r,contentSyncKey:`create-${_}`,leadingRow:A})})}]})}):gl(jx,{children:[kt(yE,{anchor:"right",open:e,onClose:(v,H)=>{H!=="backdropClick"&&t()},"aria-label":n("create.newTaskAria"),sx:{zIndex:v=>v.zIndex.modal},slotProps:{paper:{sx:{width:720,maxWidth:"100vw"}}},children:gl(kr,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[gl(kr,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1.5,flexShrink:0},children:[R({px:.5}),kt(kr,{component:"input",autoFocus:!0,spellCheck:!1,value:B,placeholder:I,onChange:v=>i.setFormValue("title",v.target.value),sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:18,fontWeight:500,color:"#37352f",p:0,m:0,"&::placeholder":{color:"#c9c8c5",fontWeight:400}}}),kt(CE,{"aria-label":n("common.close"),onClick:t,sx:{color:"#6b7280"},children:kt(vE,{})})]}),kt(Gx,{sx:{borderColor:"#e6e6e3"}}),kt(kr,{sx:{flex:1,minHeight:0},children:kt(BE,{style:{height:"100%"},contentStyle:{minWidth:0},thumb:{width:6},children:kt(Td,{...r,contentSyncKey:`create-${_}`})})}),kt(Gx,{sx:{borderColor:"#e6e6e3"}}),gl(kr,{sx:{display:"flex",justifyContent:"flex-end",gap:.5,px:2,py:1.5,flexShrink:0},children:[kt(yd,{onClick:t,color:"inherit",disabled:P,children:n("common.cancel")}),kt(yd,{onClick:i.submit,variant:"contained",disabled:P,children:P?n("create.creating"):a??n("common.register")})]})]})}),kt(Hr,{anchorEl:E,value:C,color:z,onSelect:v=>{i.setFormValue("icon",v),L(null)},onSelectColor:v=>i.setFormValue("icon_color",v),onClose:()=>L(null)})]})}import{useEffect as Kb,useRef as Gb,useState as jb}from"react";import{Box as Ac,Button as JP,Divider as Yb,Drawer as ZP,IconButton as eM,ListItemIcon as Qd,ListItemText as Jd,Menu as tM,MenuItem as Zd}from"@mui/material";import oM from"@mui/icons-material/MoreVert";import nM from"@mui/icons-material/DeleteOutline";import rM from"@mui/icons-material/ShareOutlined";import aM from"@mui/icons-material/HistoryOutlined";import iM from"@ehfuse/overlay-scrollbar";import{FormDialog as lM}from"@ehfuse/mui-form-dialog";import{useRef as Ic,useState as Tr}from"react";import{Box as be,Button as fb,Chip as wc,IconButton as Yo,Popover as oR,Tooltip as hb}from"@mui/material";import nR from"@mui/icons-material/ArrowUpwardRounded";import{TextField as rR}from"@ehfuse/mui-form-controls";import Dc from"@mui/icons-material/Close";import aR from"@mui/icons-material/EditOutlined";import gb from"@mui/icons-material/ContentCopyOutlined";import xb from"@mui/icons-material/Check";import iR from"@mui/icons-material/Favorite";import lR from"@mui/icons-material/FavoriteBorderOutlined";import sR from"@mui/icons-material/CheckCircle";import cR from"@mui/icons-material/CheckCircleOutlineOutlined";import ui from"@mui/icons-material/AttachFileOutlined";import mR from"@mui/icons-material/AddCircleOutline";import uR from"@mui/icons-material/ImageOutlined";var Cd=e=>{if(e===0)return"0 Bytes";let t=1024,o=["Bytes","KB","MB","GB","TB"],a=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,a)).toFixed(2))+" "+o[a]};import{useCallback as Cc,useEffect as wE,useMemo as DE,useRef as Xx,useState as Sd}from"react";import{Box as Sc,Paper as EE,Popper as RE}from"@mui/material";import{jsx as wa,jsxs as ME}from"react/jsx-runtime";var Qx=8,PE=[{key:"\uC88B\uC544\uC694",get label(){return n("emoji.like")},insert:"\u{1F44D}",keywords:["like","\uC5C4\uC9C0","\uAD7F"]},{key:"\uD655\uC778",get label(){return n("emoji.check")},insert:"\u2705",keywords:["check","\uC644\uB8CC","\uCCB4\uD06C"]},{key:"\uAC10\uC0AC",get label(){return n("emoji.thanks")},insert:"\u{1F64F}",keywords:["thanks","\uACE0\uB9C8\uC6CC","\uBD80\uD0C1"]},{key:"\uCD95\uD558",get label(){return n("emoji.party")},insert:"\u{1F389}",keywords:["party","\uD30C\uD2F0","\uC9DD\uC9DD"]},{key:"\uBC15\uC218",get label(){return n("emoji.clap")},insert:"\u{1F44F}",keywords:["clap","\uC798\uD588\uC5B4"]},{key:"\uD558\uD2B8",get label(){return n("emoji.heart")},insert:"\u2764\uFE0F",keywords:["heart","\uC0AC\uB791"]},{key:"\uC6C3\uC74C",get label(){return n("emoji.laugh")},insert:"\u{1F604}",keywords:["smile","\uC6C3\uAE40","\u314B\u314B"]},{key:"\uBBF8\uC18C",get label(){return n("emoji.smile")},insert:"\u{1F642}",keywords:["smile","\uC88B\uC74C"]},{key:"\uB208\uBB3C",get label(){return n("emoji.tears")},insert:"\u{1F622}",keywords:["sad","\uC2AC\uD514","\u3160\u3160"]},{key:"\uB180\uB78C",get label(){return n("emoji.wow")},insert:"\u{1F62E}",keywords:["wow","\uD5C9"]},{key:"\uACE0\uBBFC",get label(){return n("emoji.think")},insert:"\u{1F914}",keywords:["think","\uC0DD\uAC01","\uC74C"]},{key:"\uC624\uCF00\uC774",get label(){return n("emoji.ok")},insert:"\u{1F44C}",keywords:["ok","\uC54C\uACA0\uC5B4"]},{key:"\uBD88",get label(){return n("emoji.fire")},insert:"\u{1F525}",keywords:["fire","\uAE09\uD568","\uB300\uBC15"]},{key:"\uC544\uC774\uB514\uC5B4",get label(){return n("emoji.idea")},insert:"\u{1F4A1}",keywords:["idea","\uC804\uAD6C"]},{key:"\uACBD\uACE0",get label(){return n("emoji.warning")},insert:"\u26A0\uFE0F",keywords:["warning","\uC8FC\uC758"]},{key:"\uC9C8\uBB38",get label(){return n("emoji.question")},insert:"\u2753",keywords:["question","\uBB3C\uC74C"]},{key:"\uC2DC\uACC4",get label(){return n("emoji.clock")},insert:"\u23F0",keywords:["time","\uC2DC\uAC04","\uC54C\uB78C"]},{key:"\uB2EC\uB825",get label(){return n("emoji.calendar")},insert:"\u{1F4C5}",keywords:["calendar","\uC77C\uC815","\uB0A0\uC9DC"]},{key:"\uBA54\uBAA8",get label(){return n("emoji.note")},insert:"\u{1F4DD}",keywords:["note","\uAE30\uB85D"]},{key:"\uCCA8\uBD80",get label(){return n("emoji.attach")},insert:"\u{1F4CE}",keywords:["attach","\uD074\uB9BD","\uD30C\uC77C"]},{key:"\uB9C1\uD06C",get label(){return n("emoji.link")},insert:"\u{1F517}",keywords:["link","\uC8FC\uC18C"]},{key:"\uB85C\uCF13",get label(){return n("emoji.rocket")},insert:"\u{1F680}",keywords:["rocket","\uCD9C\uBC1C","\uBC30\uD3EC"]},{key:"\uBCC4",get label(){return n("emoji.star")},insert:"\u2B50",keywords:["star","\uC911\uC694"]},{key:"\uC5D1\uC2A4",get label(){return n("emoji.x")},insert:"\u274C",keywords:["x","\uC548\uB428","\uCDE8\uC18C"]}];function xl(e,t,o){let a=e.slice(0,t),i=(o==="@"?/(^|[\s(])@([^\s@]{0,20})$/:/(^|[\s(])\/([^\s/]{0,20})$/).exec(a);return i?{start:t-i[2].length-1,query:i[2]}:null}function vd(e,t){let o=ie(),a=e??o.mentionCandidates??[],r=t??o.slashCommands,i=r===!0?PE:Array.isArray(r)?r:[];return{people:a,commands:i,enabled:a.length>0||i.length>0}}function Bd(e,t,o){if(!o)return[];let a=o.query.toLowerCase();return o.trigger==="@"?e.filter(r=>r.name.toLowerCase().includes(a)).slice(0,Qx).map((r,i)=>({id:`p${i}-${r.name}`,text:`@${r.name} `,label:r.name,subtitle:r.subtitle,icon:wa(fo,{src:r.avatar??"",name:r.name,avatarSx:{width:24,height:24,fontSize:14},iconFontSize:16})})):t.filter(r=>[r.key,r.label,...r.keywords??[]].some(i=>i.toLowerCase().includes(a))).slice(0,Qx).map(r=>({id:`c-${r.key}`,text:r.insert,label:`/${r.label}`,icon:wa(Sc,{component:"span",sx:{width:24,textAlign:"center",fontSize:18,lineHeight:1},children:r.insert})}))}function _d({open:e,anchor:t,items:o,active:a,onPick:r,onHover:i}){return wa(RE,{open:e,anchorEl:t,placement:"top-start",sx:{zIndex:1500},children:wa(EE,{elevation:4,sx:{minWidth:220,maxWidth:320,py:.5,borderRadius:1.5},children:o.map((l,s)=>ME(Sc,{role:"option","aria-selected":s===a,onMouseDown:c=>c.preventDefault(),onClick:()=>r(l),onMouseEnter:()=>i(s),sx:{display:"flex",alignItems:"center",gap:1,px:1.5,py:.75,cursor:"pointer",fontSize:14,bgcolor:s===a?"action.selected":"transparent"},children:[l.icon,wa(Sc,{component:"span",sx:{fontWeight:500,whiteSpace:"nowrap"},children:l.label}),l.subtitle?wa(Sc,{component:"span",sx:{color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l.subtitle}):null]},l.id))})})}function Jx({value:e,setValue:t,candidates:o,slashCommands:a}){let{people:r,commands:i,enabled:l}=vd(o,a),s=Xx(null),[c,u]=Sd(null),[m,d]=Sd(null),[f,p]=Sd(0),g=DE(()=>Bd(r,i,m),[i,r,m]),x=!!(c&&m&&g.length>0),b=Cc(()=>{let y=s.current;if(!l||!y)return;let S=y.selectionStart??y.value.length,D=r.length>0?xl(y.value,S,"@"):null,K=!D&&i.length>0?xl(y.value,S,"/"):null,P=D?{...D,trigger:"@"}:K?{...K,trigger:"/"}:null;d(P),p(0),u(P?y.closest(".MuiInputBase-root")??y:null)},[i.length,l,r.length]),_=Xx(null);wE(()=>{let y=s.current,S=_.current;if(S!==null&&y){_.current=null,y.setSelectionRange(S,S);return}document.activeElement===y&&b()},[e,b]);let h=Cc(y=>{let S=s.current;if(!m||!S)return;let D=S.selectionStart??e.length,K=e.slice(0,m.start)+y.text+e.slice(D),P=m.start+y.text.length;_.current=K===e?null:P,t(K),d(null),u(null),requestAnimationFrame(()=>{_.current=null,S.focus(),S.setSelectionRange(P,P)})},[m,t,e]),B=Cc(y=>!x||y.nativeEvent.isComposing?!1:y.key==="ArrowDown"||y.key==="ArrowUp"?(y.preventDefault(),p(S=>(S+(y.key==="ArrowDown"?1:g.length-1))%g.length),!0):y.key==="Enter"||y.key==="Tab"?(y.preventDefault(),h(g[Math.min(f,g.length-1)]),!0):y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),d(null),u(null),!0):!1,[f,g,x,h]);return{inputRef:Cc(y=>{s.current=y},[]),onKeyDown:B,onSelectionChange:b,popper:l?wa(_d,{open:x,anchor:c,items:g,active:f,onPick:h,onHover:p}):null}}import{useCallback as Id,useEffect as OE,useRef as Zx,useState as eb}from"react";import{Box as bl,Tab as LE,Tabs as AE}from"@mui/material";import{jsx as mi,jsxs as NE}from"react/jsx-runtime";var tb=[{key:"smile",labelKey:"section.emojiSmileys",items:["\u{1F600}","\u{1F603}","\u{1F604}","\u{1F601}","\u{1F606}","\u{1F605}","\u{1F923}","\u{1F602}","\u{1F642}","\u{1F643}","\u{1F609}","\u{1F60A}","\u{1F607}","\u{1F970}","\u{1F60D}","\u{1F929}","\u{1F618}","\u{1F617}","\u{1F61A}","\u{1F619}","\u{1F60B}","\u{1F61B}","\u{1F61C}","\u{1F92A}","\u{1F61D}","\u{1F917}","\u{1F92D}","\u{1F92B}","\u{1F914}","\u{1F928}","\u{1F610}","\u{1F611}","\u{1F636}","\u{1F60F}","\u{1F612}","\u{1F644}","\u{1F62C}","\u{1F60C}","\u{1F614}","\u{1F62A}","\u{1F634}","\u{1F637}","\u{1F912}","\u{1F915}","\u{1F975}","\u{1F976}","\u{1F635}","\u{1F92F}","\u{1F60E}","\u{1F973}","\u{1F622}","\u{1F62D}","\u{1F624}","\u{1F620}","\u{1F621}","\u{1F97A}","\u{1F633}","\u{1F631}","\u{1F628}","\u{1F630}","\u{1F625}","\u{1F910}","\u{1F62F}","\u{1F62E}"]},{key:"gesture",labelKey:"section.emojiPeople",items:["\u{1F44D}","\u{1F44E}","\u{1F44C}","\u270C\uFE0F","\u{1F91E}","\u{1F91F}","\u{1F918}","\u{1F919}","\u{1F448}","\u{1F449}","\u{1F446}","\u{1F447}","\u261D\uFE0F","\u270B","\u{1F91A}","\u{1F590}\uFE0F","\u{1F596}","\u{1F44B}","\u{1F91D}","\u{1F64F}","\u{1F4AA}","\u{1F9BE}","\u{1F44F}","\u{1F64C}","\u{1F450}","\u{1F932}","\u{1FAF6}","\u270D\uFE0F","\u{1F485}","\u{1F933}","\u{1F9E0}","\u{1F440}","\u{1F647}","\u{1F64B}","\u{1F646}","\u{1F645}","\u{1F481}","\u{1F937}","\u{1F926}","\u{1F9D1}\u200D\u{1F4BB}","\u{1F468}\u200D\u{1F4BC}","\u{1F469}\u200D\u{1F4BC}","\u{1F6B6}","\u{1F3C3}","\u{1F483}","\u{1F57A}","\u{1F476}","\u{1F9D3}"]},{key:"heart",labelKey:"section.emojiHearts",items:["\u2764\uFE0F","\u{1F9E1}","\u{1F49B}","\u{1F49A}","\u{1F499}","\u{1F49C}","\u{1F5A4}","\u{1F90D}","\u{1F90E}","\u{1F494}","\u2763\uFE0F","\u{1F495}","\u{1F49E}","\u{1F493}","\u{1F497}","\u{1F496}","\u{1F498}","\u{1F49D}","\u{1F49F}","\u2728","\u{1F4AB}","\u{1F4A5}","\u{1F389}","\u{1F38A}","\u{1F388}","\u{1F381}","\u{1F451}","\u{1FAC2}","\u{1F63B}","\u{1F490}","\u{1F380}","\u{1F48C}"]},{key:"work",labelKey:"section.emojiWork",items:["\u{1F4CC}","\u{1F4CE}","\u{1F4DD}","\u{1F4C4}","\u{1F4D1}","\u{1F4CA}","\u{1F4C8}","\u{1F4C9}","\u{1F5C2}\uFE0F","\u{1F4C5}","\u{1F4C6}","\u23F0","\u231B","\u2705","\u2611\uFE0F","\u274C","\u2B55","\u2757","\u2753","\u{1F4A1}","\u{1F514}","\u{1F515}","\u{1F4E2}","\u{1F4E3}","\u{1F4AC}","\u{1F4AD}","\u{1F517}","\u{1F512}","\u{1F511}","\u2699\uFE0F","\u{1F6E0}\uFE0F","\u{1F4EC}","\u{1F4BB}","\u{1F5A5}\uFE0F","\u{1F5A8}\uFE0F","\u{1F4DE}","\u{1F4F1}","\u{1F4B0}","\u{1F4B3}","\u{1F9FE}","\u{1F4E6}","\u{1F550}","\u{1F4CB}","\u{1F587}\uFE0F","\u270F\uFE0F","\u{1F5D1}\uFE0F","\u267B\uFE0F","\u{1F50D}"]},{key:"food",labelKey:"section.emojiFood",items:["\u2615","\u{1F375}","\u{1F964}","\u{1F9C3}","\u{1F37A}","\u{1F37B}","\u{1F942}","\u{1F377}","\u{1F378}","\u{1F943}","\u{1F35A}","\u{1F35C}","\u{1F372}","\u{1F35B}","\u{1F371}","\u{1F359}","\u{1F354}","\u{1F35F}","\u{1F355}","\u{1F32D}","\u{1F96A}","\u{1F32E}","\u{1F35D}","\u{1F957}","\u{1F356}","\u{1F357}","\u{1F969}","\u{1F373}","\u{1F95E}","\u{1F9C7}","\u{1F35E}","\u{1F950}","\u{1F370}","\u{1F382}","\u{1F9C1}","\u{1F36A}","\u{1F369}","\u{1F36B}","\u{1F36C}","\u{1F36D}","\u{1F366}","\u{1F34E}","\u{1F34A}","\u{1F34B}","\u{1F34C}","\u{1F349}","\u{1F347}","\u{1F353}"]},{key:"etc",labelKey:"section.emojiOther",items:["\u{1F525}","\u2B50","\u{1F31F}","\u{1F4AF}","\u{1F3AF}","\u{1F3C6}","\u{1F947}","\u{1F680}","\u{1F308}","\u2600\uFE0F","\u{1F319}","\u26C5","\u2601\uFE0F","\u{1F327}\uFE0F","\u2744\uFE0F","\u26A1","\u{1F338}","\u{1F33A}","\u{1F337}","\u{1F339}","\u{1F33B}","\u{1F340}","\u{1F33F}","\u{1F331}","\u{1F436}","\u{1F431}","\u{1F430}","\u{1F43C}","\u{1F98A}","\u{1F43B}","\u{1F425}","\u{1F98B}","\u{1F697}","\u2708\uFE0F","\u{1F3E0}","\u{1F3E2}","\u{1F3B5}","\u{1F3B6}","\u{1F4DA}","\u{1F3AE}","\u26BD","\u{1F3C0}","\u{1F48A}","\u{1FA7A}","\u{1F9F3}","\u{1F382}","\u{1F6D2}","\u{1F9F9}"]}],qE="'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif",ob="taskbox.recentEmojis",nb=24;function rb(){try{let e=JSON.parse(window.localStorage.getItem(ob)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string").slice(0,nb):[]}catch{return[]}}function zE(e){let t=[e,...rb().filter(o=>o!==e)].slice(0,nb);try{window.localStorage.setItem(ob,JSON.stringify(t))}catch{}return t}function ab({onPick:e}){let[t,o]=eb(()=>rb()),[a,r]=eb(0),i=Zx(null),l=Zx(!1),s=t.length>0?[{key:"recent",labelKey:"section.emojiFrequent",items:t},...tb]:tb,c=Math.min(a,s.length-1),u=Id(f=>{o(zE(f)),e(f)},[e]),m=Id(f=>{r(f);let p=i.current;p&&(l.current=!0,p.scrollTo({left:p.clientWidth*f,behavior:"smooth"}),window.setTimeout(()=>{l.current=!1},350))},[]),d=Id(()=>{let f=i.current;if(!f||l.current||f.clientWidth===0)return;let p=Math.round(f.scrollLeft/f.clientWidth);r(g=>p!==g&&p>=0?p:g)},[]);return OE(()=>{let f=i.current;f&&(f.scrollLeft=f.clientWidth*c)},[]),NE(bl,{children:[mi(AE,{value:c,onChange:(f,p)=>m(p),variant:"scrollable",scrollButtons:!1,sx:{minHeight:36,borderBottom:"1px solid #ececea","& .MuiTab-root":{minHeight:36,minWidth:0,px:1.5,fontSize:13}},children:s.map(f=>mi(LE,{label:n(f.labelKey)},f.key))}),mi(bl,{ref:i,onScroll:d,sx:{display:"flex",height:268,overflowX:"auto",overflowY:"hidden",scrollSnapType:"x mandatory",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:s.map(f=>mi(bl,{sx:{flex:"0 0 100%",width:"100%",height:"100%",overflowY:"auto",scrollSnapAlign:"start",scrollSnapStop:"always",p:1},children:mi(bl,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(40px, 1fr))"},children:f.items.map((p,g)=>mi(bl,{component:"button",type:"button",onClick:()=>u(p),"aria-label":p,sx:{border:0,bgcolor:"transparent",color:"#000",cursor:"pointer",fontFamily:qE,fontSize:24,lineHeight:1,py:.75,borderRadius:"8px","&:hover":{bgcolor:"rgba(15, 23, 42, 0.06)"},"&:active":{bgcolor:"rgba(15, 23, 42, 0.1)"}},children:p},`${p}-${g}`))})},f.key))})]})}import{forwardRef as GE,useImperativeHandle as jE,useLayoutEffect as cb,useRef as _c,useState as sb}from"react";import{Box as Pd}from"@mui/material";import{EhfuseEditor as YE}from"@ehfuse/editor";import{useCallback as wd,useMemo as FE,useRef as HE,useState as Dd}from"react";import{jsx as WE}from"react/jsx-runtime";function ib(){let{people:e,commands:t,enabled:o}=vd(),[a,r]=Dd(null),[i,l]=Dd(null),s=HE(""),[c,u]=Dd(0),m=FE(()=>Bd(e,t,a),[t,e,a]),d=!!(o&&i&&a&&m.length>0),f=wd(()=>{if(!o)return;let b=window.getSelection();if(!b||b.rangeCount===0||!b.isCollapsed)return void r(null);let _=b.anchorNode;if(!_||_.nodeType!==Node.TEXT_NODE||!_.parentElement?.closest(".ehfuse-editor-content"))return void r(null);let h=_.data,B=b.anchorOffset,C=e.length>0?xl(h,B,"@"):null,z=!C&&t.length>0?xl(h,B,"/"):null,y=C?{...C,trigger:"@"}:z?{...z,trigger:"/"}:null;if(!y){s.current="",r(null),l(null);return}r({node:_,start:y.start,end:B,query:y.query,trigger:y.trigger});let S=`${y.trigger}${y.query}`;S!==s.current&&u(0),s.current=S;let D=document.createRange();D.setStart(_,y.start),D.setEnd(_,Math.min(y.start+1,h.length));let K=D.getBoundingClientRect();l({getBoundingClientRect:()=>K})},[t.length,o,e.length]),p=wd(b=>{if(!a)return;let{node:_,start:h,end:B}=a;if(!_.isConnected)return void r(null);let C=window.getSelection(),z=document.createRange();z.setStart(_,h),z.setEnd(_,Math.min(B,_.data.length)),C?.removeAllRanges(),C?.addRange(z),document.execCommand("insertText",!1,b.text),r(null),l(null)},[a]);return{handlers:{onKeyDownCapture:wd(b=>{!d||b.nativeEvent.isComposing||(b.key==="ArrowDown"||b.key==="ArrowUp"?(b.preventDefault(),b.stopPropagation(),u(_=>(_+(b.key==="ArrowDown"?1:m.length-1))%m.length)):b.key==="Enter"||b.key==="Tab"?(b.preventDefault(),b.stopPropagation(),p(m[Math.min(c,m.length-1)])):b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),r(null),l(null)))},[c,m,d,p]),onKeyUp:f,onMouseUp:f,onInput:f},popper:o?WE(_d,{open:d,anchor:i,items:m,active:c,onPick:p,onHover:u}):null,isOpen:d}}function hl(e){return/^\s*<(p|div|ul|ol|h[1-6]|blockquote|pre)[\s>]/i.test(e)}var $E=new Set(["P","BR","DIV","SPAN","STRONG","B","EM","I","U","S","STRIKE","DEL","CODE","PRE","UL","OL","LI","H1","H2","H3","H4","BLOCKQUOTE","A","MARK"]),VE=new Set(["background-color","color","text-decoration"]);function Ed(e){if(typeof DOMParser>"u")return"";let o=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html").body.firstElementChild;if(!o)return"";let a=r=>{for(let i of Array.from(r.children)){if(!$E.has(i.tagName)){if(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED","TEMPLATE"].includes(i.tagName)){i.remove();continue}a(i),i.replaceWith(...Array.from(i.childNodes));continue}for(let l of Array.from(i.attributes)){let s=l.name.toLowerCase();if(i.tagName==="A"&&s==="href"){/^(https?:|mailto:|tel:)/i.test(l.value.trim())||i.removeAttribute(l.name);continue}if(s==="style"){let c=l.value.split(";").map(u=>u.trim()).filter(u=>VE.has(u.split(":")[0]?.trim().toLowerCase()??"")&&!/url\(|expression/i.test(u)).join("; ");c?i.setAttribute("style",c):i.removeAttribute("style");continue}i.removeAttribute(l.name)}a(i)}};return a(o),o.innerHTML}function vc(e){if(typeof DOMParser>"u")return e.replace(/<[^>]*>/g,"");let t=e.replace(/<br\s*\/?>/gi,`
5
+ `).trim()}var Iw={...yx,left:(yx.left??[]).map(e=>e.filter(t=>t!=="undo"&&t!=="redo")).filter(e=>e.length>0).flatMap(e=>e.includes("indent")?[["bulletList","numberList"],e]:[e])};function cc({syncKey:e,value:t,onChange:o,readOnly:a=!1,viewFirst:r=!1,onTranslate:i,minHeight:l=180,editing:s,onEditingChange:c}){M();let{uploadContentImage:u,openExternalUrl:m,openContentImage:d}=ie(),f=v=>{m?m(v):window.open(v,"_blank","noopener,noreferrer")},[p,g]=hx(()=>!r||!_a(t).trim()),x=s!==void 0,b=x?s:p,_=Ba(c);_.current=c;let h=v=>{x||g(v),_.current?.(v)};bx(()=>{r&&h(!_a(t).trim())},[e,r]);let B=Ba(null),C=Ba(new _w),z=Ba(null),y=Ba(Date.now()+800),S=$e(),D=Cw(),K=yw(D.breakpoints.down("sm")),[P,k]=hx(!1),T=()=>{let v=_a(t);v&&navigator.clipboard.writeText(v).then(()=>{k(!0),window.setTimeout(()=>k(!1),1500)})},I=(v,H=!1)=>v instanceof Element?v.closest(H?".taskbox-content-readview a[href]":".ehfuse-editor-content a[href]"):null,E=v=>S||v.ctrlKey||v.metaKey;bx(()=>{if(a)return;let v=md(t);z.current===v||z.current===t||(z.current=v,y.current=Date.now()+800,B.current?.setHtml(v))},[e,t,a]);let L=md(t),R=Ba(null),A=Ba({el:null,html:""});return Tw(()=>{let v=R.current;v&&(A.current.el===v&&A.current.html===L||(v.innerHTML=L,A.current={el:v,html:L}))}),a||!b?sc(sl,{sx:{position:"relative",mt:1},children:[ro(sl,{onClickCapture:v=>{let H=v.target;if(H?.tagName==="IMG"&&H.src){v.preventDefault(),v.stopPropagation();let U=Array.from(v.currentTarget.querySelectorAll("img")).filter(le=>le.src),ee=U.map((le,$)=>({src:le.src,name:le.alt||decodeURIComponent(le.src.split("/").pop()||"")||`image-${$+1}`})),re=Math.max(0,U.indexOf(H));d?d(ee,re):f(ee[re].src);return}let te=I(v.target,!0);te&&(v.preventDefault(),v.stopPropagation(),f(te.href))},ref:R,className:"taskbox-content-readview","data-drag-scroll":"off",sx:{border:"1px solid #e0e0e0",borderRadius:1,p:"12px",pr:K?"12px":"52px",pb:"28px",minHeight:l,fontSize:16,lineHeight:1.6,color:"#37352f",wordBreak:"break-word",userSelect:"text","& > p:first-of-type":{mt:0},"& > p:last-of-type":{mb:0},"& a[href]":{color:"#2563eb",textDecoration:"underline",cursor:"pointer"},"& img":{maxWidth:"100%",cursor:"zoom-in"},"& ul, & ol":{pl:"1.5em",my:.5},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li > p":{my:0}}}),K?sc(sl,{sx:{display:"flex",gap:1,mt:1},children:[ro(ld,{variant:"outlined",color:"inherit",startIcon:ro(vw,{sx:{fontSize:18}}),onClick:T,sx:{flex:1,fontSize:15,color:"#37352f",borderColor:"#d9d9d6"},children:P?n("section.copied"):n("common.copy")}),a?null:ro(ld,{variant:"outlined",color:"inherit",startIcon:ro(kx,{sx:{fontSize:18}}),onClick:()=>h(!0),sx:{flex:1,fontSize:15,color:"#37352f",borderColor:"#d9d9d6"},children:n("common.edit")}),i?ro(ld,{variant:"outlined",color:"inherit",startIcon:ro(Tx,{sx:{fontSize:18}}),onClick:i,sx:{flex:1,fontSize:15,color:"#37352f",borderColor:"#d9d9d6"},children:n("section.translate")}):null]}):sc(sl,{sx:{position:"absolute",top:6,right:6,display:"flex",flexDirection:"column",gap:.25},children:[a?null:ro(cd,{title:n("section.editContent"),arrow:!0,placement:"left",children:ro(sd,{size:"small","aria-label":n("section.editContent"),onClick:()=>h(!0),sx:{color:"#9a9a97"},children:ro(kx,{sx:{fontSize:17}})})}),i?ro(cd,{title:n("section.translate"),arrow:!0,placement:"left",children:ro(sd,{size:"small","aria-label":n("section.translate"),onClick:i,sx:{color:"#9a9a97"},children:ro(Tx,{sx:{fontSize:17}})})}):null]})]}):sc(sl,{onDragOver:v=>v.stopPropagation(),onDrop:v=>v.stopPropagation(),onMouseDownCapture:v=>{E(v)&&I(v.target)&&v.preventDefault()},onClickCapture:v=>{let H=E(v)?I(v.target):null;H&&(v.preventDefault(),v.stopPropagation(),f(H.href))},sx:{mt:1,"& .ehfuse-editor-content > p:first-of-type":{mt:0},"& .ehfuse-editor-content > p:last-of-type":{mb:0},"& .ehfuse-editor-content.ehfuse-editor-empty::before":{top:"12px",left:"12px"},...S?{"& .ehfuse-editor-content a[href]":{cursor:"pointer"}}:{},position:"relative"},children:[r&&!x?ro(cd,{title:n("section.finishEditingTooltip"),arrow:!0,children:ro(sd,{size:"small","aria-label":n("section.finishEditing"),onMouseDown:v=>v.preventDefault(),onClick:()=>h(!1),sx:{position:"absolute",top:4,right:6,zIndex:2,color:"#2f9e5b"},children:ro(Sw,{sx:{fontSize:19}})})}):null,ro(Bw,{ref:B,defaultValue:md(t),autoHeight:!0,showToolbar:!S,focusBorder:!0,styles:{focusBorderColor:"var(--primary)"},toolbarOptions:Iw,plugins:[C.current],locale:ua(),minHeight:l,placeholder:n("section.contentPlaceholder"),onImageUpload:u,contentStyle:{padding:"12px"},onChange:v=>{let H=Date.now()<y.current,te=v===z.current;z.current=v,!(H||te)&&o(v)}})]})}import{Fragment as qw,jsx as Do,jsxs as uc}from"react/jsx-runtime";function pd(e){return String(e??"").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").trim().length>0}function dc({content:e,templates:t,onApply:o,onSave:a,onRemove:r,readOnly:i=!1}){M();let[l,s]=ud(null),[c,u]=ud(!1),[m,d]=ud(""),f=async g=>{s(null),!(pd(e)&&!await Pw({title:n("section.loadTemplate"),message:n("section.loadTemplateConfirm",{name:g.name})}))&&o(g.content)},p=()=>{s(null);let g=_a(e);g&&navigator.clipboard.writeText(g).then(()=>Ow(n("section.contentCopied"))).catch(()=>Mw(n("section.contentCopyFailed")))};return uc(qw,{children:[Do(Ew,{title:n("section.contentMenu"),arrow:!0,disableInteractive:!0,children:Do(Sx,{size:"small","aria-label":n("section.contentMenu"),onClick:g=>s(g.currentTarget),sx:{ml:"auto",color:"#9a9a97"},children:Do(Rw,{sx:{fontSize:18}})})}),uc(Dw,{anchorEl:l,open:!!l,onClose:()=>s(null),transitionDuration:0,children:[Do(mc,{disabled:!pd(e),onClick:p,sx:{fontSize:14,minWidth:220},children:n("menu.copyContent")}),i?null:Do(Cx,{sx:{my:.5}}),!i&&a?Do(mc,{disabled:!pd(e),onClick:()=>{s(null),d(""),u(!0)},sx:{fontSize:14,minWidth:220},children:n("section.saveAsTemplate")}):null,!i&&a?Do(Cx,{sx:{my:.5}}):null,i?null:t.length===0?Do(mc,{disabled:!0,sx:{fontSize:14,minWidth:220},children:n("section.noSavedTemplates")}):t.map(g=>uc(mc,{onClick:()=>{f(g)},sx:{fontSize:14,minWidth:220,gap:1},children:[Do(dd,{sx:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.name}),r?Do(Sx,{size:"small","aria-label":n("section.deleteTemplateAria",{name:g.name}),onClick:x=>{x.stopPropagation(),r(g.seq)},sx:{color:"#9a9a97"},children:Do(Xt,{sx:{fontSize:16}})}):null]},g.seq))]}),Do(Lw,{open:c,onClose:()=>u(!1),maxWidth:"xs",title:n("section.saveTemplateTitle"),locale:ye(),backdropClick:!1,titleIcons:{delete:{visible:!1},print:{visible:!1},share:{visible:!1}},tabs:{visible:!1},actions:{showCancelButton:!0,right:Do(ww,{variant:"contained",disabled:!m.trim(),onClick:()=>{a?.(m.trim(),e),u(!1)},children:n("common.save")})},sections:[{id:"template-name",title:"",showTitle:!1,children:uc(dd,{sx:{display:"flex",flexDirection:"column",gap:1},children:[Do(dd,{sx:{fontSize:15,color:"#37352f"},children:n("section.saveTemplateHint")}),Do(Aw,{size:"medium",fullWidth:!0,autoFocus:!0,placeholder:n("section.templateNamePlaceholder"),value:m,onChange:g=>d(g.target.value)})]})}]})]})}import{useState as ml}from"react";import{Box as Ht,Button as _x,Dialog as Qw,IconButton as li,Switch as Jw,TextField as Zw,Tooltip as fd}from"@mui/material";import{DndContext as eD,PointerSensor as tD,closestCenter as oD,useSensor as nD,useSensors as rD}from"@dnd-kit/core";import{restrictToParentElement as aD,restrictToVerticalAxis as iD}from"@dnd-kit/modifiers";import{SortableContext as lD,arrayMove as sD,useSortable as cD,verticalListSortingStrategy as mD}from"@dnd-kit/sortable";import{CSS as uD}from"@dnd-kit/utilities";import Ix from"@mui/icons-material/Close";import dD from"@mui/icons-material/AddCircle";import wx from"@mui/icons-material/AddTask";import pD from"@mui/icons-material/Checklist";import fD from"@mui/icons-material/CheckCircle";import gD from"@mui/icons-material/DragIndicator";import xD from"@mui/icons-material/Launch";import bD from"@mui/icons-material/LinkOutlined";import hD from"@mui/icons-material/RadioButtonUnchecked";import{useMemo as Ww}from"react";import{Box as Kn,Button as $w,Tab as Vw,Tabs as Uw}from"@mui/material";import{FormDialog as Kw}from"@ehfuse/mui-form-dialog";import{ClearTextField as Gw}from"@ehfuse/mui-form-controls";import jw from"@mui/icons-material/CheckCircle";import Yw from"@mui/icons-material/RadioButtonUnchecked";import{OverlayScrollbar as Xw}from"@ehfuse/overlay-scrollbar";import{useRef as zw}from"react";import{useGlobalForm as Nw,useModal as Fw}from"@ehfuse/forma";import{ErrorAlert as Hw}from"@ehfuse/alerts";var vx={type:"related",search:"",selectedSeqs:[]};function cl(e){M();let t=zw(e);t.current=e;let o={link:Fw({modalId:ve("taskbox-task-link")})},a=Nw({formId:ve("taskbox-task-link-form"),initialValues:vx,onValidate:l=>l.selectedSeqs.length===0?(Hw(n("link.selectTask")),!1):!0,onSubmit:l=>{for(let s of l.selectedSeqs)t.current.onSubmit(s,l.type);return o.link.close(),!0}});return{form:a,modals:o,openDialog:()=>{a.setFormValues({...vx,selectedSeqs:[]}),o.link.open()},toggleSelected:l=>{let s=a.getFormValue("selectedSeqs")??[];if(s.includes(l)){a.setFormValue("selectedSeqs",s.filter(c=>c!==l));return}a.setFormValue("selectedSeqs",t.current.multiSelect?[...s,l]:[l])}}}import{jsx as xo,jsxs as pc}from"react/jsx-runtime";var Bx=[{type:"related",get label(){return n("link.related")},get hint(){return n("link.relatedHint")}},{type:"follow_up",get label(){return n("link.previous")},get hint(){return n("link.previousHint")}},{type:"duplicate_of",get label(){return n("link.duplicate")},get hint(){return n("link.duplicateHint")}}];function fc({controller:e,task:t,tasks:o,excludeSeqs:a=[],hideRelationType:r=!1,title:i=n("link.title"),confirmLabel:l=n("link.confirm")}){M();let s=$e(),{form:c}=e,u=e.modals.link,m=c.useValue("type")??"related",d=String(c.useValue("search")??""),f=c.useValue("selectedSeqs")??[],p=Ww(()=>{let b=new Set([t.seq,...a]),_=d.trim().toLowerCase();return o.filter(h=>b.has(h.seq)||h.is_event||h.is_notice||h.linked_only?!1:_?h.title.toLowerCase().includes(_)||(h.ticket_no??"").toLowerCase().includes(_):!0).sort((h,B)=>!!h.completed!=!!B.completed?h.completed?1:-1:B.seq-h.seq)},[o,t.seq,a,d]),g=Bx.find(b=>b.type===m)?.hint??"",x=pc(Kn,{sx:{display:"flex",flexDirection:"column",minHeight:0,height:s?"100%":"auto"},children:[r?null:xo(Uw,{value:m,onChange:(b,_)=>c.setFormValue("type",_),sx:{minHeight:38,flexShrink:0,borderBottom:"1px solid #ededeb","& .MuiTab-root":{minHeight:38,py:.5,fontSize:16,color:"#333333"}},children:Bx.map(b=>xo(Vw,{value:b.type,label:b.label},b.type))}),r?null:xo(Kn,{sx:{mt:1,mb:1.5,fontSize:14,flexShrink:0},children:g}),pc(Kn,{sx:{...s?{height:"100%",minHeight:0}:{height:560},display:"flex",flexDirection:"column",...s?{}:{border:"1px solid #cccccc",borderRadius:1},overflow:"hidden",userSelect:"none"},children:[xo(Kn,{sx:{px:1.5,py:1,borderBottom:"1px solid #cccccc",flexShrink:0},children:xo(Gw,{placeholder:n("link.searchPlaceholder"),name:"search",form:c,fullWidth:!0,autoFocus:!0,size:"small",sx:{"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiInputBase-root":{px:0}}})}),xo(Kn,{sx:{flex:1,minHeight:0},children:xo(Xw,{style:{height:"100%"},contentStyle:{paddingTop:0},children:xo(Kn,{sx:{display:"flex",flexDirection:"column"},children:p.length===0?xo(Kn,{sx:{py:4,textAlign:"center",fontSize:13.5,color:"#9a9a97"},children:n("link.empty")}):p.map(b=>{let _=b.is_notice||b.is_event?Oe(b.icon||(b.is_notice?vt:zt)):null,h=f.includes(b.seq);return pc(Kn,{onClick:()=>e.toggleSelected(b.seq),sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:1.25,flexShrink:0,cursor:"pointer",borderBottom:"1px solid #ededeb","&:last-of-type":{borderBottom:"none"},bgcolor:h?"#e3eefb":"transparent","&:hover":{bgcolor:h?"#e3eefb":"#f7f7f5"}},children:[h?xo(jw,{sx:{fontSize:20,flexShrink:0,color:"#2f6fd0"}}):xo(Yw,{sx:{fontSize:20,flexShrink:0,color:"#c9c8c5"}}),_?xo(_,{sx:{fontSize:17,flexShrink:0,color:b.icon_color||"#1e3a8a"}}):null,pc(Kn,{component:"span",sx:{flex:1,minWidth:0,fontSize:15,color:"#37352f",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:3,overflow:"hidden",lineHeight:1.5,wordBreak:"break-word"},children:[b.ticket_no?`${b.ticket_no} `:"",b.title]}),xo(Kn,{sx:{flexShrink:0,display:"flex",alignItems:"center"},children:xo(Ke,{option:Nt(b)})})]},b.seq)})})})})]})]});return xo(Kw,{open:u.isOpen,onClose:u.close,maxWidth:"sm",fullScreen:s,mobilePresentation:s?"slide":"dialog",...s?{contentPaddingX:0,contentTopPadding:0,sectionsPaddingTop:0}:{},sx:s?{DialogContent:{pb:0,"& .os-content > div":{height:"100%",boxSizing:"border-box",paddingBottom:0,marginBottom:0},"& .FormSection-content, & .section-content":{height:"100%",paddingBottom:0,marginBottom:0}}}:void 0,title:i,locale:ye(),tabs:{visible:!1},titleIcons:{delete:{visible:!1}},fontScale:{enabled:!0},fontScaleKey:"taskbox-task-link",sections:[{id:"task-link",showTitle:!1,children:x}],scrollPastLastSection:!1,sectionContentPaddingTop:0,contentTopPadding:12,actions:{showCancelButton:!0,right:xo($w,{variant:"contained",disabled:f.length===0,onClick:()=>{c.submit()},children:l})}})}import{ConfirmActionPopper as kD}from"@ehfuse/mui-confirm-action";import{Fragment as CD,jsx as Se,jsxs as Gn}from"react/jsx-runtime";var Dx="taskbox.checklist.hideCompleted";function TD({id:e,children:t}){let{attributes:o,listeners:a,setNodeRef:r,transform:i,transition:l,isDragging:s}=cD({id:e});return Se(Ht,{ref:r,sx:{transform:uD.Transform.toString(i),transition:l,...s?{opacity:.6,position:"relative",zIndex:1}:{}},children:t({handleProps:{...o,...a},dragging:s})})}function yD({sortable:e,sensors:t,rowIds:o,onDragEnd:a,compact:r,children:i}){let l=Se(Ht,{sx:{display:"flex",flexDirection:"column",mt:.5,pl:r?0:3.25},children:i});return e?Se(eD,{sensors:t,collisionDetection:oD,modifiers:[iD,aD],onDragEnd:a,children:Se(lD,{items:o,strategy:mD,children:l})}):l}function gc({taskSeq:e,checklist:t,onAdd:o,onToggle:a,confirmOnToggle:r=!1,onRemove:i,onUpdate:l,onReorder:s,removeLocked:c=!1,onConvertToTask:u,onOpenLinkedTask:m,linkCandidates:d,linkBaseTask:f,onLinkExistingTask:p,resolveLinkedTask:g,myAccountSeq:x=0}){M();let[b,_]=ml(""),h=cl({multiSelect:!0,onSubmit:$=>{if(!p)return;let Z=d?.find(W=>W.seq===$);p(e,$,String(Z?.title??"").trim())}}),[B,C]=ml(null),z=$e(),[y,S]=ml(null),[D,K]=ml(null),P=$=>{let Z=$.task_seq?g?.($.task_seq):void 0;return Z?Z.completed:$.checked},k=$=>{if(!$.task_seq||x<=0)return!1;let Z=g?.($.task_seq);return Z?!Wf(Z,x):!1},T=$=>!!$.task_seq&&!!g&&!g?.($.task_seq),I=t.filter($=>!T($)),E=I.filter(P).length,[L,R]=ml(()=>{try{return localStorage.getItem(Dx)==="1"}catch{return!1}}),A=$=>{R($);try{localStorage.setItem(Dx,$?"1":"0")}catch{}},v=!!s&&!z&&!c,H=rD(nD(tD,{activationConstraint:{distance:5}})),te=($,Z)=>$.task_seq?`linked-${$.task_seq}`:`row-${Z}`,U=t.map(te),ee=U.filter(($,Z)=>{let W=t[Z];return T(W)?!1:!(L&&P(W))}),re=$=>{let{active:Z,over:W}=$;if(!W||Z.id===W.id)return;let V=U.indexOf(String(Z.id)),fe=U.indexOf(String(W.id));V<0||fe<0||s?.(e,sD(t,V,fe))},le=()=>{b.trim()&&(o(e,b),_(""))};return Gn(zo,{icon:Se(pD,{sx:{fontSize:19,display:"block"}}),title:Gn(CD,{children:[n("section.todo"),t.length>0?Gn(Ht,{component:"span",sx:{fontSize:12.5,color:"#9a9a97"},children:[E," / ",t.length]}):null]}),titleExtra:I.length>0?Gn(Ht,{sx:{flex:1,minWidth:0,ml:1,display:"flex",alignItems:"center",gap:1},children:[Se(Ht,{sx:{flex:1,minWidth:0,height:6,borderRadius:3,bgcolor:"#ececea"},children:Se(Ht,{sx:{height:"100%",borderRadius:3,width:`${Math.round(E/I.length*100)}%`,bgcolor:"#2f80ed",transition:"width 0.2s"}})}),E>0?Gn(Ht,{component:"label",sx:{display:"inline-flex",alignItems:"center",gap:.25,flexShrink:0,cursor:"pointer",fontSize:13.5,fontWeight:400,color:"#57564f",userSelect:"none"},children:[Se(Jw,{size:"small",checked:L,onChange:($,Z)=>A(Z)}),n("section.hideDone")]}):null]}):null,children:[Se(yD,{sortable:v,sensors:H,rowIds:ee,onDragEnd:re,compact:z,children:t.map(($,Z)=>{let W=$.task_seq?g?.($.task_seq):void 0,V=P($);if(L&&V||T($))return null;let fe=!!$.task_seq,Ee=k($),nt=se=>Gn(Ht,{sx:{display:"flex",alignItems:z?"flex-start":"center",gap:1,px:1.25,...v?{ml:-3,pl:.5}:{},py:.5,borderRadius:1,"&:hover":{bgcolor:"#f7f7f5"},"&:hover .taskbox-checklist-remove":{opacity:1},"&:hover .taskbox-checklist-convert":{opacity:1},"&:hover .taskbox-checklist-handle":{opacity:1}},children:[se?Se(Ht,{className:"taskbox-checklist-handle",...se,sx:{display:"inline-flex",flexShrink:0,alignItems:"center",color:"#c9c8c5",opacity:0,transition:"opacity 0.15s",cursor:"grab","&:active":{cursor:"grabbing"},touchAction:"none",userSelect:"none"},children:Se(gD,{sx:{fontSize:16}})}):null,Se(fd,{title:Ee?n("section.toggleLocked"):"",arrow:!0,disableInteractive:!0,children:Se(Ht,{component:"span",onClick:Ee?void 0:Q=>r?K({anchorEl:Q.currentTarget,index:Z,checked:!V}):a(e,Z,!V),sx:{display:"inline-flex",flexShrink:0,cursor:Ee?"default":"pointer",...z?{mt:"1px"}:{}},children:V?Se(fD,{sx:{fontSize:18,color:Ee?"#a9c6ec":"#2f80ed"}}):Se(hD,{sx:{fontSize:18,color:Ee?"#d6d5d1":"#9a9a97"}})})}),B?.index===Z?Se(Ht,{component:"input",autoFocus:!0,spellCheck:!1,value:B.label,enterKeyHint:"done",onChange:Q=>C({index:Z,label:Q.target.value}),onBlur:()=>{B.label.trim()&&B.label.trim()!==$.label&&l?.(e,Z,B.label),C(null)},onKeyDown:Q=>{Q.key==="Enter"&&Q.target.blur(),Q.key==="Escape"&&C(null)},sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:14,color:"#37352f",bgcolor:"transparent",p:0}}):Se(Ht,{component:"span",onClick:fe?$.task_seq&&m?()=>m($.task_seq):void 0:c||!l?void 0:z?()=>S({index:Z,label:$.label}):()=>C({index:Z,label:$.label}),sx:{flex:1,minWidth:0,fontSize:14.5,color:"#37352f",textDecoration:V?"line-through":"none",overflow:"hidden",textOverflow:"ellipsis",...z?{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:3,lineHeight:1.4,wordBreak:"break-word"}:{whiteSpace:"nowrap"},...fe?m?{cursor:"pointer","&:hover":{color:"#2f80ed"}}:{}:c||!l?{}:{cursor:"text"}},children:$.label}),fe?Gn(Ht,{component:"span",onClick:$.task_seq&&m?()=>m($.task_seq):void 0,sx:{display:"inline-flex",alignItems:"center",gap:.4,flexShrink:0,...z?{mt:"1px"}:{},px:.75,py:.2,borderRadius:1,fontSize:12,fontWeight:500,color:"#1d4f91",bgcolor:"#e3eefb",whiteSpace:"nowrap",...m?{cursor:"pointer"}:{}},children:[Se(xD,{sx:{fontSize:12}}),W?.manager_name?.trim()||n("template.task")]}):null,!c&&!fe&&u?Se(fd,{title:n("section.makeTask"),arrow:!0,enterDelay:300,disableInteractive:!0,children:Se(li,{className:"taskbox-checklist-convert",size:"small","aria-label":n("section.makeTask"),onClick:()=>u(e,Z,$.label),sx:{display:z?"none":"inline-flex",opacity:0,transition:"opacity 0.15s",color:"#9a9a97"},children:Se(wx,{sx:{fontSize:16}})})}):null,c?null:Se(li,{className:"taskbox-checklist-remove",size:"small","aria-label":n("section.deleteTodo"),onClick:()=>i(e,Z),sx:{display:z?"none":"inline-flex",opacity:0,transition:"opacity 0.15s",color:"#9a9a97"},children:Se(Ix,{sx:{fontSize:15}})})]});return v?Se(TD,{id:U[Z],children:({handleProps:se})=>nt(se)},U[Z]):Se(Ht,{children:nt(null)},U[Z])})}),Gn(Ht,{sx:{mt:.5,ml:z?0:3.25,display:"flex",alignItems:"center",gap:.5},children:[Se(Ht,{component:"input",spellCheck:!1,value:b,placeholder:n("section.addTodoPlaceholder"),enterKeyHint:"done",onChange:$=>_($.target.value),onKeyDown:$=>{$.key==="Enter"&&le()},sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:14,color:"#37352f",bgcolor:"transparent",px:1.25,py:.75,"&::placeholder":{color:"#9a9a97"}}}),d&&f&&p?Se(fd,{title:n("section.attachExisting"),arrow:!0,children:Se(li,{size:"small","aria-label":n("section.attachExisting"),onMouseDown:$=>$.preventDefault(),onClick:h.openDialog,sx:{flexShrink:0,color:"#9a9a97"},children:Se(bD,{sx:{fontSize:20}})})}):null,Se(li,{size:"small","aria-label":n("section.addTodo"),disabled:!b.trim(),onMouseDown:$=>$.preventDefault(),onClick:le,sx:{flexShrink:0,color:b.trim()?"#2f80ed":"#c9c8c5"},children:Se(dD,{sx:{fontSize:20}})})]}),d&&f&&p?Se(fc,{controller:h,task:f,tasks:d,excludeSeqs:t.map($=>Number($.task_seq??0)).filter($=>$>0),hideRelationType:!0,title:n("section.attachExisting"),confirmLabel:n("section.attach")}):null,Se(kD,{open:!!D,anchorEl:D?.anchorEl??null,title:D?.checked?n("calendar.checklistCompleteConfirm"):n("task.uncompleteConfirm"),confirmText:D?.checked?n("common.done"):n("task.unmark"),onCancel:()=>K(null),onConfirm:()=>{D&&a(e,D.index,D.checked),K(null)}}),Se(Qw,{open:!!y,onClose:()=>S(null),maxWidth:"xs",fullWidth:!0,slotProps:{paper:{sx:{borderRadius:2,m:2}}},children:Gn(Ht,{sx:{p:2,display:"flex",flexDirection:"column",gap:1.5},children:[Se(Ht,{sx:{fontSize:15.5,fontWeight:600,color:"#37352f"},children:n("section.editTodo")}),Se(Zw,{autoFocus:!0,fullWidth:!0,size:"medium",value:y?.label??"",onChange:$=>S(Z=>Z&&{...Z,label:$.target.value}),onKeyDown:$=>{if($.key!=="Enter")return;let Z=y;Z&&Z.label.trim()&&l?.(e,Z.index,Z.label.trim()),S(null)}}),Gn(Ht,{sx:{display:"flex",alignItems:"center",gap:1},children:[!c&&u&&y&&!t[y.index]?.task_seq?Se(li,{"aria-label":n("section.makeTask"),onClick:()=>{u(e,y.index,t[y.index]?.label??""),S(null)},sx:{color:"#57564f"},children:Se(wx,{sx:{fontSize:20}})}):null,!c&&y?Se(li,{"aria-label":n("section.deleteTodo"),onClick:()=>{i(e,y.index),S(null)},sx:{color:"#e5484d"},children:Se(Ix,{sx:{fontSize:19}})}):null,Se(Ht,{sx:{flex:1}}),Se(_x,{color:"inherit",onClick:()=>S(null),children:n("common.cancel")}),Se(_x,{variant:"contained",disabled:!y?.label.trim(),onClick:()=>{y&&y.label.trim()&&l?.(e,y.index,y.label.trim()),S(null)},children:n("common.confirm")})]})]})})]})}import{useRef as wD,useState as DD}from"react";import{Box as sn,IconButton as ED}from"@mui/material";import{DndContext as RD,PointerSensor as PD,closestCenter as MD,useSensor as OD,useSensors as LD}from"@dnd-kit/core";import{restrictToParentElement as AD,restrictToVerticalAxis as qD}from"@dnd-kit/modifiers";import{SortableContext as zD,useSortable as ND,verticalListSortingStrategy as FD}from"@dnd-kit/sortable";import{CSS as HD}from"@dnd-kit/utilities";import WD from"@mui/icons-material/DragIndicator";import $D from"@mui/icons-material/Close";import Px from"@mui/icons-material/AttachFileOutlined";var SD=new Set(["jpg","jpeg","png","gif","bmp","webp","svg","pdf","txt","json","xml","log","md","markdown","csv","xls","xlsx","html","htm","js","jsx","ts","tsx","css","scss","sass","less","php","py","java","c","cpp","h","hpp","cs","go","rs","rb","swift","kt","scala","sql","sh","bash","bat","ps1","yml","yaml","toml","ini","conf","mp4","avi","mov","wmv","flv","webm","mp3","wav","ogg","m4a","aac"]),xc=e=>{let t=e?.split(".").pop()?.toLowerCase()??"";return SD.has(t)};import{LinearProgress as vD}from"@mui/material";import{Fragment as BD,jsx as ID,jsxs as _D}from"react/jsx-runtime";function Ex(e){let t=xn(),o=t.useValue("attachmentUpload.taskSeq"),a=t.useValue("attachmentUpload.index"),r=t.useValue("attachmentUpload.total"),i=t.useValue("attachmentUpload.queue"),l=a??0;return!l||e>0&&(o??0)!==e?null:{index:l,total:r??0,queue:i??[]}}function gd(){let t=xn().useValue("attachmentUpload.progress");return _D(BD,{children:[t??0,"%"]})}function Rx(){let t=xn().useValue("attachmentUpload.progress");return ID(vD,{variant:"determinate",value:t??0,sx:{height:4,borderRadius:2,bgcolor:"#dbe9fb",mt:.75}})}import{Fragment as Mx,jsx as It,jsxs as dl}from"react/jsx-runtime";function VD({id:e,children:t}){let{attributes:o,listeners:a,setNodeRef:r,transform:i,transition:l,isDragging:s}=ND({id:e});return It(sn,{ref:r,sx:{transform:HD.Transform.toString(i),transition:l,...s?{opacity:.6,position:"relative",zIndex:1}:{}},children:t({...o,...a})})}function ul(e){return e>=1048576?`${(e/1048576).toFixed(1)}MB`:`${Math.max(1,Math.round(e/1024))}KB`}var bc={flex:1,minWidth:0,fontSize:13.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function hc({taskSeq:e,attachments:t,onAdd:o,onRemove:a,removeLocked:r=!1,onPreview:i,onDownload:l,onReorder:s}){M();let[c,u]=DD(!1),m=wD(null),d=$e(),f=Ai(),p=Li(),g=Ex(e),x=e===0,b=!!s&&!x&&!d&&!r&&!g&&t.length>1,_=LD(OD(PD,{activationConstraint:{distance:5}})),h=(P,k)=>P.uuid?`file-${P.uuid}`:`file-${k}`,B=t.map(h),C=P=>{let{active:k,over:T}=P;if(!T||k.id===T.id)return;let I=B.indexOf(String(k.id)),E=B.indexOf(String(T.id));I<0||E<0||s?.(e,I,E)},z=P=>{if(i){i(P);return}window.open(p(P.uuid??""),"_blank","noopener,noreferrer")},y=P=>{if(l){l(P);return}window.open(p(P.uuid??"",{download:!0}),"_blank","noopener,noreferrer")},S=P=>g?P+1<g.index?"done":P+1===g.index?"uploading":"waiting":"waiting",D=(P,k,T,I={})=>dl(sn,{sx:{px:1,py:.5,borderRadius:1,border:"1px solid",borderColor:I.uploading?"#d5e6fb":"#e6e6e3",bgcolor:I.uploading?"#f4f9ff":"transparent","&:hover .taskbox-file-remove":{opacity:1},"&:hover .taskbox-file-handle":{opacity:1}},children:[dl(sn,{sx:{display:"flex",alignItems:"center",gap:1,minWidth:0},children:[I.handleProps?It(sn,{className:"taskbox-file-handle","aria-label":n("section.reorder"),...I.handleProps,sx:{display:"inline-flex",flexShrink:0,alignItems:"center",ml:-.5,mr:-.5,color:"#c9c8c5",opacity:0,transition:"opacity 0.15s",cursor:"grab","&:active":{cursor:"grabbing"},touchAction:"none",userSelect:"none"},children:It(WD,{sx:{fontSize:16}})}):null,It(Px,{sx:{fontSize:16,color:"#9a9a97"}}),k,It(sn,{component:"span",sx:{fontSize:12,color:I.uploading?"#2f80ed":"#9a9a97",flexShrink:0},children:T}),I.removeIndex!==void 0?It(ED,{className:"taskbox-file-remove",size:"small","aria-label":n("section.deleteAttachment"),onClick:()=>a(e,I.removeIndex),sx:{opacity:0,transition:"opacity 0.15s",color:"#9a9a97"},children:It($D,{sx:{fontSize:15}})}):null]}),I.uploading?It(Rx,{}):null]},P),K=P=>{let k=xc(P.name);return It(sn,{component:"button",type:"button",onClick:()=>k?z(P):y(P),title:n("section.fileAction",{name:P.name,value:k?n("section.preview"):n("section.download")}),sx:{...bc,color:"#37352f",textAlign:"left",p:0,border:"none",background:"none",font:"inherit",fontSize:13.5,cursor:"pointer",outline:"none","&:focus-visible":{textDecoration:"underline",color:"#2f80ed"},"&:hover":{textDecoration:"underline",color:"#2f80ed"}},children:P.name})};return dl(zo,{icon:It(Px,{sx:{fontSize:18,display:"block"}}),title:dl(Mx,{children:[n("section.files")," ",t.length>0?t.length:""]}),children:[It(UD,{sortable:b,sensors:_,rowIds:B,onDragEnd:C,children:dl(sn,{sx:{display:"flex",flexDirection:"column",gap:.5,mt:1},children:[t.map((P,k)=>{let T=`${P.uuid||P.name}-${k}`;if(x){let I=S(k),E=I==="uploading";return D(T,It(sn,{component:"span",sx:{...bc,color:I==="done"?"#37352f":"#9a9a97"},children:P.name}),E?It(gd,{}):ul(P.size),{uploading:E,removeIndex:!r&&!g?k:void 0})}return P.uuid?b?It(VD,{id:h(P,k),children:I=>D(T,K(P),ul(P.size),{removeIndex:r?void 0:k,handleProps:I})},h(P,k)):D(T,K(P),ul(P.size),{removeIndex:r?void 0:k}):D(T,It(sn,{component:"span",title:n("section.legacyAttachment"),sx:{...bc,color:"#9a9a97"},children:P.name}),ul(P.size),{removeIndex:r?void 0:k})}),!x&&g?g.queue.slice(g.index-1).map((P,k)=>{let T=k===0;return D(`uploading-${g.index+k}-${P.name}`,It(sn,{component:"span",sx:{...bc,color:"#9a9a97"},children:P.name}),T?It(gd,{}):ul(P.size),{uploading:T})}):null]})}),It(sn,{onClick:()=>m.current?.click(),onDragOver:P=>{P.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:P=>{P.preventDefault(),u(!1);let k=Array.from(P.dataTransfer.files);k.length>0&&o(e,k)},sx:{mt:1,py:2.5,display:"flex",alignItems:"center",justifyContent:"center",gap:.5,border:"1.5px dashed",borderColor:c?"#2f80ed":"#cfcfcc",borderRadius:1,bgcolor:c?"#eef6ff":"transparent",color:"#787774",fontSize:13.5,cursor:"pointer",transition:"background-color 0.15s, border-color 0.15s","&:hover":{bgcolor:"#fafaf9",borderColor:"#9a9a97"}},children:d?n("section.attachHint",{uploadMaxMb:f}):n("section.attachHintDrag",{uploadMaxMb:f})}),It(sn,{component:"input",ref:m,type:"file",multiple:!0,onChange:P=>{let k=Array.from(P.target.files??[]);k.length>0&&o(e,k),P.target.value=""},sx:{display:"none"}})]})}function UD({sortable:e,sensors:t,rowIds:o,onDragEnd:a,children:r}){return e?It(RD,{sensors:t,collisionDetection:MD,modifiers:[qD,AD],onDragEnd:a,children:It(zD,{items:o,strategy:FD,children:r})}):It(Mx,{children:r})}import{useState as JD}from"react";import{Checkbox as ZD,Divider as eE,ListItemIcon as tE,Menu as oE,MenuItem as qx}from"@mui/material";import nE from"@mui/icons-material/Add";import{Box as xd,Button as jD}from"@mui/material";import{FormDialog as YD}from"@ehfuse/mui-form-dialog";import{ClearTextField as XD}from"@ehfuse/mui-form-controls";import{ColorPicker as QD}from"@ehfuse/mui-color-picker";import{useGlobalForm as KD}from"@ehfuse/forma";import{ErrorAlert as GD}from"@ehfuse/alerts";var Ox="#2f80ed";function Lx({open:e,onClose:t,onSubmit:o}){M();let a=KD({formId:ve("taskbox-add-label-form"),initialValues:{name:"",color:Ox},onValidate:i=>String(i.name??"").trim()?!0:(GD(n("dialog.enterLabelName")),!1),onSubmit:i=>(o(String(i.name).trim(),i.color),r.form.close(),!0)}),r={form:to({modalIdPrefix:"taskbox-add-label-dialog",open:e,onClose:t,onOpen:()=>a.setFormValues({name:"",color:Ox})})};return{form:a,modals:r}}import{jsx as pl,jsxs as bd}from"react/jsx-runtime";function Ax({open:e,onClose:t,onSubmit:o}){M();let{form:a,modals:r}=Lx({open:e,onClose:t,onSubmit:o}),i=String(a.useFormValue("name")??""),l=String(a.useFormValue("color")??""),s=ff(l),c=bd(xd,{children:[bd(xd,{sx:{display:"flex",alignItems:"center",gap:1.5,mt:.5},children:[pl(XD,{form:a,name:"name",label:n("dialog.labelName"),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),a.submit())},fullWidth:!0,autoFocus:!0}),pl(QD,{value:l,onChange:u=>a.setFormValue("color",u),shape:"circle",colorSize:28})]}),bd(xd,{sx:{mt:2,display:"flex",alignItems:"center",gap:1,fontSize:13,color:"#787774"},children:[n("dialog.preview"),pl(Ke,{option:{key:"__preview__",name:i.trim()||n("dialog.label"),...s}})]})]});return pl(YD,{open:r.form.isOpen,onClose:r.form.close,maxWidth:"xs",title:n("dialog.addLabelTitle"),locale:ye(),tabs:{visible:!1},titleIcons:{delete:{visible:!1}},fontScale:{enabled:!0},fontScaleKey:"taskbox-add-label",sections:[{id:"add-label",showTitle:!1,children:c}],actions:{showCancelButton:!0,right:pl(jD,{variant:"contained",onClick:()=>{a.submit()},children:n("common.add")})}})}import{Fragment as rE,jsx as si,jsxs as kc}from"react/jsx-runtime";function Tc({anchorEl:e,selectedKeys:t,labelOptions:o,onToggle:a,onAddLabel:r,onClose:i}){M();let[l,s]=JD(!1),c=Ln();return kc(rE,{children:[kc(oE,{anchorEl:e,open:!!e,onClose:i,transitionDuration:0,...c,children:[o.map(u=>{let m=t.includes(u.key);return kc(qx,{onClick:()=>a(u.key),sx:{fontSize:14,minWidth:170,gap:1},children:[si(ZD,{size:"small",checked:m,sx:{p:0}}),si(Ke,{option:u})]},u.key)}),si(eE,{}),kc(qx,{onClick:()=>s(!0),sx:{fontSize:14,color:"#787774"},children:[si(tE,{children:si(nE,{sx:{fontSize:18,color:"#787774"}})}),n("menu.addLabel")]})]}),si(Ax,{open:l,onClose:()=>s(!1),onSubmit:r})]})}function zx(e,t){let o=Number(e.author_account_seq??0);return t.filter(a=>{let r=Number(a.account_seq??0);return r>0&&r!==o})}function Nx(e,t){let o=(e.target_account_seqs??[]).filter(d=>d>0);if(o.length===0)return null;let a=new Set(o),r=zx(e,t),i=new Map;for(let d of r){let f=String(d.department??"").trim();if(!f)continue;let p=i.get(f)??[];p.push(d),i.set(f,p)}let l=[],s=new Set;for(let[d,f]of i)if(f.every(g=>a.has(Number(g.account_seq??0)))){l.push(d);for(let g of f)s.add(Number(g.account_seq??0))}let c=new Map(r.map(d=>[Number(d.account_seq??0),d.name])),u=e.target_names??[],m=[];return o.forEach((d,f)=>{s.has(d)||m.push(c.get(d)??u[f]??n("dialog.noName"))}),{teamNames:l,individualNames:m}}function yc(e,t){let o=Nx(e,t);return o?[...o.teamNames,...o.individualNames].join(", "):n("col.allEmployees")}function xK(e,t){let o=Nx(e,t);return o?{kind:"members",teamNames:o.teamNames,individualNames:o.individualNames}:{kind:"everyone"}}function Fx(e,t,o){let a=(e.target_account_seqs??[]).filter(p=>p>0),r=zx(e,t),i=a.length>0?a.length:r.length,l=e.acks??[],s=o>0&&l.some(p=>p.account_seq===o),c=o>0&&Number(e.author_account_seq??0)===o,u=a.length===0||a.includes(o),m=new Set(l.map(p=>p.account_seq)),f=(a.length>0?r.filter(p=>a.includes(Number(p.account_seq??0))):r).filter(p=>!m.has(Number(p.account_seq??0))).map(p=>String(p.name??"").trim()).filter(p=>p.length>0);return{count:l.length,total:i,acked:s,pendingNames:f,canAck:o>0&&!c&&u&&!s&&!e.completed}}import{DatePicker as xE}from"@ehfuse/mui-datetime-picker";import{Fragment as Ia,jsx as pe,jsxs as vn}from"react/jsx-runtime";var Ux="taskbox:create-expanded";function bE(){try{return window.localStorage.getItem(Ux)==="1"}catch{return!1}}function Td({form:e,statusOptions:t,customTabs:o,sprints:a=[],avatarSrcByName:r,isNotice:i=!1,hideProject:l=!1,hideBug:s=!1,hideTypeToggle:c=!1,leadingRow:u,extraRows:m,hideLabel:d=!1,simple:f=!1,hideMembers:p=!1,templateItem:g=!1,postMode:x=!1,employees:b=[],workspaceName:_="",workspaceSlot:h,myAccountSeq:B=0,departments:C=[],myGroupSeq:z=0,onMemberEdit:y,onAddProject:S,onAddLabelOption:D,contentSyncKey:K="create",contentTemplates:P,contentTitleExtra:k,onSaveContentTemplate:T,onRemoveContentTemplate:I}){M();let E=xn(),L=Ai(),R=e.useFormValue("manager_name"),A=e.useFormValue("receiver_names"),v=e.useFormValue("start_date"),H=!!e.useFormValue("is_event"),te=!!e.useFormValue("is_bug"),U=e.useFormValue("bug_repro")??"",ee=e.useFormValue("bug_device")??"",re=e.useFormValue("bug_where")??"",le=e.useFormValue("bug_version")??"",$=e.useFormValue("event_time")??"",Z=e.useFormValue("event_place")??"",W=e.useFormValue("event_address")??"",V=e.useFormValue("due_date"),fe=e.useFormValue("reminders")??[],Ee=e.useFormValue("priority"),nt=e.useFormValue("content"),se=e.useFormValue("note")??"",N=e.useFormValue("checklist")??[],j=e.useFormValue("tab_key"),ae=e.useFormValue("sprint_seq")??0,me=e.useFormValue("story_points")??0,we=o.find(w=>w.key===j&&w.useSprints),Ce=we?a.filter(w=>`custom-${w.group_seq}`===j):[],[Ct,Ne]=ci(null),Re=e.useFormValue("label_keys"),[Pt,Ve]=ci(null),gt=e.useFormValue("visibility")||"involved",io=Number(e.useFormValue("visibility_group_seq")??0),[J,Be]=ci(null),qe=e.useFormValue("repeat_rule")||"",Ye=e.useFormValue("repeat_until")||"",[Jn,Zn]=ci(null),[Co,Dn]=ci(null),er=e.useFormValue("target_names"),pn=e.useFormValue("target_account_seqs"),En=E.useValue("createAttachmentFiles")??[],Vt=i?yc({author_account_seq:B,target_names:er,target_account_seqs:pn},b):"",[lt,Wo]=ci(bE),fn=f&&!H&&!i&&!x,Mt=fn&&!lt,Oo=()=>{let w=!lt;Wo(w);try{window.localStorage.setItem(Ux,w?"1":"0")}catch{}},lo=!x,Me=p?1:2;return vn(Ia,{children:[u,!i&&!c?vn(hr,{sx:{display:"flex",gap:1.25,px:2,pt:1.5,pb:1.5,flexShrink:0},children:[h?pe(hr,{sx:{alignSelf:"center",mr:"6px",minWidth:0,display:"flex"},children:h}):_?pe(hr,{sx:{alignSelf:"center",fontSize:13.5,fontWeight:600,color:"#37352f",mr:"6px",maxWidth:160,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:_,children:_}):null,[{value:"task",label:n("kind.task")},{value:"event",label:n("kind.event")},...s?[]:[{value:"bug",label:n("kind.bug")}]].map(w=>{let ue=(te?"bug":H?"event":"task")===w.value;return pe(Hx,{onClick:()=>Lm(e,w.value),sx:{px:1.75,lineHeight:1,pt:"8px",pb:"10px",borderRadius:99,fontSize:13.5,fontWeight:ue?600:400,color:ue?"#ffffff":"#787774",bgcolor:ue?"#2563eb":"#f4f4f2"},children:w.label},w.label)})]}):null,pe(fl,{sx:{borderColor:"#e6e6e3"}}),vn(hr,{sx:{pt:1.5,pb:2,display:"flex",flexDirection:"column",gap:.25},children:[pe(ic,{hideProject:l||x||Mt&&!j,hideManager:p||Mt&&!R,hideReceivers:g||p||Mt&&A.length===0,hideStartDate:Mt||x,hideReminder:g||x||Mt&&fe.length===0,hidePriority:x,hideDueDate:x||!H&&!!qe,values:{tabKey:j,managerName:R,receiverNames:A,startDate:v,dueDate:V,reminders:fe,priority:Ee,eventTime:$,eventPlace:Z,eventAddress:W},customTabs:o,avatarSrcByName:r,notice:i,event:H,onChangeEventTime:w=>e.setFormValue("event_time",w),onChangeEventPlace:w=>e.setFormValue("event_place",w),onChangeEventAddress:w=>e.setFormValue("event_address",w),targetSummary:Vt,onChangeProject:w=>e.setFormValue("tab_key",w),onAddProject:S,onChangeStartDate:w=>e.setFormValue("start_date",w),onClearStartDate:()=>e.setFormValue("start_date",""),onChangeDueDate:w=>e.setFormValue("due_date",w),onChangeReminder:w=>e.setFormValue("reminders",w),onChangePriority:w=>e.setFormValue("priority",w),onMemberEdit:y,pinColumns:lo,beforeStart:vn(Ia,{children:[!g&&!te&&!x&&!(Mt&&!qe)?pe(he,{icon:pe(dE,{sx:{fontSize:17,...qe?{color:"#2f80ed"}:{}}}),label:n("create.repeat"),onClick:w=>Zn(w),sx:H||!lo?void 0:pt(Me),children:qe?ss(qe):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("common.none")})}):null,!g&&!te&&!x&&qe?pe(he,{icon:pe(pE,{sx:{fontSize:17}}),label:n("create.repeatUntil"),onClick:w=>Dn(w),sx:H||!lo?void 0:pt(Me),children:Ye?Vo(Ye):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("create.auto")})}):null]}),trailing:vn(Ia,{children:[!i&&!p&&!(Mt&&gt==="involved")?pe(he,{icon:gt==="all"?pe($x,{sx:{fontSize:17,color:"#2f80ed"}}):gt==="group"?pe(Vx,{sx:{fontSize:17,color:"#d9730d"}}):pe(Wx,{sx:{fontSize:17}}),label:n("create.visibility"),onClick:w=>Be(w),sx:H||!lo?void 0:pt(1),children:gt==="all"?n("create.visibilityPublic"):gt==="group"?n("create.visibilityDept",{value:C.find(w=>w.seq===io)?.name??n("create.department")}):n("create.visibilityPrivate")}):null,we&&!H&&!i&&!x&&!(Mt&&ae===0&&me===0)?vn(Ia,{children:[pe(he,{icon:pe(uE,{sx:{fontSize:17}}),label:n("col.goal"),onClick:w=>Ne(w),sx:lo?pt(1):void 0,children:ae>0?Ce.find(w=>w.seq===ae)?.name??n("create.deletedGoal"):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("board.unassigned")})}),pe(he,{icon:pe(fE,{sx:{fontSize:17}}),label:"\uD3EC\uC778\uD2B8",sx:lo?pt(1):void 0,children:pe(xr,{value:me>0?String(me):"",placeholder:n("create.notEstimated"),onCommit:w=>e.setFormValue("story_points",Number(w.replace(/[^0-9.]/g,""))||0)})})]}):null,te?pe(lc,{values:{repro:U,device:ee,where:re,version:le},onChangeRepro:w=>e.setFormValue("bug_repro",w),onChangeDevice:w=>e.setFormValue("bug_device",w),onChangeWhere:w=>e.setFormValue("bug_where",w),onChangeVersion:w=>e.setFormValue("bug_version",w)}):null,!g&&!x&&!i?(m??[]).filter(w=>!(Mt&&!w.filled)).map(w=>pe(he,{icon:w.icon,label:w.label,onClick:w.onClick,sx:H||!lo?void 0:pt(Me),children:w.value},w.key)):null]}),leading:H||d?null:pe(hr,{sx:{gridColumn:"1 / -1"},children:pe(he,{icon:pe(mE,{sx:{fontSize:17}}),label:n("dialog.label"),onClick:w=>Ve(w),children:(Re??[]).length>0?pe(Nr,{labelKeys:Re??[],labelOptions:t}):pe(hr,{component:"span",sx:{color:"#9a9a97"},children:n("menu.empty")})})})}),fn?vn(Hx,{onClick:Oo,"aria-expanded":lt,sx:{alignSelf:"flex-start",display:"flex",alignItems:"center",gap:.5,minHeight:32,mx:2,pr:1,borderRadius:1,fontSize:14,color:"#2563eb","&:hover":{bgcolor:"#f2f2f0"}},children:[lt?pe(aE,{sx:{fontSize:17}}):pe(iE,{sx:{fontSize:17}}),lt?n("create.collapseFields"):n("create.expandFields")]}):null,pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),pe(zo,{icon:pe(sE,{sx:{fontSize:18,display:"block"}}),title:n("common.content"),titleExtra:k||P?vn(Ia,{children:[k,P?pe(dc,{content:nt,templates:P,onApply:w=>e.setFormValue("content",w),onSave:T,onRemove:I}):null]}):void 0,children:pe(cc,{syncKey:K,value:nt,onChange:w=>e.setFormValue("content",w)})}),te||x||Mt&&!se?null:vn(Ia,{children:[pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),pe(zo,{icon:pe(cE,{sx:{fontSize:18,display:"block"}}),title:n("col.note"),children:pe(gE,{form:e,name:"note",placeholder:n("create.notePlaceholder"),fullWidth:!0,size:"medium",sx:{mt:1}})})]}),H||x||Mt&&N.length===0?null:pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),H||x||Mt&&N.length===0?null:pe(gc,{taskSeq:0,checklist:N,onAdd:(w,Y)=>zm(e,Y),onToggle:(w,Y,ue)=>Nm(e,Y,ue),onRemove:(w,Y)=>Fm(e,Y),onUpdate:(w,Y,ue)=>Hm(e,Y,ue)}),g?null:vn(Ia,{children:[pe(fl,{sx:{my:1.5,borderColor:"#e6e6e3"}}),pe(hc,{taskSeq:0,attachments:En.map(w=>({name:w.name,size:w.size})),onAdd:(w,Y)=>Wm(E,Y,L),onRemove:(w,Y)=>$m(E,Y)})]})]}),pe(hd,{transitionDuration:0,anchorEl:Ct,open:!!Ct,onClose:()=>Ne(null),children:[{seq:0,label:n("board.unassigned")},...Ce.map(w=>({seq:w.seq,label:nn(w)}))].map(w=>pe(kd,{onClick:()=>{e.setFormValue("sprint_seq",w.seq),Ne(null)},sx:{fontSize:14,minWidth:170},children:w.label},w.seq))}),pe(hd,{transitionDuration:0,anchorEl:Jn,open:!!Jn,onClose:()=>Zn(null),children:[{value:"",label:n("common.none")},...Wi].map(w=>pe(kd,{selected:qe===w.value,onClick:()=>{Zn(null),Am(e,w.value)},sx:{fontSize:14,minWidth:140},children:w.label},w.value||"none"))}),pe(xE,{anchorEl:Co,open:!!Co,onClose:()=>Dn(null),selectedDate:Ye?new Date(`${Ye}T00:00:00`):new Date,onDateChange:w=>{qm(e,w),Dn(null)}}),pe(hd,{transitionDuration:0,anchorEl:J,open:!!J,onClose:()=>Be(null),children:[{key:"involved",label:n("create.visibilityPrivate"),tip:n("create.privateTip"),icon:pe(Wx,{sx:{fontSize:17,color:"#57564f"}}),selected:gt==="involved",onPick:()=>$i(e,"involved")},{key:"all",label:n("create.visibilityPublic"),tip:n("create.publicTip"),icon:pe($x,{sx:{fontSize:17,color:"#2f80ed"}}),selected:gt==="all",onPick:()=>$i(e,"all")},...[...C].sort((w,Y)=>w.seq===z?-1:Y.seq===z?1:0).map(w=>({key:`group-${w.seq}`,label:n("create.visibilityDeptName",{name:w.name}),tip:n("create.deptTip",{name:w.name}),icon:pe(Vx,{sx:{fontSize:17,color:"#d9730d"}}),selected:gt==="group"&&io===w.seq,onPick:()=>$i(e,"group",w.seq)}))].map(w=>pe(lE,{title:w.tip,arrow:!0,disableInteractive:!0,placement:"right",children:vn(kd,{selected:w.selected,onClick:()=>{w.onPick(),Be(null)},sx:{fontSize:14,minWidth:170,gap:1},children:[w.icon,w.label]})},w.key))}),pe(Tc,{anchorEl:Pt,selectedKeys:Re??[],labelOptions:t,onToggle:w=>e.setFormValue("label_keys",bs(Re??[],w)),onAddLabel:(w,Y)=>D?.(w,Y),onClose:()=>Ve(null)})]})}import{Fragment as jx,jsx as kt,jsxs as gl}from"react/jsx-runtime";var IE={gap:"0.75rem !important","& .left-actions, & .right-actions":{display:"contents"},"& .left-actions > span:empty":{display:"none"},"& .left-actions:not(:has(*:not(:empty)))":{display:"none"},"& .left-actions .MuiButton-root, & .right-actions .MuiButton-root":{flex:"1 1 0",minWidth:0,margin:"0 !important",paddingLeft:"8px !important",paddingRight:"8px !important",whiteSpace:"nowrap"},"& .right-actions .MuiButton-text":{border:"1px solid rgba(0, 0, 0, 0.23)"},"& .right-actions .MuiButton-contained":{border:"1px solid transparent"}};function Yx({open:e,onClose:t,desktopPresentation:o="drawer",submitLabel:a,...r}){M();let{form:i,presetTitle:l="",presetContent:s="",presetVisibility:c,presetVisibilityGroupSeq:u=0,presetDueDate:m="",presetTabKey:d="",presetManager:f=null,isNotice:p=!1,defaultBug:g=!1}=r,x=xn(),b=kE(!1),[_,h]=Kx(0),B=i.useFormValue("title"),C=i.useFormValue("icon"),z=i.useFormValue("icon_color"),y=!!i.useFormValue("is_event"),S=!!i.useFormValue("is_bug"),D=$e(),P=x.useValue("createSubmitting")??!1,k=p||y?Oe(C||(p?vt:zt)):null,T=p?n("create.titleNotice"):y?n("create.titleEvent"):S?n("task.createBug"):n("task.createTask"),I=p?n("create.noticeTitlePlaceholder"):y?n("create.eventTitlePlaceholder"):S?n("create.bugTitlePlaceholder"):n("create.taskTitlePlaceholder");hE(()=>{let v=b.current;b.current=e,!(!e||v)&&(Om(i,x,{presetTitle:l,presetContent:s,presetVisibility:c,presetVisibilityGroupSeq:u,presetDueDate:m,presetTabKey:d,presetManager:f,isNotice:p,defaultBug:g}),h(H=>H+1))},[e]);let[E,L]=Kx(null),R=v=>k?y?kt(SE,{title:n("col.changeIcon"),arrow:!0,enterDelay:400,disableInteractive:!0,children:kt(TE,{onClick:H=>L(H.currentTarget),sx:{display:"flex",p:.5,borderRadius:1,color:z||"#1e3a8a","&:hover":{bgcolor:"#f2f2f0"}},children:kt(k,{sx:{fontSize:20}})})}):kt(kr,{sx:[{display:"flex",color:z||"#1e3a8a"},v],children:kt(k,{sx:{fontSize:20}})}):null,A=gl(kr,{sx:{display:"flex",alignItems:"center",gap:1,px:2,pt:2,pb:1},children:[R({p:0}),kt(kr,{component:"input",autoFocus:!0,spellCheck:!1,value:B,placeholder:I,onChange:v=>i.setFormValue("title",v.target.value),sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:19,fontWeight:600,color:"#37352f",p:0,m:0,"&::placeholder":{color:"#c9c8c5",fontWeight:400}}})]});return D||o==="dialog"?kt(jx,{children:kt(_E,{open:e,onClose:t,backdropClick:!1,locale:ye(),fontScale:D?{enabled:!0,default:1.1,min:.6}:{enabled:!0},title:T,titleIcons:{delete:{visible:!1},print:{visible:!1},share:{visible:!1}},fullScreen:D,mobilePresentation:D?"slide":"dialog",maxWidth:"md",actions:{showCancelButton:!0,right:kt(yd,{variant:"contained",disableElevation:!0,disabled:P,onClick:P?void 0:i.submit,children:P?n("create.saving"):a??n("create.saveButton")})},dialogActionSx:D?IE:void 0,tabs:{visible:!1},contentTopPadding:0,contentPaddingX:0,sectionsPaddingTop:0,sectionContentPaddingTop:0,contentBottomPadding:0,scrollPastLastSection:!1,overlayScrollbar:{enabled:!0,contentStyle:{minWidth:0}},sections:[{id:"task-create",title:"",showTitle:!1,children:kt(kr,{sx:{width:"100%",minWidth:0,display:"flex",flexDirection:"column",gap:0},children:kt(Td,{...r,contentSyncKey:`create-${_}`,leadingRow:A})})}]})}):gl(jx,{children:[kt(yE,{anchor:"right",open:e,onClose:(v,H)=>{H!=="backdropClick"&&t()},"aria-label":n("create.newTaskAria"),sx:{zIndex:v=>v.zIndex.modal},slotProps:{paper:{sx:{width:720,maxWidth:"100vw"}}},children:gl(kr,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[gl(kr,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1.5,flexShrink:0},children:[R({px:.5}),kt(kr,{component:"input",autoFocus:!0,spellCheck:!1,value:B,placeholder:I,onChange:v=>i.setFormValue("title",v.target.value),sx:{flex:1,minWidth:0,border:"none",outline:"none",font:"inherit",fontSize:18,fontWeight:500,color:"#37352f",p:0,m:0,"&::placeholder":{color:"#c9c8c5",fontWeight:400}}}),kt(CE,{"aria-label":n("common.close"),onClick:t,sx:{color:"#6b7280"},children:kt(vE,{})})]}),kt(Gx,{sx:{borderColor:"#e6e6e3"}}),kt(kr,{sx:{flex:1,minHeight:0},children:kt(BE,{style:{height:"100%"},contentStyle:{minWidth:0},thumb:{width:6},children:kt(Td,{...r,contentSyncKey:`create-${_}`})})}),kt(Gx,{sx:{borderColor:"#e6e6e3"}}),gl(kr,{sx:{display:"flex",justifyContent:"flex-end",gap:.5,px:2,py:1.5,flexShrink:0},children:[kt(yd,{onClick:t,color:"inherit",disabled:P,children:n("common.cancel")}),kt(yd,{onClick:i.submit,variant:"contained",disabled:P,children:P?n("create.creating"):a??n("common.register")})]})]})}),kt(Hr,{anchorEl:E,value:C,color:z,onSelect:v=>{i.setFormValue("icon",v),L(null)},onSelectColor:v=>i.setFormValue("icon_color",v),onClose:()=>L(null)})]})}import{useEffect as Kb,useRef as Gb,useState as jb}from"react";import{Box as Ac,Button as JP,Divider as Yb,Drawer as ZP,IconButton as eM,ListItemIcon as Qd,ListItemText as Jd,Menu as tM,MenuItem as Zd}from"@mui/material";import oM from"@mui/icons-material/MoreVert";import nM from"@mui/icons-material/DeleteOutline";import rM from"@mui/icons-material/ShareOutlined";import aM from"@mui/icons-material/HistoryOutlined";import iM from"@ehfuse/overlay-scrollbar";import{FormDialog as lM}from"@ehfuse/mui-form-dialog";import{useRef as Ic,useState as Tr}from"react";import{Box as be,Button as fb,Chip as wc,IconButton as Yo,Popover as oR,Tooltip as hb}from"@mui/material";import nR from"@mui/icons-material/ArrowUpwardRounded";import{TextField as rR}from"@ehfuse/mui-form-controls";import Dc from"@mui/icons-material/Close";import aR from"@mui/icons-material/EditOutlined";import gb from"@mui/icons-material/ContentCopyOutlined";import xb from"@mui/icons-material/Check";import iR from"@mui/icons-material/Favorite";import lR from"@mui/icons-material/FavoriteBorderOutlined";import sR from"@mui/icons-material/CheckCircle";import cR from"@mui/icons-material/CheckCircleOutlineOutlined";import ui from"@mui/icons-material/AttachFileOutlined";import mR from"@mui/icons-material/AddCircleOutline";import uR from"@mui/icons-material/ImageOutlined";var Cd=e=>{if(e===0)return"0 Bytes";let t=1024,o=["Bytes","KB","MB","GB","TB"],a=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,a)).toFixed(2))+" "+o[a]};import{useCallback as Cc,useEffect as wE,useMemo as DE,useRef as Xx,useState as Sd}from"react";import{Box as Sc,Paper as EE,Popper as RE}from"@mui/material";import{jsx as wa,jsxs as ME}from"react/jsx-runtime";var Qx=8,PE=[{key:"\uC88B\uC544\uC694",get label(){return n("emoji.like")},insert:"\u{1F44D}",keywords:["like","\uC5C4\uC9C0","\uAD7F"]},{key:"\uD655\uC778",get label(){return n("emoji.check")},insert:"\u2705",keywords:["check","\uC644\uB8CC","\uCCB4\uD06C"]},{key:"\uAC10\uC0AC",get label(){return n("emoji.thanks")},insert:"\u{1F64F}",keywords:["thanks","\uACE0\uB9C8\uC6CC","\uBD80\uD0C1"]},{key:"\uCD95\uD558",get label(){return n("emoji.party")},insert:"\u{1F389}",keywords:["party","\uD30C\uD2F0","\uC9DD\uC9DD"]},{key:"\uBC15\uC218",get label(){return n("emoji.clap")},insert:"\u{1F44F}",keywords:["clap","\uC798\uD588\uC5B4"]},{key:"\uD558\uD2B8",get label(){return n("emoji.heart")},insert:"\u2764\uFE0F",keywords:["heart","\uC0AC\uB791"]},{key:"\uC6C3\uC74C",get label(){return n("emoji.laugh")},insert:"\u{1F604}",keywords:["smile","\uC6C3\uAE40","\u314B\u314B"]},{key:"\uBBF8\uC18C",get label(){return n("emoji.smile")},insert:"\u{1F642}",keywords:["smile","\uC88B\uC74C"]},{key:"\uB208\uBB3C",get label(){return n("emoji.tears")},insert:"\u{1F622}",keywords:["sad","\uC2AC\uD514","\u3160\u3160"]},{key:"\uB180\uB78C",get label(){return n("emoji.wow")},insert:"\u{1F62E}",keywords:["wow","\uD5C9"]},{key:"\uACE0\uBBFC",get label(){return n("emoji.think")},insert:"\u{1F914}",keywords:["think","\uC0DD\uAC01","\uC74C"]},{key:"\uC624\uCF00\uC774",get label(){return n("emoji.ok")},insert:"\u{1F44C}",keywords:["ok","\uC54C\uACA0\uC5B4"]},{key:"\uBD88",get label(){return n("emoji.fire")},insert:"\u{1F525}",keywords:["fire","\uAE09\uD568","\uB300\uBC15"]},{key:"\uC544\uC774\uB514\uC5B4",get label(){return n("emoji.idea")},insert:"\u{1F4A1}",keywords:["idea","\uC804\uAD6C"]},{key:"\uACBD\uACE0",get label(){return n("emoji.warning")},insert:"\u26A0\uFE0F",keywords:["warning","\uC8FC\uC758"]},{key:"\uC9C8\uBB38",get label(){return n("emoji.question")},insert:"\u2753",keywords:["question","\uBB3C\uC74C"]},{key:"\uC2DC\uACC4",get label(){return n("emoji.clock")},insert:"\u23F0",keywords:["time","\uC2DC\uAC04","\uC54C\uB78C"]},{key:"\uB2EC\uB825",get label(){return n("emoji.calendar")},insert:"\u{1F4C5}",keywords:["calendar","\uC77C\uC815","\uB0A0\uC9DC"]},{key:"\uBA54\uBAA8",get label(){return n("emoji.note")},insert:"\u{1F4DD}",keywords:["note","\uAE30\uB85D"]},{key:"\uCCA8\uBD80",get label(){return n("emoji.attach")},insert:"\u{1F4CE}",keywords:["attach","\uD074\uB9BD","\uD30C\uC77C"]},{key:"\uB9C1\uD06C",get label(){return n("emoji.link")},insert:"\u{1F517}",keywords:["link","\uC8FC\uC18C"]},{key:"\uB85C\uCF13",get label(){return n("emoji.rocket")},insert:"\u{1F680}",keywords:["rocket","\uCD9C\uBC1C","\uBC30\uD3EC"]},{key:"\uBCC4",get label(){return n("emoji.star")},insert:"\u2B50",keywords:["star","\uC911\uC694"]},{key:"\uC5D1\uC2A4",get label(){return n("emoji.x")},insert:"\u274C",keywords:["x","\uC548\uB428","\uCDE8\uC18C"]}];function xl(e,t,o){let a=e.slice(0,t),i=(o==="@"?/(^|[\s(])@([^\s@]{0,20})$/:/(^|[\s(])\/([^\s/]{0,20})$/).exec(a);return i?{start:t-i[2].length-1,query:i[2]}:null}function vd(e,t){let o=ie(),a=e??o.mentionCandidates??[],r=t??o.slashCommands,i=r===!0?PE:Array.isArray(r)?r:[];return{people:a,commands:i,enabled:a.length>0||i.length>0}}function Bd(e,t,o){if(!o)return[];let a=o.query.toLowerCase();return o.trigger==="@"?e.filter(r=>r.name.toLowerCase().includes(a)).slice(0,Qx).map((r,i)=>({id:`p${i}-${r.name}`,text:`@${r.name} `,label:r.name,subtitle:r.subtitle,icon:wa(fo,{src:r.avatar??"",name:r.name,avatarSx:{width:24,height:24,fontSize:14},iconFontSize:16})})):t.filter(r=>[r.key,r.label,...r.keywords??[]].some(i=>i.toLowerCase().includes(a))).slice(0,Qx).map(r=>({id:`c-${r.key}`,text:r.insert,label:`/${r.label}`,icon:wa(Sc,{component:"span",sx:{width:24,textAlign:"center",fontSize:18,lineHeight:1},children:r.insert})}))}function _d({open:e,anchor:t,items:o,active:a,onPick:r,onHover:i}){return wa(RE,{open:e,anchorEl:t,placement:"top-start",sx:{zIndex:1500},children:wa(EE,{elevation:4,sx:{minWidth:220,maxWidth:320,py:.5,borderRadius:1.5},children:o.map((l,s)=>ME(Sc,{role:"option","aria-selected":s===a,onMouseDown:c=>c.preventDefault(),onClick:()=>r(l),onMouseEnter:()=>i(s),sx:{display:"flex",alignItems:"center",gap:1,px:1.5,py:.75,cursor:"pointer",fontSize:14,bgcolor:s===a?"action.selected":"transparent"},children:[l.icon,wa(Sc,{component:"span",sx:{fontWeight:500,whiteSpace:"nowrap"},children:l.label}),l.subtitle?wa(Sc,{component:"span",sx:{color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l.subtitle}):null]},l.id))})})}function Jx({value:e,setValue:t,candidates:o,slashCommands:a}){let{people:r,commands:i,enabled:l}=vd(o,a),s=Xx(null),[c,u]=Sd(null),[m,d]=Sd(null),[f,p]=Sd(0),g=DE(()=>Bd(r,i,m),[i,r,m]),x=!!(c&&m&&g.length>0),b=Cc(()=>{let y=s.current;if(!l||!y)return;let S=y.selectionStart??y.value.length,D=r.length>0?xl(y.value,S,"@"):null,K=!D&&i.length>0?xl(y.value,S,"/"):null,P=D?{...D,trigger:"@"}:K?{...K,trigger:"/"}:null;d(P),p(0),u(P?y.closest(".MuiInputBase-root")??y:null)},[i.length,l,r.length]),_=Xx(null);wE(()=>{let y=s.current,S=_.current;if(S!==null&&y){_.current=null,y.setSelectionRange(S,S);return}document.activeElement===y&&b()},[e,b]);let h=Cc(y=>{let S=s.current;if(!m||!S)return;let D=S.selectionStart??e.length,K=e.slice(0,m.start)+y.text+e.slice(D),P=m.start+y.text.length;_.current=K===e?null:P,t(K),d(null),u(null),requestAnimationFrame(()=>{_.current=null,S.focus(),S.setSelectionRange(P,P)})},[m,t,e]),B=Cc(y=>!x||y.nativeEvent.isComposing?!1:y.key==="ArrowDown"||y.key==="ArrowUp"?(y.preventDefault(),p(S=>(S+(y.key==="ArrowDown"?1:g.length-1))%g.length),!0):y.key==="Enter"||y.key==="Tab"?(y.preventDefault(),h(g[Math.min(f,g.length-1)]),!0):y.key==="Escape"?(y.preventDefault(),y.stopPropagation(),d(null),u(null),!0):!1,[f,g,x,h]);return{inputRef:Cc(y=>{s.current=y},[]),onKeyDown:B,onSelectionChange:b,popper:l?wa(_d,{open:x,anchor:c,items:g,active:f,onPick:h,onHover:p}):null}}import{useCallback as Id,useEffect as OE,useRef as Zx,useState as eb}from"react";import{Box as bl,Tab as LE,Tabs as AE}from"@mui/material";import{jsx as mi,jsxs as NE}from"react/jsx-runtime";var tb=[{key:"smile",labelKey:"section.emojiSmileys",items:["\u{1F600}","\u{1F603}","\u{1F604}","\u{1F601}","\u{1F606}","\u{1F605}","\u{1F923}","\u{1F602}","\u{1F642}","\u{1F643}","\u{1F609}","\u{1F60A}","\u{1F607}","\u{1F970}","\u{1F60D}","\u{1F929}","\u{1F618}","\u{1F617}","\u{1F61A}","\u{1F619}","\u{1F60B}","\u{1F61B}","\u{1F61C}","\u{1F92A}","\u{1F61D}","\u{1F917}","\u{1F92D}","\u{1F92B}","\u{1F914}","\u{1F928}","\u{1F610}","\u{1F611}","\u{1F636}","\u{1F60F}","\u{1F612}","\u{1F644}","\u{1F62C}","\u{1F60C}","\u{1F614}","\u{1F62A}","\u{1F634}","\u{1F637}","\u{1F912}","\u{1F915}","\u{1F975}","\u{1F976}","\u{1F635}","\u{1F92F}","\u{1F60E}","\u{1F973}","\u{1F622}","\u{1F62D}","\u{1F624}","\u{1F620}","\u{1F621}","\u{1F97A}","\u{1F633}","\u{1F631}","\u{1F628}","\u{1F630}","\u{1F625}","\u{1F910}","\u{1F62F}","\u{1F62E}"]},{key:"gesture",labelKey:"section.emojiPeople",items:["\u{1F44D}","\u{1F44E}","\u{1F44C}","\u270C\uFE0F","\u{1F91E}","\u{1F91F}","\u{1F918}","\u{1F919}","\u{1F448}","\u{1F449}","\u{1F446}","\u{1F447}","\u261D\uFE0F","\u270B","\u{1F91A}","\u{1F590}\uFE0F","\u{1F596}","\u{1F44B}","\u{1F91D}","\u{1F64F}","\u{1F4AA}","\u{1F9BE}","\u{1F44F}","\u{1F64C}","\u{1F450}","\u{1F932}","\u{1FAF6}","\u270D\uFE0F","\u{1F485}","\u{1F933}","\u{1F9E0}","\u{1F440}","\u{1F647}","\u{1F64B}","\u{1F646}","\u{1F645}","\u{1F481}","\u{1F937}","\u{1F926}","\u{1F9D1}\u200D\u{1F4BB}","\u{1F468}\u200D\u{1F4BC}","\u{1F469}\u200D\u{1F4BC}","\u{1F6B6}","\u{1F3C3}","\u{1F483}","\u{1F57A}","\u{1F476}","\u{1F9D3}"]},{key:"heart",labelKey:"section.emojiHearts",items:["\u2764\uFE0F","\u{1F9E1}","\u{1F49B}","\u{1F49A}","\u{1F499}","\u{1F49C}","\u{1F5A4}","\u{1F90D}","\u{1F90E}","\u{1F494}","\u2763\uFE0F","\u{1F495}","\u{1F49E}","\u{1F493}","\u{1F497}","\u{1F496}","\u{1F498}","\u{1F49D}","\u{1F49F}","\u2728","\u{1F4AB}","\u{1F4A5}","\u{1F389}","\u{1F38A}","\u{1F388}","\u{1F381}","\u{1F451}","\u{1FAC2}","\u{1F63B}","\u{1F490}","\u{1F380}","\u{1F48C}"]},{key:"work",labelKey:"section.emojiWork",items:["\u{1F4CC}","\u{1F4CE}","\u{1F4DD}","\u{1F4C4}","\u{1F4D1}","\u{1F4CA}","\u{1F4C8}","\u{1F4C9}","\u{1F5C2}\uFE0F","\u{1F4C5}","\u{1F4C6}","\u23F0","\u231B","\u2705","\u2611\uFE0F","\u274C","\u2B55","\u2757","\u2753","\u{1F4A1}","\u{1F514}","\u{1F515}","\u{1F4E2}","\u{1F4E3}","\u{1F4AC}","\u{1F4AD}","\u{1F517}","\u{1F512}","\u{1F511}","\u2699\uFE0F","\u{1F6E0}\uFE0F","\u{1F4EC}","\u{1F4BB}","\u{1F5A5}\uFE0F","\u{1F5A8}\uFE0F","\u{1F4DE}","\u{1F4F1}","\u{1F4B0}","\u{1F4B3}","\u{1F9FE}","\u{1F4E6}","\u{1F550}","\u{1F4CB}","\u{1F587}\uFE0F","\u270F\uFE0F","\u{1F5D1}\uFE0F","\u267B\uFE0F","\u{1F50D}"]},{key:"food",labelKey:"section.emojiFood",items:["\u2615","\u{1F375}","\u{1F964}","\u{1F9C3}","\u{1F37A}","\u{1F37B}","\u{1F942}","\u{1F377}","\u{1F378}","\u{1F943}","\u{1F35A}","\u{1F35C}","\u{1F372}","\u{1F35B}","\u{1F371}","\u{1F359}","\u{1F354}","\u{1F35F}","\u{1F355}","\u{1F32D}","\u{1F96A}","\u{1F32E}","\u{1F35D}","\u{1F957}","\u{1F356}","\u{1F357}","\u{1F969}","\u{1F373}","\u{1F95E}","\u{1F9C7}","\u{1F35E}","\u{1F950}","\u{1F370}","\u{1F382}","\u{1F9C1}","\u{1F36A}","\u{1F369}","\u{1F36B}","\u{1F36C}","\u{1F36D}","\u{1F366}","\u{1F34E}","\u{1F34A}","\u{1F34B}","\u{1F34C}","\u{1F349}","\u{1F347}","\u{1F353}"]},{key:"etc",labelKey:"section.emojiOther",items:["\u{1F525}","\u2B50","\u{1F31F}","\u{1F4AF}","\u{1F3AF}","\u{1F3C6}","\u{1F947}","\u{1F680}","\u{1F308}","\u2600\uFE0F","\u{1F319}","\u26C5","\u2601\uFE0F","\u{1F327}\uFE0F","\u2744\uFE0F","\u26A1","\u{1F338}","\u{1F33A}","\u{1F337}","\u{1F339}","\u{1F33B}","\u{1F340}","\u{1F33F}","\u{1F331}","\u{1F436}","\u{1F431}","\u{1F430}","\u{1F43C}","\u{1F98A}","\u{1F43B}","\u{1F425}","\u{1F98B}","\u{1F697}","\u2708\uFE0F","\u{1F3E0}","\u{1F3E2}","\u{1F3B5}","\u{1F3B6}","\u{1F4DA}","\u{1F3AE}","\u26BD","\u{1F3C0}","\u{1F48A}","\u{1FA7A}","\u{1F9F3}","\u{1F382}","\u{1F6D2}","\u{1F9F9}"]}],qE="'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif",ob="taskbox.recentEmojis",nb=24;function rb(){try{let e=JSON.parse(window.localStorage.getItem(ob)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string").slice(0,nb):[]}catch{return[]}}function zE(e){let t=[e,...rb().filter(o=>o!==e)].slice(0,nb);try{window.localStorage.setItem(ob,JSON.stringify(t))}catch{}return t}function ab({onPick:e}){let[t,o]=eb(()=>rb()),[a,r]=eb(0),i=Zx(null),l=Zx(!1),s=t.length>0?[{key:"recent",labelKey:"section.emojiFrequent",items:t},...tb]:tb,c=Math.min(a,s.length-1),u=Id(f=>{o(zE(f)),e(f)},[e]),m=Id(f=>{r(f);let p=i.current;p&&(l.current=!0,p.scrollTo({left:p.clientWidth*f,behavior:"smooth"}),window.setTimeout(()=>{l.current=!1},350))},[]),d=Id(()=>{let f=i.current;if(!f||l.current||f.clientWidth===0)return;let p=Math.round(f.scrollLeft/f.clientWidth);r(g=>p!==g&&p>=0?p:g)},[]);return OE(()=>{let f=i.current;f&&(f.scrollLeft=f.clientWidth*c)},[]),NE(bl,{children:[mi(AE,{value:c,onChange:(f,p)=>m(p),variant:"scrollable",scrollButtons:!1,sx:{minHeight:36,borderBottom:"1px solid #ececea","& .MuiTab-root":{minHeight:36,minWidth:0,px:1.5,fontSize:13}},children:s.map(f=>mi(LE,{label:n(f.labelKey)},f.key))}),mi(bl,{ref:i,onScroll:d,sx:{display:"flex",height:352,overflowX:"auto",overflowY:"hidden",scrollSnapType:"x mandatory",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:s.map(f=>mi(bl,{sx:{flex:"0 0 100%",width:"100%",height:"100%",overflowY:"auto",scrollSnapAlign:"start",scrollSnapStop:"always",p:1},children:mi(bl,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(40px, 1fr))"},children:f.items.map((p,g)=>mi(bl,{component:"button",type:"button",onClick:()=>u(p),"aria-label":p,sx:{border:0,bgcolor:"transparent",color:"#000",cursor:"pointer",fontFamily:qE,fontSize:24,lineHeight:1,py:.75,borderRadius:"8px","&:hover":{bgcolor:"rgba(15, 23, 42, 0.06)"},"&:active":{bgcolor:"rgba(15, 23, 42, 0.1)"}},children:p},`${p}-${g}`))})},f.key))})]})}import{forwardRef as GE,useImperativeHandle as jE,useLayoutEffect as cb,useRef as _c,useState as sb}from"react";import{Box as Pd}from"@mui/material";import{EhfuseEditor as YE}from"@ehfuse/editor";import{useCallback as wd,useMemo as FE,useRef as HE,useState as Dd}from"react";import{jsx as WE}from"react/jsx-runtime";function ib(){let{people:e,commands:t,enabled:o}=vd(),[a,r]=Dd(null),[i,l]=Dd(null),s=HE(""),[c,u]=Dd(0),m=FE(()=>Bd(e,t,a),[t,e,a]),d=!!(o&&i&&a&&m.length>0),f=wd(()=>{if(!o)return;let b=window.getSelection();if(!b||b.rangeCount===0||!b.isCollapsed)return void r(null);let _=b.anchorNode;if(!_||_.nodeType!==Node.TEXT_NODE||!_.parentElement?.closest(".ehfuse-editor-content"))return void r(null);let h=_.data,B=b.anchorOffset,C=e.length>0?xl(h,B,"@"):null,z=!C&&t.length>0?xl(h,B,"/"):null,y=C?{...C,trigger:"@"}:z?{...z,trigger:"/"}:null;if(!y){s.current="",r(null),l(null);return}r({node:_,start:y.start,end:B,query:y.query,trigger:y.trigger});let S=`${y.trigger}${y.query}`;S!==s.current&&u(0),s.current=S;let D=document.createRange();D.setStart(_,y.start),D.setEnd(_,Math.min(y.start+1,h.length));let K=D.getBoundingClientRect();l({getBoundingClientRect:()=>K})},[t.length,o,e.length]),p=wd(b=>{if(!a)return;let{node:_,start:h,end:B}=a;if(!_.isConnected)return void r(null);let C=window.getSelection(),z=document.createRange();z.setStart(_,h),z.setEnd(_,Math.min(B,_.data.length)),C?.removeAllRanges(),C?.addRange(z),document.execCommand("insertText",!1,b.text),r(null),l(null)},[a]);return{handlers:{onKeyDownCapture:wd(b=>{!d||b.nativeEvent.isComposing||(b.key==="ArrowDown"||b.key==="ArrowUp"?(b.preventDefault(),b.stopPropagation(),u(_=>(_+(b.key==="ArrowDown"?1:m.length-1))%m.length)):b.key==="Enter"||b.key==="Tab"?(b.preventDefault(),b.stopPropagation(),p(m[Math.min(c,m.length-1)])):b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),r(null),l(null)))},[c,m,d,p]),onKeyUp:f,onMouseUp:f,onInput:f},popper:o?WE(_d,{open:d,anchor:i,items:m,active:c,onPick:p,onHover:u}):null,isOpen:d}}function hl(e){return/^\s*<(p|div|ul|ol|h[1-6]|blockquote|pre)[\s>]/i.test(e)}var $E=new Set(["P","BR","DIV","SPAN","STRONG","B","EM","I","U","S","STRIKE","DEL","CODE","PRE","UL","OL","LI","H1","H2","H3","H4","BLOCKQUOTE","A","MARK"]),VE=new Set(["background-color","color","text-decoration"]);function Ed(e){if(typeof DOMParser>"u")return"";let o=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html").body.firstElementChild;if(!o)return"";let a=r=>{for(let i of Array.from(r.children)){if(!$E.has(i.tagName)){if(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED","TEMPLATE"].includes(i.tagName)){i.remove();continue}a(i),i.replaceWith(...Array.from(i.childNodes));continue}for(let l of Array.from(i.attributes)){let s=l.name.toLowerCase();if(i.tagName==="A"&&s==="href"){/^(https?:|mailto:|tel:)/i.test(l.value.trim())||i.removeAttribute(l.name);continue}if(s==="style"){let c=l.value.split(";").map(u=>u.trim()).filter(u=>VE.has(u.split(":")[0]?.trim().toLowerCase()??"")&&!/url\(|expression/i.test(u)).join("; ");c?i.setAttribute("style",c):i.removeAttribute("style");continue}i.removeAttribute(l.name)}a(i)}};return a(o),o.innerHTML}function vc(e){if(typeof DOMParser>"u")return e.replace(/<[^>]*>/g,"");let t=e.replace(/<br\s*\/?>/gi,`
6
6
  `).replace(/<\/(p|div|li|h[1-6]|blockquote|pre)>/gi,`
7
7
  `).replace(/<li[^>]*>/gi,"\u2022 ");return(new DOMParser().parseFromString(t,"text/html").body.textContent??"").replace(/\n{3,}/g,`
8
8