@univerjs/sheets-ui 0.8.0-nightly.202506051607 → 0.8.0-nightly.202506061607
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +9 -1
- package/lib/index.js +9 -1
- package/lib/umd/index.js +1 -1
- package/package.json +13 -13
package/lib/umd/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
`,g={...u,body:{dataStream:h,textRuns:c.textRuns,paragraphs:go(h)}};d==null||d.reset(g),o=d==null?void 0:d.getSnapshot(),i=c.dataStream}else i=Hh(r.innerHTML.replace(/[\r\n]/g,""));return{cellText:i,cellRichStyle:o}}_generateDocumentDataModelSnapshot(r){var l;const e=this._getCurrentSkeleton();if(e==null)return null;const{skeleton:t}=e,i=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...i==null?void 0:i.getSnapshot(),...r};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}process(r,e,t,i){var o,s,l;for(const c of e)if(c.nodeName.toLowerCase()==="table")i.push({index:((o=t==null?void 0:t.paragraphs)==null?void 0:o.length)||0});else if(c.nodeType===Node.TEXT_NODE){if(((s=c.nodeValue)==null?void 0:s.trim())==="")continue;const d=(l=c.nodeValue)==null?void 0:l.replace(/[\r\n]/g,"");let u;r&&this._styleCache.has(r)&&(u=this._styleCache.get(r));const h={dataStream:"",textRuns:[]};t.dataStream+=d,h.dataStream+=d,u&&Object.getOwnPropertyNames(u).length&&(t.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}),h.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}))}else{if(a.skipParseTagNames.includes(c.nodeName.toLowerCase()))continue;if(c.nodeName.toLowerCase()==="br")t.paragraphs||(t.paragraphs=[]),t.paragraphs.push({startIndex:t.dataStream.length}),t.dataStream+="\r";else if(c.nodeType===Node.ELEMENT_NODE){if(c.nodeName==="STYLE")continue;const d=c,u=this._processBeforeLink(d,{body:t}),h=r?this._styleCache.get(r):{},g=this._styleRules.find(({filter:p})=>Ua(c,p)),S=g?g.getStyle(c):Qi(c);this._styleCache.set(c,{...h,...S});const{childNodes:f}=c;this.process(c,f,t,i);const v=this._afterProcessRules.find(({filter:p})=>Ua(c,p));v&&v.handler(t,c),this._processAfterLink(d,{body:t},u)}}}_processBeforeLink(r,e){return e.body.dataStream.length}_processAfterLink(r,e,t){var s,l;const i=e.body,o=r;o.tagName.toUpperCase()==="A"&&(i.customRanges=(s=i.customRanges)!=null?s:[],i.customRanges.push({startIndex:t,endIndex:i.dataStream.length-1,rangeId:(l=o.dataset.rangeid)!=null?l:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:o.href}}))}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear()}};T(kr,"_pluginList",[]);let dn=kr;function kh(n){const r=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=n.matchAll(r);if(!e)return{rowProperties:[],rowCount:0};const i=Array.from(e).map(o=>Fa(o[1])).map(o=>{if(!o.height){const s=o.style,l=s&&s.match(/height\s*:\s*(\d+(\.\d+)?)px/);o.height=`${l?Number.parseInt(l[1],10):a.DEFAULT_WORKSHEET_ROW_HEIGHT}`}return o});return{rowProperties:i,rowCount:i.length}}function Ba(n){const r={};return n.split(";").forEach(t=>{const[i,o]=t.split(":");r[i]=o}),r}function Fa(n){if(!n)return{};const r={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let t;for(;(t=e.exec(n))!==null;){const[,i,,o,s]=t,l=o!==void 0?o:s;r[i]=l}return r}function Nh(n){const r=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=n.match(r),t=/<col([\s\S]*?)>/g;let i;if(e!=null&&e[2]?i=e[2].matchAll(t):i=n.matchAll(t),!i)return null;const o=Array.from(i).map(l=>Fa(l[1])),s=[];return o.forEach(l=>{const c=Number(l.span);if(c)for(let d=0;d<c;d++){const u={...l};delete u.span,s.push(u)}else s.push(l)}),s}function Hh(n){const r={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return n.replace(/<|>|&|"|'| |<br>/g,e=>r[e])}function za(n,r){if(!n||!r)return null;const e=new RegExp(`(${r}\\s*:\\s*[^;]+);`,"i"),t=n.match(e);return t?t[1]:null}function Vh(n,r,e,t){const{rowSpan:i,colSpan:o,rowIndex:s,colSetValueIndex:l}=t;for(let c=s;c<s+i;c++)for(let d=l;d<l+o;d++)c===s&&d===l?n.setValue(c,d,{...e,style:r}):n.setValue(c,d,{style:r})}const Wh={name:"univer-doc-paste-plugin-lark",checkPasteType(n){return/lark-record-clipboard/i.test(n)},stylesRules:[{filter:["s"],getStyle(n){const r=Qi(n);return{st:{s:a.BooleanNumber.TRUE},...r}}}],afterProcessRules:[{filter(n){return n.tagName==="DIV"&&/ace-line/i.test(n.className)},handler(n){n.paragraphs==null&&(n.paragraphs=[]),n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+="\r"}}]},xh={name:"univer-doc-paste-plugin-univer",checkPasteType(n){return/UniverNormal/i.test(n)},stylesRules:[],afterProcessRules:[{filter(n){return n.tagName==="P"&&/UniverNormal/i.test(n.className)},handler(n,r){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Wa(r);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]},Lh={name:"univer-doc-paste-plugin-word",checkPasteType(n){return/word|mso/i.test(n)},stylesRules:[{filter:["b"],getStyle(n){const r=Qi(n);return{bl:a.BooleanNumber.TRUE,...r}}}],afterProcessRules:[{filter(n){return n.tagName==="P"&&/mso/i.test(n.className)},handler(n,r){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Wa(r);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]};var Je=(n=>(n.COPY="COPY",n.CUT="CUT",n))(Je||{});function Uh(n,r,e,t,i){const o=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,n)}).filter(d=>!!d),s=So(o),l=fo(s),c=r.map(d=>{if(!i.has(`${n}-${d}`)){const u=t.getValue(n,d);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=n;h<n+u.rowSpan;h++)for(let g=d;g<d+u.colSpan;g++)i.add(`${h}-${g}`);return Bh(n,d,e,t)}return null}).filter(d=>!!d).join("");return`<tr${l}>${c}</tr>`}function Bh(n,r,e,t){const i=t.getValue(n,r),o=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,n,r,i==null?void 0:i.rowSpan,i==null?void 0:i.colSpan)}).filter(d=>!!d),s=So(o),l=fo(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,n,r))||""},"");return`<td${l}>${c}</td>`}function Fh(n,r){return`<colgroup>${n.map(t=>{const i=r.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,t)}).filter(l=>!!l),o=So(i);return`<col ${fo(o)} />`}).join("")}</colgroup>`}function So(n){return n.reduce((r,e)=>(Object.keys(e).forEach(i=>{r[i]?r[i]+=`;${e[i]}`:r[i]=e[i]}),r),{})}function fo(n){return Object.keys(n).reduce((r,e)=>`${r} ${e}="${n[e]}"`,"")}class zh{convert(r,e,t){const{cols:i,rows:o}=e;if(!i.length)return"";const s=Fh(i,t),l=[],c=new Set;return o.forEach(u=>{l.push(Uh(u,i,t,r,c))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
|
|
17
17
|
<tbody>${l.join("")}</tbody></table>`}}const Xh=(n,r,e=!1)=>{const t=h=>h.endRow-h.startRow+1,i=h=>h.endColumn-h.startColumn+1,o=t(r)%t(n),s=i(r)%i(n),l={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:i(n)-1},c=Math.floor(t(r)/t(n)),d=Math.floor(i(r)/i(n)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let g=1;g<=d;g++){const S=t(n)*(h-1),f=i(n)*(g-1),v={startRow:S+r.startRow,endRow:S+r.startRow,startColumn:f+r.startColumn,endColumn:f+r.startColumn};u.push({repeatRelativeRange:l,startRange:v})}else if(!o&&s&&!e)for(let h=1;h<=c;h++){const g=t(n)*(h-1),S=0,f={startRow:g+r.startRow,endRow:g+r.startRow,startColumn:S+r.startColumn,endColumn:S+r.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else if(o&&!s&&!e)for(let h=1;h<=d;h++){const S=i(n)*(h-1),f={startRow:0+r.startRow,endRow:0+r.startRow,startColumn:S+r.startColumn,endColumn:S+r.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else{const h={startRow:r.startRow,endRow:r.startRow,startColumn:r.startColumn,endColumn:r.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};function Xa(n){return n?[/<td[^>]*class=".*?xl.*?"[^>]*>/i,/xmlns:x="urn:schemas-microsoft-com:office:excel"/i,/ProgId="Excel.Sheet"/i,/xmlns:o="urn:schemas-microsoft-com:office:office"/i,/@mso-|mso-excel/i,/<x:ExcelWorkbook>/i].some(e=>e.test(n)):!1}function Yh(n){if(!n)return!1;const r=/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i;return(n.match(r)||[]).length>0}function jh(...n){if(n.length===1)return n[0];const r=new a.ObjectMatrix;return n.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((i,o,s)=>{r.setValue(i,o,{...r.getValue(i,o),...s})})}),r.getMatrix()}function Gh(n,r){return n.id===r.id&&n.params.unitId===r.params.unitId&&n.params.subUnitId===r.params.subUnitId}function vo(n){const r=[];for(let e=0;e<n.length;){let t=1;if(n[e].id===m.SetRangeValuesMutation.id){const i=n[e],o=[i];for(;e+t<n.length&&Gh(i,n[e+t]);)o.push(n[e+t]),t+=1;const s=jh(...o.map(l=>l.params.cellValue||{}));r.push({...i,params:{...i.params,cellValue:s}})}else r.push(n[e]);e+=t}return r}function po(n,r){const{startRow:e,endRow:t,startColumn:i,endColumn:o}=n;for(let s=e;s<=t;s++)for(let l=i;l<=o;l++)if(r.rows.includes(s)&&r.cols.includes(l))return!0}function Ya(n,r){const{startRow:e,endRow:t,startColumn:i,endColumn:o}=r;for(let s=e;s<=t;s++)if(!n.rows.includes(s))return!1;for(let s=i;s<=o;s++)if(!n.cols.includes(s))return!1;return!0}function Zh(n){const r=n.trim().split(`
|
|
18
18
|
`);let e="<table>";return r.forEach(t=>{const i=t.split(" ");e+="<tr>",i.forEach(o=>{e+=`<td>${o}</td>`}),e+="</tr>"}),e+="</table>",e}var Kh=Object.getOwnPropertyDescriptor,qh=(n,r,e,t)=>{for(var i=t>1?void 0:t?Kh(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Me=(n,r)=>(e,t)=>r(e,t,n);const Se={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border",SPECIAL_PASTE_FORMULA:"special-paste-formula"},Qh={[_.FILE_PNG_CLIPBOARD_MIME_TYPE]:"png",[_.FILE__JPEG_CLIPBOARD_MIME_TYPE]:"jpg",[_.FILE__WEBP_CLIPBOARD_MIME_TYPE]:"webp",[_.FILE__BMP_CLIPBOARD_MIME_TYPE]:"bmp"};dn.use(Lh),dn.use(Wh),dn.use(xh);const We=a.createIdentifier("sheet.clipboard-service");y.SheetClipboardService=class extends a.Disposable{constructor(e,t,i,o,s,l,c,d,u,h,g,S,f,v){super();T(this,"_clipboardHooks",[]);T(this,"_clipboardHooks$",new D.BehaviorSubject([]));T(this,"clipboardHooks$",this._clipboardHooks$.asObservable());T(this,"_htmlToUSM");T(this,"_usmToHtml");T(this,"_copyContentCache");T(this,"_copyMarkId",null);T(this,"_pasteOptionsCache$",new D.BehaviorSubject(null));T(this,"pasteOptionsCache$",this._pasteOptionsCache$.asObservable());T(this,"_showMenu$",new D.BehaviorSubject(!1));T(this,"showMenu$",this._showMenu$.asObservable());this._logService=e,this._univerInstanceService=t,this._selectionManagerService=i,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._notificationService=d,this._platformService=u,this._renderManagerService=h,this._themeService=g,this._localeService=S,this._errorService=f,this._injector=v,this._htmlToUSM=new dn({getCurrentSkeleton:()=>{var p;return(p=R.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,y.SheetSkeletonManagerService,this._univerInstanceService,this._renderManagerService))==null?void 0:p.getCurrentParam()}}),this._usmToHtml=new zh,this._copyContentCache=new Oh,this.disposeWithMe(this._htmlToUSM),this._initUnitDisposed()}setShowMenu(e){this._showMenu$.next(e)}getPasteMenuVisible(){return this._showMenu$.getValue()}getPasteOptionsCache(){return this._pasteOptionsCache$.getValue()}copyContentCache(){return this._copyContentCache}generateCopyContent(e,t,i,o=Je.COPY){const s=this._clipboardHooks;s.forEach(c=>{var d;return(d=c.onBeforeCopy)==null?void 0:d.call(c,e,t,i,o)});const l=this._generateCopyContent(e,t,i,this._clipboardHooks);return s.forEach(c=>{var d;return(d=c.onAfterCopy)==null?void 0:d.call(c)}),l}async copy(e=Je.COPY){const t=this._selectionManagerService.getCurrentLastSelection();if(!t)return!1;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=i.getActiveSheet();if(!o)return!1;const s=i.getUnitId(),l=o.getSheetId(),c=this.generateCopyContent(s,l,t.range);if(!c)return!1;const{html:d,plain:u,matrixFragment:h,copyId:g,discreteRange:S}=c;this._copyContentCache.set(g,{unitId:i.getUnitId(),subUnitId:o.getSheetId(),range:S,matrix:h,copyType:e}),await this._clipboardInterfaceService.write(u,d),this._markSelectionService.removeAllShapes();const f=Ha(this._themeService);return this._copyMarkId=this._markSelectionService.addShape({...t,style:f}),!0}async cut(){return this.copy(Je.CUT)}async paste(e,t=Se.DEFAULT_PASTE){const i=e.types,o=i.indexOf(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",s=i.indexOf(_.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.HTML_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",l=i.findIndex(d=>_.imageMimeTypeSet.has(d)),c=l===-1||!Yh(s);if(s&&c)return this._platformService.isWindows&&Xa(s)&&this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),this._pasteHTML(s,t);if(l!==-1){const d=i[l],u=await e.getType(d);if(u){const h=Qh[d],g=new File([u],`clipboard-image.${h}`,{type:d});return this._pasteFiles([g],t)}}return o?this._pastePlainText(o,t):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}async legacyPaste(e,t,i){const o=Xa(e!=null?e:"");return i&&!o?this._pasteFiles(i,Se.DEFAULT_PASTE):e?this._pasteHTML(e,Se.DEFAULT_PASTE):t?/[\n\t]/.test(t)?this._pasteHTML(Zh(t),Se.DEFAULT_PASTE):this._pastePlainText(t,Se.DEFAULT_PASTE):this._pasteUnrecognized()}rePasteWithPasteType(e){const t=this._pasteOptionsCache$.getValue();if(!t)return!1;const i=this._injector.get(a.IUndoRedoService),o=i.pitchTopUndoElement();o&&a.sequenceExecute(o.undoMutations,this._commandService)&&i.popUndoToRedo();const{cellMatrix:s,rowProperties:l=[],colProperties:c=[],source:d,target:u}=t;return this._pasteUSM({cellMatrix:s,colProperties:c,rowProperties:l},u,Se[e],d),!0}updatePasteOptionsCache(e){this._pasteOptionsCache$.next(e)}addClipboardHook(e){if(this._clipboardHooks.findIndex(i=>i.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const t=this._clipboardHooks.findIndex(i=>{const o=i.priority||0;return(e.priority||0)<o});return this._clipboardHooks.splice(t!==-1?t:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const i=this._clipboardHooks.indexOf(e);i>-1&&(this._clipboardHooks.splice(i,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,t,i,o){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(t);if(!s||!l)return null;const c=o.reduce((O,M)=>{var A;const P=(A=M.getFilteredOutRows)==null?void 0:A.call(M,i);return P==null||P.forEach(k=>O.add(k)),O},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:g}=i,S=l.getMatrixWithMergedCells(u,d,g,h,a.CellModeEnum.Both),f=new a.ObjectMatrix;let v=u;const p=new a.ObjectMatrix,C={rows:[],cols:[]};for(let O=u;O<=g;O++)if(!c.has(O)){C.rows.push(O);for(let M=d;M<=h;M++){const P=S.getValue(O,M);if(P){const A=a.Tools.deepClone(P);p.setValue(v-u,M-d,{...Zn(),...A}),delete A.displayV,f.setValue(v-u,M-d,{...Zn(),...A})}else p.setValue(v-u,M-d,Zn()),f.setValue(v-u,M-d,Zn()),S.setValue(O,M,Zn())}v+=1}for(let O=d;O<=h;O++)C.cols.push(O);let b=this._usmToHtml.convert(S,C,o);const w=ja(p),E=Mh();return b=b.replace(/(<[a-z]+)/,(O,M)=>`${M} data-copy-id="${E}"`),{copyId:E,plain:w,html:b,matrixFragment:f,discreteRange:C}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _executePaste(e){const t=this._getPastingTarget();if(!t.subUnitId||!t.selection)return!1;const i=this._injector.invoke(S=>m.rangeToDiscreteRange(t.selection.range,S,t.unitId,t.subUnitId));if(!i)return!1;const{unitId:o,subUnitId:s}=t,l=this._clipboardHooks,c=[];if(l.some(S=>{var f;return c.push(S)&&((f=S.onBeforePaste)==null?void 0:f.call(S,{unitId:o,subUnitId:s,range:i}))===!1}))return c.forEach(S=>{var f;return(f=S.onAfterPaste)==null?void 0:f.call(S,!1)}),!1;const u=[],h=[];c.forEach(S=>{const f=e(S,{unitId:o,subUnitId:s,range:i});f&&(u.push(...f.redos),h.push(...f.undos))});const g=u.every(S=>this._commandService.executeCommand(S.id,S.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:h,redoMutations:u}),g}async _pasteFiles(e,t){return this._executePaste((i,o)=>{var s;return(s=i.onPasteFiles)==null?void 0:s.call(i,o,e,{pasteType:t})})}async _pastePlainText(e,t){return this._executePaste((i,o)=>{var s;return(s=i.onPastePlainText)==null?void 0:s.call(i,o,e,{pasteType:t})})}_pasteUnrecognized(){return this._executePaste((e,t)=>{var i;return(i=e.onPasteUnrecognized)==null?void 0:i.call(e,t)})}async _pasteHTML(e,t){const i=Ph(e);return i&&this._copyContentCache.get(i)?this._pasteInternal(i,t):this._pasteExternal(e,t)}async _pasteExternal(e,t){var h;const{rowProperties:i,colProperties:o,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const c=(h=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:h.getSheetBySheetId(l.subUnitId);if(!c)return!1;const d=c==null?void 0:c.getMergeData();return d.length&&d.some(S=>po(S,l.pastedRange)&&!Ya(l.pastedRange,S))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:i,colProperties:o,cellMatrix:s},l,t)}async _pasteInternal(e,t){var O,M;const i=a.Tools.deepClone(this._copyContentCache.get(e)),{range:o,matrix:s,unitId:l,subUnitId:c}=i||{};if(!s||!i||!o||!l||!c||!s||!i)return!1;const{mapFunc:d}=dt([o]),u=(O=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:O.getSheetBySheetId(c);s.forValue((P,A,k)=>{const{row:N,col:H}=d(P,A),x=u==null?void 0:u.getComposedCellStyle(N,H),L=a.Tools.deepClone(k);if(L.s=x,s.setValue(P,A,L),k.colSpan||k.rowSpan)for(let V=0;V<k.rowSpan;V++)for(let U=0;U<k.colSpan;U++){if(V===0&&U===0)continue;const B=P+V,Y=A+U;s.setValue(B,Y,{s:x})}});const h=this._getPastedRange(s);if(!h)return!1;const g=(M=this._univerInstanceService.getUniverSheetInstance(h.unitId))==null?void 0:M.getSheetBySheetId(h.subUnitId);if(!g)return!1;const S=g==null?void 0:g.getMergeData();if(S&&S.some(A=>po(A,h.pastedRange)&&!Ya(h.pastedRange,A)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const f=this._univerInstanceService.getUnit(l);if(!f)return!1;const v=f.getSheetBySheetId(c);if(!v)return!1;const p=v.getColumnManager(),C=v.getRowManager(),b=[],w=[];if(o.cols.forEach(P=>{b.push({width:`${p.getColumnWidth(P)}`})}),o.rows.forEach(P=>{w.push({height:`${C.getRowHeight(P)}`})}),i.copyType===Je.CUT){const P=h.pastedRange.rows[0],A=o.rows[o.rows.length-1]-o.rows[0]+P;h.pastedRange.rows=Array.from(new Array(A+1).keys()).slice(P)}const E=this._pasteUSM({cellMatrix:s,colProperties:b,rowProperties:w},h,t,{range:o,unitId:i.unitId,subUnitId:i.subUnitId,copyType:i.copyType,copyId:e});return i.copyType===Je.CUT&&(this._copyContentCache.set(e,{...i,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),E}_pasteUSM(e,t,i,o){const{rowProperties:s,colProperties:l,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=t,g=h.cols.length,S=this._clipboardHooks,f=[];if(S.some(P=>{var A;return f.push(P)&&((A=P.onBeforePaste)==null?void 0:A.call(P,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(P=>{var A;return(A=P.onAfterPaste)==null?void 0:A.call(P,!1)}),!1;if(!c)return!1;const p=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,C={copyType:(o==null?void 0:o.copyType)||Je.COPY,copyId:o==null?void 0:o.copyId,pasteType:i};let b=[],w=[];const E=f.filter(P=>!P.specialPasteInfo&&P.id!==Se.DEFAULT_PASTE||i===P.id);E.forEach(P=>{var N,H,x;if(s){const L=(N=P.onPasteRows)==null?void 0:N.call(P,{range:h,unitId:d,subUnitId:u},s,{pasteType:i});L&&(b.push(...L.redos),w.push(...L.undos))}const A=(H=P.onPasteColumns)==null?void 0:H.call(P,{range:h,unitId:d,subUnitId:u},l||new Array(g).map(()=>({})),{pasteType:i});A&&(b.push(...A.redos),w.push(...A.undos));const k=(x=P.onPasteCells)==null?void 0:x.call(P,p,{range:h,unitId:d,subUnitId:u},c,C);k&&(b.push(...k.redos),w.push(...k.undos))});const O=this._getSetSelectionOperation(d,u,h,c,i);O&&b.push(O),b=vo(b),w=vo(w),w.push({id:m.SetWorksheetActiveOperation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId}}),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:w,redoMutationsInfo:b});const M=b.every(P=>this._commandService.syncExecuteCommand(P.id,P.params));return M&&(this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:w,redoMutations:b}),this.updatePasteOptionsCache({target:{pastedRange:h,unitId:d,subUnitId:u},cellMatrix:c,rowProperties:s,colProperties:l,pasteType:i,source:o}),this.setShowMenu(!0)),E.forEach(P=>{var A;return(A=P.onAfterPaste)==null?void 0:A.call(P,M)}),M}_getSetSelectionOperation(e,t,i,o,s){var O;const l=(O=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:O.getSheetBySheetId(t);if(!l)return null;const{rows:c,cols:d}=i,u=c[0],h=d[0],g=c[c.length-1],S=d[d.length-1],f={startRow:u,endRow:u,startColumn:h,endColumn:h},v=m.getPrimaryForRange(f,l),p=o.getValue(0,0),C=(p==null?void 0:p.rowSpan)||1,b=(p==null?void 0:p.colSpan)||1;if((s===Se.DEFAULT_PASTE||s===Se.SPECIAL_PASTE_BESIDES_BORDER||s===Se.SPECIAL_PASTE_FORMAT)&&(C>1||b>1)){const M={startRow:u,endRow:u+C-1,startColumn:h,endColumn:h+b-1};v.startRow=M.startRow,v.endRow=M.endRow,v.startColumn=M.startColumn,v.endColumn=M.endColumn,v.isMerged=!0,v.isMergedMainCell=!0}const E={unitId:e,subUnitId:t,selections:[{range:{startRow:u,endRow:g,startColumn:h,endColumn:S},primary:v,style:null}]};return{id:m.SetSelectionsOperation.id,params:E}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=e.getActiveSheet(),i=this._selectionManagerService.getCurrentLastSelection();return{unitId:e.getUnitId(),subUnitId:t==null?void 0:t.getSheetId(),selection:i}}_transformPastedData(e,t,i){const o=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:c}=o;if(!c||!s)return null;const d=this._injector.invoke(H=>m.rangeToDiscreteRange(s.range,H,l,c));if(!d)return null;const{ranges:[u],mapFunc:h}=dt([d]),{startRow:g,startColumn:S,endRow:f,endColumn:v}=u,p=f-g+1,C=v-S+1,b=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),w=b==null?void 0:b.getActiveSheet();if(!w)return null;const O=w.getMergeData().filter(H=>d.rows.includes(H.startRow)&&d.cols.includes(H.startColumn)),M=O[0];let P=0,A=0,k=0,N=0;if(M&&(P=M.startRow,A=M.startColumn,k=M.endRow,N=M.endColumn),p%e===0&&C%t===0)if(O.length>0&&(p!==e||C!==t))if(P===d.rows[0]&&A===d.cols[0]&&k===d.rows[p-1]&&N===d.cols[C-1])if(tm(i))for(let x=0;x<p;x++)for(let L=0;L<C;L++){const V=i.getValue(x%e,L%t);V&&i.setValue(x,L,V)}else i.forValue((x,L,V)=>{V.s=null,delete V.colSpan,delete V.rowSpan});else for(let H=0;H<p;H++)for(let x=0;x<C;x++){const L=i.getValue(H%e,x%t);L&&i.setValue(H,x,L)}else for(let H=0;H<p;H++)for(let x=0;x<C;x++){const L=i.getValue(H%e,x%t);L&&i.setValue(H,x,L)}else if(O.length>0){const{row:H,col:x}=h(g,S);if(this._topLeftCellsMatch(e,t,{topRow:H,leftCol:x})){const V=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=V.rows,d.cols=V.cols}else{if(f>M.endRow||v>M.endColumn)return null;i.forValue((V,U,B)=>{B.s=null,delete B.colSpan,delete B.rowSpan})}}else{const H=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=H.rows,d.cols=H.cols}return{pastedRange:d,unitId:l,subUnitId:c}}_getPastedRange(e){var w;const t=this._getPastingTarget(),{selection:i,unitId:o,subUnitId:s}=t;if(!s||!i)return null;const l=this._injector.invoke(E=>m.rangeToDiscreteRange(i.range,E,o,s));if(!l)return null;const{startColumn:c,endColumn:d,startRow:u,endRow:h}=e.getDataRange(),g=h-u+1,S=d-c+1;if(g<=0||S<=0)return null;const f=l.rows.length,v=l.cols.length,p=(w=this._univerInstanceService.getUniverSheetInstance(o))==null?void 0:w.getSheetBySheetId(s);if(!p)return null;const C=p==null?void 0:p.getMergeData();if(f%g===0&&v%S===0&&!(C==null?void 0:C.some(O=>po(O,l)))){for(let O=0;O<f;O++)for(let M=0;M<v;M++){const P=e.getValue(O%g,M%S);P&&e.setValue(O,M,P)}return{pastedRange:l,unitId:o,subUnitId:s}}const b=this._expandOrShrinkRowsCols(o,s,l,S,g);return l.rows=b.rows,l.cols=b.cols,{pastedRange:l,unitId:o,subUnitId:s}}_expandOrShrinkRowsCols(e,t,i,o,s){const{rows:l,cols:c}=i,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(t);let h,g;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let S=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(S)||h.push(S),S++}if(c.length>=o)g=c.slice(0,o);else{g=c.slice(0);let S=c[c.length-1]+1;for(;g.length<o;)g.push(S),S++}return{rows:h,cols:g}}_topLeftCellsMatch(e,t,i){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:c}=i,d=$h(l+e-1,c,c+t-1,s),u=em(c+t-1,l,l+e-1,s);return!d&&!u}removeMarkSelection(){this._copyMarkId&&(this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null)}_initUnitDisposed(){this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&this.copyContentCache().clearWithUnitId(e.getUnitId())}))}disposePasteOptionsCache(){this.setShowMenu(!1),this.updatePasteOptionsCache(null)}},y.SheetClipboardService=qh([Me(0,a.ILogService),Me(1,a.IUniverInstanceService),Me(2,a.Inject(m.SheetsSelectionsService)),Me(3,_.IClipboardInterfaceService),Me(4,a.IUndoRedoService),Me(5,a.ICommandService),Me(6,Mt),Me(7,_.INotificationService),Me(8,_.IPlatformService),Me(9,R.IRenderManagerService),Me(10,a.Inject(a.ThemeService)),Me(11,a.Inject(a.LocaleService)),Me(12,a.Inject(a.ErrorService)),Me(13,a.Inject(a.Injector))],y.SheetClipboardService);function ja(n){let r="";const e=n.getLength();return n.forRow((t,i)=>{const o=[];i.forEach(s=>{const l=n.getValue(t,s);if(l){const c=Jh(l);o.push(c)}}),r+=o.join(" "),t!==e-1&&(r+=`
|
|
19
|
-
`)}),r}function Jh(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function $h(n,r,e,t){return t.getMergeData().some(i=>i.startRow<=n&&n<i.endRow&&r<=i.startColumn&&i.startColumn<=e)}function em(n,r,e,t){return t.getMergeData().some(i=>i.startColumn<=n&&n<i.endColumn&&r<=i.startRow&&i.startRow<=e)}function tm(n){let r=0;return n.forValue((e,t,i)=>{if(i&&r++,r>1)return!1}),r>1}function Zn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Co=998,Be={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Co,preconditions:lo,handler:async n=>n.get(We).copy()},Ji={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Co,preconditions:lo,handler:async n=>n.get(We).cut()},Fe={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Co,preconditions:lo,handler:async(n,r)=>{const t=await n.get(_.IClipboardInterfaceService).read(),i=n.get(We);return t.length!==0?i.paste(t[0],r==null?void 0:r.value):!1}},$i={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,r)=>{const e=n.get(We),{htmlContent:t,textContent:i,files:o}=r;return e.legacyPaste(t,i,o),!0}},un={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_VALUE})},hn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_FORMAT})},Pt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_COL_WIDTH})},mn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_BESIDES_BORDER})},Ga={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:r})=>n.get(We).rePasteWithPasteType(r)},Kn={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),i=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(i);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(Ys(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetRowHiddenCommand.id),!0}},qn={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),i=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(i);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(js(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetColHiddenCommand.id),!0}},Ot={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatBoldCommand.id):r.executeCommand(m.SetBoldCommand.id)}},At={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatItalicCommand.id):r.executeCommand(m.SetItalicCommand.id)}},Dt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatUnderlineCommand.id):r.executeCommand(m.SetUnderlineCommand.id)}},kt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatStrikethroughCommand.id):r.executeCommand(m.SetStrikeThroughCommand.id)}},_o={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatSubscriptCommand.id):!1}},Io={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatSuperscriptCommand.id):!1}},Qn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,r)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatFontSizeCommand.id,r):e.executeCommand(m.SetFontSizeCommand.id,r)}},Jn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,r)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatFontFamilyCommand.id,r):e.executeCommand(m.SetFontFamilyCommand.id,r)}},gn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,r)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatTextColorCommand.id,r):e.executeCommand(m.SetTextColorCommand.id,r)}},bo={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const r=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),i=n.get(a.ThemeService);return t?r.executeCommand(q.SetInlineFormatTextColorCommand.id,{value:null}):r.executeCommand(m.SetTextColorCommand.id,{value:i.getColorFromTheme("gray.900")})}};var nm=Object.getOwnPropertyDescriptor,im=(n,r,e,t)=>{for(var i=t>1?void 0:t?nm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Sn=(n,r)=>(e,t)=>r(e,t,n),Oe=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Oe||{});const je=a.createIdentifier("univer.format-painter-service");let er=class extends a.Disposable{constructor(r,e,t,i,o,s){super();T(this,"status$");T(this,"_selectionFormat");T(this,"_markId",null);T(this,"_status$");T(this,"_defaultHook",null);T(this,"_extendHooks",[]);this._selectionManagerService=r,this._themeService=e,this._markSelectionService=t,this._logService=i,this._commandService=o,this._undoRedoService=s,this._status$=new D.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(r){var e,t,i;r.isDefaultHook&&((e=r.priority)!=null?e:0)>((i=(t=this._defaultHook)==null?void 0:t.priority)!=null?i:-1)?this._defaultHook=r:(this._extendHooks.push(r),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(r){this._updateRangeMark(r),this._status$.next(r),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(r)})}getStatus(){return this._status$.getValue()}setSelectionFormat(r){this._selectionFormat=r}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(r,e,t){const i=this.getHooks(),o=[],s=[];i.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(r,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of i)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:r,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:s,redoMutations:o}),l}_updateRangeMark(r){if(this._markSelectionService.removeAllShapes(),r!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=Ha(this._themeService);r===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};er=im([Sn(0,a.Inject(m.SheetsSelectionsService)),Sn(1,a.Inject(a.ThemeService)),Sn(2,Mt),Sn(3,a.ILogService),Sn(4,a.ICommandService),Sn(5,a.IUndoRedoService)],er);const $n={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,r)=>r?(n.get(je).setStatus(r.status),!0):!1},tr={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(je).getStatus();let t;return e!==Oe.OFF?t=Oe.OFF:t=Oe.INFINITE,n.get(a.ICommandService).executeCommand($n.id,{status:t})}},fn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(je).getStatus();let t;return e!==Oe.OFF?t=Oe.OFF:t=Oe.ONCE,n.get(a.ICommandService).executeCommand($n.id,{status:t})}},ei={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,r)=>n.get(je).applyFormatPainter(r.unitId,r.subUnitId,r.range)},$e={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,r)=>{const{type:e}=r||{},t=n.get(a.IUniverInstanceService),i=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(R.IRenderManagerService).getRenderById(s).with(y.SheetScrollManagerService),{sheetViewStartRow:v=0,sheetViewStartColumn:p=0}=f.getCurrentScrollState()||{};let C,b,w,E;const{startRow:O,startColumn:M,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=O,w=O-v,b=-1,E=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,w=0,b=M,E=M-p;else if(P===a.RANGE_TYPE.NORMAL)C=O,w=O-v,b=M,E=M-p;else return!1;const A={unitId:s,subUnitId:l,startRow:C,startColumn:b,xSplit:b>0?Math.max(1,E):E,ySplit:C>0?Math.max(1,w):w},k=m.SetFrozenMutationFactory(n,A);return c.syncExecuteCommand(m.SetFrozenMutation.id,A)&&i.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:k}],redoMutations:[{id:m.SetFrozenMutation.id,params:A}]}),!0}},ti={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand($e.id,{type:1}),!0)},ni={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand($e.id,{type:2}),!0)};var rm=Object.getOwnPropertyDescriptor,om=(n,r,e,t)=>{for(var i=t>1?void 0:t?rm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Za=(n,r)=>(e,t)=>r(e,t,n);const sm=(n,r)=>{const{unitId:e,subUnitId:t,ranges:i}=n,o={},s=r.getColumnManager();for(let l=0;l<i.length;l++){const c=i[l];for(let d=c.startColumn;d<c.endColumn+1;d++)o[d]=s.getColumnWidth(d)}return{unitId:e,subUnitId:t,ranges:i,colWidth:o}};y.AutoWidthController=class extends a.Disposable{constructor(r,e){super(),this._renderManagerService=r,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(r){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,i=m.getSheetCommandTarget(t);if(!i)return e;const{unitId:o,subUnitId:s,worksheet:l}=i,c=this._renderManagerService.getRenderById(o).with(y.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(r.ranges),h={};for(const{col:f,width:v}of u)h[f]=v;const g={subUnitId:s,unitId:o,ranges:r.ranges,colWidth:h},S=sm(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}},y.AutoWidthController=om([Za(0,R.IRenderManagerService),Za(1,a.Inject(a.IUniverInstanceService))],y.AutoWidthController);const ii={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,r)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,r);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(r!=null&&r.ranges)d=[...r.ranges];else{const f=i.getCurrentSelections();for(let v=0;v<f.length;v++)d.push(f[v].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(y.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Ka="UI_PLUGIN_SHEETS",Ge=`${Ka}_MENU_ITEM_INPUT_COMPONENT`,qa=n=>{const{prefix:r,suffix:e,value:t,onChange:i,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=W.useState(),h=S=>{if(!S){u(o.toString());return}const f=S.toString();u(f),i(f)};W.useEffect(()=>{c.visible||u(t)},[c.visible]),W.useEffect(()=>{+t<o?u(o.toString()):+t>s?u(s.toString()):u(t)},[t]);function g(){d&&i(d)}return I.jsxs("div",{className:"univer-inline-flex univer-items-center univer-gap-1",children:[l.t(r),I.jsx("div",{className:"univer-w-16",onClick:S=>S.stopPropagation(),children:I.jsx(X.InputNumber,{value:Number(d),size:"mini",precision:0,min:o,max:s,onPressEnter:g,onChange:h})}),l.t(e)]})};function am(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(de.switchMap(r=>r?r.activeSheet$.pipe(de.map(e=>e?{workbook:r,worksheet:e}:null)):D.of(null)))}function be(n,r,e){return am(n).pipe(de.switchMap(t=>t?e(t):D.of(r)))}function Qa(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),i=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(de.switchMap(s=>s?D.combineLatest([i.selectionMoveEnd$,s.activeSheet$]).pipe(de.switchMap(([l,c])=>{if(!c||l.length===0)return D.of(!1);const d=t.getInterestGroupId(l);if(r){const u=d.filter(h=>r.has(h));return D.of(u.length>0)}else return D.of(d.length>0)})):D.of(!1)))}function Nt(n,r,e){return D.combineLatest([r,Qa(n,e)]).pipe(de.map(([t,i])=>t||i))}function ee(n,r={},e=!1){var g;const i=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(me)?n.get(me):null,l=n.get(a.IContextService),d=((g=s==null?void 0:s.visible$)!=null?g:D.of(null)).pipe(de.startWith(null),de.shareReplay(1)),u=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).pipe(de.startWith(!1),de.shareReplay(1));return D.combineLatest([o.currentUser$,i,d,u]).pipe(de.switchMap(([S,f,v,p])=>!f||v!=null&&v.visible&&v.unitId===f.getUnitId()&&!e||p&&!e?D.of(!0):f.activeSheet$.pipe(de.switchMap(C=>{if(!C)return D.of(!0);const b=n.get(m.SheetsSelectionsService),w=n.get(m.RangeProtectionRuleModel),E=n.get(m.WorksheetProtectionRuleModel),M=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(de.startWith(!1));return D.combineLatest([b.selectionMoveEnd$,M]).pipe(de.switchMap(([P,A])=>{if(A)return D.of(!0);const k=f.getUnitId(),N=C.getSheetId(),H=n.get(a.IPermissionService),{workbookTypes:x=[m.WorkbookEditablePermission],worksheetTypes:L,rangeTypes:V}=r,U=[];if(x==null||x.forEach(z=>{U.push(new z(k).id)}),L==null||L.forEach(z=>{U.push(new z(k,N).id)}),E.getRule(k,N))return H.composePermission$(U).pipe(de.map(z=>z.some(j=>j.value===!1)));const Y=P==null?void 0:P.map(z=>z.range),F=w.getSubunitRuleList(k,N).filter(z=>Y==null?void 0:Y.some(j=>z.ranges.some(Q=>a.Rectangle.intersects(j,Q))));return V==null||V.forEach(z=>{F.forEach(j=>{U.push(new z(k,N,j.permissionId).id)})}),H.composePermission$(U).pipe(de.map(z=>z.some(j=>j.value===!1)))}))}))))}function vn(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),i=n.get(a.IPermissionService);return D.merge(e.selectionMoveEnd$,i.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),i.composePermission(u).some(g=>g.value===!1)}))}function Ja(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return D.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return i.getSubunitRuleList(d,u).filter(S=>r==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function $a(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return D.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return r==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(v=>a.Rectangle.intersects(g,v))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function nr(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return D.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return r==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(v=>a.Rectangle.intersects(g,v))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function pn(n,r){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return D.combineLatest([l.currentUser$,t]).pipe(de.switchMap(([c,d])=>d?d.activeSheet$.pipe(de.switchMap(u=>{if(!u)return D.of(!0);const h=d.getUnitId(),g=[];return r.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(de.map(f=>f.every(v=>v.value===!0))).pipe(de.map(f=>{if(!f)return!0;const v=u.getSheetId(),p=i.getRule(h,v),C=o.getSubunitRuleList(h,v);return!!(p||C.length)}))})):D.of(!0)))}var el=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(el||{});function lm(n){const r=n.get(je);return{id:fn.id,subId:tr.id,type:_.MenuItemType.BUTTON,icon:"BrushIcon",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new D.Observable(e=>{let t=!1;const i=r.status$.subscribe(o=>{t=o!==Oe.OFF,e.next(t)});return e.next(t),()=>{i.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function cm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),i=n.get(m.SheetsSelectionsService);return{id:Ot.id,type:_.MenuItemType.BUTTON,icon:"BoldIcon",title:"Set bold",tooltip:"toolbar.bold",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=i.getCurrentLastSelection())==null?void 0:S.primary;let p=a.FontWeight.NORMAL;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getFontWeight()}s.next(p===a.FontWeight.BOLD)}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.bl;s.next(p===a.BooleanNumber.TRUE)}}),c=(u=i.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function dm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:At.id,type:_.MenuItemType.BUTTON,icon:"ItalicIcon",title:"Set italic",tooltip:"toolbar.italic",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let p=a.FontItalic.NORMAL;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getFontStyle()}s.next(p===a.FontItalic.ITALIC)}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.it;s.next(p===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function um(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:Dt.id,type:_.MenuItemType.BUTTON,icon:"UnderlineIcon",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let p;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getUnderline()}s.next(!!(p&&p.s))}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.ul;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function hm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:kt.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughIcon",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let p;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getStrikeThrough()}s.next(!!(p&&p.s))}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.st;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function mm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=a.DEFAULT_STYLES.ff;return{id:Jn.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:_.FONT_FAMILY_COMPONENT,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:_.FONT_FAMILY_ITEM_COMPONENT},value:o.value})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,i,({worksheet:o})=>new D.Observable(s=>{const l=()=>{var h;let d=i;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const g=o.getCellStyle(u.startRow,u.startColumn),S=o.getDefaultCellStyleInternal(),f=o.getRowStyle(u.startRow),v=o.getColumnStyle(u.startColumn),p=a.composeStyles(S,f,v,g);p.ff&&(d=p.ff)}s.next(d)},c=r.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function gm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:Qn.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:_.FONT_SIZE_COMPONENT,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new D.Observable(c=>{const d=()=>{var f;let g=o;const S=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(S!=null){const v=l.getComposedCellStyle(S.startRow,S.startColumn);v.fs&&(g=v.fs)}c.next(g)},u=()=>{var S,f;const g=si(n);if(g!=null){const v=(f=(S=g.ts)==null?void 0:S.fs)!=null?f:o;c.next(v)}},h=r.onCommandExecuted(g=>{const S=g.id;(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id)&&d(),(S===_e.SetTextSelectionsOperation.id||S===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Sm(n){return{id:bo.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColorDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function fm(n){const r=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:gn.id,icon:"FontColorDoubleIcon",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:_.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1}}],value$:new D.Observable(t=>{const i=e.getColorFromTheme("gray.900"),o=r.onCommandExecuted(s=>{if(s.id===gn.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function vm(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColorDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function pm(n){const r=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucketDoubleIcon",selections:[{label:{name:_.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1}}],value$:new D.Observable(t=>{const i=e.getColorFromTheme("primary.600"),o=r.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const tl=[{label:"align.left",icon:"LeftJustifyingIcon",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallyIcon",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingIcon",value:a.HorizontalAlign.RIGHT}];function Cm(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:tl[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:tl,value$:be(r,t,({worksheet:i})=>new D.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);S=v==null?void 0:v.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const nl=[{label:"align.top",icon:"AlignTopIcon",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterIcon",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomIcon",value:a.VerticalAlign.BOTTOM}];function _m(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:nl[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:nl,value$:be(r,t,({worksheet:i})=>new D.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);S=v==null?void 0:v.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const il=[{label:"textWrap.overflow",icon:"OverflowIcon",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapIcon",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationIcon",value:a.WrapStrategy.CLIP}];function Im(n){const r=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:il[0].icon,type:_.MenuItemType.SELECTOR,selections:il,value$:be(e,t,({worksheet:i})=>new D.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=r.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);S=v==null?void 0:v.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=r.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const rl=[{label:"textRotate.none",icon:"NoRotationIcon",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesIcon",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesIcon",value:45},{label:"textRotate.vertical",icon:"VerticalTextIcon",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesIcon",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesIcon",value:90}];function bm(n){const r=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:rl[0].icon,type:_.MenuItemType.SELECTOR,selections:rl,value$:be(e,t,({worksheet:i})=>new D.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var v,p;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(v=r.getCurrentLastSelection())==null?void 0:v.primary;let f;if(S!=null){const C=i.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((p=f&&f.a)!=null?p:t)}),l=(d=r.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=i.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function ri(n){return new D.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function Cn(n){return{id:Be.name,commandId:Be.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"CopyDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wo(n){return{id:Fe.name,commandId:Fe.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecialDoubleIcon",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const oi="sheet.menu.paste-special";function Eo(n){return{id:oi,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecialDoubleIcon",title:"rightClick.pasteSpecial",hidden$:Nt(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function To(n){return{id:un.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function yo(n){return{id:hn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ro(n){return{id:Pt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e))}}function Mo(n){return{id:mn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wm(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeightDoubleIcon",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Em(n){return{id:ii.id,type:_.MenuItemType.BUTTON,icon:"AutoWidthDoubleIcon",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const ol="sheet.menu.sheet-frozen";function Tm(n){return{id:ol,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Po="sheet.header-menu.sheet-frozen";function sl(n){return{id:Po,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Oo(n){return{id:$e.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ym(n){return{id:ti.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rm(n){return{id:ni.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ao(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Mm(n){return{id:Kn.id,type:_.MenuItemType.BUTTON,icon:"HideDoubleIcon",title:"rightClick.hideSelectedRow",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Pm(n){return{id:qn.id,type:_.MenuItemType.BUTTON,icon:"HideDoubleIcon",title:"rightClick.hideSelectedColumn",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Om(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,icon:"EyeOutlineIcon",title:"rightClick.showHideRow",hidden$:be(r,!0,({worksheet:o})=>new D.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Am(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,icon:"EyeOutlineIcon",title:"rightClick.showHideColumn",hidden$:be(r,!0,({worksheet:o})=>new D.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Dm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=2;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeightDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.rowHeight",suffix:"px",min:i,max:1e3}},value$:be(e,i,({worksheet:o})=>new D.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):o.getConfig().defaultRowHeight;s.next(u)}const c=r.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function km(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=2;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidthDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.columnWidth",suffix:"px",min:i,max:1e3}},value$:be(e,i,({worksheet:o})=>new D.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getColumnWidth(d.startColumn):o.getConfig().defaultColumnWidth;s.next(u)}const c=r.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function si(n){var c;const r=n.get(a.IUniverInstanceService),e=n.get(_e.DocSelectionManagerService),t=r.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),i=e.getActiveTextRange();if(t==null||i==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var Nm=Object.getOwnPropertyDescriptor,Hm=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Ht=(n,r)=>(e,t)=>r(e,t,n);const Vm="__SpreadsheetFreezeRowMainName__",Wm="__SpreadsheetFreezeRowHeaderName__",xm="__SpreadsheetFreezeColumnMainName__",Lm="__SpreadsheetFreezeColumnHeaderName__",Do=2,Um=.01,ai=a.createInterceptorKey("freezePermissionCheck");y.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,i,o,s,l,c,d){super();T(this,"_rowFreezeHeaderRect");T(this,"_rowFreezeMainRect");T(this,"_columnFreezeHeaderRect");T(this,"_columnFreezeMainRect");T(this,"_freezeDownSubs");T(this,"_freezePointerEnterSubs");T(this,"_freezePointerLeaveSubs");T(this,"_scenePointerMoveSub");T(this,"_scenePointerUpSub");T(this,"_changeToRow",-1);T(this,"_changeToColumn",-1);T(this,"_changeToOffsetX",0);T(this,"_changeToOffsetY",0);T(this,"_activeViewport",null);T(this,"_freezeNormalHeaderColor","");T(this,"_freezeNormalMainColor","");T(this,"_freezeActiveColor","");T(this,"_freezeHoverColor","");T(this,"_lastFreeze");T(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:ai}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=i,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var A;const i=t!=null?t:this._getFreeze();if(i==null)return null;const o=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton,{startRow:s,startColumn:l}=i,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:v}=c,{rowTotalHeight:p,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:b,columnHeaderHeightAndMarginTop:w}=o,E=h>C+b?h:C+w,O=g>p+w?g:p+w;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=v;const M=Math.max(S.scaleX,S.scaleY);let P=Do/Math.max(1,M);if(e===0){(s===-1||s===0)&&(P=P*2);const k=P;this._rowFreezeHeaderRect=new R.Rect(Wm,{fill:this._freezeNormalHeaderColor,width:b,height:P,left:0,top:v-k,zIndex:3});let N=this._freezeNormalHeaderColor;(s===-1||s===0)&&(N=this._freezeNormalMainColor),this._rowFreezeMainRect=new R.Rect(Vm,{fill:N,width:E*2/M,height:P,left:b,top:v-k,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],st)}else{(l===-1||l===0)&&(P=P*2);const k=P;this._columnFreezeHeaderRect=new R.Rect(Lm,{fill:this._freezeNormalHeaderColor,width:P,height:w,left:f-k,top:0,zIndex:3});let N=this._freezeNormalHeaderColor;(l===-1||l===0)&&(N=this._freezeNormalMainColor),this._columnFreezeMainRect=new R.Rect(xm,{fill:N,width:P,height:O*2/M,left:f-k,top:w,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],st)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,i=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,i=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new D.Subscription,this._freezePointerLeaveSubs=new D.Subscription,this._freezeDownSubs=new D.Subscription,i){const d=i.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(R.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=i.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(R.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,i,e)});l&&this._freezeDownSubs.add(l);const c=i==null?void 0:i.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,i,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,b,w,E,O,M,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const i=e.scene,o=Math.max(i.scaleX,i.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(b=s==null?void 0:s.sheetViewStartRow)!=null?b:0,u=d===0?-((w=s==null?void 0:s.offsetY)!=null?w:0):t.rowHeightAccumulation[d-1]-((E=s==null?void 0:s.offsetY)!=null?E:0);let h=0,g=!1;for(let A=d,k=t.rowHeightAccumulation.length;A<k;A++)if(t.rowHeightAccumulation[A]-u>l){h=A,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(O=s==null?void 0:s.sheetViewStartColumn)!=null?O:0,f=S===0?-((M=s==null?void 0:s.offsetX)!=null?M:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let v=0,p=!1;for(let A=S,k=t.columnWidthAccumulation.length;A<k;A++)if(t.columnWidthAccumulation[A]-f>c){v=A,p=!0;break}return p||(v=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:v}}_getActiveViewport(e){var i;const t=(i=this._getSheetObject())==null?void 0:i.scene.getViewports();return t&&t.find(o=>o.isHit(new R.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,i,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;const{scene:d}=l;d.setCursor(R.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(v=>{var P,A,k,N;const p=this._getActiveViewport(v),{startX:C,startY:b,row:w,column:E}=ze(v.offsetX,v.offsetY,d,s,p||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;d.setCursor(R.CURSOR_TYPE.GRABBING);const M=Do/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(b,h)-M/2}))==null||P.setProps({fill:this._freezeActiveColor}),(A=i.transformByState({top:Math.min(b,h)-M/2}))==null||A.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?w:Math.min(w,u.lastRow),this._changeToOffsetY=Math.min(b,h),this._activeViewport=p):((k=t.transformByState({left:Math.min(C,g)-M/2}))==null||k.setProps({fill:this._freezeActiveColor}),(N=i.transformByState({left:Math.min(C,g)-M/2}))==null||N.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?E:Math.min(E,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=p)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var H,x;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:v,columnHeaderHeightAndMarginTop:p}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),i.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),i==null||i.setProps({fill:this._freezeNormalHeaderColor}));const C=Do/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:p-C}),i.transformByState({top:p-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:v-C}),i.transformByState({left:v-C}));const b=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:w,sheetViewStartColumn:E}=b;if(E==null||w==null)return;const O=this._context.unit,M=O.getActiveSheet();if(!M)return;const P=(H=M.getConfig())==null?void 0:H.freeze;let A=(P==null?void 0:P.xSplit)||0,k=(P==null?void 0:P.ySplit)||0;const N=(x=this._activeViewport)==null?void 0:x.viewportKey;o===0&&(!N||N===R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?k=this._changeToRow-(P.startRow-P.ySplit):k=this._changeToRow-w,k=k<0?0:k),o===1&&(!N||N===R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||N===R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?A=this._changeToColumn-(P.startColumn-P.xSplit):A=this._changeToColumn-E,A=A<0?0:A),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:k===0?-1:this._changeToRow,startColumn:A===0?-1:this._changeToColumn,ySplit:k,xSplit:A,unitId:O.getUnitId(),subUnitId:M.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,i=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(i==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:i,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:i,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),i.isActive&&i.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,i=0,o=0,s=3){var A;const l=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:v,viewColumnRight:p,viewRowTop:C,viewRowBottom:b,viewLeftTop:w}=u;p.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),b.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),w.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let E=!0,O=!0;g.enable(),(e===-1||e===0)&&(E=!1),(t===-1||t===0)&&(O=!1);const M=l.getNoMergeCellWithCoordByIndex(e-i,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),v.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),v.resetPadding(),E===!1&&O===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:0}),v.resizeWhenFreezeChange({left:0,top:0,height:d+1,width:0});else if(E===!0&&O===!1){const k=P.startY-M.startY;h.resizeWhenFreezeChange({left:c,top:d+k,bottom:0,right:0}),h.setPadding({startY:M.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(Ue.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:M.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:k}),C.updateScrollVal({viewportScrollY:M.startY}),b.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c+1}),f.enable(),C.enable()}else if(E===!1&&O===!0){const k=P.startX-M.startX;h.resizeWhenFreezeChange({left:c+k,top:d,bottom:0,right:0}),h.setPadding({startX:M.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(Ue.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:k,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:M.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),v.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),v.updateScrollVal({viewportScrollX:M.startX}),p.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),S.enable(),v.enable()}else{const k=P.startX-M.startX,N=P.startY-M.startY;h.resizeWhenFreezeChange({left:c+k,top:d+N,bottom:0,right:0}),h.setPadding({startY:M.startY,endY:P.startY,startX:M.startX,endX:P.startX}),s&&this._commandService.executeCommand(Ue.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+N,width:k,bottom:0}),S.updateScrollVal({viewportScrollX:M.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+k,top:d,height:N,right:0}),f.updateScrollVal({viewportScrollY:M.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:k,height:N}),g.updateScrollVal({viewportScrollX:M.startX,viewportScrollY:M.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:N}),C.updateScrollVal({viewportScrollY:M.startY}),b.resizeWhenFreezeChange({left:0,top:d+N,bottom:0,width:c+1}),v.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),v.updateScrollVal({viewportScrollX:M.startX}),p.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),v.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const i=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=i;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=a.get(e,"gray.300"),this._freezeNormalMainColor=new a.ColorKit(this._freezeNormalHeaderColor).setAlpha(Um).toRgbString(),this._freezeActiveColor=a.get(e,"primary.600"),this._freezeHoverColor=a.get(e,"gray.500")}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},i=this._getFreeze();if(!i)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<i.startRow||l.startRow+1===i.startRow&&c===a.Direction.UP){const u={...i,startRow:Math.max(1,i.startRow+d),ySplit:Math.max(1,i.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<i.startColumn||l.startColumn+1===i.startColumn&&c===a.Direction.LEFT){const u={...i,startColumn:Math.max(1,i.startColumn+d),xSplit:Math.max(1,i.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!i||i.startColumn<=0||u.startColumn>=i.startColumn&&h.startColumn>=i.startColumn||u.startColumn===h.startColumn||u.endColumn<i.startColumn&&h.startColumn<i.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(i.startColumn,u.endColumn+1)-u.startColumn,0);let f,v;h.startColumn>=i.startColumn?(f=Math.max(i.startColumn-S,1),v=Math.max(i.xSplit-S,1)):(f=i.startColumn+g-S,v=i.xSplit+g-S);const p={...i,startColumn:f,xSplit:v};return o(p)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!i||i.startRow<=0||u.startRow>=i.startRow&&h.startRow>=i.startRow||u.startRow===h.startRow||u.endRow<i.startRow&&h.startRow<i.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(i.startRow,u.endRow+1)-u.startRow,0);let f,v;h.startRow>=i.startRow?(f=Math.max(i.startRow-S,1),v=Math.max(i.ySplit-S,1)):(f=i.startRow+g-S,v=i.ySplit+g-S);const p={...i,startRow:f,ySplit:v};return o(p)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<i.startColumn){const c=Math.min(i.startColumn,l.endColumn+1)-l.startColumn,d={...i,startColumn:Math.max(1,i.startColumn-c),xSplit:Math.max(1,i.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<i.startRow){const c=Math.min(i.startRow,l.endRow+1)-l.startRow,d={...i,startRow:Math.max(1,i.startRow-c),ySplit:Math.max(1,i.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Ne.id:{const t=this._lastFreeze,i=this._context.unit,o=i.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===i.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),i=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&i&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(i=>i.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,i=this._getFreeze();if(i&&i.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<i.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,i=this._getFreeze(),o=t.ranges;i&&i.startColumn>-1&&o.some(s=>s.startColumn<i.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,i=this._getFreeze(),o=t.ranges;i&&i.startRow>-1&&o.some(s=>s.startRow<i.startRow)&&this._refreshCurrent()}break;case Ni.id:case Hi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(i=>{[R.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,R.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(i.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,i;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(i=this._scenePointerUpSub)==null||i.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,i,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return ke(this._context.unit,this._context)}_refreshFreeze(e,t,i,o,s){var c;const l={startRow:e,startColumn:t,ySplit:i,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,i,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}},y.HeaderFreezeRenderController=Hm([Ht(1,a.Inject(y.SheetSkeletonManagerService)),Ht(2,a.ICommandService),Ht(3,a.Inject(m.SheetsSelectionsService)),Ht(4,a.Inject(y.SheetScrollManagerService)),Ht(5,a.Inject(a.ThemeService)),Ht(6,a.Inject(m.SheetInterceptorService)),Ht(7,a.Inject(a.Injector))],y.HeaderFreezeRenderController);function Bm(n){const r=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),i=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return D.combineLatest([r.selectionMoveEnd$,o.pipe(D.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(D.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:D.of(null)}))]).pipe(D.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(i.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(v=>a.Rectangle.intersects(v,S)&&!a.Rectangle.contains(v,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function al(n,r){return!!li(n,r,a.RANGE_TYPE.ROW)}function ll(n,r){return!!li(n,r,a.RANGE_TYPE.COLUMN)}function li(n,r,e){return n.find(i=>{const o=i.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=r&&r<=d||e===a.RANGE_TYPE.ROW&&s<=r&&r<=l)})}var Fm=Object.getOwnPropertyDescriptor,zm=(n,r,e,t)=>{for(var i=t>1?void 0:t?Fm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ko=(n,r)=>(e,t)=>r(e,t,n);const Xm="__SpreadsheetHeaderMoveControllerBackground__",Ym="__SpreadsheetHeaderMoveControllerShapeLine__",jm="rgba(0, 0, 0, 0.1)",Gm="rgb(119, 119, 119)",Zm=4,No=a.createInterceptorKey("headerMovePermissionCheck");y.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,i,o){super();T(this,"_startOffsetX",Number.NEGATIVE_INFINITY);T(this,"_startOffsetY",Number.NEGATIVE_INFINITY);T(this,"_moveHelperBackgroundShape");T(this,"_moveHelperLineShape");T(this,"_headerPointerDownSubs");T(this,"_headerPointerMoveSubs");T(this,"_headerPointerLeaveSubs");T(this,"_dragHeaderMoveSub");T(this,"_scenePointerUpSub");T(this,"_scrollTimer");T(this,"_changeFromColumn",-1);T(this,"_changeFromRow",-1);T(this,"_changeToColumn",-1);T(this,"_changeToRow",-1);T(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:No}));T(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=i,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,i,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(i=this._headerPointerMoveSubs)==null||i.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),i=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?i:t,l=u=>{var b,w;const h=(b=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:b.skeleton;if(h==null)return;const g=(w=this._workbookSelections.getCurrentLastSelection())==null?void 0:w.range;if(!g||!this.interceptor.fetchThroughInterceptors(No)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:v,column:p}=ze(u.offsetX,u.offsetY,o,h);if(!li(f,e===a.RANGE_TYPE.ROW?v:p,e)){o.resetCursor();return}o.setCursor(R.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var L,V;if(h.isStopPropagation)return;const g=(L=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:L.skeleton;if(g==null)return;const S=(V=this._workbookSelections.getCurrentLastSelection())==null?void 0:V.range;if(!S||!this.interceptor.fetchThroughInterceptors(No)(!1,S))return;const{offsetX:v,offsetY:p}=u,C=o.getCoordRelativeToViewport(R.Vector2.FromArray([v,p])),{x:b,y:w}=C;this._startOffsetX=b,this._startOffsetY=w;const{row:E,column:O}=ze(u.offsetX,u.offsetY,o,g);let M;e===a.RANGE_TYPE.ROW?(this._changeFromRow=E,M=R.ScrollTimerType.Y):(this._changeFromColumn=O,M=R.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),A=li(P,e===a.RANGE_TYPE.ROW?E:O,e);if(!A)return;const k=o.getScrollXYInfoByViewport(R.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(R.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let N=!1,H;const x=()=>{if(N)return;H=R.ScrollTimer.create(o,M),this._scrollTimer=H;const U=o.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN);H.startScroll(b,w,U),N=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{x();const{offsetX:B,offsetY:Y}=U,{x:F,y:z}=o.getCoordRelativeToViewport(R.Vector2.FromArray([B,Y]));this._rowColumnMoving(F,z,A,k,e),H.scrolling(F,z,()=>{this._rowColumnMoving(F,z,A,k,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var B,Y,F;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(B=this._scrollTimer)==null||B.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const j=(Y=((U==null?void 0:U.filter(Q=>Q.range.rangeType===a.RANGE_TYPE.ROW&&Q.range.startRow<=this._changeFromRow&&this._changeFromRow<=Q.range.endRow))||[])[0])==null?void 0:Y.range;j&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:j,toRange:{...j,startRow:this._changeToRow,endRow:this._changeToRow+j.endRow-j.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const j=(F=((U==null?void 0:U.filter(Q=>Q.range.rangeType===a.RANGE_TYPE.COLUMN&&Q.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=Q.range.endColumn))||[])[0])==null?void 0:F.range;j&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:j,toRange:{...j,startColumn:this._changeToColumn,endColumn:this._changeToColumn+j.endColumn-j.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new D.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new D.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new D.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,i,o,s){var z,j,Q,ie,$,se,Z;const l=this._context.scene,c=(z=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:z.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:v}=l.getAncestorScale(),p=c.getCellIndexByOffset(e,t,f,v,S),{row:C,column:b}=p,w=c.getNoMergeCellWithCoordByIndex(C,b),{startX:E,startY:O,endX:M,endY:P}=w,A=this._sheetSkeletonManagerService.attachRangeWithCoord(i.range);if(A==null)return;const k=Math.max(f,f),{startX:N,endX:H,startY:x,endY:L,startRow:V,startColumn:U,endRow:B,endColumn:Y}=A;s===a.RANGE_TYPE.ROW?(j=this._moveHelperBackgroundShape)==null||j.transformByState({height:L-x,width:g+d,left:0,top:x+(t-this._startOffsetY)/k+S.y-o.y}):(Q=this._moveHelperBackgroundShape)==null||Q.transformByState({height:h+u,width:H-N,left:N+(e-this._startOffsetX)/k+S.x-o.x,top:0}),(ie=this._moveHelperBackgroundShape)==null||ie.show();const F=Zm/k;if(s===a.RANGE_TYPE.ROW){let G=0;if(C<=V)G=O-F/2,this._changeToRow=C;else if(C>B)G=P-F/2,this._changeToRow=C+1;else return;($=this._moveHelperLineShape)==null||$.transformByState({height:F,width:g,left:d,top:G})}else{let G=0;if(b<=U)G=E-F/2,this._changeToColumn=b;else if(b>Y)G=M-F/2,this._changeToColumn=b+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:F,left:G,top:u})}(Z=this._moveHelperLineShape)==null||Z.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new R.Rect(Xm,{fill:jm,evented:!1,zIndex:100}),this._moveHelperLineShape=new R.Rect(Ym,{fill:Gm,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],st)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}},y.HeaderMoveRenderController=zm([ko(1,a.Inject(m.SheetsSelectionsService)),ko(2,a.Inject(y.SheetSkeletonManagerService)),ko(3,a.ICommandService)],y.HeaderMoveRenderController);var Ho=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Ho||{});const Km="rgba(120, 120, 120, 0.01)",Vo="rgb(68, 71, 70)",ci=12,qm=44,Wo=4;class cl extends R.Shape{constructor(e,t){super(e,t);T(this,"_size",ci);T(this,"_color",Vo);T(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:i,scaleY:o}=t.getAncestorScale(),s=Math.max(i,o),l=ci/s,c=Wo/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),R.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:Km}),R.Rect.drawWith(e,{width:d,height:u,fill:Vo,radius:c}),e.save(),e.transform(1,0,0,1,h,g),R.Rect.drawWith(e,{width:d,height:u,fill:Vo,radius:c}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:ci,height:this.size}):this.transformByState({width:this.size,height:ci}),this}}var Qm=Object.getOwnPropertyDescriptor,Jm=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},xo=(n,r)=>(e,t)=>r(e,t,n);const $m="__SpreadsheetHeaderResizeControllerShapeRow__",eg="__SpreadsheetHeaderResizeControllerShapeColumn__",dl="__SpreadsheetHeaderResizeControllerShapeHelper__",ul="rgb(199, 199, 199)",tg=2,Lo=a.createInterceptorKey("headerResizePermissionCheck");y.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,i,o){super();T(this,"_currentRow",0);T(this,"_currentColumn",0);T(this,"_rowResizeRect");T(this,"_columnResizeRect");T(this,"_headerPointerSubs");T(this,"_scenePointerMoveSub");T(this,"_scenePointerUpSub");T(this,"_resizeHelperShape");T(this,"_startOffsetX",Number.POSITIVE_INFINITY);T(this,"_startOffsetY",Number.POSITIVE_INFINITY);T(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:Lo}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=i,this._commandService=o,this._init()}dispose(){var e,t,i;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(i=this._headerPointerSubs)==null||i.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new cl($m,{visible:!1,mode:Ho.HORIZONTAL,zIndex:100}),this._columnResizeRect=new cl(eg,{visible:!1,mode:Ho.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],st),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),i=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?i:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var k;const h=(k=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:k.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:v,endX:p,endY:C,row:b,column:w}=ze(d.offsetX,d.offsetY,o,h),E=xn(d.offsetX,d.offsetY,o),{scaleX:O,scaleY:M}=o.getAncestorScale(),P=Math.max(O,M),A=ci/P;if(e===0){let N=v-A/2;if(E.y<=v+A/2&&E.y>=v)this._currentRow=b-1;else if(E.y>=C-A/2&&E.y<=C)this._currentRow=b,N=C-A/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(Lo)(null,{row:this._currentRow}))return!1;const x=Math.min(qm,g/3);this._rowResizeRect.transformByState({left:g/2-x/2,top:N}),this._rowResizeRect.setShapeProps({size:x}),this._rowResizeRect.show()}else{let N=f-A/2;if(E.x<=f+A/2&&E.x>=f)this._currentColumn=w-1;else if(E.x>=p-A/2&&E.x<=p)this._currentColumn=w,N=p-A/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(Lo)(null,{col:this._currentColumn}))return!1;const x=S*.7;this._columnResizeRect.transformByState({left:N,top:S/2-x/2}),this._columnResizeRect.setShapeProps({size:x}),this._columnResizeRect.show()}};this._headerPointerSubs=new D.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,i=e===0?this._rowResizeRect:this._columnResizeRect;i!=null&&(this.disposeWithMe(i.onPointerEnter$.subscribeEvent(()=>{i!=null&&(i.show(),t.setCursor(e===0?R.CURSOR_TYPE.ROW_RESIZE:R.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(i.onPointerLeave$.subscribeEvent(()=>{i!=null&&(i.hide(),t.resetCursor())})),this.disposeWithMe(i.onPointerDown$.subscribeEvent(o=>{var Y,F,z,j,Q,ie,$;const s=(Y=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:Y.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((z=(F=h==null?void 0:h.getScrollBar())==null?void 0:F.horizonScrollTrack)==null?void 0:z.height)||0)+10,S=(((Q=(j=h==null?void 0:h.getScrollBar())==null?void 0:j.verticalScrollTrack)==null?void 0:Q.width)||0)+10,f=xn(o.offsetX,o.offsetY,l),{scaleX:v,scaleY:p}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),b=s.getOffsetByRow(this._currentRow),w=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let E=!1,O=0,M=0;const{columnTotalWidth:P,rowHeaderWidth:A,rowTotalHeight:k,columnHeaderHeight:N}=s,H=u>P+A?u:P+A,x=d>k+N?d:k+N,L=Math.max(v,p),V=Wo/L;e===0?this._resizeHelperShape=new R.Rect(dl,{width:H,height:V,fill:ul,left:0,top:b-V/2}):this._resizeHelperShape=new R.Rect(dl,{width:V,height:x,fill:ul,left:C-V/2,top:0});const U=((ie=this._columnResizeRect)==null?void 0:ie.left)||0,B=(($=this._rowResizeRect)==null?void 0:$.top)||0;l.addObject(this._resizeHelperShape,st),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var pe,we,Ee,Ct,_t,jt;const Z=l.getCoordRelativeToViewport(R.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),G=l.getScrollXYInfoByViewport(Z,h),J=xn(se.offsetX,se.offsetY,l),{x:re,y:ue}=J,{scaleX:oe,scaleY:ae}=l.getAncestorScale(),te=Math.max(oe,ae),fe=Wo/te;O=re-this._startOffsetX-fe/2,M=ue-this._startOffsetY-fe/2,Math.abs(e===0?M:O)>=tg&&(E=!0),e===0?(M>d-g+G.y-w.startY&&(M=d-g+G.y-w.startY),M<-(w.endY-w.startY)+2&&(M=-(w.endY-w.startY)+2),E&&((pe=this._resizeHelperShape)==null||pe.transformByState({top:b+M}),(we=this._rowResizeRect)==null||we.transformByState({top:B+M+fe/2}),(Ee=this._rowResizeRect)==null||Ee.show(),l.setCursor(R.CURSOR_TYPE.ROW_RESIZE))):(O>u-S+G.x-w.startX&&(O=u-S+G.x-w.startX),O<-(w.endX-w.startX)+2&&(O=-(w.endX-w.startX)+2),E&&((Ct=this._resizeHelperShape)==null||Ct.transformByState({left:C+O}),(_t=this._columnResizeRect)==null||_t.transformByState({left:U+O+fe/2}),(jt=this._columnResizeRect)==null||jt.show(),l.setCursor(R.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var G,J,re;const Z=this._context.scene;this._clearObserverEvent(),(G=this._resizeHelperShape)==null||G.dispose(),this._resizeHelperShape=null,Z.enableObjectsEvent(),E&&(Z.resetCursor(),(J=this._rowResizeRect)==null||J.hide(),(re=this._columnResizeRect)==null||re.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:M,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})})),this.disposeWithMe(i.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),v=[];for(let p=0;p<f.length;p++){const C=f[p];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&v.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}v.length===0&&v.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(ii.id,{ranges:v}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}},y.HeaderResizeRenderController=Jm([xo(1,a.Inject(y.SheetSkeletonManagerService)),xo(2,a.Inject(m.SheetsSelectionsService)),xo(3,a.ICommandService)],y.HeaderResizeRenderController);var ng=Object.getOwnPropertyDescriptor,ig=(n,r,e,t)=>{for(var i=t>1?void 0:t?ng(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},di=(n,r)=>(e,t)=>r(e,t,n);const rg=60;y.SheetRenderController=class extends a.RxDisposable{constructor(e,t,i,o,s,l){super();T(this,"_renderMetric$",new D.Subject);T(this,"renderMetric$",this._renderMetric$.asObservable());T(this,"_renderFrameTimeMetric",null);T(this,"_renderFrameTags",{});T(this,"_afterRenderMetric$",new D.Subject);this._context=e,this._configService=t,this._sheetSkeletonManagerService=i,this._sheetRenderService=o,this._commandService=s,this._telemetryService=l,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:i}=this._context;this._addComponent(i),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(R.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([i,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[i]||(this._renderFrameTimeMetric[i]=[]),this._renderFrameTimeMetric[i].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([i,o])=>{this._renderFrameTags[i]=o});const t=[];this._afterRenderMetric$.pipe(D.withLatestFrom(e.endFrame$)).subscribe(([i,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...i.frameTimeMetric,...i.tags}),t.length>rg&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const i=S=>{let f=0;const p=Object.entries(S).filter(([b,w])=>Array.isArray(w)).map(([b])=>b).reduce((b,w)=>{const E=S[w].reduce((O,M)=>O+M,0);return b[w]=E,b},{});return Object.keys(S).filter(b=>b.startsWith(R.SHEET_EXTENSION_PREFIX)).forEach(b=>{f+=p[b]}),{...p,extensionTotal:f}},o=e.map(S=>({...S,...i(S)})),l=(S=>Object.entries(S[0]).filter(([p,C])=>!["elapsedTime"].includes(p)).filter(([p,C])=>typeof C=="number").map(([p])=>p).reduce((p,C)=>{const b=S.map(M=>M[C]),w=Math.max(...b),E=Math.min(...b),O=b.reduce((M,P)=>M+P,0)/b.length;return p[C]={max:Math.round(w*100)/100,min:Math.round(E*100)/100,avg:Math.round(O*100)/100},p},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:i}=this._context,o=e.getActiveSheet(),s=new R.Spreadsheet(he.MAIN);this._addViewport(o);const l=new R.SpreadsheetRowHeader(he.ROW),c=new R.SpreadsheetColumnHeader(he.COLUMN),d=new R.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,i.set(he.MAIN,s),i.set(he.ROW,l),i.set(he.COLUMN,c),i.set(he.LEFT_TOP,d),t.addObjects([s],ys),t.addObjects([l,c,d],st),t.enableLayerCache(ys,st)}_initViewports(e,t,i){const l=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:i.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:i.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),S=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:i.height+1,right:0,isWheelPreventDefaultX:!0}),v=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:i.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:v,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:i,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,i,o),l=this._configService.getConfig(He),c=l==null?void 0:l.scrollConfig;return new R.ScrollBar(s,c),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:i}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(i);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:i}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(i)||this._sheetRenderService.checkMutationShouldTriggerRerender(i)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:i},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:i})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(i)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:i}=this._context;if(e.id===K.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),i.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(i);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,i=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),i<Number(S)&&(i=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:i}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:i[u-1]+l,v=i[h]+l,p=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:p,bottom:v,right:C,width:C-p,height:v-f})}return c}_markViewportDirty(e,t){const i=e.filter(o=>o.isActive&&o.cacheBound);for(const o of i)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}},y.SheetRenderController=ig([di(1,a.Inject(a.IConfigService)),di(2,a.Inject(y.SheetSkeletonManagerService)),di(3,a.Inject(y.SheetsRenderService)),di(4,a.ICommandService),di(5,a.Optional(Jc.ITelemetryService))],y.SheetRenderController);function og(n,r){if(n.length!==r.length)return!1;const e=n.sort((i,o)=>i.id.localeCompare(o.id)),t=r.sort((i,o)=>i.id.localeCompare(o.id));return e.every((i,o)=>{var s,l;return((s=i.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&i.role===t[o].role})}function hl(n,r){return r.some(e=>sg(n,e))}function sg(n,r){const{startRow:e,startColumn:t,endColumn:i,endRow:o}=r,s=n.getMatrixWithMergedCells(e,t,o,i);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function ml(n,r,e,t){const i=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=ag(e,l),d={unitId:r,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);i.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:i,redos:o}}function ag(n,r){const{startRow:e,startColumn:t,endColumn:i,endRow:o}=r,s=n.getMatrixWithMergedCells(e,t,o,i,a.CellModeEnum.Raw),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,v;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((v=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?v:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function lg(n,r,e,t){const i=e.getActiveViewportByCoord(R.Vector2.FromArray([n,r]));if(!i)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:i.viewportScrollX,y:i.viewportScrollY},c=t.getCellIndexByOffset(n,r,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function gl(n,r,e,t){const i=t.getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0||n>=i.startRow&&r>=i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<i.startRow&&r<i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<i.startRow&&r>=i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=i.startRow&&r<i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function cg(n,r,e,t){const i=Sl(n.left,n.top,r,e,t),o=Sl(n.right,n.bottom,r,e,t);return{left:i.x,top:i.y,right:o.x,bottom:o.y}}function Sl(n,r,e,t,i){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:r};const c=i.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:v,columnHeaderHeight:p}=t,C=f.startX-S.startX,b=f.startY-S.startY,{top:w,left:E,viewportScrollX:O,viewportScrollY:M}=l;let P;n>E?P=(n-O)*o:P=(C+v-(E-n))*o;let A;return r>w?A=(r-M)*s:A=(b+p-(w-r))*o,{x:P,y:A}}function fl(n,r,e,t,i){let o=t,s=i;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:r.getSheetId(),workbook:n,worksheet:r,row:l.actualRow,col:l.actualColumn}}function vl(n,r,e,t,i,o){const{scene:s}=n,l=r.getUnitId(),{skeleton:c,sheetId:d}=t,u=lg(i,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:r,worksheet:e,row:g,col:h};c.overflowCache.forValue((M,P,A)=>{A.startRow<=g&&A.endRow>=g&&A.startColumn<=h&&A.endColumn>=h&&(h=P,g=M)});const f=c.getCellWithCoordByIndex(g,h),v=fl(r,e,c,g,h);let p;f.mergeInfo?p=f.mergeInfo:p={startRow:v.row,endRow:v.row,startColumn:v.col,endColumn:v.col};const C=s.getActiveViewportByCoord(R.Vector2.FromArray([i,o]));if(!C)return;const{scaleX:b,scaleY:w}=s.getAncestorScale(),E={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(p.startColumn-1)-E.x)*b,endX:(c.getOffsetByColumn(p.endColumn)-E.x)*b,startY:(c.getOffsetByRow(p.startRow-1)-E.y)*w,endY:(c.getOffsetByRow(p.endRow)-E.y)*w},location:S,overflowLocation:v}}const gt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,r)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=r.unitId,c=r.subUnitId,d=r.selections,u=m.getAddMergeMutationRangeByType(d,r.value),h=i.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=hl(h,u);if(f&&!r.defaultMerge&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,v),b=m.AddMergeUndoMutationFactory(n,p);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:p}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:b}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const A=ml(n,l,h,u);g.unshift(...A.redos),S.push(...A.undos)}const w=m.AddMergeRedoSelectionsOperationFactory(n,r,u);w&&g.push(w);const E=m.AddMergeUndoSelectionsOperationFactory(n,r);E&&S.push(E);const M=n.get(m.SheetInterceptorService).onCommandExecute({id:gt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...M.redos),S.push(...M.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},Uo={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const r=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=Qr(Fi.MergeAll,t);if(!(i!=null&&i.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return r.executeCommand(gt.id,{selections:i,unitId:c,subUnitId:d})}},Bo={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const r=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=Qr(Fi.MergeVertical,t);if(!(i!=null&&i.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return r.executeCommand(gt.id,{value:a.Dimension.COLUMNS,selections:i,unitId:c,subUnitId:d})}},Fo={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const r=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=Qr(Fi.MergeHorizontal,t);if(!(i!=null&&i.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return r.executeCommand(gt.id,{value:a.Dimension.ROWS,selections:i,unitId:c,subUnitId:d})}},_n={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:_n.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Vt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await r.confirm({id:Vt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:Vt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await r.confirm({id:Wt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:Wt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},In={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:In.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var pl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(pl||{}),ne=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ne||{}),Ae=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ae||{}),et=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(et||{}),Ze=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ze||{});const ui="UNIVER_SHEET_PERMISSION_PANEL",bn="UNIVER_SHEET_PERMISSION_USER_PART",ir="UNIVER_SHEET_PERMISSION_BACKGROUND",Cl="UNIVER_SHEET_PERMISSION_USER_DIALOG",_l="UNIVER_SHEET_PERMISSION_DIALOG",rr="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",or="UNIVER_SHEET_PERMISSION_DIALOG_ID",sr={[ne.Copy]:"Copy",[ne.SetCellStyle]:"SetCellStyle",[ne.SetCellValue]:"SetCellValue",[ne.SetRowStyle]:"SetRowStyle",[ne.SetColumnStyle]:"SetColumnStyle",[ne.InsertRow]:"InsertRow",[ne.InsertColumn]:"InsertColumn",[ne.InsertHyperlink]:"InsertHyperlink",[ne.DeleteRow]:"DeleteRow",[ne.DeleteColumn]:"DeleteColumn",[ne.Sort]:"Sort",[ne.Filter]:"Filter",[ne.PivotTable]:"PivotTable",[ne.EditExtraObject]:"EditExtraObject"},dg=[ne.Copy,ne.SetCellStyle,ne.SetCellValue,ne.SetRowStyle,ne.SetColumnStyle,ne.InsertRow,ne.InsertColumn,ne.InsertHyperlink,ne.DeleteRow,ne.DeleteColumn,ne.Sort,ne.Filter,ne.PivotTable,ne.EditExtraObject,ne.View],Il="sheet-permission-menu-icon",ug="sheet-permission-delete-icon",hg="sheet-permission-edit-icon",mg="sheet-permission-check-icon",bl="sheet-permission-lock-icon",gg={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class wn{constructor(){T(this,"_rule",gg);T(this,"_visible",!1)}setVisible(r){this._visible=r}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class St{constructor(){T(this,"_userList",[]);T(this,"_userList$",new D.BehaviorSubject(this._userList));T(this,"userList$",this._userList$.asObservable());T(this,"_oldCollaboratorList",[]);T(this,"_selectUserList",[]);T(this,"_selectUserList$",new D.BehaviorSubject(this._selectUserList));T(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(r){this._userList=r,this._userList$.next(r)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(r){this._oldCollaboratorList=r}get selectUserList(){return this._selectUserList}setSelectUserList(r){this._selectUserList=r,this._selectUserList$.next(r)}}const Ke={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,r={}){const e=n.get(_.ISidebarService),t=n.get(wn),i=n.get(St),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=r,d={header:{title:"permission.panel.title"},children:{label:ui,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),i.reset()}};return t.setVisible(!0),e.open(d),!0}},hi={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!0}),!0}},xt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!0}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!1}),!0}},mi={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{fromSheetBar:!0,showDetail:!0}),!0}},gi={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!1}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return r.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=i.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const v=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(p=>p.ranges.some(C=>a.Rectangle.intersects(C,g)));if(v){const p={unitId:c,subUnitId:d,ruleIds:[v.id]};return await r.executeCommand(m.DeleteRangeProtectionMutation.id,p)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:p}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[v]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=i.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await r.executeCommand(Ke.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(v=>{var p;return(p=v==null?void 0:v.ranges)==null?void 0:p.some(C=>a.Rectangle.intersects(C,h))});if(f){const v={...f,unitId:l,subUnitId:c};return await r.executeCommand(Ke.id,{showDetail:!0,rule:a.Tools.deepClone(v),oldRule:a.Tools.deepClone(v)}),!0}else return!1}}},En={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,r)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=r==null?void 0:r.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(Ys(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Tn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,r)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=r==null?void 0:r.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(js(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},Si={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,r)=>{const{subUnitId:e}=r,t=n.get(_.IConfirmService),i=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await i.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},fi={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Tt).triggerSheetBarMenu(),!0)},vi={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,r){if(!r)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(pl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=i.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},pi={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},Ci={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,r)=>{const e=n.get(Tt);return r&&e.setRenameId(r.subUnitId),!0}},zo={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,r){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:or,title:{title:"permission.dialog.allowedPermissionType"},children:{label:_l},width:393,destroyOnClose:!0,onClose:()=>e.close(or)}),!0}},Sg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z"}),I.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z"}),I.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z"}),I.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z"}),I.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z"}),I.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z"}),I.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z"}),I.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z"}),I.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z"}),I.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z"}),I.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z"}),I.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z"}),I.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z"}),I.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z"}),I.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z"}),I.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z"}),I.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z"}),I.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z"}),I.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z"}),I.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z"}),I.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z"}),I.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z"}),I.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z"}),I.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z"}),I.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z"}),I.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z"}),I.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z"})]}),fg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z"}),I.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z"}),I.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z"}),I.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z"}),I.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z"}),I.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z"}),I.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z"}),I.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z"}),I.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z"}),I.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z"}),I.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z"}),I.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z"}),I.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z"}),I.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z"}),I.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z"}),I.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z"}),I.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z"}),I.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z"}),I.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z"}),I.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z"}),I.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z"}),I.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z"}),I.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z"}),I.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z"}),I.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z"}),I.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z"}),I.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z"}),I.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z"})]}),vg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z"}),I.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z"}),I.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z"}),I.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z"}),I.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z"}),I.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z"}),I.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z"}),I.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z"}),I.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z"}),I.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z"}),I.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z"}),I.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z"}),I.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z"}),I.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z"}),I.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z"}),I.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z"}),I.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z"}),I.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z"}),I.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z"}),I.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z"})]}),pg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z"}),I.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z"}),I.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z"}),I.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z"}),I.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z"}),I.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z"}),I.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z"}),I.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z"}),I.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z"}),I.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z"}),I.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z"}),I.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z"}),I.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z"}),I.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z"}),I.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z"}),I.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z"}),I.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z"}),I.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z"}),I.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z"}),I.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z"}),I.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z"}),I.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z"}),I.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z"}),I.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z"}),I.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z"}),I.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z"}),I.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z"}),I.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z"}),I.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z"}),I.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z"}),I.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z"}),I.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z"}),I.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z"}),I.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z"}),I.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z"}),I.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z"}),I.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z"}),I.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z"}),I.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z"}),I.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z"}),I.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z"}),I.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z"}),I.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z"}),I.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z"}),I.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z"}),I.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z"}),I.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z"}),I.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z"}),I.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z"}),I.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z"}),I.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z"}),I.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z"})]}),Cg=({className:n})=>I.jsx("svg",{className:n,width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z"})}),_g=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z"}),I.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z"}),I.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z"}),I.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z"}),I.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z"}),I.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z"}),I.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z"}),I.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z"}),I.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z"}),I.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z"}),I.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z"}),I.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z"}),I.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z"}),I.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z"}),I.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z"}),I.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z"}),I.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z"}),I.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z"})]}),Ig=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z"}),I.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z"}),I.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z"}),I.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z"}),I.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z"}),I.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z"}),I.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z"}),I.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z"}),I.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z"}),I.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z"}),I.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z"}),I.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z"}),I.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z"}),I.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z"}),I.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z"}),I.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z"}),I.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z"}),I.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z"}),I.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z"}),I.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z"})]}),bg=({className:n})=>I.jsxs("svg",{className:n,width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z"}),I.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z"}),I.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z"}),I.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z"}),I.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z"}),I.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z"}),I.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z"}),I.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z"}),I.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z"}),I.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z"}),I.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z"}),I.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z"}),I.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z"}),I.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z"}),I.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z"}),I.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z"}),I.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z"}),I.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z"}),I.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z"}),I.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z"})]}),wg=({className:n})=>I.jsx("svg",{className:n,width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z"})}),Eg=({className:n})=>I.jsx("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z"})});function wl(n){const{type:r=a.BorderStyleTypes.THIN,className:e}=n;switch(r){case a.BorderStyleTypes.DASH_DOT:return I.jsx(Sg,{className:e});case a.BorderStyleTypes.DASH_DOT_DOT:return I.jsx(fg,{className:e});case a.BorderStyleTypes.DASHED:return I.jsx(vg,{className:e});case a.BorderStyleTypes.HAIR:return I.jsx(pg,{className:e});case a.BorderStyleTypes.MEDIUM:return I.jsx(Cg,{className:e});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return I.jsx(_g,{className:e});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return I.jsx(Ig,{className:e});case a.BorderStyleTypes.MEDIUM_DASHED:return I.jsx(bg,{className:e});case a.BorderStyleTypes.THICK:return I.jsx(wg,{className:e});case a.BorderStyleTypes.THIN:default:return I.jsx(Eg,{className:e})}}const Xo=`${Ka}_BORDER_PANEL_COMPONENT`,El=[{label:"borderLine.borderTop",icon:"UpBorderDoubleIcon",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorderDoubleIcon",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorderDoubleIcon",value:"left"},{label:"borderLine.borderRight",icon:"RightBorderDoubleIcon",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderIcon",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderIcon",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorderDoubleIcon",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorderDoubleIcon",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorderDoubleIcon",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorderDoubleIcon",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashIcon",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalIcon",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalIcon",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashIcon",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalIcon",value:"mltr_bctr"}],Tg=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function Tl(n){var l;const r=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:i}=n;function o(c,d){t==null||t({...i,[d]:c})}function s(c){const d=r.get(c);return d&&I.jsx(d,{className:"univer-fill-primary-600"})}return I.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[I.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2 univer-text-gray-600 dark:!univer-text-gray-200",children:El.map(c=>I.jsx("a",{className:X.clsx("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-justify-self-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-200 dark:!univer-bg-gray-600":e.getBorderInfo().type===c.value}),onClick:d=>{d.stopPropagation(),o(c.value,"type")},children:s(c.icon)},c.value))}),I.jsx(X.Separator,{}),I.jsxs("div",{className:"univer-flex univer-items-center univer-gap-2",children:[I.jsx("div",{children:I.jsx(X.Dropdown,{overlay:I.jsx("div",{className:"univer-rounded-lg univer-p-4",children:I.jsx(X.ColorPicker,{onChange:c=>o(c,"color")})}),children:I.jsxs("button",{className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",type:"button",children:[I.jsx(ia,{className:"univer-fill-primary-600 dark:!univer-text-white",extend:{colorChannel1:(l=i==null?void 0:i.color)!=null?l:""}}),I.jsx(sn,{className:"dark:!univer-text-white"})]})})}),I.jsx("div",{children:I.jsx(X.Dropdown,{overlay:I.jsx("section",{className:"univer-rounded-lg univer-p-1.5",children:I.jsx("ul",{className:"univer-m-0 univer-grid univer-list-none univer-gap-1 univer-p-0",children:Tg.map(c=>I.jsx("li",{className:"univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-px-1 univer-py-2 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>o(c.value,"style"),children:I.jsx(wl,{className:"univer-fill-gray-900 dark:!univer-fill-white",type:c.value})},c.value))})}),children:I.jsxs("button",{className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",type:"button",children:[I.jsx(wl,{className:"univer-fill-gray-900 dark:!univer-fill-white",type:a.BorderStyleTypes.THIN}),I.jsx(sn,{className:"dark:!univer-text-white"})]})})})]})]})}const yl="sheets.component.cell-popup";var yg=Object.getOwnPropertyDescriptor,Rg=(n,r,e,t)=>{for(var i=t>1?void 0:t?yg(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Ft=(n,r)=>(e,t)=>r(e,t,n);y.SheetCanvasPopManagerService=class extends a.Disposable{constructor(e,t,i,o,s,l,c){super();T(this,"_popupMenuFeatureMap",new Map);T(this,"_isSelectionMoving",!1);this._globalPopupManagerService=e,this._renderManagerService=t,this._univerInstanceService=i,this._refRangeService=o,this._commandService=s,this._refSelectionsService=l,this._selectionManagerService=c,this._initMoving()}_initMoving(){this.disposeWithMe(this._refSelectionsService.selectionMoving$.subscribe(()=>{this._isSelectionMoving=!0})),this.disposeWithMe(this._refSelectionsService.selectionMoveEnd$.subscribe(()=>{this._isSelectionMoving=!1})),this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(()=>{this._isSelectionMoving=!0})),this.disposeWithMe(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{this._isSelectionMoving=!1}))}registerFeatureMenu(e,t){this._popupMenuFeatureMap.set(e,t)}getFeatureMenu(e,t,i,o){const s=this._popupMenuFeatureMap.get(o);if(s)return s(e,t,i,o)}dispose(){super.dispose(),this._popupMenuFeatureMap.clear()}_createHiddenRectObserver(e){const{row:t,column:i,worksheet:o,skeleton:s,currentRender:l}=e,c=()=>{var z,j;const g=o.getFreeze(),{startRow:S,startColumn:f,xSplit:v,ySplit:p}=g,C=S-p,b=f-v,{rowHeightAccumulation:w,columnWidthAccumulation:E,rowHeaderWidth:O,columnHeaderHeight:M}=s,P=O+(b===-1?0:E[b+v-1]-((z=E[b-1])!=null?z:0)),A=M+(C===-1?0:w[C+p-1]-((j=w[C])!=null?j:0)),k=l.engine.getCanvasElement(),N=k.getBoundingClientRect(),H=Yo(k.style.width),x=N.width/H,L=l.scene.getAncestorScale().scaleX,V=P*x*L,U=A*x*L,B={left:-1/0,top:-1/0,right:N.left+V,bottom:N.top+U},Y={left:N.left+V,top:-1/0,right:1/0,bottom:N.top+U},F={left:-1/0,top:N.top+U,right:N.left+V,bottom:1/0};return t<S&&i<f?[]:t<S?[B]:i<f?[B]:[B,Y,F]},d=c(),u=new D.BehaviorSubject(d),h=new a.DisposableCollection;return h.add(this._commandService.onCommandExecuted(g=>{g.id===m.SetFrozenMutation.id&&u.next(c())})),h.add(a.fromEventSubject(l.engine.onTransformChange$).pipe(D.throttleTime(16)).subscribe(()=>{u.next(c())})),{rects$:u,disposable:h}}_createPositionObserver(e,t,i,o){const s=()=>{const{scene:u}=t,h=cg(e,u,i,o),g=t.engine.getCanvasElement(),S=g.getBoundingClientRect(),f=Yo(g.style.width),v=S.width/f;return{left:h.left*v+S.left,right:h.right*v+S.left,top:h.top*v+S.top,bottom:h.bottom*v+S.top}},l=s(),c=new D.BehaviorSubject(l),d=new a.DisposableCollection;return d.add(this._commandService.onCommandExecuted(u=>{(u.id===Le.id||u.id===Ne.id)&&c.next(s())})),{position:l,position$:c,disposable:d}}attachPopupToObject(e,t){var w;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=i.getActiveSheet();if(!o||this._isSelectionMoving&&!t.showOnSelectionMoving)return{dispose:()=>{},canDispose:()=>!0};const s=i.getUnitId(),l=o.getSheetId(),c=(w=this._renderManagerService.getRenderById(s))==null?void 0:w.with(y.SheetSkeletonManagerService).ensureSkeleton(l),d=this._renderManagerService.getRenderById(s);if(!d||!c)return{dispose:()=>{},canDispose:()=>!0};const{left:u,top:h,width:g,height:S}=e,f={left:u,right:u+g,top:h,bottom:h+S},{position:v,position$:p,disposable:C}=this._createPositionObserver(f,d,c,o),b=this._globalPopupManagerService.addPopup({...t,unitId:s,subUnitId:l,anchorRect:v,anchorRect$:p,canvasElement:d.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(b),p.complete(),C.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==b}}attachPopupByPosition(e,t,i){var C;const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet();if(!s)return null;const l=o.getUnitId(),c=s.getSheetId();if(l!==i.unitId||i.subUnitId!==c)return null;if(this._isSelectionMoving&&!t.showOnSelectionMoving)return;const d=(C=this._renderManagerService.getRenderById(l))==null?void 0:C.with(y.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:c}),u=this._renderManagerService.getRenderById(l);if(!u||!d)return null;const{position:h,position$:g,disposable:S}=this._createPositionObserver(e,u,d,s),{rects$:f,disposable:v}=this._createHiddenRectObserver({row:i.row,column:i.col,worksheet:s,skeleton:d,currentRender:u}),p=this._globalPopupManagerService.addPopup({...t,unitId:l,subUnitId:c,anchorRect:h,anchorRect$:g,hiddenRects$:f,canvasElement:u.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(p),g.complete(),S.dispose(),v.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==p}}attachPopupToAbsolutePosition(e,t,i,o){var f;const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet();if(!l)return null;const c=s.getUnitId(),d=l.getSheetId();if(i&&c!==i||o&&o!==d)return null;const u=(f=this._renderManagerService.getRenderById(c))==null?void 0:f.with(y.SheetSkeletonManagerService).ensureSkeleton(d),h=this._renderManagerService.getRenderById(c);if(!h||!u)return null;if(this._isSelectionMoving&&!t.showOnSelectionMoving)return;const g=new D.BehaviorSubject(e),S=this._globalPopupManagerService.addPopup({...t,unitId:c,subUnitId:d,anchorRect:e,anchorRect$:g.asObservable(),canvasElement:h.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(S),g.complete()},canDispose:()=>this._globalPopupManagerService.activePopupId!==S}}attachPopupToCell(e,t,i,o,s,l){const c=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d=c.getActiveSheet();if(!d)return null;const u=c.getUnitId(),h=d.getSheetId();if(o&&u!==o||s&&h!==s)return null;const g=this._renderManagerService.getRenderById(u),S=g==null?void 0:g.with(y.SheetSkeletonManagerService).ensureSkeleton(h),f=g==null?void 0:g.with(ve);if(!g||!S||!f)return null;if(this._isSelectionMoving&&!i.showOnSelectionMoving)return;const v=l!=null?l:gl(e,t,g.scene,d);if(!v)return null;const{position:p,position$:C,disposable:b,updateRowCol:w}=this._createCellPositionObserver(e,t,g,S,v),{rects$:E,disposable:O}=this._createHiddenRectObserver({row:e,column:t,worksheet:d,skeleton:S,currentRender:g}),M=this._globalPopupManagerService.addPopup({...i,unitId:u,subUnitId:h,anchorRect:p,anchorRect$:C,canvasElement:g.engine.getCanvasElement(),hiddenRects$:E}),P=new a.DisposableCollection;P.add(b),P.add(a.toDisposable(()=>{this._globalPopupManagerService.removePopup(M),C.complete()})),P.add(O);const A={startRow:e,endRow:e,startColumn:t,endColumn:t};return P.add(this._refRangeService.watchRange(u,h,A,(k,N)=>{N?w(N.startRow,N.startColumn):P.dispose()})),{dispose(){P.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==M}}attachRangePopup(e,t,i,o,s,l=!1){const c=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d=c.getActiveSheet();if(!d)return null;const u=c.getUnitId(),h=d.getSheetId();if(i&&u!==i||o&&h!==o)return null;const g=this._renderManagerService.getRenderById(u),S=g==null?void 0:g.with(y.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:h}),f=g==null?void 0:g.with(ve);if(!g||!S||!f)return null;if(f.selectionMoving&&!l)return;const v=s!=null?s:gl(e.startRow,e.startColumn,g.scene,d);if(!v)return null;const{position:p,position$:C,disposable:b,updateRowCol:w,topLeftPos$:E,rightBottomPos$:O}=this._createRangePositionObserver(e,g,S,v),{rects$:M,disposable:P}=this._createHiddenRectObserver({row:e.startRow,column:e.startColumn,worksheet:d,skeleton:S,currentRender:g}),A=this._globalPopupManagerService.addPopup({...t,unitId:u,subUnitId:h,anchorRect:p,anchorRect$:C,canvasElement:g.engine.getCanvasElement(),hiddenRects$:M}),k=new a.DisposableCollection;k.add(b),k.add(a.toDisposable(()=>{this._globalPopupManagerService.removePopup(A),E.complete(),O.complete()})),k.add(P);const N={...e};return k.add(this._refRangeService.watchRange(u,h,N,(H,x)=>{x?w(x.startRow,x.startColumn):k.dispose()})),{dispose(){k.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==A}}_createCellPositionObserver(e,t,i,o,s){let l=e,c=t;const d=this._calcCellPositionByCell(l,c,i,o,s),u=new D.BehaviorSubject(d),h=()=>u.next(this._calcCellPositionByCell(l,c,i,o,s)),g=new a.DisposableCollection;return g.add(i.engine.clientRect$.subscribe(()=>h())),g.add(a.fromEventSubject(i.engine.onTransformChange$).pipe(D.throttleTime(16)).subscribe(()=>h())),g.add(this._commandService.onCommandExecuted(f=>{if(f.id===m.SetWorksheetRowAutoHeightMutation.id&&f.params.rowsAutoHeightInfo.findIndex(p=>p.row===l)>-1){h();return}(m.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(f.id)>-1||f.id===Le.id||f.id===Ne.id)&&h()})),{position$:u,disposable:g,position:d,updateRowCol:(f,v)=>{l=f,c=v,h()}}}_calcCellPositionByCell(e,t,i,o,s){const{scene:l,engine:c}=i,d=o.getCellWithCoordByIndex(e,t),u=d.isMergedMainCell?d.mergeInfo:d,{scaleX:h,scaleY:g}=l.getAncestorScale(),S={x:s.viewportScrollX,y:s.viewportScrollY},f=c.getCanvasElement(),v=f.getBoundingClientRect(),p=Yo(f.style.width),{top:C,left:b,width:w}=v,E=w/p;return{left:(u.startX-S.x)*E*h+b,right:(u.endX-S.x)*E*h+b,top:(u.startY-S.y)*E*g+C,bottom:(u.endY-S.y)*E*g+C}}_createRangePositionObserver(e,t,i,o){let{startRow:s,startColumn:l}=e;const c=this._calcCellPositionByCell(s,l,t,i,o),d=new D.BehaviorSubject(c),u=this._calcCellPositionByCell(e.endRow,e.endColumn,t,i,o),h=new D.BehaviorSubject(u),g=()=>{const C=this._calcCellPositionByCell(s,l,t,i,o),b=this._calcCellPositionByCell(e.endRow,e.endColumn,t,i,o);d.next(C),h.next(b)},S=new a.DisposableCollection;S.add(t.engine.clientRect$.subscribe(()=>g())),S.add(this._commandService.onCommandExecuted(C=>{if(C.id===m.SetWorksheetRowAutoHeightMutation.id&&C.params.rowsAutoHeightInfo.findIndex(w=>w.row===s)>-1){g();return}(m.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(C.id)>-1||C.id===Le.id||C.id===Ne.id)&&g()}));const f=(C,b)=>{s=C,l=b,g()},v=d.pipe(D.map(C=>{const b=this._calcCellPositionByCell(e.endRow,e.endColumn,t,i,o);return{top:C.top,left:C.left,right:b.right,bottom:b.bottom}})),p={top:c.top,left:c.left,right:u.right,bottom:u.bottom};return{position$:v,position:p,updateRowCol:f,topLeftPos$:d,rightBottomPos$:h,disposable:S}}},y.SheetCanvasPopManagerService=Rg([Ft(0,a.Inject(_.ICanvasPopupService)),Ft(1,R.IRenderManagerService),Ft(2,a.IUniverInstanceService),Ft(3,a.Inject(m.RefRangeService)),Ft(4,a.ICommandService),Ft(5,m.IRefSelectionsService),Ft(6,a.Inject(m.SheetsSelectionsService))],y.SheetCanvasPopManagerService);function Yo(n){return Number.parseInt(n.replace("px",""))}var Mg=Object.getOwnPropertyDescriptor,Pg=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mg(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Og=(n,r)=>(e,t)=>r(e,t,n);y.CellPopupManagerService=class extends a.Disposable{constructor(e){super();T(this,"_cellPopupMap",new Map);T(this,"_change$",new D.Subject);T(this,"change$",this._change$.asObservable());this._sheetCanvasPopManagerService=e}_ensureCellPopupMap(e,t){let i=this._cellPopupMap.get(e);i||(i=new Map,this._cellPopupMap.set(e,i));let o=i.get(t);return o||(o=new a.ObjectMatrix,i.set(t,o)),o}showPopup(e,t){var g,S;const{direction:i="horizontal"}=t,{unitId:o,subUnitId:s,row:l,col:c}=e,d=this._ensureCellPopupMap(o,s),u=(g=d.getValue(l,c))==null?void 0:g[i];t.id=(S=t.id)!=null?S:a.generateRandomId();const h=()=>{const f=d.getValue(l,c);if(!f)return;const v=f[i];if(!v)return;const p=v==null?void 0:v.popups.findIndex(C=>C.id===t.id&&C.componentKey===t.componentKey);v==null||v.popups.splice(p,1),v.popups.length===0&&(v.disposable.dispose(),f[i]=void 0),this._change$.next({...e,direction:i})};if(u)u.popups.push(t),u.popups.sort((f,v)=>f.priority-v.priority);else{const f=this._sheetCanvasPopManagerService.attachPopupToCell(l,c,{...t,direction:i,componentKey:yl,extraProps:{...e,direction:i},noPushMinimumGap:!0,autoRelayout:!1,zIndex:90},o,s);d.setValue(l,c,{...d.getValue(l,c),[i]:{disposable:f,popups:[t]}})}return this._change$.next({...e,direction:i}),a.toDisposable(h)}getPopups(e,t,i,o,s){var c,d;return((d=(c=this._ensureCellPopupMap(e,t).getValue(i,o))==null?void 0:c[s])==null?void 0:d.popups)||[]}},y.CellPopupManagerService=Pg([Og(0,a.Inject(y.SheetCanvasPopManagerService))],y.CellPopupManagerService);const Ag=n=>{const{popup:r}=n,e=r.extraProps,{row:t,col:i,direction:o,unitId:s,subUnitId:l}=e,c=_.useDependency(y.CellPopupManagerService);_.useObservable(W.useMemo(()=>c.change$.pipe(D.filter(h=>h.row===t&&h.col===i&&h.direction===o)),[c,t,i,o]));const d=c.getPopups(s,l,t,i,o),u=_.useDependency(_.ComponentManager);return I.jsx("div",{"data-u-comp":"cell-popup",className:"univer-ml-px univer-flex univer-flex-col",children:d.map(h=>{var S;const g=u.get(h.componentKey);return g?I.jsx(g,{popup:h},(S=h.id)!=null?S:h.componentKey):null})})},Rl=n=>{const{inputId:r,state:e=!1,type:t="range",confirm:i,cancel:o,name:s,formulaOrRefString:l,comment:c="",localSheetId:d=m.SCOPE_WORKBOOK_VALUE_DEFINED_NAME,hidden:u=!1,id:h}=n,S=_.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),f=_.useDependency(a.LocaleService),v=_.useDependency(K.IDefinedNamesService),p=_.useDependency(K.IFunctionService),C=_.useDependency(K.LexerTreeBuilder),b=_.useDependency(_.ComponentManager),w=W.useMemo(()=>b.get(Vr),[]),E=W.useMemo(()=>b.get(Di),[]);if(S==null)return;const O=W.useMemo(()=>S.getUnitId(),[]),M=W.useMemo(()=>S.getActiveSheet().getSheetId(),[]),[P,A]=W.useState(s),[k,N]=W.useState(l),[H,x]=W.useState(c),[L,V]=W.useState(d),[U,B]=W.useState(""),[Y,F]=W.useState(t),[z,j]=W.useState(!0),Q=[{label:f.t("definedName.scopeWorkbook"),value:m.SCOPE_WORKBOOK_VALUE_DEFINED_NAME}],ie=oe=>!K.isReferenceStrings(oe);W.useEffect(()=>{j(!0),A(s),x(c),V(d);let oe=l;l.substring(0,1)===K.operatorToken.EQUALS?F("formula"):ie(l)?(F("formula"),oe=K.operatorToken.EQUALS+l):F("range"),N(oe),B("")},[e]),S.getSheetOrders().forEach(oe=>{const ae=S.getSheetBySheetId(oe);Q.push({label:(ae==null?void 0:ae.getName())||"",value:oe})});const $=oe=>{N(oe)},se=oe=>{N(oe||"")},Z=()=>{if(P.length===0){B(f.t("definedName.nameEmpty"));return}if(v.getValueByName(O,P)!=null&&(h==null||h.length===0)){B(f.t("definedName.nameDuplicate"));return}if(!a.Tools.isValidParameter(P)||K.isReferenceStringWithEffectiveColumn(P)||!a.Tools.isStartValidPosition(P)&&!R.hasCJKText(P.substring(0,1))){B(f.t("definedName.nameInvalid"));return}if(S.getSheetOrders().map(te=>{var fe;return((fe=S.getSheetBySheetId(te))==null?void 0:fe.getName())||""}).includes(P)){B(f.t("definedName.nameSheetConflict"));return}if(k.length===0){B(f.t("definedName.formulaOrRefStringEmpty"));return}if(!z){B(f.t("definedName.formulaOrRefStringInvalid"));return}if(p.hasExecutor(P.toUpperCase())){B(f.t("definedName.nameConflict"));return}const ae=S.getActiveSheet().getName();i&&i({id:h||"",name:P,formulaOrRefString:C.convertRefersToAbsolute(k,a.AbsoluteRefType.ALL,a.AbsoluteRefType.ALL,ae),comment:H,localSheetId:L})},G=oe=>{const ae=oe;ae==="formula"?l[0]===K.operatorToken.EQUALS?N(l):N(`${K.operatorToken.EQUALS}`):l[0]===K.operatorToken.EQUALS?N(""):N(l),F(ae)},J=W.useRef(null),[re,ue]=W.useState(!1);return _.useSidebarClick(oe=>{var te;((te=J.current)==null?void 0:te.isClickOutSide(oe))&&ue(!1)}),I.jsxs("div",{className:X.clsx("univer-grid univer-space-y-2 univer-pb-1",X.borderBottomClassName,{"univer-hidden":!e}),children:[I.jsx("div",{children:I.jsx(X.Input,{className:"univer-w-full",placeholder:f.t("definedName.inputNamePlaceholder"),value:P,allowClear:!0,onChange:A})}),I.jsx("div",{children:I.jsxs(X.RadioGroup,{value:Y,onChange:G,children:[I.jsx(X.Radio,{value:"range",children:f.t("definedName.ratioRange")}),I.jsx(X.Radio,{value:"formula",children:f.t("definedName.ratioFormula")})]})}),Y==="range"?w&&I.jsx(w,{unitId:O,subUnitId:M,initialValue:k,onChange:(oe,ae)=>$(ae),supportAcrossSheet:!0}):E&&I.jsx("div",{className:"univer-relative univer-mt-4 univer-h-full",children:I.jsx("div",{className:"univer-relative univer-h-8 univer-select-none",children:I.jsx(E,{ref:J,className:X.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",X.borderClassName),initValue:k,unitId:O,subUnitId:M,isFocus:re,isSupportAcrossSheet:!0,onChange:(oe="")=>{se(oe||"")},onVerify:oe=>{j(oe)},onFocus:()=>ue(!0)})})}),I.jsx("div",{children:I.jsx(X.Select,{className:"univer-w-full",value:L,options:Q,onChange:V})}),I.jsx("div",{children:I.jsx(X.Input,{className:"univer-w-full",placeholder:f.t("definedName.inputCommentPlaceholder"),value:H,onChange:x})}),I.jsxs("div",{className:X.clsx("univer-items-center univer-gap-1 univer-text-sm univer-text-red-500",{"univer-hidden":U.length===0,"univer-flex":U.length!==0}),children:[I.jsx("span",{children:U}),I.jsx(to,{})]}),I.jsxs("div",{className:"univer-flex univer-gap-2",children:[I.jsx(X.Button,{onClick:()=>{o==null||o()},children:f.t("definedName.cancel")}),I.jsx(X.Button,{variant:"primary",onClick:Z,children:f.t("definedName.confirm")})]})]})},Ml=()=>{const n=_.useDependency(a.ICommandService),e=_.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=_.useDependency(a.LocaleService),i=_.useDependency(K.IDefinedNamesService),o=_.useDependency(m.SheetsSelectionsService);if(e==null)return;const s=e.getUnitId(),l=()=>{const H=i.getDefinedNameMap(s);return H?Array.from(Object.values(H)):[]},[c,d]=W.useState(!1),[u,h]=W.useState(l()),[g,S]=W.useState(null),[f,v]=W.useState();W.useEffect(()=>{const H=i.update$.subscribe(()=>{h(l())});return()=>{H.unsubscribe()}},[]);const p=H=>{const{name:x,formulaOrRefString:L,comment:V,localSheetId:U,hidden:B}=H;let Y=H.id;if(Y==null||Y.length===0)Y=a.Tools.generateRandomId(10),n.executeCommand(m.InsertDefinedNameCommand.id,{id:Y,unitId:s,name:x,formulaOrRefString:L,comment:V,localSheetId:U,hidden:B});else{const F={id:Y,unitId:s,name:x,formulaOrRefString:L,comment:V,localSheetId:U,hidden:B};n.executeCommand(m.SetDefinedNameCommand.id,F)}d(!1),S(null)},C=H=>{v(H)};function b(){v(null)}function w(H){const x=i.getValueById(s,H);n.executeCommand(m.RemoveDefinedNameCommand.id,{...x,unitId:s}),v(null)}const E=async H=>{const{formulaOrRefString:x,id:L}=H,V=i.getWorksheetByRef(s,x);if(!V)return;V.isSheetHidden()&&await n.executeCommand(m.SetWorksheetShowCommand.id,{unitId:s,subUnitId:V.getSheetId()}),i.focusRange(s,L)},O=()=>{const H=u.length+1,x=t.t("definedName.defaultName")+H;if(i.getValueByName(s,x)==null)return x;let L=H+1;for(;;){const V=t.t("definedName.defaultName")+L;if(i.getValueByName(s,V)==null)return V;L++}},M=()=>{var V;const H=(V=e.getActiveSheet())==null?void 0:V.getName();if(!H)return"";const x=o.getCurrentSelections();return x==null?"":x.map(U=>K.serializeRangeWithSheet(H,U.range)).join(",")},P=()=>{d(!1),S(null)},A=()=>{d(!0),S(null)},k=H=>{d(!1),S(H)},N=H=>{const x=e.getSheetBySheetId(H);return x==null?"":x.getName()};return I.jsx("div",{"data-u-comp":"defined-name-container",className:"univer-relative univer-box-border univer-w-full",children:I.jsxs("div",{className:X.clsx("univer-w-full univer-overflow-hidden univer-overflow-y-auto",X.scrollbarClassName),children:[I.jsxs("div",{className:"univer-mb-4",children:[I.jsxs(X.Button,{className:X.clsx("univer-w-full",{"univer-hidden":c}),onClick:A,children:[I.jsx(no,{}),I.jsx("span",{className:"univer-ml-1",children:t.t("definedName.addButton")})]}),c&&I.jsx(Rl,{confirm:p,cancel:P,state:c,inputId:"insertDefinedName",name:O(),formulaOrRefString:M()})]},"insertDefinedName"),u.map((H,x)=>I.jsxs("div",{className:"univer-divide-x-0 univer-divide-y univer-divide-solid univer-divide-gray-200 dark:!univer-divide-gray-600",children:[I.jsxs("div",{className:X.clsx("univer-group univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-justify-between univer-rounded-md univer-p-2 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-50",{"univer-hidden":H.id===g}),onClick:()=>{E(H)},children:[I.jsxs("div",{title:H.comment,children:[I.jsxs("div",{className:"univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-overflow-hidden univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",children:[H.name,I.jsx("span",{className:"univer-text-xxs univer-ml-1 univer-text-gray-400",children:H.localSheetId===m.SCOPE_WORKBOOK_VALUE_DEFINED_NAME||H.localSheetId==null?"":N(H.localSheetId)})]}),I.jsx("div",{className:"univer-my-1 univer-max-h-[100px] univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-text-gray-500",children:H.formulaOrRefString})]}),I.jsx(X.Tooltip,{title:t.t("definedName.updateButton"),placement:"top",children:I.jsx("a",{className:"univer-absolute univer-right-[60px] univer-top-1/2 univer-hidden -univer-translate-y-1/2 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-xs univer-text-primary-600 dark:hover:!univer-bg-gray-600 group-hover:univer-flex hover:univer-bg-gray-100",onClick:L=>{L.stopPropagation(),k(H.id)},children:I.jsx(oa,{})})}),I.jsx(X.Tooltip,{title:t.t("definedName.deleteButton"),placement:"top",children:I.jsx("a",{className:"univer-absolute univer-text-xs univer-text-error univer-right-5 univer-top-1/2 univer-hidden -univer-translate-y-1/2 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-red-600 dark:hover:!univer-bg-gray-600 group-hover:univer-flex hover:univer-bg-gray-100",onClick:L=>{L.stopPropagation(),C(H.id)},children:I.jsx(zi,{})})})]}),I.jsx(X.Confirm,{visible:f===H.id,onClose:b,onConfirm:()=>{w(H.id)},children:t.t("definedName.deleteConfirmText")}),H.id===g&&I.jsx(Rl,{confirm:p,cancel:P,state:H.id===g,id:H.id,inputId:H.id+x,name:H.name,formulaOrRefString:H.formulaOrRefString,comment:H.comment,localSheetId:H.localSheetId})]},x))]})})};function Dg(n){const r=n.get(m.BorderStyleManagerService),e=ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]});return{id:m.SetBorderBasicCommand.id,icon:new D.Observable(t=>{const i="AllBorderIcon",o=n.get(m.BorderStyleManagerService),s=n.get(a.ICommandService).onCommandExecuted(l=>{var g;if(l.id!==m.SetBorderBasicCommand.id)return;const{type:d}=o.getBorderInfo(),u=El.find(S=>S.value===d),h=(g=u==null?void 0:u.icon)!=null?g:i;t.next(h)});return t.next(i),s.dispose}),tooltip:"toolbar.border.main",type:_.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:Xo,hoverable:!1,selectable:!1},value$:r.borderInfo$}],value$:r.borderInfo$,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:e}}const ar="sheet.menu.clear-selection";function jo(n){return{id:ar,type:_.MenuItemType.SUBITEMS,icon:"ClearFormatDoubleIcon",title:"rightClick.clearSelection",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Go(n){return{id:m.ClearSelectionContentCommand.id,type:_.MenuItemType.BUTTON,icon:"ClearFormatDoubleIcon",title:"rightClick.clearContent",disabled$:Nt(n,ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellValuePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Zo(n){return{id:m.ClearSelectionFormatCommand.id,type:_.MenuItemType.BUTTON,icon:"ClearFormatDoubleIcon",title:"rightClick.clearFormat",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function lr(n){return{id:m.ClearSelectionAllCommand.id,type:_.MenuItemType.BUTTON,icon:"ClearFormatDoubleIcon",title:"rightClick.clearAll",tooltip:"rightClick.clearAll",disabled$:Nt(n,ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellValuePermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Pl="sheet.menu.delete";function kg(n){return{id:Pl,type:_.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"ReduceDoubleIcon",hidden$:Nt(n,vn(n)),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission]})}}function Ol(n){return{id:Tn.id,type:_.MenuItemType.BUTTON,icon:"DeleteColumnDoubleIcon",title:"rightClick.deleteSelectedColumn",hidden$:$a(n,"col"),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetDeleteColumnPermission]})}}function Al(n){return{id:En.id,type:_.MenuItemType.BUTTON,icon:"DeleteRowDoubleIcon",title:"rightClick.deleteSelectedRow",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetDeleteRowPermission]}),hidden$:$a(n,"row")}}function Ng(n){return{id:_n.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeftDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"col")}}function Hg(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUpDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"row")}}function Vg(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService);return{id:m.ToggleGridlinesCommand.id,type:_.MenuItemType.BUTTON,tooltip:"toolbar.toggleGridlines",icon:"HideGridlinesDoubleIcon",activated$:new D.Observable(t=>{const i=()=>{const s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return s?s.getActiveSheet().getConfig().showGridlines===a.BooleanNumber.TRUE:!1},o=new a.DisposableCollection;return o.add(r.onCommandExecuted(s=>{(s.id===m.ToggleGridlinesMutation.id||s.id===m.SetWorksheetActiveOperation.id)&&t.next(i())})),o.add(e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(()=>{t.next(i())})),t.next(i()),()=>o.dispose()}),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission]})}}const Dl="sheet.menu.cell-insert";function Wg(n){return{id:Dl,type:_.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"InsertDoubleIcon",hidden$:Nt(n,vn(n)),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertColumnPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function xg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertRowBeforeCommand.id,type:_.MenuItemType.BUTTON,icon:"InsertRowAboveDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertRowsAbove",min:1,max:1e3,suffix:"rightClick.insertRowsAboveSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endRow)-(c==null?void 0:c.startRow)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:Ja(n,"row")}}function Lg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertColBeforeCommand.id,type:_.MenuItemType.BUTTON,icon:"LeftInsertColumnDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertColsLeft",min:1,max:1e3,suffix:"rightClick.insertColsLeftSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endColumn)-(c==null?void 0:c.startColumn)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertColumnPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:Ja(n,"col")}}function Ug(n){return{id:In.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRightDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"col")}}function Bg(n){return{id:Wt.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDownDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"row")}}function Fg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiRowsAfterCommand.id,type:_.MenuItemType.BUTTON,icon:"InsertRowBelowDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertRowsAfter",min:1,max:1e3,suffix:"rightClick.insertRowsAfterSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endRow)-(c==null?void 0:c.startRow)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function zg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiRowsAboveCommand.id,type:_.MenuItemType.BUTTON,icon:"InsertRowAboveDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertRowsAbove",min:1,max:1e3,suffix:"rightClick.insertRowsAboveSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endRow)-(c==null?void 0:c.startRow)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function Xg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiColsLeftCommand.id,type:_.MenuItemType.BUTTON,icon:"LeftInsertColumnDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertColsLeft",min:1,max:1e3,suffix:"rightClick.insertColsLeftSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endColumn)-(c==null?void 0:c.startColumn)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function Yg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiColsRightCommand.id,type:_.MenuItemType.BUTTON,icon:"RightInsertColumnDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertColsRight",min:1,max:1e3,suffix:"rightClick.insertColsRightSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endColumn)-(c==null?void 0:c.startColumn)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function jg(n){const r=Nt(n,ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellValuePermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})),e=Bm(n);return{id:gt.id,icon:"MergeAllIcon",tooltip:"toolbar.mergeCell.main",type:_.MenuItemType.SUBITEMS,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:r.pipe(D.combineLatestWith(e),D.map(([t,i])=>t||i))}}function Gg(n){return{id:Uo.id,type:_.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Zg(n){return{id:Bo.id,type:_.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Kg(n){return{id:Fo.id,type:_.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qg(n){return{id:m.RemoveWorksheetMergeCommand.id,type:_.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Qg(n){const e=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),t=n.get(a.UserManagerService);return D.combineLatest([e,t.currentUser$]).pipe(D.switchMap(([i,o])=>i?i.activeSheet$.pipe(D.switchMap(s=>{if(!s)return D.of(!0);const l=n.get(m.RangeProtectionRuleModel),c=n.get(m.WorksheetProtectionRuleModel),d=n.get(m.SheetsSelectionsService);return D.merge(d.selectionMoveEnd$,l.ruleChange$,c.ruleChange$).pipe(D.map(()=>{const u=i.getUnitId(),h=s.getSheetId(),g=l.getSubunitRuleList(u,h),S=d.getCurrentSelections(),f=S==null?void 0:S.map(C=>C.range),v=g.map(C=>C.ranges).flat();if(!f)return!1;const p=c.getRule(u,h);return p!=null&&p.permissionId?!0:f==null?void 0:f.some(C=>v.some(b=>a.Rectangle.intersects(C,b)))}))})):D.of(!0)))}function Jg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.RangeProtectionRuleModel),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{if(!l)return D.of(!0);const c=n.get(m.RangeProtectionRuleModel),d=n.get(m.WorksheetProtectionRuleModel),u=n.get(a.IPermissionService),h=n.get(m.SheetsSelectionsService);return D.merge(h.selectionMoveEnd$,c.ruleChange$,d.ruleChange$).pipe(D.map(()=>{var A,k;const g=o.getUnitId(),S=l.getSheetId(),f=e.getSubunitRuleList(g,S),v=(A=h.getCurrentSelections())==null?void 0:A.map(N=>N.range);if(f.map(N=>N.ranges).flat(),!(v!=null&&v.length)||v.length>1)return!0;const p=v[0];if((p==null?void 0:p.rangeType)===a.RANGE_TYPE.ALL||(p==null?void 0:p.rangeType)===a.RANGE_TYPE.COLUMN||(p==null?void 0:p.rangeType)===a.RANGE_TYPE.ROW)return!0;const C=d.getRule(g,S);if(C!=null&&C.permissionId)return((k=u.getPermissionPoint(new m.WorksheetManageCollaboratorPermission(g,S).id))==null?void 0:k.value)===!1;if(f.filter(N=>N.ranges.some(H=>a.Rectangle.intersects(H,p))).length!==1)return!0;const{startRow:w,endRow:E,startColumn:O,endColumn:M}=p,P=n.get(m.RangeProtectionCache);for(let N=w;N<=E;N++)for(let H=O;H<=M;H++){const x=P.getCellInfo(g,S,N,H);if(x)return x[m.UnitAction.ManageCollaborator]===!1}return!1}))})):D.of(!0)))}function $g(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{var f;if(!l)return D.of(!0);const c=o.getUnitId(),d=n.get(m.SheetsSelectionsService),u=n.get(m.RangeProtectionRuleModel),h=n.get(m.WorksheetProtectionRuleModel),g=(f=e.composePermission$([new m.WorkbookEditablePermission(c).id]).pipe(D.map(v=>v.every(p=>p.value))))!=null?f:D.of(!1),S=D.merge(u.ruleChange$,h.ruleChange$).pipe(D.startWith(null));return D.combineLatest([g,S,d.selectionMoveEnd$]).pipe(D.map(([v,p,C])=>{if(!v)return!0;const b=d.getCurrentSelections(),w=b==null?void 0:b.map(E=>E.range);return w!=null&&w.length?w.length>1:!1}))})):D.of(!0)))}function kl(n){var d;const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService),o=n.has(me)?n.get(me):null,l=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).pipe(D.startWith(!1),D.shareReplay(1)),c=(d=o==null?void 0:o.visible$.pipe(D.startWith(null),D.shareReplay(1)))!=null?d:D.of(null);return D.combineLatest([t,i.currentUser$,c,l]).pipe(D.switchMap(([u,h,g,S])=>!u||g!=null&&g.visible&&g.unitId===u.getUnitId()||S?D.of(!0):u.activeSheet$.pipe(D.switchMap(f=>{var A;if(!f)return D.of(!0);const p=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(D.startWith(!1)),C=u.getUnitId(),b=f.getSheetId(),w=n.get(m.RangeProtectionRuleModel),E=n.get(m.WorksheetProtectionRuleModel),O=n.get(m.SheetsSelectionsService),M=(A=e.composePermission$([new m.WorkbookCreateProtectPermission(C).id]).pipe(D.map(k=>k.every(N=>N.value))))!=null?A:D.of(!1),P=D.merge(w.ruleChange$,E.ruleChange$).pipe(D.startWith(null));return D.combineLatest([M,P,O.selectionMoveEnd$,p]).pipe(D.map(([k,N,H,x])=>{if(!k||x)return!0;const L=O.getCurrentSelections(),V=L==null?void 0:L.map(F=>F.range);if(!(V!=null&&V.length))return!0;const U=E.getRule(C,b);if(U!=null&&U.permissionId)return!0;const B=w.getSubunitRuleList(C,b);return V==null?void 0:V.some(F=>B.some(z=>z.ranges.some(j=>a.Rectangle.intersects(F,j))))}))}))))}function eS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{var f;if(!l)return D.of(!0);const c=o.getUnitId(),d=l.getSheetId(),u=n.get(m.RangeProtectionRuleModel),h=n.get(m.WorksheetProtectionRuleModel),g=(f=e.composePermission$([new m.WorkbookCreateProtectPermission(c).id]).pipe(D.map(v=>v.every(p=>p.value))))!=null?f:D.of(!1),S=D.merge(u.ruleChange$,h.ruleChange$).pipe(D.startWith(null));return D.combineLatest([g,S]).pipe(D.map(([v,p])=>{var w;if(!v)return!0;const C=h.getRule(c,d);return C!=null&&C.permissionId?!0:((w=u.getSubunitRuleList(c,d))==null?void 0:w.filter(E=>E==null?void 0:E.permissionId)).length>0}))})):D.of(!0)))}function tS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{if(!l)return D.of(!0);const c=o.getUnitId(),d=l.getSheetId(),u=n.get(m.WorksheetProtectionRuleModel);return u.ruleChange$.pipe(D.startWith(null)).pipe(D.map(()=>{var g;return u.getRule(c,d)?((g=e.getPermissionPoint(new m.WorksheetDeleteProtectionPermission(c,d).id))==null?void 0:g.value)===!1:!0}))})):D.of(!0)))}function nS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{var f;if(!l)return D.of(!0);const c=o.getUnitId(),d=n.get(m.RangeProtectionRuleModel),u=n.get(m.WorksheetProtectionRuleModel),h=(f=e.composePermission$([new m.WorkbookCreateProtectPermission(c).id,new m.WorkbookManageCollaboratorPermission(c).id]).pipe(D.map(v=>v.every(p=>p.value))))!=null?f:D.of(!1),g=u.ruleChange$.pipe(D.startWith(null)),S=d.ruleChange$.pipe(D.startWith(null));return D.combineLatest([h,g,S]).pipe(D.map(([v,p,C])=>{if(!v)return!0;const b=l.getSheetId(),w=u.getRule(c,b),E=d.getSubunitRuleList(c,b);return!(w||E.length)}))})):D.of(!0)))}function iS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{if(!l)return D.of(!0);const c=o.getUnitId(),d=l.getSheetId(),u=n.get(m.SheetsSelectionsService),h=n.get(m.RangeProtectionRuleModel),g=n.get(m.WorksheetProtectionRuleModel),S=D.merge(h.ruleChange$,g.ruleChange$,u.selectionMoveEnd$).pipe(D.startWith(null));return D.combineLatest([S]).pipe(D.map(([f])=>{var k;const v=n.get(m.SheetsSelectionsService).getCurrentSelections(),p=v==null?void 0:v.map(N=>N.range);if(!(p!=null&&p.length)||p.length>1)return!0;const C=p[0];if((C==null?void 0:C.rangeType)===a.RANGE_TYPE.ALL||(C==null?void 0:C.rangeType)===a.RANGE_TYPE.COLUMN||(C==null?void 0:C.rangeType)===a.RANGE_TYPE.ROW)return!0;const b=g.getRule(c,d);if(b!=null&&b.permissionId)return((k=e.getPermissionPoint(new m.WorksheetDeleteProtectionPermission(c,d).id))==null?void 0:k.value)===!1;if(h.getSubunitRuleList(c,d).filter(N=>N.ranges.some(H=>a.Rectangle.intersects(H,C))).length!==1)return!0;const{startRow:E,endRow:O,startColumn:M,endColumn:P}=C,A=n.get(m.RangeProtectionCache);for(let N=E;N<=O;N++)for(let H=M;H<=P;H++){const x=A.getCellInfo(c,d,N,H);if(x)return x[m.UnitAction.Delete]===!1}return!1}))})):D.of(!0)))}function Nl(n){var d;const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService),o=n.has(me)?n.get(me):null,l=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR),c=(d=o==null?void 0:o.visible$)!=null?d:D.of(null);return D.combineLatest([t,i.currentUser$,c,l]).pipe(D.switchMap(([u,h,g,S])=>!u||g!=null&&g.visible&&g.unitId===u.getUnitId()||S?D.of(!0):u.activeSheet$.pipe(D.switchMap(f=>{var C,b;if(!f)return D.of(!0);const v=u.getUnitId();return((b=(C=e.getPermissionPoint$(new m.WorkbookEditablePermission(v).id))==null?void 0:C.pipe(D.map(w=>!!w.value)))!=null?b:D.of(!1)).pipe(D.map(w=>!w))}))))}const cr="sheet.contextMenu.permission";function rS(n){return{id:hi.id,type:_.MenuItemType.BUTTON,icon:Il,tooltip:"permission.toolbarMenu",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:kl(n)}}function Ko(n){return{id:cr,type:_.MenuItemType.SUBITEMS,title:"rightClick.protectRange",icon:bl,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qo(n){return{id:xt.id,type:_.MenuItemType.BUTTON,title:"rightClick.turnOnProtectRange",hidden$:Qg(n),disabled$:kl(n)}}function Qo(n){return{id:Bt.id,type:_.MenuItemType.BUTTON,title:"rightClick.editProtectRange",disabled$:$g(n),hidden$:Jg(n)}}function Jo(n){return{id:Ut.id,type:_.MenuItemType.BUTTON,title:"rightClick.removeProtectRange",disabled$:iS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function $o(n){return{id:Lt.id,type:_.MenuItemType.BUTTON,title:"rightClick.viewAllProtectArea",disabled$:Nl(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function oS(n){return{id:mi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.addProtectSheet",disabled$:eS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function sS(n){return{id:vi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.removeProtectSheet",disabled$:tS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function aS(n){return{id:pi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.changeSheetPermission",disabled$:nS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function lS(n){return{id:gi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.viewAllProtectArea",disabled$:Nl(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function cS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.ICommandService),t=new D.Observable(o=>{const s=e.onCommandExecuted(l=>{const c=l.id;(c===m.RemoveSheetMutation.id||c===m.InsertSheetMutation.id||c===m.SetWorksheetHideMutation.id)&&dr(r,o)});return dr(r,o),s.dispose}),i=pn(n,[m.WorkbookEditablePermission,m.WorkbookDeleteSheetPermission]);return{id:Si.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.delete",disabled$:D.combineLatest([t,i]).pipe(D.map(([o,s])=>o||s)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function dS(n){return{id:m.CopySheetCommand.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.copy",disabled$:pn(n,[m.WorkbookEditablePermission,m.WorkbookCreateSheetPermission]),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function uS(n){return{id:Ci.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.rename",disabled$:pn(n,[m.WorkbookEditablePermission,m.WorkbookRenameSheetPermission]),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function hS(n){return{id:m.SetTabColorCommand.id,title:"sheetConfig.changeColor",type:_.MenuItemType.SELECTOR,selections:[{label:{name:_.COLOR_PICKER_COMPONENT,hoverable:!1}}],hidden$:pn(n,[m.WorkbookEditablePermission])}}function mS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.ICommandService);return{id:m.SetWorksheetHideCommand.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.hide",disabled$:new D.Observable(t=>{const i=e.onCommandExecuted(o=>{const s=o.id;(s===m.RemoveSheetMutation.id||s===m.InsertSheetMutation.id||s===m.SetWorksheetHideMutation.id)&&dr(r,t)});return dr(r,t),i.dispose}).pipe(D.combineLatestWith(pn(n,[m.WorkbookEditablePermission,m.WorkbookHideSheetPermission])),D.map(([t,i])=>t||i)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function gS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.ICommandService);return{id:fi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.unhide",disabled$:new D.Observable(t=>{function i(){const s=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),l=Array.from(s.values());t.next(l.length===1)}const o=e.onCommandExecuted(s=>{const l=s.id;(l===m.RemoveSheetMutation.id||l===m.InsertSheetMutation.id||l===m.SetWorksheetHideMutation.id)&&i()});return i(),o.dispose}).pipe(D.combineLatestWith(pn(n,[m.WorkbookEditablePermission,m.WorkbookHideSheetPermission])),D.map(([t,i])=>t||i)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function dr(n,r){const e=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),t=Array.from(e.values()).filter(i=>i.getConfig().hidden===a.BooleanNumber.FALSE);r.next(t.length===1)}const Hl={[_.RibbonPosition.START]:{[_.RibbonStartGroup.HISTORY]:{[fn.id]:{order:2,menuItemFactory:lm},[m.ClearSelectionAllCommand.id]:{order:3,menuItemFactory:lr}},[_.RibbonStartGroup.FORMAT]:{[Jn.id]:{order:1,menuItemFactory:mm},[Qn.id]:{order:2,menuItemFactory:gm},[Ot.id]:{order:5,menuItemFactory:cm},[At.id]:{order:6,menuItemFactory:dm},[Dt.id]:{order:7,menuItemFactory:um},[kt.id]:{order:8,menuItemFactory:hm},[gn.id]:{order:9,menuItemFactory:fm,[m.ResetTextColorCommand.id]:{order:0,menuItemFactory:Sm}},[m.SetBackgroundColorCommand.id]:{order:10,menuItemFactory:pm,[m.ResetBackgroundColorCommand.id]:{order:0,menuItemFactory:vm}},[m.SetBorderBasicCommand.id]:{order:11,menuItemFactory:Dg}},[_.RibbonStartGroup.LAYOUT]:{[m.SetHorizontalTextAlignCommand.id]:{order:0,menuItemFactory:Cm},[m.SetVerticalTextAlignCommand.id]:{order:3,menuItemFactory:_m},[m.SetTextWrapCommand.id]:{order:6,menuItemFactory:Im},[m.SetTextRotationCommand.id]:{order:7,menuItemFactory:bm},[m.AddWorksheetMergeCommand.id]:{order:8,menuItemFactory:jg,[m.AddWorksheetMergeAllCommand.id]:{order:0,menuItemFactory:Gg},[m.AddWorksheetMergeVerticalCommand.id]:{order:1,menuItemFactory:Zg},[m.AddWorksheetMergeHorizontalCommand.id]:{order:2,menuItemFactory:Kg},[m.RemoveWorksheetMergeCommand.id]:{order:3,menuItemFactory:qg}}},[_.RibbonStartGroup.OTHERS]:{[hi.id]:{order:0,menuItemFactory:rS}}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.FORMAT]:{[Be.name]:{order:0,menuItemFactory:Cn},[Fe.name]:{order:2,menuItemFactory:wo},[oi]:{order:3,menuItemFactory:Eo,[un.id]:{order:0,menuItemFactory:To},[hn.id]:{order:1,menuItemFactory:yo},[Pt.id]:{order:2,menuItemFactory:Ro},[mn.id]:{order:3,menuItemFactory:Mo}},[ar]:{order:4,menuItemFactory:jo,[m.ClearSelectionContentCommand.id]:{order:0,menuItemFactory:Go},[m.ClearSelectionFormatCommand.id]:{order:1,menuItemFactory:Zo},[m.ClearSelectionAllCommand.id]:{order:2,menuItemFactory:lr}}},[_.ContextMenuGroup.LAYOUT]:{order:1,[Dl]:{order:0,menuItemFactory:Wg,[m.InsertRowBeforeCommand.id]:{order:0,menuItemFactory:xg},[m.InsertColBeforeCommand.id]:{order:1,menuItemFactory:Lg},[In.id]:{order:2,menuItemFactory:Ug},[Wt.id]:{order:3,menuItemFactory:Bg}},[Pl]:{order:0,menuItemFactory:kg,[Tn.id]:{order:0,menuItemFactory:Ol},[En.id]:{order:1,menuItemFactory:Al},[_n.id]:{order:2,menuItemFactory:Ng},[Vt.id]:{order:3,menuItemFactory:Hg}},[ol]:{order:2,menuItemFactory:Tm,[$e.id]:{order:0,menuItemFactory:Oo},[ti.id]:{order:1,menuItemFactory:ym},[ni.id]:{order:2,menuItemFactory:Rm},[m.CancelFrozenCommand.id]:{order:3,menuItemFactory:Ao}},[cr]:{order:3,menuItemFactory:Ko,[xt.id]:{order:0,menuItemFactory:qo},[Bt.id]:{order:1,menuItemFactory:Qo},[Ut.id]:{order:2,menuItemFactory:Jo},[Lt.id]:{order:3,menuItemFactory:$o}}},[_.ContextMenuGroup.DATA]:{order:2},[_.ContextMenuGroup.OTHERS]:{order:3}},[_.ContextMenuPosition.COL_HEADER]:{[_.ContextMenuGroup.FORMAT]:{[Be.name]:{order:0,menuItemFactory:Cn},[Fe.name]:{order:2,menuItemFactory:wo},[oi]:{order:3,menuItemFactory:Eo,[un.id]:{order:0,menuItemFactory:To},[hn.id]:{order:1,menuItemFactory:yo},[Pt.id]:{order:2,menuItemFactory:Ro},[mn.id]:{order:3,menuItemFactory:Mo}},[ar]:{order:4,menuItemFactory:jo,[m.ClearSelectionContentCommand.id]:{order:0,menuItemFactory:Go},[m.ClearSelectionFormatCommand.id]:{order:1,menuItemFactory:Zo},[m.ClearSelectionAllCommand.id]:{order:2,menuItemFactory:lr}}},[_.ContextMenuGroup.LAYOUT]:{order:1,[m.InsertMultiColsLeftCommand.id]:{order:0,menuItemFactory:Xg},[m.InsertMultiColsRightCommand.id]:{order:0,menuItemFactory:Yg},[qn.id]:{order:1,menuItemFactory:Pm},[m.SetSelectedColsVisibleCommand.id]:{order:2,menuItemFactory:Am},[Tn.id]:{order:2,menuItemFactory:Ol},[m.SetColWidthCommand.id]:{order:3,menuItemFactory:km},[ii.id]:{order:4,menuItemFactory:Em},[Po]:{order:5,menuItemFactory:sl,[$e.id]:{order:0,menuItemFactory:Oo},[m.CancelFrozenCommand.id]:{order:3,menuItemFactory:Ao}},[cr]:{order:6,menuItemFactory:Ko,[xt.id]:{order:0,menuItemFactory:qo},[Bt.id]:{order:1,menuItemFactory:Qo},[Ut.id]:{order:2,menuItemFactory:Jo},[Lt.id]:{order:3,menuItemFactory:$o}}},[_.ContextMenuGroup.DATA]:{order:2},[_.ContextMenuGroup.OTHERS]:{order:3}},[_.ContextMenuPosition.ROW_HEADER]:{[_.ContextMenuGroup.FORMAT]:{[Be.name]:{order:0,menuItemFactory:Cn},[Fe.name]:{order:2,menuItemFactory:wo},[oi]:{order:3,menuItemFactory:Eo,[un.id]:{order:0,menuItemFactory:To},[hn.id]:{order:1,menuItemFactory:yo},[Pt.id]:{order:2,menuItemFactory:Ro},[mn.id]:{order:3,menuItemFactory:Mo}},[ar]:{order:4,menuItemFactory:jo,[m.ClearSelectionContentCommand.id]:{order:0,menuItemFactory:Go},[m.ClearSelectionFormatCommand.id]:{order:1,menuItemFactory:Zo},[m.ClearSelectionAllCommand.id]:{order:2,menuItemFactory:lr}}},[_.ContextMenuGroup.LAYOUT]:{order:1,[m.InsertMultiRowsAboveCommand.id]:{order:0,menuItemFactory:zg},[m.InsertMultiRowsAfterCommand.id]:{order:1,menuItemFactory:Fg},[En.id]:{order:1,menuItemFactory:Al},[Kn.id]:{order:2,menuItemFactory:Mm},[m.SetSelectedRowsVisibleCommand.id]:{order:2,menuItemFactory:Om},[m.SetRowHeightCommand.id]:{order:3,menuItemFactory:Dm},[m.SetWorksheetRowIsAutoHeightCommand.id]:{order:4,menuItemFactory:wm},[Po]:{order:5,menuItemFactory:sl,[$e.id]:{order:0,menuItemFactory:Oo},[m.CancelFrozenCommand.id]:{order:3,menuItemFactory:Ao}},[cr]:{order:6,menuItemFactory:Ko,[xt.id]:{order:0,menuItemFactory:qo},[Bt.id]:{order:1,menuItemFactory:Qo},[Ut.id]:{order:2,menuItemFactory:Jo},[Lt.id]:{order:3,menuItemFactory:$o}}},[_.ContextMenuGroup.DATA]:{order:2},[_.ContextMenuGroup.OTHERS]:{order:3}},[_.ContextMenuPosition.FOOTER_TABS]:{[_.ContextMenuGroup.OTHERS]:{order:0,[Si.id]:{order:0,menuItemFactory:cS},[m.CopySheetCommand.id]:{order:1,menuItemFactory:dS},[Ci.id]:{order:2,menuItemFactory:uS},[m.SetTabColorCommand.id]:{order:3,menuItemFactory:hS},[m.SetWorksheetHideCommand.id]:{order:4,menuItemFactory:mS},[fi.id]:{order:6,menuItemFactory:gS},[mi.id]:{order:7,menuItemFactory:oS},[vi.id]:{order:8,menuItemFactory:sS},[pi.id]:{order:9,menuItemFactory:aS},[gi.id]:{order:10,menuItemFactory:lS}}},[_.ContextMenuPosition.FOOTER_MENU]:{[_.ContextMenuGroup.OTHERS]:{[m.ToggleGridlinesCommand.id]:{order:1,menuItemFactory:Vg}}}},Vl={id:m.SetRowHiddenCommand.id,preconditions:n=>le(n),binding:_.KeyCode.Digit9|_.MetaKeys.CTRL_COMMAND},Wl={id:m.SetColHiddenCommand.id,preconditions:n=>le(n),binding:_.KeyCode.Digit0|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.SHIFT},xl={id:Re.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN,priority:100,preconditions:le,staticParameters:{direction:a.Direction.DOWN}},Ll={id:Re.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP,priority:100,preconditions:le,staticParameters:{direction:a.Direction.UP}},Ul={id:Re.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT,priority:100,preconditions:_a,staticParameters:{direction:a.Direction.LEFT}},Bl={id:Re.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT,priority:100,preconditions:_a,staticParameters:{direction:a.Direction.RIGHT}},Fl={id:Ye.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:_.KeyCode.TAB,priority:100,preconditions:le,staticParameters:{direction:a.Direction.RIGHT,keycode:_.KeyCode.TAB}},zl={id:Ye.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:_.KeyCode.TAB|_.MetaKeys.SHIFT,priority:100,preconditions:le,staticParameters:{direction:a.Direction.LEFT,keycode:_.KeyCode.TAB}},Xl={id:Ye.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:_.KeyCode.ENTER,priority:100,preconditions:le,staticParameters:{direction:a.Direction.DOWN,keycode:_.KeyCode.ENTER}},Yl={id:Ye.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:_.KeyCode.ENTER|_.MetaKeys.SHIFT,priority:100,preconditions:le,staticParameters:{direction:a.Direction.UP,keycode:_.KeyCode.ENTER}},jl={id:Re.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.DOWN,jumpOver:Xe.moveGap}},Gl={id:Re.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.UP,jumpOver:Xe.moveGap}},Zl={id:Re.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.LEFT,jumpOver:Xe.moveGap}},Kl={id:Re.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Xe.moveGap}},ql={id:Pe.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.DOWN}},Ql={id:Pe.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.UP}},Jl={id:Pe.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.LEFT}},$l={id:Pe.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.RIGHT}},ec={id:Pe.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.DOWN,jumpOver:Xe.moveGap}},tc={id:Pe.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.UP,jumpOver:Xe.moveGap}},nc={id:Pe.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.LEFT,jumpOver:Xe.moveGap}},ic={id:Pe.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Xe.moveGap}},rc={id:Fn.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:_.KeyCode.A|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{expandToGapFirst:!0,loop:!0}},oc={id:Ot.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.B|_.MetaKeys.CTRL_COMMAND},sc={id:At.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.I|_.MetaKeys.CTRL_COMMAND},ac={id:Dt.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.U|_.MetaKeys.CTRL_COMMAND},lc={id:kt.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.X|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND},cc={id:m.ClearSelectionContentCommand.id,preconditions:n=>le(n),binding:_.KeyCode.DELETE,mac:_.KeyCode.BACKSPACE},SS={id:m.ClearSelectionContentCommand.id,preconditions:n=>le(n),mac:_.KeyCode.DELETE},fS={id:m.ClearSelectionContentCommand.id,preconditions:n=>le(n),binding:_.MetaKeys.SHIFT+_.KeyCode.BACKSPACE},vS={id:Ji.id,preconditions:n=>le(n),binding:_.MetaKeys.SHIFT+_.KeyCode.DELETE},dc={id:$t.id,description:"shortcut.sheet.zoom-in",binding:_.KeyCode.EQUAL|_.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:le,priority:1,staticParameters:{delta:.2}},uc={id:a.NilCommand.id,binding:_.KeyCode.EQUAL|_.MetaKeys.CTRL_COMMAND},hc={id:$t.id,description:"shortcut.sheet.zoom-out",binding:_.KeyCode.MINUS|_.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:le,priority:1,staticParameters:{delta:-.2}},mc={id:a.NilCommand.id,binding:_.KeyCode.MINUS|_.MetaKeys.CTRL_COMMAND},gc={id:$t.id,description:"shortcut.sheet.reset-zoom",binding:_.KeyCode.Digit0|_.MetaKeys.CTRL_COMMAND,preconditions:le,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},Sc={id:a.NilCommand.id,binding:_.KeyCode.Digit0|_.MetaKeys.CTRL_COMMAND};var pS=Object.getOwnPropertyDescriptor,CS=(n,r,e,t)=>{for(var i=t>1?void 0:t?pS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ft=(n,r)=>(e,t)=>r(e,t,n);y.SheetUIController=class extends a.Disposable{constructor(r,e,t,i,o,s,l,c){super(),this._injector=r,this._componentManager=e,this._layoutService=t,this._commandService=i,this._shortcutService=o,this._menuManagerService=s,this._uiPartsService=l,this._configService=c,this._init()}_init(){this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Ge,qa)),this.disposeWithMe(r.register(Xo,Tl)),this.disposeWithMe(r.register(Yn,Ml)),this.disposeWithMe(r.register(yl,Ag)),this.disposeWithMe(r.register("HideGridlinesDoubleIcon",ta))}_initCommands(){[Uo,gt,Fo,Bo,$t,Pe,Re,Ye,Ci,Si,En,Tn,Kn,qn,Ue,Jr,Fn,Zi,m.SetBoldCommand,wt,ge,Wn,Ot,At,Dt,kt,_o,Io,Qn,Jn,gn,bo,m.SetItalicCommand,m.SetStrikeThroughCommand,m.SetFontFamilyCommand,m.SetFontSizeCommand,$n,tr,fn,ei,Le,nn,$e,ti,ni,$r,m.SetUnderlineCommand,en,Ne,fi,Vn,Wt,Vt,In,_n,Yi,ht,Qt,Ke,zo,hi,xt,Lt,mi,gi,pi,Ut,Bt,vi,ii,Ni,Hi].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}_initMenus(){this._menuManagerService.mergeMenu(Hl)}_initShortcuts(){[xl,Ll,Ul,Bl,Fl,zl,Xl,Yl,jl,Gl,Zl,Kl,ql,Ql,Jl,$l,ec,tc,nc,ic,rc,dc,hc,gc,Sc,uc,mc,oc,sc,ac,lc,cc,SS,fS,vS,...ba(),Ea,wa,Ta,Ra,Ma,ah,Pa,ya,sh,lh,Vl,Wl].forEach(r=>{this.disposeWithMe(this._shortcutService.registerShortcut(r))})}_initWorkbenchParts(){const r=this._uiPartsService,e=this._injector;this.disposeWithMe(r.registerComponent(_.BuiltInUIPart.HEADER,()=>_.connectInjector(Sa,e))),this.disposeWithMe(r.registerComponent(_.BuiltInUIPart.FOOTER,()=>_.connectInjector(ga,e))),this.disposeWithMe(r.registerComponent(_.BuiltInUIPart.CONTENT,()=>_.connectInjector(fa,e)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_SHEET,r=>{const e=this._injector.get(R.IRenderManagerService),t=this._injector.get(a.IUniverInstanceService),i=R.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_DOC,t,e),o=i==null?void 0:i.with(q.DocSelectionRenderService);o==null||o.focus()}))}},y.SheetUIController=CS([ft(0,a.Inject(a.Injector)),ft(1,a.Inject(_.ComponentManager)),ft(2,_.ILayoutService),ft(3,a.ICommandService),ft(4,_.IShortcutService),ft(5,_.IMenuManagerService),ft(6,_.IUIPartsService),ft(7,a.IConfigService)],y.SheetUIController);const fc=(n=[])=>{const r=_.useDependency(Mt);W.useEffect(()=>{const e=n.map(t=>r.addShape({range:t,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:{startColumn:t.startColumn,endColumn:t.endColumn,startRow:t.startRow,endRow:t.endRow,actualRow:t.startRow,actualColumn:t.startColumn,isMerged:!1,isMergedMainCell:!1}}));return()=>{e.forEach(t=>{t&&r.removeShape(t)})}},[n])};var _S=Object.getOwnPropertyDescriptor,IS=(n,r,e,t)=>{for(var i=t>1?void 0:t?_S(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},vc=(n,r)=>(e,t)=>r(e,t,n);let _i=class extends a.Disposable{constructor(r,e){super();T(this,"_previousSheetIndex",-1);this._commandService=r,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{if(t.id===m.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(t)})),this.disposeWithMe(this._commandService.onCommandExecuted((t,i)=>{if(t.id===m.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(t);if(t.id===m.SetWorksheetHideMutation.id&&t.params.hidden)return this._adjustActiveSheetOnHideSheet(t);if(i!=null&&i.fromCollab)return!1;if(t.id===m.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(t);if(t.id===m.SetWorksheetHideMutation.id&&!t.params.hidden)return this._adjustActiveSheetOnShowSheet(t);if(t.id===m.SetSelectionsOperation.id)return this._adjustActiveSheetOnSelection(t)}))}_adjustActiveSheetOnHideSheet(r){var c;const{unitId:e,subUnitId:t}=r.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i||((c=i.getActiveSheet())==null?void 0:c.getSheetId())!==t)return;const s=i.getActiveSheetIndex(),l=pc(i,s);this._switchToNextSheet(e,l)}_beforeAdjustActiveSheetOnRemoveSheet(r){const{unitId:e,subUnitId:t}=r.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i)return;const o=i.getSheetBySheetId(t);o&&(this._previousSheetIndex=i.getSheetIndex(o))}_adjustActiveSheetOnRemoveSheet(r){if(this._previousSheetIndex===-1)return;const{unitId:e}=r.params,t=this._univerInstanceService.getUniverSheetInstance(e);if(!t)return;if(t.getActiveSheet().getSheetId()===r.params.subUnitId){const o=this._previousSheetIndex,s=o>=1?o-1:0,l=pc(t,s);this._switchToNextSheet(e,l)}}_adjustActiveSheetOnInsertSheet(r){const{unitId:e,sheet:t}=r.params;this._switchToNextSheet(e,t.id)}_adjustActiveSheetOnShowSheet(r){const{unitId:e,subUnitId:t}=r.params;this._switchToNextSheet(e,t)}_adjustActiveSheetOnSelection(r){var i;const{unitId:e,subUnitId:t}=r.params;t!==((i=this._univerInstanceService.getUnit(e))==null?void 0:i.getActiveSheet().getSheetId())&&this._switchToNextSheet(e,t)}_switchToNextSheet(r,e){this._commandService.executeCommand(m.SetWorksheetActiveOperation.id,{unitId:r,subUnitId:e})}};_i=IS([vc(0,a.ICommandService),vc(1,a.IUniverInstanceService)],_i);function pc(n,r){const e=n.getSheetSize();for(let t=r;t>-1;t--){const i=n.getSheetByIndex(t);if(!i.getConfig().hidden)return i.getSheetId()}for(let t=r;t<e;t++){const i=n.getSheetByIndex(t);if(!i.getConfig().hidden)return i.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var bS=Object.getOwnPropertyDescriptor,wS=(n,r,e,t)=>{for(var i=t>1?void 0:t?bS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Cc=(n,r)=>(e,t)=>r(e,t,n),yn=(n=>(n[n.INFO=0]="INFO",n[n.WARNING=1]="WARNING",n[n.ERROR=2]="ERROR",n))(yn||{});y.CellAlertManagerService=class extends a.Disposable{constructor(e,t){super();T(this,"_currentAlert$",new D.Subject);T(this,"_currentAlert",new Map);T(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=e,this._cellPopupManagerService=t,this.disposeWithMe(()=>{this._currentAlert$.complete()})}get currentAlert(){return this._currentAlert}showAlert(e){let t=this._currentAlert.get(e.key);t&&t.dispose.dispose(),t?t.dispose.dispose():(t={alert:e,dispose:{dispose(){}}},this._currentAlert.set(e.key,t));const{location:i}=e,{row:o,col:s,unitId:l,subUnitId:c}=i;if(!this._renderManagerService.getRenderById(l))return;const u=this._cellPopupManagerService.showPopup({unitId:l,subUnitId:c,row:o,col:s},{componentKey:_c,direction:"horizontal",extraProps:{alert:e},priority:1});u&&(t.dispose=u),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}removeAlert(e){const t=this._currentAlert.get(e);t&&(this._currentAlert.delete(e),t==null||t.dispose.dispose(),this._currentAlert$.next(Array.from(this._currentAlert.entries())))}clearAlert(){this._currentAlert.forEach(e=>{e.dispose.dispose()}),this._currentAlert.clear(),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}},y.CellAlertManagerService=wS([Cc(0,R.IRenderManagerService),Cc(1,a.Inject(y.CellPopupManagerService))],y.CellAlertManagerService);function ES({popup:n}){var s;const r=(s=n.extraProps)==null?void 0:s.alert;if(!r)return null;const{type:e,title:t,message:i}=r,o={[yn.ERROR]:I.jsx(to,{className:"univer-mr-1.5 univer-text-red-500"}),[yn.INFO]:I.jsx(na,{className:"univer-mr-1.5 univer-text-blue-500"}),[yn.WARNING]:I.jsx(aa,{className:"univer-mr-1.5 univer-text-yellow-500"})};return I.jsxs("div",{className:"univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-white univer-px-2 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-black dark:!univer-text-white",children:[I.jsxs("div",{className:"univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-text-sm univer-font-medium",children:[e?o[e]:null,t]}),I.jsx("div",{className:"univer-text-sm",children:i})]})}const _c="univer.sheet.cell-alert";var TS=Object.getOwnPropertyDescriptor,yS=(n,r,e,t)=>{for(var i=t>1?void 0:t?TS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},RS=(n,r)=>(e,t)=>r(e,t,n);let ur=class extends a.Disposable{constructor(n,r){super(),this._context=n,this._componentManager=r,this._initComponent()}_initComponent(){this.disposeWithMe(this._componentManager.register(_c,ES))}};ur=yS([RS(1,a.Inject(_.ComponentManager))],ur);const Ic=2,MS=[{value:"DEFAULT_PASTE",label:"rightClick.paste"},{value:"SPECIAL_PASTE_VALUE",label:"rightClick.pasteValue"},{value:"SPECIAL_PASTE_FORMAT",label:"rightClick.pasteFormat"},{value:"SPECIAL_PASTE_COL_WIDTH",label:"rightClick.pasteColWidth"},{value:"SPECIAL_PASTE_BESIDES_BORDER",label:"rightClick.pasteBesidesBorder"},{value:"SPECIAL_PASTE_FORMULA",label:"formula.operation.pasteFormula"}],PS=n=>{var H,x,L,V,U;const r=_.useDependency(a.IUniverInstanceService),e=_.useDependency(R.IRenderManagerService),t=lt();if(!n||!t)return null;const i={startRow:n.rows[0],startCol:n.cols[0],endRow:n.rows[n.rows.length-1],endCol:n.cols[n.cols.length-1]};if(i.endRow<0||i.endCol<0)return null;const o=e.getRenderById(t.getUnitId()),s=o==null?void 0:o.with(y.SheetSkeletonManagerService),l=o==null?void 0:o.with(ve),c=ke(r,e);if(!c||!l)return null;const{scene:d}=c,u=s==null?void 0:s.getCurrentSkeleton(),h=l.getViewPort(),g=d==null?void 0:d.scaleX,S=d==null?void 0:d.scaleY,f=d==null?void 0:d.getViewportScrollXY(h),v=(H=d.getEngine())==null?void 0:H.getCanvas();if(!g||!d||!g||!S||!f)return null;const p=u==null?void 0:u.getNoMergeCellPositionByIndex(i.endRow,i.endCol),C=(x=p==null?void 0:p.endX)!=null?x:0,b=(L=p==null?void 0:p.endY)!=null?L:0,w=(V=R.convertTransformToOffsetX(C,g,f))!=null?V:-9999,E=(U=R.convertTransformToOffsetY(b,S,f))!=null?U:-9999,O=v==null?void 0:v.getWidth(),M=v==null?void 0:v.getHeight();if(!O||!M)return null;const P=w+50<=O,A=E+50<=M;let k=w,N=E;return P||(k=O-100),A||(N=M-100),{positionX:k,positionY:N}},OS=()=>{const n=_.useDependency(We),r=_.useObservable(n.showMenu$,!1),e=_.useObservable(n.pasteOptionsCache$,null),t=_.useDependency(a.LocaleService),i=_.useDependency(a.ICommandService),[o,s]=W.useState(!1),[l,c]=W.useState(!1),d=e==null?void 0:e.target.pastedRange,u=PS(d);if(!u||!r||u.positionX<50||u.positionY<30)return null;const h=o||l,g=S=>{c(!1),i.executeCommand(Ga.id,{type:S})};return I.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:I.jsx("div",{className:"univer-absolute",style:{left:u.positionX+Ic,top:u.positionY+Ic},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:I.jsx(X.DropdownMenu,{align:"start",items:MS.map(S=>({type:"checkbox",value:S.value,label:t.t(S.label),checked:(e==null?void 0:e.pasteType)===Se[S.value],onSelect:()=>g(S.value)})),open:l,onOpenChange:c,children:I.jsxs("div",{className:X.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",X.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":l,"univer-bg-white dark:!univer-bg-gray-900":!l}),children:[I.jsx(ra,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),h&&I.jsx(sn,{className:"dark:!univer-text-white"})]})})})})},AS=[ge.id,m.SetRangeValuesCommand.id,Ne.id,m.MoveRangeMutation.id,m.RemoveRowMutation.id,m.RemoveColMutation.id,m.InsertRowMutation.id,m.InsertColMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id,m.SetWorksheetColWidthMutation.id,m.SetWorksheetRowHeightMutation.id,m.SetSelectionsOperation.id,a.UndoCommandId];function DS(n,r,e,t,i){const o=[],s=[];if(t.copyType===Je.CUT){const{undos:l,redos:c}=kS(n,r,i);o.push(...c),s.push(...l)}else{const{undos:l,redos:c}=Ec(r,e,i);o.push(...c),s.push(...l);const{undos:d,redos:u}=NS(r,e,i);o.push(...u),s.push(...d);const{undos:h,redos:g}=bc(r,n,e,i);o.push(...g),s.push(...h);const{undos:S,redos:f}=wc(r,n,e,i,!0);o.push(...f),s.push(...S);const{undos:v,redos:p}=es(r,e,i);o.push(...p),s.push(...v)}return{undos:s,redos:o}}function kS(n,r,e){let t=[],i=[];const{range:o,subUnitId:s,unitId:l}=n,{range:c,subUnitId:d}=r,u=c?ct(c):null,h=o?ct(o):null;if(h&&u){const g=e.get(a.IUniverInstanceService),S=e.get(m.SheetInterceptorService),f=g.getUniverSheetInstance(l),v=f==null?void 0:f.getSheetBySheetId(s),p=f==null?void 0:f.getSheetBySheetId(d);if(v&&p){const C=new a.ObjectMatrix,b=new a.ObjectMatrix,w=v.getCellMatrix(),E=p.getCellMatrix();a.Range.foreach(h,(F,z)=>{C.setValue(F,z,a.Tools.deepClone(w.getValue(F,z))),b.setValue(F,z,null)});const O=new a.ObjectMatrix;a.Range.foreach(u,(F,z)=>{O.setValue(F,z,a.Tools.deepClone(E.getValue(F,z)))});const M=new a.ObjectMatrix;a.Range.foreach(h,(F,z)=>{const j=a.cellToRange(F,z),Q=a.Rectangle.getRelativeRange(j,h),ie=a.Rectangle.getPositionRange(Q,u);M.setValue(ie.startRow,ie.startColumn,w.getValue(F,z))});const P={fromRange:h,toRange:u,from:{value:b.getMatrix(),subUnitId:s},to:{value:M.getMatrix(),subUnitId:d},unitId:l},A={fromRange:u,toRange:h,from:{value:C.getMatrix(),subUnitId:s},to:{value:O.getMatrix(),subUnitId:d},unitId:l},k=S.onCommandExecute({id:m.MoveRangeCommand.id,params:{toRange:u,fromRange:h}}),N=v.getMergeData(),H=p.getMergeData(),x=N.filter(F=>a.Rectangle.intersects(F,h)),L=H.filter(F=>a.Rectangle.intersects(F,u)),V=x.map(F=>a.Rectangle.getRelativeRange(F,h)).map(F=>a.Rectangle.getPositionRange(F,u)),U=m.getAddMergeMutationRangeByType(V),B=[{id:m.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:x}},{id:m.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:L}},{id:m.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:d,ranges:U}}],Y=[{id:m.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:d,ranges:U}},{id:m.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:d,ranges:L}},{id:m.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:x}}];t=[{id:m.MoveRangeMutation.id,params:P},...k.redos,...B,{id:m.SetSelectionsOperation.id,params:{unitId:l,subUnitId:d,selections:[{range:u}],type:m.SelectionMoveType.MOVE_END}}],i=[{id:m.MoveRangeMutation.id,params:A},...k.undos,...Y,{id:m.SetSelectionsOperation.id,params:{unitId:l,subUnitId:s,type:m.SelectionMoveType.MOVE_END,selections:[{range:h}]}}]}}return{undos:i,redos:t}}function bc(n,r,e,t){var f;const{unitId:i,subUnitId:o,range:s}=n,l=(f=t.get(a.IUniverInstanceService).getUniverSheetInstance(i))==null?void 0:f.getSheetBySheetId(o),c=[],d=[],{mapFunc:u}=dt([s]),h=new a.ObjectMatrix;e.forValue((v,p,C)=>{var O,M;const{row:b,col:w}=u(v,p),E={v:C.v,t:C.t};if(!C.p&&C.v&&!r){const P=l==null?void 0:l.getCellStyle(b,w);if(Oi.isTextFormat((O=P==null?void 0:P.n)==null?void 0:O.pattern))E.t=a.CellValueType.STRING;else{const A=String(C.v),k=a.numfmt.parseValue(A);(k==null?void 0:k.v)!==void 0&&typeof k.v=="number"&&(!k.z&&a.willLoseNumericPrecision(A)?E.t=a.CellValueType.FORCE_STRING:E.v=k.v)}}if((M=C.p)!=null&&M.body&&ho(C.p.body)){const P=a.Tools.deepClone({p:C.p,v:C.v});h.setValue(b,w,P)}else h.setValue(b,w,a.Tools.deepClone(E))});const g={unitId:i,subUnitId:o,cellValue:a.Tools.deepClone(h.getMatrix())};c.push({id:m.SetRangeValuesMutation.id,params:g});const S=m.SetRangeValuesUndoMutationFactory(t,g);return d.push({id:m.SetRangeValuesMutation.id,params:S}),{undos:d,redos:c}}function wc(n,r,e,t,i=!1){var v;const o=[],s=[],{unitId:l,subUnitId:c,range:d}=n,u=(v=t.get(a.IUniverInstanceService).getUniverSheetInstance(l))==null?void 0:v.getSheetBySheetId(c),h=new a.ObjectMatrix,{mapFunc:g}=dt([d]);e.forValue((p,C,b)=>{var A,k;const w={s:Object.assign({},{...a.DEFAULT_STYLES,pd:R.DEFAULT_PADDING_DATA,bg:null,cl:null},b.s)},E=w.s.bd;E&&(Object.keys(E).length>0||(w.s.bd={b:null,l:null,r:null,t:null}));const{row:O,col:M}=g(p,C),P=u==null?void 0:u.getCellStyle(O,M);if(b.v&&!r&&Oi.isTextFormat((A=P==null?void 0:P.n)==null?void 0:A.pattern))w.s||(w.s={}),w.s.n=P==null?void 0:P.n;else{const N=String(b.v),H=a.numfmt.parseValue(N);H!=null&&H.z&&(w.s||(w.s={}),typeof w.s=="object"&&((k=w.s)!=null&&k.n?w.s.n.pattern=H.z:w.s.n={pattern:H.z}))}h.setValue(O,M,w)});const S={unitId:l,subUnitId:c,cellValue:a.Tools.deepClone(h.getMatrix())};o.push({id:m.SetRangeValuesMutation.id,params:S});const f=m.SetRangeValuesUndoMutationFactory(t,S);return s.push({id:m.SetRangeValuesMutation.id,params:f}),{undos:s,redos:o}}function Ec(n,r,e){const t=[],i=[],o=new a.ObjectMatrix,{unitId:s,subUnitId:l,range:c}=n,{mapFunc:d}=dt([c]);if(r.forEach((u,h)=>{Object.keys(h).forEach(g=>{const S=Number(g),{row:f,col:v}=d(u,S);o.setValue(f,v,{s:null})})}),o.getLength()>0){const u={subUnitId:l,unitId:s,cellValue:a.Tools.deepClone(o.getMatrix())};t.push({id:m.SetRangeValuesMutation.id,params:u});const h=m.SetRangeValuesUndoMutationFactory(e,u);i.push({id:m.SetRangeValuesMutation.id,params:h})}return{undos:i,redos:t}}function NS(n,r,e){const t=[],i=[],o=new a.ObjectMatrix,{unitId:s,subUnitId:l,range:c}=n,{mapFunc:d}=dt([c]);if(r.forValue((u,h,g)=>{const{row:S,col:f}=d(u,h);o.setValue(S,f,{v:null,p:null})}),o.getLength()>0){const u={subUnitId:l,unitId:s,cellValue:a.Tools.deepClone(o.getMatrix())};t.push({id:m.SetRangeValuesMutation.id,params:u});const h=m.SetRangeValuesUndoMutationFactory(e,u);i.push({id:m.SetRangeValuesMutation.id,params:h})}return{undos:i,redos:t}}function es(n,r,e){const t=[],i=[],{unitId:o,subUnitId:s,range:l}=n,{startColumn:c,startRow:d,endColumn:u,endRow:h}=ct(l),g=[];r.forValue((b,w,E)=>{if(E.rowSpan&&E.rowSpan>1){const O=E.colSpan||1,M={startRow:d+b,endRow:d+b+E.rowSpan-1,startColumn:c+w,endColumn:c+w+O-1};g.push(M)}else if(E.colSpan&&E.colSpan>1){const O=E.rowSpan||1,M={startRow:d+b,endRow:d+b+O-1,startColumn:c+w,endColumn:c+w+E.colSpan-1};g.push(M)}});const f=e.get(a.IUniverInstanceService).getUniverSheetInstance(o),v=f==null?void 0:f.getSheetBySheetId(s);if(f&&v){const w=v.getMergeData().filter(M=>a.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},M)),E={unitId:o,subUnitId:s,ranges:w};t.push({id:m.RemoveWorksheetMergeMutation.id,params:E});const O=m.RemoveMergeUndoMutationFactory(e,E);i.push({id:m.AddWorksheetMergeMutation.id,params:O})}const p={unitId:o,subUnitId:s,ranges:g};g.length>0&&t.push({id:m.AddWorksheetMergeMutation.id,params:p});const C=m.AddMergeUndoMutationFactory(e,p);return g.length>0&&i.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),{undos:i,redos:t}}function HS(n){if(!n.includes("\r")&&a.Tools.isLegalUrl(n)){const t=a.generateRandomId(),i=`${n}`,o={startIndex:0,endIndex:i.length-1,rangeId:t,rangeType:a.CustomRangeType.HYPERLINK,properties:{url:n}};return{dataStream:`${i}\r
|
|
19
|
+
`)}),r}function Jh(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function $h(n,r,e,t){return t.getMergeData().some(i=>i.startRow<=n&&n<i.endRow&&r<=i.startColumn&&i.startColumn<=e)}function em(n,r,e,t){return t.getMergeData().some(i=>i.startColumn<=n&&n<i.endColumn&&r<=i.startRow&&i.startRow<=e)}function tm(n){let r=0;return n.forValue((e,t,i)=>{if(i&&r++,r>1)return!1}),r>1}function Zn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Co=998,Be={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Co,preconditions:lo,handler:async n=>n.get(We).copy()},Ji={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Co,preconditions:lo,handler:async n=>n.get(We).cut()},Fe={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Co,preconditions:lo,handler:async(n,r)=>{const t=await n.get(_.IClipboardInterfaceService).read(),i=n.get(We);return t.length!==0?i.paste(t[0],r==null?void 0:r.value):!1}},$i={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,r)=>{const e=n.get(We),{htmlContent:t,textContent:i,files:o}=r;return e.legacyPaste(t,i,o),!0}},un={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_VALUE})},hn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_FORMAT})},Pt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_COL_WIDTH})},mn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Fe.id,{value:Se.SPECIAL_PASTE_BESIDES_BORDER})},Ga={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:r})=>n.get(We).rePasteWithPasteType(r)},Kn={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),i=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(i);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(Ys(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetRowHiddenCommand.id),!0}},qn={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),i=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(i);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(js(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await t.executeCommand(m.SetColHiddenCommand.id),!0}},Ot={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatBoldCommand.id):r.executeCommand(m.SetBoldCommand.id)}},At={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatItalicCommand.id):r.executeCommand(m.SetItalicCommand.id)}},Dt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatUnderlineCommand.id):r.executeCommand(m.SetUnderlineCommand.id)}},kt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatStrikethroughCommand.id):r.executeCommand(m.SetStrikeThroughCommand.id)}},_o={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatSubscriptCommand.id):!1}},Io={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const r=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?r.executeCommand(q.SetInlineFormatSuperscriptCommand.id):!1}},Qn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,r)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatFontSizeCommand.id,r):e.executeCommand(m.SetFontSizeCommand.id,r)}},Jn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,r)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatFontFamilyCommand.id,r):e.executeCommand(m.SetFontFamilyCommand.id,r)}},gn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,r)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(q.SetInlineFormatTextColorCommand.id,r):e.executeCommand(m.SetTextColorCommand.id,r)}},bo={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const r=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),i=n.get(a.ThemeService);return t?r.executeCommand(q.SetInlineFormatTextColorCommand.id,{value:null}):r.executeCommand(m.SetTextColorCommand.id,{value:i.getColorFromTheme("gray.900")})}};var nm=Object.getOwnPropertyDescriptor,im=(n,r,e,t)=>{for(var i=t>1?void 0:t?nm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Sn=(n,r)=>(e,t)=>r(e,t,n),Oe=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Oe||{});const je=a.createIdentifier("univer.format-painter-service");let er=class extends a.Disposable{constructor(r,e,t,i,o,s){super();T(this,"status$");T(this,"_selectionFormat");T(this,"_markId",null);T(this,"_status$");T(this,"_defaultHook",null);T(this,"_extendHooks",[]);this._selectionManagerService=r,this._themeService=e,this._markSelectionService=t,this._logService=i,this._commandService=o,this._undoRedoService=s,this._status$=new D.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(r){var e,t,i;r.isDefaultHook&&((e=r.priority)!=null?e:0)>((i=(t=this._defaultHook)==null?void 0:t.priority)!=null?i:-1)?this._defaultHook=r:(this._extendHooks.push(r),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(r){this._updateRangeMark(r),this._status$.next(r),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(r)})}getStatus(){return this._status$.getValue()}setSelectionFormat(r){this._selectionFormat=r}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(r,e,t){const i=this.getHooks(),o=[],s=[];i.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(r,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of i)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:r,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:r,undoMutations:s,redoMutations:o}),l}_updateRangeMark(r){if(this._markSelectionService.removeAllShapes(),r!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=Ha(this._themeService);r===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};er=im([Sn(0,a.Inject(m.SheetsSelectionsService)),Sn(1,a.Inject(a.ThemeService)),Sn(2,Mt),Sn(3,a.ILogService),Sn(4,a.ICommandService),Sn(5,a.IUndoRedoService)],er);const $n={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,r)=>r?(n.get(je).setStatus(r.status),!0):!1},tr={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(je).getStatus();let t;return e!==Oe.OFF?t=Oe.OFF:t=Oe.INFINITE,n.get(a.ICommandService).executeCommand($n.id,{status:t})}},fn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(je).getStatus();let t;return e!==Oe.OFF?t=Oe.OFF:t=Oe.ONCE,n.get(a.ICommandService).executeCommand($n.id,{status:t})}},ei={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,r)=>n.get(je).applyFormatPainter(r.unitId,r.subUnitId,r.range)},$e={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,r)=>{const{type:e}=r||{},t=n.get(a.IUniverInstanceService),i=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(R.IRenderManagerService).getRenderById(s).with(y.SheetScrollManagerService),{sheetViewStartRow:v=0,sheetViewStartColumn:p=0}=f.getCurrentScrollState()||{};let C,b,w,E;const{startRow:O,startColumn:M,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=O,w=O-v,b=-1,E=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,w=0,b=M,E=M-p;else if(P===a.RANGE_TYPE.NORMAL)C=O,w=O-v,b=M,E=M-p;else return!1;const A={unitId:s,subUnitId:l,startRow:C,startColumn:b,xSplit:b>0?Math.max(1,E):E,ySplit:C>0?Math.max(1,w):w},k=m.SetFrozenMutationFactory(n,A);return c.syncExecuteCommand(m.SetFrozenMutation.id,A)&&i.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:k}],redoMutations:[{id:m.SetFrozenMutation.id,params:A}]}),!0}},ti={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand($e.id,{type:1}),!0)},ni={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand($e.id,{type:2}),!0)};var rm=Object.getOwnPropertyDescriptor,om=(n,r,e,t)=>{for(var i=t>1?void 0:t?rm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Za=(n,r)=>(e,t)=>r(e,t,n);const sm=(n,r)=>{const{unitId:e,subUnitId:t,ranges:i}=n,o={},s=r.getColumnManager();for(let l=0;l<i.length;l++){const c=i[l];for(let d=c.startColumn;d<c.endColumn+1;d++)o[d]=s.getColumnWidth(d)}return{unitId:e,subUnitId:t,ranges:i,colWidth:o}};y.AutoWidthController=class extends a.Disposable{constructor(r,e){super(),this._renderManagerService=r,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(r){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,i=m.getSheetCommandTarget(t);if(!i)return e;const{unitId:o,subUnitId:s,worksheet:l}=i,c=this._renderManagerService.getRenderById(o).with(y.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(r.ranges),h={};for(const{col:f,width:v}of u)h[f]=v;const g={subUnitId:s,unitId:o,ranges:r.ranges,colWidth:h},S=sm(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}},y.AutoWidthController=om([Za(0,R.IRenderManagerService),Za(1,a.Inject(a.IUniverInstanceService))],y.AutoWidthController);const ii={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,r)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,r);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(r!=null&&r.ranges)d=[...r.ranges];else{const f=i.getCurrentSelections();for(let v=0;v<f.length;v++)d.push(f[v].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(y.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Ka="UI_PLUGIN_SHEETS",Ge=`${Ka}_MENU_ITEM_INPUT_COMPONENT`,qa=n=>{const{prefix:r,suffix:e,value:t,onChange:i,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=W.useState(),h=S=>{if(!S){u(o.toString());return}const f=S.toString();u(f),i(f)};W.useEffect(()=>{c.visible||u(t)},[c.visible]),W.useEffect(()=>{+t<o?u(o.toString()):+t>s?u(s.toString()):u(t)},[t]);function g(){d&&i(d)}return I.jsxs("div",{className:"univer-inline-flex univer-items-center univer-gap-1",children:[l.t(r),I.jsx("div",{className:"univer-w-16",onClick:S=>S.stopPropagation(),children:I.jsx(X.InputNumber,{value:Number(d),size:"mini",precision:0,min:o,max:s,onPressEnter:g,onChange:h})}),l.t(e)]})};function am(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(de.switchMap(r=>r?r.activeSheet$.pipe(de.map(e=>e?{workbook:r,worksheet:e}:null)):D.of(null)))}function be(n,r,e){return am(n).pipe(de.switchMap(t=>t?e(t):D.of(r)))}function Qa(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),i=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(de.switchMap(s=>s?D.combineLatest([i.selectionMoveEnd$,s.activeSheet$]).pipe(de.switchMap(([l,c])=>{if(!c||l.length===0)return D.of(!1);const d=t.getInterestGroupId(l);if(r){const u=d.filter(h=>r.has(h));return D.of(u.length>0)}else return D.of(d.length>0)})):D.of(!1)))}function Nt(n,r,e){return D.combineLatest([r,Qa(n,e)]).pipe(de.map(([t,i])=>t||i))}function ee(n,r={},e=!1){var g;const i=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(me)?n.get(me):null,l=n.get(a.IContextService),d=((g=s==null?void 0:s.visible$)!=null?g:D.of(null)).pipe(de.startWith(null),de.shareReplay(1)),u=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).pipe(de.startWith(!1),de.shareReplay(1));return D.combineLatest([o.currentUser$,i,d,u]).pipe(de.switchMap(([S,f,v,p])=>!f||v!=null&&v.visible&&v.unitId===f.getUnitId()&&!e||p&&!e?D.of(!0):f.activeSheet$.pipe(de.switchMap(C=>{if(!C)return D.of(!0);const b=n.get(m.SheetsSelectionsService),w=n.get(m.RangeProtectionRuleModel),E=n.get(m.WorksheetProtectionRuleModel),M=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(de.startWith(!1));return D.combineLatest([b.selectionMoveEnd$,M]).pipe(de.switchMap(([P,A])=>{if(A)return D.of(!0);const k=f.getUnitId(),N=C.getSheetId(),H=n.get(a.IPermissionService),{workbookTypes:x=[m.WorkbookEditablePermission],worksheetTypes:L,rangeTypes:V}=r,U=[];if(x==null||x.forEach(z=>{U.push(new z(k).id)}),L==null||L.forEach(z=>{U.push(new z(k,N).id)}),E.getRule(k,N))return H.composePermission$(U).pipe(de.map(z=>z.some(j=>j.value===!1)));const Y=P==null?void 0:P.map(z=>z.range),F=w.getSubunitRuleList(k,N).filter(z=>Y==null?void 0:Y.some(j=>z.ranges.some(Q=>a.Rectangle.intersects(j,Q))));return V==null||V.forEach(z=>{F.forEach(j=>{U.push(new z(k,N,j.permissionId).id)})}),H.composePermission$(U).pipe(de.map(z=>z.some(j=>j.value===!1)))}))}))))}function vn(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),i=n.get(a.IPermissionService);return D.merge(e.selectionMoveEnd$,i.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),i.composePermission(u).some(g=>g.value===!1)}))}function Ja(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return D.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return i.getSubunitRuleList(d,u).filter(S=>r==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function $a(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return D.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return r==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(v=>a.Rectangle.intersects(g,v))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function nr(n,r){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return D.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(de.debounceTime(100))).pipe(de.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return r==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,i.getSubunitRuleList(d,u).filter(f=>f.ranges.some(v=>a.Rectangle.intersects(g,v))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function pn(n,r){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return D.combineLatest([l.currentUser$,t]).pipe(de.switchMap(([c,d])=>d?d.activeSheet$.pipe(de.switchMap(u=>{if(!u)return D.of(!0);const h=d.getUnitId(),g=[];return r.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(de.map(f=>f.every(v=>v.value===!0))).pipe(de.map(f=>{if(!f)return!0;const v=u.getSheetId(),p=i.getRule(h,v),C=o.getSubunitRuleList(h,v);return!!(p||C.length)}))})):D.of(!0)))}var el=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(el||{});function lm(n){const r=n.get(je);return{id:fn.id,subId:tr.id,type:_.MenuItemType.BUTTON,icon:"BrushIcon",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new D.Observable(e=>{let t=!1;const i=r.status$.subscribe(o=>{t=o!==Oe.OFF,e.next(t)});return e.next(t),()=>{i.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function cm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),i=n.get(m.SheetsSelectionsService);return{id:Ot.id,type:_.MenuItemType.BUTTON,icon:"BoldIcon",title:"Set bold",tooltip:"toolbar.bold",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=i.getCurrentLastSelection())==null?void 0:S.primary;let p=a.FontWeight.NORMAL;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getFontWeight()}s.next(p===a.FontWeight.BOLD)}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.bl;s.next(p===a.BooleanNumber.TRUE)}}),c=(u=i.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function dm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:At.id,type:_.MenuItemType.BUTTON,icon:"ItalicIcon",title:"Set italic",tooltip:"toolbar.italic",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let p=a.FontItalic.NORMAL;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getFontStyle()}s.next(p===a.FontItalic.ITALIC)}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.it;s.next(p===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function um(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:Dt.id,type:_.MenuItemType.BUTTON,icon:"UnderlineIcon",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let p;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getUnderline()}s.next(!!(p&&p.s))}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.ul;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function hm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService);return{id:kt.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughIcon",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new D.Observable(s=>{var u;const l=r.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const v=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let p;if(v!=null){const C=o.getRange(v.startRow,v.startColumn);p=C==null?void 0:C.getStrikeThrough()}s.next(!!(p&&p.s))}if((g===_e.SetTextSelectionsOperation.id||g===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)){const v=si(n);if(v==null)return;const p=(f=v.ts)==null?void 0:f.st;s.next((p==null?void 0:p.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function mm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=a.DEFAULT_STYLES.ff;return{id:Jn.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:_.FONT_FAMILY_COMPONENT,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:_.FONT_FAMILY_ITEM_COMPONENT},value:o.value})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,i,({worksheet:o})=>new D.Observable(s=>{const l=()=>{var h;let d=i;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const g=o.getCellStyle(u.startRow,u.startColumn),S=o.getDefaultCellStyleInternal(),f=o.getRowStyle(u.startRow),v=o.getColumnStyle(u.startColumn),p=a.composeStyles(S,f,v,g);p.ff&&(d=p.ff)}s.next(d)},c=r.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function gm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:Qn.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:_.FONT_SIZE_COMPONENT,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new D.Observable(c=>{const d=()=>{var f;let g=o;const S=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(S!=null){const v=l.getComposedCellStyle(S.startRow,S.startColumn);v.fs&&(g=v.fs)}c.next(g)},u=()=>{var S,f;const g=si(n);if(g!=null){const v=(f=(S=g.ts)==null?void 0:S.fs)!=null?f:o;c.next(v)}},h=r.onCommandExecuted(g=>{const S=g.id;(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id)&&d(),(S===_e.SetTextSelectionsOperation.id||S===q.SetInlineFormatCommand.id)&&i.getContextValue(a.EDITOR_ACTIVATED)&&i.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Sm(n){return{id:bo.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColorDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function fm(n){const r=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:gn.id,icon:"FontColorDoubleIcon",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:_.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1}}],value$:new D.Observable(t=>{const i=e.getColorFromTheme("gray.900"),o=r.onCommandExecuted(s=>{if(s.id===gn.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function vm(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColorDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function pm(n){const r=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucketDoubleIcon",selections:[{label:{name:_.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1}}],value$:new D.Observable(t=>{const i=e.getColorFromTheme("primary.600"),o=r.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:i)}});return t.next(i),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const tl=[{label:"align.left",icon:"LeftJustifyingIcon",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallyIcon",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingIcon",value:a.HorizontalAlign.RIGHT}];function Cm(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:tl[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:tl,value$:be(r,t,({worksheet:i})=>new D.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);S=v==null?void 0:v.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const nl=[{label:"align.top",icon:"AlignTopIcon",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterIcon",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomIcon",value:a.VerticalAlign.BOTTOM}];function _m(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:nl[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:nl,value$:be(r,t,({worksheet:i})=>new D.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);S=v==null?void 0:v.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const il=[{label:"textWrap.overflow",icon:"OverflowIcon",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapIcon",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationIcon",value:a.WrapStrategy.CLIP}];function Im(n){const r=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:il[0].icon,type:_.MenuItemType.SELECTOR,selections:il,value$:be(e,t,({worksheet:i})=>new D.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=r.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);S=v==null?void 0:v.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=r.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=i.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const rl=[{label:"textRotate.none",icon:"NoRotationIcon",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesIcon",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesIcon",value:45},{label:"textRotate.vertical",icon:"VerticalTextIcon",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesIcon",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesIcon",value:90}];function bm(n){const r=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:rl[0].icon,type:_.MenuItemType.SELECTOR,selections:rl,value$:be(e,t,({worksheet:i})=>new D.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var v,p;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(v=r.getCurrentLastSelection())==null?void 0:v.primary;let f;if(S!=null){const C=i.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((p=f&&f.a)!=null?p:t)}),l=(d=r.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=i.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function ri(n){return new D.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function Cn(n){return{id:Be.name,commandId:Be.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"CopyDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wo(n){return{id:Fe.name,commandId:Fe.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecialDoubleIcon",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const oi="sheet.menu.paste-special";function Eo(n){return{id:oi,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecialDoubleIcon",title:"rightClick.pasteSpecial",hidden$:Nt(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function To(n){return{id:un.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function yo(n){return{id:hn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ro(n){return{id:Pt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e))}}function Mo(n){return{id:mn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:ri(n).pipe(D.combineLatestWith(ee(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),D.map(([r,e])=>r||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wm(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeightDoubleIcon",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Em(n){return{id:ii.id,type:_.MenuItemType.BUTTON,icon:"AutoWidthDoubleIcon",title:"rightClick.fitContent",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const ol="sheet.menu.sheet-frozen";function Tm(n){return{id:ol,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Po="sheet.header-menu.sheet-frozen";function sl(n){return{id:Po,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Oo(n){return{id:$e.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ym(n){return{id:ti.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rm(n){return{id:ni.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ao(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Mm(n){return{id:Kn.id,type:_.MenuItemType.BUTTON,icon:"HideDoubleIcon",title:"rightClick.hideSelectedRow",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Pm(n){return{id:qn.id,type:_.MenuItemType.BUTTON,icon:"HideDoubleIcon",title:"rightClick.hideSelectedColumn",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Om(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,icon:"EyeOutlineIcon",title:"rightClick.showHideRow",hidden$:be(r,!0,({worksheet:o})=>new D.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Am(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,icon:"EyeOutlineIcon",title:"rightClick.showHideColumn",hidden$:be(r,!0,({worksheet:o})=>new D.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Dm(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=2;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeightDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.rowHeight",suffix:"px",min:i,max:1e3}},value$:be(e,i,({worksheet:o})=>new D.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):o.getConfig().defaultRowHeight;s.next(u)}const c=r.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function km(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=2;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidthDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.columnWidth",suffix:"px",min:i,max:1e3}},value$:be(e,i,({worksheet:o})=>new D.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getColumnWidth(d.startColumn):o.getConfig().defaultColumnWidth;s.next(u)}const c=r.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function si(n){var c;const r=n.get(a.IUniverInstanceService),e=n.get(_e.DocSelectionManagerService),t=r.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),i=e.getActiveTextRange();if(t==null||i==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=i;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var Nm=Object.getOwnPropertyDescriptor,Hm=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Ht=(n,r)=>(e,t)=>r(e,t,n);const Vm="__SpreadsheetFreezeRowMainName__",Wm="__SpreadsheetFreezeRowHeaderName__",xm="__SpreadsheetFreezeColumnMainName__",Lm="__SpreadsheetFreezeColumnHeaderName__",Do=2,Um=.01,ai=a.createInterceptorKey("freezePermissionCheck");y.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,i,o,s,l,c,d){super();T(this,"_rowFreezeHeaderRect");T(this,"_rowFreezeMainRect");T(this,"_columnFreezeHeaderRect");T(this,"_columnFreezeMainRect");T(this,"_freezeDownSubs");T(this,"_freezePointerEnterSubs");T(this,"_freezePointerLeaveSubs");T(this,"_scenePointerMoveSub");T(this,"_scenePointerUpSub");T(this,"_changeToRow",-1);T(this,"_changeToColumn",-1);T(this,"_changeToOffsetX",0);T(this,"_changeToOffsetY",0);T(this,"_activeViewport",null);T(this,"_freezeNormalHeaderColor","");T(this,"_freezeNormalMainColor","");T(this,"_freezeActiveColor","");T(this,"_freezeHoverColor","");T(this,"_lastFreeze");T(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:ai}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=i,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var A;const i=t!=null?t:this._getFreeze();if(i==null)return null;const o=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton,{startRow:s,startColumn:l}=i,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:v}=c,{rowTotalHeight:p,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:b,columnHeaderHeightAndMarginTop:w}=o,E=h>C+b?h:C+w,O=g>p+w?g:p+w;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=v;const M=Math.max(S.scaleX,S.scaleY);let P=Do/Math.max(1,M);if(e===0){(s===-1||s===0)&&(P=P*2);const k=P;this._rowFreezeHeaderRect=new R.Rect(Wm,{fill:this._freezeNormalHeaderColor,width:b,height:P,left:0,top:v-k,zIndex:3});let N=this._freezeNormalHeaderColor;(s===-1||s===0)&&(N=this._freezeNormalMainColor),this._rowFreezeMainRect=new R.Rect(Vm,{fill:N,width:E*2/M,height:P,left:b,top:v-k,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],st)}else{(l===-1||l===0)&&(P=P*2);const k=P;this._columnFreezeHeaderRect=new R.Rect(Lm,{fill:this._freezeNormalHeaderColor,width:P,height:w,left:f-k,top:0,zIndex:3});let N=this._freezeNormalHeaderColor;(l===-1||l===0)&&(N=this._freezeNormalMainColor),this._columnFreezeMainRect=new R.Rect(xm,{fill:N,width:P,height:O*2/M,left:f-k,top:w,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],st)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,i=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,i=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new D.Subscription,this._freezePointerLeaveSubs=new D.Subscription,this._freezeDownSubs=new D.Subscription,i){const d=i.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(R.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=i.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(R.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,i,e)});l&&this._freezeDownSubs.add(l);const c=i==null?void 0:i.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,i,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,b,w,E,O,M,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const i=e.scene,o=Math.max(i.scaleX,i.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(b=s==null?void 0:s.sheetViewStartRow)!=null?b:0,u=d===0?-((w=s==null?void 0:s.offsetY)!=null?w:0):t.rowHeightAccumulation[d-1]-((E=s==null?void 0:s.offsetY)!=null?E:0);let h=0,g=!1;for(let A=d,k=t.rowHeightAccumulation.length;A<k;A++)if(t.rowHeightAccumulation[A]-u>l){h=A,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(O=s==null?void 0:s.sheetViewStartColumn)!=null?O:0,f=S===0?-((M=s==null?void 0:s.offsetX)!=null?M:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let v=0,p=!1;for(let A=S,k=t.columnWidthAccumulation.length;A<k;A++)if(t.columnWidthAccumulation[A]-f>c){v=A,p=!0;break}return p||(v=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:v}}_getActiveViewport(e){var i;const t=(i=this._getSheetObject())==null?void 0:i.scene.getViewports();return t&&t.find(o=>o.isHit(new R.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,i,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;const{scene:d}=l;d.setCursor(R.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(v=>{var P,A,k,N;const p=this._getActiveViewport(v),{startX:C,startY:b,row:w,column:E}=ze(v.offsetX,v.offsetY,d,s,p||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(ai)(!0,null))return!1;d.setCursor(R.CURSOR_TYPE.GRABBING);const M=Do/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(b,h)-M/2}))==null||P.setProps({fill:this._freezeActiveColor}),(A=i.transformByState({top:Math.min(b,h)-M/2}))==null||A.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?w:Math.min(w,u.lastRow),this._changeToOffsetY=Math.min(b,h),this._activeViewport=p):((k=t.transformByState({left:Math.min(C,g)-M/2}))==null||k.setProps({fill:this._freezeActiveColor}),(N=i.transformByState({left:Math.min(C,g)-M/2}))==null||N.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?E:Math.min(E,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=p)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var H,x;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:v,columnHeaderHeightAndMarginTop:p}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),i.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),i==null||i.setProps({fill:this._freezeNormalHeaderColor}));const C=Do/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:p-C}),i.transformByState({top:p-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:v-C}),i.transformByState({left:v-C}));const b=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:w,sheetViewStartColumn:E}=b;if(E==null||w==null)return;const O=this._context.unit,M=O.getActiveSheet();if(!M)return;const P=(H=M.getConfig())==null?void 0:H.freeze;let A=(P==null?void 0:P.xSplit)||0,k=(P==null?void 0:P.ySplit)||0;const N=(x=this._activeViewport)==null?void 0:x.viewportKey;o===0&&(!N||N===R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?k=this._changeToRow-(P.startRow-P.ySplit):k=this._changeToRow-w,k=k<0?0:k),o===1&&(!N||N===R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||N===R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||N===R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?A=this._changeToColumn-(P.startColumn-P.xSplit):A=this._changeToColumn-E,A=A<0?0:A),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:k===0?-1:this._changeToRow,startColumn:A===0?-1:this._changeToColumn,ySplit:k,xSplit:A,unitId:O.getUnitId(),subUnitId:M.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,i=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(i==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:i,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:i,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),i.isActive&&i.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,i=0,o=0,s=3){var A;const l=(A=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:A.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:v,viewColumnRight:p,viewRowTop:C,viewRowBottom:b,viewLeftTop:w}=u;p.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),b.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),w.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let E=!0,O=!0;g.enable(),(e===-1||e===0)&&(E=!1),(t===-1||t===0)&&(O=!1);const M=l.getNoMergeCellWithCoordByIndex(e-i,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),v.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),v.resetPadding(),E===!1&&O===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:0}),v.resizeWhenFreezeChange({left:0,top:0,height:d+1,width:0});else if(E===!0&&O===!1){const k=P.startY-M.startY;h.resizeWhenFreezeChange({left:c,top:d+k,bottom:0,right:0}),h.setPadding({startY:M.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(Ue.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:M.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:k}),C.updateScrollVal({viewportScrollY:M.startY}),b.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c+1}),f.enable(),C.enable()}else if(E===!1&&O===!0){const k=P.startX-M.startX;h.resizeWhenFreezeChange({left:c+k,top:d,bottom:0,right:0}),h.setPadding({startX:M.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(Ue.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:k,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:M.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),v.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),v.updateScrollVal({viewportScrollX:M.startX}),p.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),S.enable(),v.enable()}else{const k=P.startX-M.startX,N=P.startY-M.startY;h.resizeWhenFreezeChange({left:c+k,top:d+N,bottom:0,right:0}),h.setPadding({startY:M.startY,endY:P.startY,startX:M.startX,endX:P.startX}),s&&this._commandService.executeCommand(Ue.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+N,width:k,bottom:0}),S.updateScrollVal({viewportScrollX:M.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+k,top:d,height:N,right:0}),f.updateScrollVal({viewportScrollY:M.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:k,height:N}),g.updateScrollVal({viewportScrollX:M.startX,viewportScrollY:M.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:N}),C.updateScrollVal({viewportScrollY:M.startY}),b.resizeWhenFreezeChange({left:0,top:d+N,bottom:0,width:c+1}),v.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),v.updateScrollVal({viewportScrollX:M.startX}),p.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),v.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const i=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=i;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=a.get(e,"gray.300"),this._freezeNormalMainColor=new a.ColorKit(this._freezeNormalHeaderColor).setAlpha(Um).toRgbString(),this._freezeActiveColor=a.get(e,"primary.600"),this._freezeHoverColor=a.get(e,"gray.500")}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},i=this._getFreeze();if(!i)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<i.startRow||l.startRow+1===i.startRow&&c===a.Direction.UP){const u={...i,startRow:Math.max(1,i.startRow+d),ySplit:Math.max(1,i.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<i.startColumn||l.startColumn+1===i.startColumn&&c===a.Direction.LEFT){const u={...i,startColumn:Math.max(1,i.startColumn+d),xSplit:Math.max(1,i.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!i||i.startColumn<=0||u.startColumn>=i.startColumn&&h.startColumn>=i.startColumn||u.startColumn===h.startColumn||u.endColumn<i.startColumn&&h.startColumn<i.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(i.startColumn,u.endColumn+1)-u.startColumn,0);let f,v;h.startColumn>=i.startColumn?(f=Math.max(i.startColumn-S,1),v=Math.max(i.xSplit-S,1)):(f=i.startColumn+g-S,v=i.xSplit+g-S);const p={...i,startColumn:f,xSplit:v};return o(p)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!i||i.startRow<=0||u.startRow>=i.startRow&&h.startRow>=i.startRow||u.startRow===h.startRow||u.endRow<i.startRow&&h.startRow<i.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(i.startRow,u.endRow+1)-u.startRow,0);let f,v;h.startRow>=i.startRow?(f=Math.max(i.startRow-S,1),v=Math.max(i.ySplit-S,1)):(f=i.startRow+g-S,v=i.ySplit+g-S);const p={...i,startRow:f,ySplit:v};return o(p)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<i.startColumn){const c=Math.min(i.startColumn,l.endColumn+1)-l.startColumn,d={...i,startColumn:Math.max(1,i.startColumn-c),xSplit:Math.max(1,i.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<i.startRow){const c=Math.min(i.startRow,l.endRow+1)-l.startRow,d={...i,startRow:Math.max(1,i.startRow-c),ySplit:Math.max(1,i.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Ne.id:{const t=this._lastFreeze,i=this._context.unit,o=i.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===i.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),i=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&i&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(i=>i.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,i=this._getFreeze();if(i&&i.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<i.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,i=this._getFreeze(),o=t.ranges;i&&i.startColumn>-1&&o.some(s=>s.startColumn<i.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,i=this._getFreeze(),o=t.ranges;i&&i.startRow>-1&&o.some(s=>s.startRow<i.startRow)&&this._refreshCurrent()}break;case Ni.id:case Hi.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(i=>{[R.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,R.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(i.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,i;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(i=this._scenePointerUpSub)==null||i.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,i,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return ke(this._context.unit,this._context)}_refreshFreeze(e,t,i,o,s){var c;const l={startRow:e,startColumn:t,ySplit:i,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,i,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}},y.HeaderFreezeRenderController=Hm([Ht(1,a.Inject(y.SheetSkeletonManagerService)),Ht(2,a.ICommandService),Ht(3,a.Inject(m.SheetsSelectionsService)),Ht(4,a.Inject(y.SheetScrollManagerService)),Ht(5,a.Inject(a.ThemeService)),Ht(6,a.Inject(m.SheetInterceptorService)),Ht(7,a.Inject(a.Injector))],y.HeaderFreezeRenderController);function Bm(n){const r=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),i=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return D.combineLatest([r.selectionMoveEnd$,o.pipe(D.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(D.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:D.of(null)}))]).pipe(D.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(i.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(v=>a.Rectangle.intersects(v,S)&&!a.Rectangle.contains(v,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function al(n,r){return!!li(n,r,a.RANGE_TYPE.ROW)}function ll(n,r){return!!li(n,r,a.RANGE_TYPE.COLUMN)}function li(n,r,e){return n.find(i=>{const o=i.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=r&&r<=d||e===a.RANGE_TYPE.ROW&&s<=r&&r<=l)})}var Fm=Object.getOwnPropertyDescriptor,zm=(n,r,e,t)=>{for(var i=t>1?void 0:t?Fm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ko=(n,r)=>(e,t)=>r(e,t,n);const Xm="__SpreadsheetHeaderMoveControllerBackground__",Ym="__SpreadsheetHeaderMoveControllerShapeLine__",jm="rgba(0, 0, 0, 0.1)",Gm="rgb(119, 119, 119)",Zm=4,No=a.createInterceptorKey("headerMovePermissionCheck");y.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,i,o){super();T(this,"_startOffsetX",Number.NEGATIVE_INFINITY);T(this,"_startOffsetY",Number.NEGATIVE_INFINITY);T(this,"_moveHelperBackgroundShape");T(this,"_moveHelperLineShape");T(this,"_headerPointerDownSubs");T(this,"_headerPointerMoveSubs");T(this,"_headerPointerLeaveSubs");T(this,"_dragHeaderMoveSub");T(this,"_scenePointerUpSub");T(this,"_scrollTimer");T(this,"_changeFromColumn",-1);T(this,"_changeFromRow",-1);T(this,"_changeToColumn",-1);T(this,"_changeToRow",-1);T(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:No}));T(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=i,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,i,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(i=this._headerPointerMoveSubs)==null||i.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),i=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?i:t,l=u=>{var b,w;const h=(b=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:b.skeleton;if(h==null)return;const g=(w=this._workbookSelections.getCurrentLastSelection())==null?void 0:w.range;if(!g||!this.interceptor.fetchThroughInterceptors(No)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:v,column:p}=ze(u.offsetX,u.offsetY,o,h);if(!li(f,e===a.RANGE_TYPE.ROW?v:p,e)){o.resetCursor();return}o.setCursor(R.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var L,V;if(h.isStopPropagation)return;const g=(L=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:L.skeleton;if(g==null)return;const S=(V=this._workbookSelections.getCurrentLastSelection())==null?void 0:V.range;if(!S||!this.interceptor.fetchThroughInterceptors(No)(!1,S))return;const{offsetX:v,offsetY:p}=u,C=o.getCoordRelativeToViewport(R.Vector2.FromArray([v,p])),{x:b,y:w}=C;this._startOffsetX=b,this._startOffsetY=w;const{row:E,column:O}=ze(u.offsetX,u.offsetY,o,g);let M;e===a.RANGE_TYPE.ROW?(this._changeFromRow=E,M=R.ScrollTimerType.Y):(this._changeFromColumn=O,M=R.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),A=li(P,e===a.RANGE_TYPE.ROW?E:O,e);if(!A)return;const k=o.getScrollXYInfoByViewport(R.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(R.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let N=!1,H;const x=()=>{if(N)return;H=R.ScrollTimer.create(o,M),this._scrollTimer=H;const U=o.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN);H.startScroll(b,w,U),N=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{x();const{offsetX:B,offsetY:Y}=U,{x:F,y:z}=o.getCoordRelativeToViewport(R.Vector2.FromArray([B,Y]));this._rowColumnMoving(F,z,A,k,e),H.scrolling(F,z,()=>{this._rowColumnMoving(F,z,A,k,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var B,Y,F;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(B=this._scrollTimer)==null||B.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const j=(Y=((U==null?void 0:U.filter(Q=>Q.range.rangeType===a.RANGE_TYPE.ROW&&Q.range.startRow<=this._changeFromRow&&this._changeFromRow<=Q.range.endRow))||[])[0])==null?void 0:Y.range;j&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:j,toRange:{...j,startRow:this._changeToRow,endRow:this._changeToRow+j.endRow-j.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const j=(F=((U==null?void 0:U.filter(Q=>Q.range.rangeType===a.RANGE_TYPE.COLUMN&&Q.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=Q.range.endColumn))||[])[0])==null?void 0:F.range;j&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:j,toRange:{...j,startColumn:this._changeToColumn,endColumn:this._changeToColumn+j.endColumn-j.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new D.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new D.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new D.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,i,o,s){var z,j,Q,ie,$,se,Z;const l=this._context.scene,c=(z=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:z.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:v}=l.getAncestorScale(),p=c.getCellIndexByOffset(e,t,f,v,S),{row:C,column:b}=p,w=c.getNoMergeCellWithCoordByIndex(C,b),{startX:E,startY:O,endX:M,endY:P}=w,A=this._sheetSkeletonManagerService.attachRangeWithCoord(i.range);if(A==null)return;const k=Math.max(f,f),{startX:N,endX:H,startY:x,endY:L,startRow:V,startColumn:U,endRow:B,endColumn:Y}=A;s===a.RANGE_TYPE.ROW?(j=this._moveHelperBackgroundShape)==null||j.transformByState({height:L-x,width:g+d,left:0,top:x+(t-this._startOffsetY)/k+S.y-o.y}):(Q=this._moveHelperBackgroundShape)==null||Q.transformByState({height:h+u,width:H-N,left:N+(e-this._startOffsetX)/k+S.x-o.x,top:0}),(ie=this._moveHelperBackgroundShape)==null||ie.show();const F=Zm/k;if(s===a.RANGE_TYPE.ROW){let G=0;if(C<=V)G=O-F/2,this._changeToRow=C;else if(C>B)G=P-F/2,this._changeToRow=C+1;else return;($=this._moveHelperLineShape)==null||$.transformByState({height:F,width:g,left:d,top:G})}else{let G=0;if(b<=U)G=E-F/2,this._changeToColumn=b;else if(b>Y)G=M-F/2,this._changeToColumn=b+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:F,left:G,top:u})}(Z=this._moveHelperLineShape)==null||Z.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new R.Rect(Xm,{fill:jm,evented:!1,zIndex:100}),this._moveHelperLineShape=new R.Rect(Ym,{fill:Gm,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],st)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}},y.HeaderMoveRenderController=zm([ko(1,a.Inject(m.SheetsSelectionsService)),ko(2,a.Inject(y.SheetSkeletonManagerService)),ko(3,a.ICommandService)],y.HeaderMoveRenderController);var Ho=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Ho||{});const Km="rgba(120, 120, 120, 0.01)",Vo="rgb(68, 71, 70)",ci=12,qm=44,Wo=4;class cl extends R.Shape{constructor(e,t){super(e,t);T(this,"_size",ci);T(this,"_color",Vo);T(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:i,scaleY:o}=t.getAncestorScale(),s=Math.max(i,o),l=ci/s,c=Wo/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),R.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:Km}),R.Rect.drawWith(e,{width:d,height:u,fill:Vo,radius:c}),e.save(),e.transform(1,0,0,1,h,g),R.Rect.drawWith(e,{width:d,height:u,fill:Vo,radius:c}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:ci,height:this.size}):this.transformByState({width:this.size,height:ci}),this}}var Qm=Object.getOwnPropertyDescriptor,Jm=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qm(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},xo=(n,r)=>(e,t)=>r(e,t,n);const $m="__SpreadsheetHeaderResizeControllerShapeRow__",eg="__SpreadsheetHeaderResizeControllerShapeColumn__",dl="__SpreadsheetHeaderResizeControllerShapeHelper__",ul="rgb(199, 199, 199)",tg=2,Lo=a.createInterceptorKey("headerResizePermissionCheck");y.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,i,o){super();T(this,"_currentRow",0);T(this,"_currentColumn",0);T(this,"_rowResizeRect");T(this,"_columnResizeRect");T(this,"_headerPointerSubs");T(this,"_scenePointerMoveSub");T(this,"_scenePointerUpSub");T(this,"_resizeHelperShape");T(this,"_startOffsetX",Number.POSITIVE_INFINITY);T(this,"_startOffsetY",Number.POSITIVE_INFINITY);T(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:Lo}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=i,this._commandService=o,this._init()}dispose(){var e,t,i;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(i=this._headerPointerSubs)==null||i.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new cl($m,{visible:!1,mode:Ho.HORIZONTAL,zIndex:100}),this._columnResizeRect=new cl(eg,{visible:!1,mode:Ho.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],st),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),i=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?i:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var k;const h=(k=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:k.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:v,endX:p,endY:C,row:b,column:w}=ze(d.offsetX,d.offsetY,o,h),E=xn(d.offsetX,d.offsetY,o),{scaleX:O,scaleY:M}=o.getAncestorScale(),P=Math.max(O,M),A=ci/P;if(e===0){let N=v-A/2;if(E.y<=v+A/2&&E.y>=v)this._currentRow=b-1;else if(E.y>=C-A/2&&E.y<=C)this._currentRow=b,N=C-A/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(Lo)(null,{row:this._currentRow}))return!1;const x=Math.min(qm,g/3);this._rowResizeRect.transformByState({left:g/2-x/2,top:N}),this._rowResizeRect.setShapeProps({size:x}),this._rowResizeRect.show()}else{let N=f-A/2;if(E.x<=f+A/2&&E.x>=f)this._currentColumn=w-1;else if(E.x>=p-A/2&&E.x<=p)this._currentColumn=w,N=p-A/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(Lo)(null,{col:this._currentColumn}))return!1;const x=S*.7;this._columnResizeRect.transformByState({left:N,top:S/2-x/2}),this._columnResizeRect.setShapeProps({size:x}),this._columnResizeRect.show()}};this._headerPointerSubs=new D.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,i=e===0?this._rowResizeRect:this._columnResizeRect;i!=null&&(this.disposeWithMe(i.onPointerEnter$.subscribeEvent(()=>{i!=null&&(i.show(),t.setCursor(e===0?R.CURSOR_TYPE.ROW_RESIZE:R.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(i.onPointerLeave$.subscribeEvent(()=>{i!=null&&(i.hide(),t.resetCursor())})),this.disposeWithMe(i.onPointerDown$.subscribeEvent(o=>{var Y,F,z,j,Q,ie,$;const s=(Y=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:Y.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((z=(F=h==null?void 0:h.getScrollBar())==null?void 0:F.horizonScrollTrack)==null?void 0:z.height)||0)+10,S=(((Q=(j=h==null?void 0:h.getScrollBar())==null?void 0:j.verticalScrollTrack)==null?void 0:Q.width)||0)+10,f=xn(o.offsetX,o.offsetY,l),{scaleX:v,scaleY:p}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),b=s.getOffsetByRow(this._currentRow),w=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let E=!1,O=0,M=0;const{columnTotalWidth:P,rowHeaderWidth:A,rowTotalHeight:k,columnHeaderHeight:N}=s,H=u>P+A?u:P+A,x=d>k+N?d:k+N,L=Math.max(v,p),V=Wo/L;e===0?this._resizeHelperShape=new R.Rect(dl,{width:H,height:V,fill:ul,left:0,top:b-V/2}):this._resizeHelperShape=new R.Rect(dl,{width:V,height:x,fill:ul,left:C-V/2,top:0});const U=((ie=this._columnResizeRect)==null?void 0:ie.left)||0,B=(($=this._rowResizeRect)==null?void 0:$.top)||0;l.addObject(this._resizeHelperShape,st),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var pe,we,Ee,Ct,_t,jt;const Z=l.getCoordRelativeToViewport(R.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),G=l.getScrollXYInfoByViewport(Z,h),J=xn(se.offsetX,se.offsetY,l),{x:re,y:ue}=J,{scaleX:oe,scaleY:ae}=l.getAncestorScale(),te=Math.max(oe,ae),fe=Wo/te;O=re-this._startOffsetX-fe/2,M=ue-this._startOffsetY-fe/2,Math.abs(e===0?M:O)>=tg&&(E=!0),e===0?(M>d-g+G.y-w.startY&&(M=d-g+G.y-w.startY),M<-(w.endY-w.startY)+2&&(M=-(w.endY-w.startY)+2),E&&((pe=this._resizeHelperShape)==null||pe.transformByState({top:b+M}),(we=this._rowResizeRect)==null||we.transformByState({top:B+M+fe/2}),(Ee=this._rowResizeRect)==null||Ee.show(),l.setCursor(R.CURSOR_TYPE.ROW_RESIZE))):(O>u-S+G.x-w.startX&&(O=u-S+G.x-w.startX),O<-(w.endX-w.startX)+2&&(O=-(w.endX-w.startX)+2),E&&((Ct=this._resizeHelperShape)==null||Ct.transformByState({left:C+O}),(_t=this._columnResizeRect)==null||_t.transformByState({left:U+O+fe/2}),(jt=this._columnResizeRect)==null||jt.show(),l.setCursor(R.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var G,J,re;const Z=this._context.scene;this._clearObserverEvent(),(G=this._resizeHelperShape)==null||G.dispose(),this._resizeHelperShape=null,Z.enableObjectsEvent(),E&&(Z.resetCursor(),(J=this._rowResizeRect)==null||J.hide(),(re=this._columnResizeRect)==null||re.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:M,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:O,anchorCol:this._currentColumn}))})})),this.disposeWithMe(i.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),v=[];for(let p=0;p<f.length;p++){const C=f[p];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&v.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}v.length===0&&v.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(ii.id,{ranges:v}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}},y.HeaderResizeRenderController=Jm([xo(1,a.Inject(y.SheetSkeletonManagerService)),xo(2,a.Inject(m.SheetsSelectionsService)),xo(3,a.ICommandService)],y.HeaderResizeRenderController);var ng=Object.getOwnPropertyDescriptor,ig=(n,r,e,t)=>{for(var i=t>1?void 0:t?ng(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},di=(n,r)=>(e,t)=>r(e,t,n);const rg=60;y.SheetRenderController=class extends a.RxDisposable{constructor(e,t,i,o,s,l){super();T(this,"_renderMetric$",new D.Subject);T(this,"renderMetric$",this._renderMetric$.asObservable());T(this,"_renderFrameTimeMetric",null);T(this,"_renderFrameTags",{});T(this,"_afterRenderMetric$",new D.Subject);this._context=e,this._configService=t,this._sheetSkeletonManagerService=i,this._sheetRenderService=o,this._commandService=s,this._telemetryService=l,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:i}=this._context;this._addComponent(i),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(R.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([i,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[i]||(this._renderFrameTimeMetric[i]=[]),this._renderFrameTimeMetric[i].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([i,o])=>{this._renderFrameTags[i]=o});const t=[];this._afterRenderMetric$.pipe(D.withLatestFrom(e.endFrame$)).subscribe(([i,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...i.frameTimeMetric,...i.tags}),t.length>rg&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const i=S=>{let f=0;const p=Object.entries(S).filter(([b,w])=>Array.isArray(w)).map(([b])=>b).reduce((b,w)=>{const E=S[w].reduce((O,M)=>O+M,0);return b[w]=E,b},{});return Object.keys(S).filter(b=>b.startsWith(R.SHEET_EXTENSION_PREFIX)).forEach(b=>{f+=p[b]}),{...p,extensionTotal:f}},o=e.map(S=>({...S,...i(S)})),l=(S=>Object.entries(S[0]).filter(([p,C])=>!["elapsedTime"].includes(p)).filter(([p,C])=>typeof C=="number").map(([p])=>p).reduce((p,C)=>{const b=S.map(M=>M[C]),w=Math.max(...b),E=Math.min(...b),O=b.reduce((M,P)=>M+P,0)/b.length;return p[C]={max:Math.round(w*100)/100,min:Math.round(E*100)/100,avg:Math.round(O*100)/100},p},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:i}=this._context,o=e.getActiveSheet(),s=new R.Spreadsheet(he.MAIN);this._addViewport(o);const l=new R.SpreadsheetRowHeader(he.ROW),c=new R.SpreadsheetColumnHeader(he.COLUMN),d=new R.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,i.set(he.MAIN,s),i.set(he.ROW,l),i.set(he.COLUMN,c),i.set(he.LEFT_TOP,d),t.addObjects([s],ys),t.addObjects([l,c,d],st),t.enableLayerCache(ys,st)}_initViewports(e,t,i){const l=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:i.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:i.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),S=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:i.height+1,right:0,isWheelPreventDefaultX:!0}),v=new R.Viewport(R.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:i.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:v,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:i,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,i,o),l=this._configService.getConfig(He),c=l==null?void 0:l.scrollConfig;return new R.ScrollBar(s,c),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:i}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(i);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:i}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(i)||this._sheetRenderService.checkMutationShouldTriggerRerender(i)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:i},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:i})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(i)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:i}=this._context;if(e.id===K.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),i.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(i);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,i=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),i<Number(S)&&(i=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:i}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:i,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:i[u-1]+l,v=i[h]+l,p=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:p,bottom:v,right:C,width:C-p,height:v-f})}return c}_markViewportDirty(e,t){const i=e.filter(o=>o.isActive&&o.cacheBound);for(const o of i)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}},y.SheetRenderController=ig([di(1,a.Inject(a.IConfigService)),di(2,a.Inject(y.SheetSkeletonManagerService)),di(3,a.Inject(y.SheetsRenderService)),di(4,a.ICommandService),di(5,a.Optional(Jc.ITelemetryService))],y.SheetRenderController);function og(n,r){if(n.length!==r.length)return!1;const e=n.sort((i,o)=>i.id.localeCompare(o.id)),t=r.sort((i,o)=>i.id.localeCompare(o.id));return e.every((i,o)=>{var s,l;return((s=i.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&i.role===t[o].role})}function hl(n,r){return r.some(e=>sg(n,e))}function sg(n,r){const{startRow:e,startColumn:t,endColumn:i,endRow:o}=r,s=n.getMatrixWithMergedCells(e,t,o,i);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function ml(n,r,e,t){const i=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=ag(e,l),d={unitId:r,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);i.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:i,redos:o}}function ag(n,r){const{startRow:e,startColumn:t,endColumn:i,endRow:o}=r,s=n.getMatrixWithMergedCells(e,t,o,i,a.CellModeEnum.Raw),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,v;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((v=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?v:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function lg(n,r,e,t){const i=e.getActiveViewportByCoord(R.Vector2.FromArray([n,r]));if(!i)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:i.viewportScrollX,y:i.viewportScrollY},c=t.getCellIndexByOffset(n,r,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function gl(n,r,e,t){const i=t.getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0||n>=i.startRow&&r>=i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<i.startRow&&r<i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<i.startRow&&r>=i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=i.startRow&&r<i.startColumn)return e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function cg(n,r,e,t){const i=Sl(n.left,n.top,r,e,t),o=Sl(n.right,n.bottom,r,e,t);return{left:i.x,top:i.y,right:o.x,bottom:o.y}}function Sl(n,r,e,t,i){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(R.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:r};const c=i.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:v,columnHeaderHeight:p}=t,C=f.startX-S.startX,b=f.startY-S.startY,{top:w,left:E,viewportScrollX:O,viewportScrollY:M}=l;let P;n>E?P=(n-O)*o:P=(C+v-(E-n))*o;let A;return r>w?A=(r-M)*s:A=(b+p-(w-r))*o,{x:P,y:A}}function fl(n,r,e,t,i){let o=t,s=i;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:r.getSheetId(),workbook:n,worksheet:r,row:l.actualRow,col:l.actualColumn}}function vl(n,r,e,t,i,o){const{scene:s}=n,l=r.getUnitId(),{skeleton:c,sheetId:d}=t,u=lg(i,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:r,worksheet:e,row:g,col:h};c.overflowCache.forValue((M,P,A)=>{A.startRow<=g&&A.endRow>=g&&A.startColumn<=h&&A.endColumn>=h&&(h=P,g=M)});const f=c.getCellWithCoordByIndex(g,h),v=fl(r,e,c,g,h);let p;f.mergeInfo?p=f.mergeInfo:p={startRow:v.row,endRow:v.row,startColumn:v.col,endColumn:v.col};const C=s.getActiveViewportByCoord(R.Vector2.FromArray([i,o]));if(!C)return;const{scaleX:b,scaleY:w}=s.getAncestorScale(),E={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(p.startColumn-1)-E.x)*b,endX:(c.getOffsetByColumn(p.endColumn)-E.x)*b,startY:(c.getOffsetByRow(p.startRow-1)-E.y)*w,endY:(c.getOffsetByRow(p.endRow)-E.y)*w},location:S,overflowLocation:v}}const gt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,r)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=r.unitId,c=r.subUnitId,d=r.selections,u=m.getAddMergeMutationRangeByType(d,r.value),h=i.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=hl(h,u);if(f&&!r.defaultMerge&&!await o.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,v),b=m.AddMergeUndoMutationFactory(n,p);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:p}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:b}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const A=ml(n,l,h,u);g.unshift(...A.redos),S.push(...A.undos)}const w=m.AddMergeRedoSelectionsOperationFactory(n,r,u);w&&g.push(w);const E=m.AddMergeUndoSelectionsOperationFactory(n,r);E&&S.push(E);const M=n.get(m.SheetInterceptorService).onCommandExecute({id:gt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...M.redos),S.push(...M.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},Uo={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const r=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=Qr(Fi.MergeAll,t);if(!(i!=null&&i.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return r.executeCommand(gt.id,{selections:i,unitId:c,subUnitId:d})}},Bo={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const r=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=Qr(Fi.MergeVertical,t);if(!(i!=null&&i.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return r.executeCommand(gt.id,{value:a.Dimension.COLUMNS,selections:i,unitId:c,subUnitId:d})}},Fo={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const r=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),i=Qr(Fi.MergeHorizontal,t);if(!(i!=null&&i.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return r.executeCommand(gt.id,{value:a.Dimension.ROWS,selections:i,unitId:c,subUnitId:d})}},_n={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:_n.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Vt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await r.confirm({id:Vt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:Vt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await r.confirm({id:Wt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:Wt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},In={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const r=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),i=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=i.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await r.confirm({id:In.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var pl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(pl||{}),ne=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ne||{}),Ae=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ae||{}),et=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(et||{}),Ze=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ze||{});const ui="UNIVER_SHEET_PERMISSION_PANEL",bn="UNIVER_SHEET_PERMISSION_USER_PART",ir="UNIVER_SHEET_PERMISSION_BACKGROUND",Cl="UNIVER_SHEET_PERMISSION_USER_DIALOG",_l="UNIVER_SHEET_PERMISSION_DIALOG",rr="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",or="UNIVER_SHEET_PERMISSION_DIALOG_ID",sr={[ne.Copy]:"Copy",[ne.SetCellStyle]:"SetCellStyle",[ne.SetCellValue]:"SetCellValue",[ne.SetRowStyle]:"SetRowStyle",[ne.SetColumnStyle]:"SetColumnStyle",[ne.InsertRow]:"InsertRow",[ne.InsertColumn]:"InsertColumn",[ne.InsertHyperlink]:"InsertHyperlink",[ne.DeleteRow]:"DeleteRow",[ne.DeleteColumn]:"DeleteColumn",[ne.Sort]:"Sort",[ne.Filter]:"Filter",[ne.PivotTable]:"PivotTable",[ne.EditExtraObject]:"EditExtraObject"},dg=[ne.Copy,ne.SetCellStyle,ne.SetCellValue,ne.SetRowStyle,ne.SetColumnStyle,ne.InsertRow,ne.InsertColumn,ne.InsertHyperlink,ne.DeleteRow,ne.DeleteColumn,ne.Sort,ne.Filter,ne.PivotTable,ne.EditExtraObject,ne.View],Il="sheet-permission-menu-icon",ug="sheet-permission-delete-icon",hg="sheet-permission-edit-icon",mg="sheet-permission-check-icon",bl="sheet-permission-lock-icon",gg={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class wn{constructor(){T(this,"_rule",gg);T(this,"_visible",!1)}setVisible(r){this._visible=r}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class St{constructor(){T(this,"_userList",[]);T(this,"_userList$",new D.BehaviorSubject(this._userList));T(this,"userList$",this._userList$.asObservable());T(this,"_oldCollaboratorList",[]);T(this,"_selectUserList",[]);T(this,"_selectUserList$",new D.BehaviorSubject(this._selectUserList));T(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(r){this._userList=r,this._userList$.next(r)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(r){this._oldCollaboratorList=r}get selectUserList(){return this._selectUserList}setSelectUserList(r){this._selectUserList=r,this._selectUserList$.next(r)}}const Ke={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,r={}){const e=n.get(_.ISidebarService),t=n.get(wn),i=n.get(St),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=r,d={header:{title:"permission.panel.title"},children:{label:ui,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),i.reset()}};return t.setVisible(!0),e.open(d),!0}},hi={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!0}),!0}},xt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!0}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!1}),!0}},mi={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{fromSheetBar:!0,showDetail:!0}),!0}},gi={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Ke.id,{showDetail:!1}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),i=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return r.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=i.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const v=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(p=>p.ranges.some(C=>a.Rectangle.intersects(C,g)));if(v){const p={unitId:c,subUnitId:d,ruleIds:[v.id]};return await r.executeCommand(m.DeleteRangeProtectionMutation.id,p)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:p}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[v]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),i=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=i.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await r.executeCommand(Ke.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(v=>{var p;return(p=v==null?void 0:v.ranges)==null?void 0:p.some(C=>a.Rectangle.intersects(C,h))});if(f){const v={...f,unitId:l,subUnitId:c};return await r.executeCommand(Ke.id,{showDetail:!0,rule:a.Tools.deepClone(v),oldRule:a.Tools.deepClone(v)}),!0}else return!1}}},En={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,r)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=r==null?void 0:r.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(Ys(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Tn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,r)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=r==null?void 0:r.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const i=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(js(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},Si={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,r)=>{const{subUnitId:e}=r,t=n.get(_.IConfirmService),i=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await i.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},fi={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Tt).triggerSheetBarMenu(),!0)},vi={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,r){if(!r)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),i=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(pl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=i.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},pi={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},Ci={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,r)=>{const e=n.get(Tt);return r&&e.setRenameId(r.subUnitId),!0}},zo={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,r){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:or,title:{title:"permission.dialog.allowedPermissionType"},children:{label:_l},width:393,destroyOnClose:!0,onClose:()=>e.close(or)}),!0}},Sg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z"}),I.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z"}),I.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z"}),I.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z"}),I.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z"}),I.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z"}),I.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z"}),I.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z"}),I.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z"}),I.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z"}),I.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z"}),I.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z"}),I.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z"}),I.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z"}),I.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z"}),I.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z"}),I.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z"}),I.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z"}),I.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z"}),I.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z"}),I.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z"}),I.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z"}),I.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z"}),I.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z"}),I.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z"}),I.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z"}),I.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z"})]}),fg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z"}),I.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z"}),I.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z"}),I.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z"}),I.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z"}),I.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z"}),I.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z"}),I.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z"}),I.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z"}),I.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z"}),I.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z"}),I.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z"}),I.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z"}),I.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z"}),I.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z"}),I.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z"}),I.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z"}),I.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z"}),I.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z"}),I.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z"}),I.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z"}),I.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z"}),I.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z"}),I.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z"}),I.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z"}),I.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z"}),I.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z"}),I.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z"})]}),vg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z"}),I.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z"}),I.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z"}),I.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z"}),I.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z"}),I.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z"}),I.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z"}),I.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z"}),I.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z"}),I.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z"}),I.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z"}),I.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z"}),I.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z"}),I.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z"}),I.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z"}),I.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z"}),I.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z"}),I.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z"}),I.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z"}),I.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z"})]}),pg=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z"}),I.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z"}),I.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z"}),I.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z"}),I.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z"}),I.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z"}),I.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z"}),I.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z"}),I.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z"}),I.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z"}),I.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z"}),I.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z"}),I.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z"}),I.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z"}),I.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z"}),I.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z"}),I.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z"}),I.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z"}),I.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z"}),I.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z"}),I.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z"}),I.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z"}),I.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z"}),I.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z"}),I.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z"}),I.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z"}),I.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z"}),I.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z"}),I.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z"}),I.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z"}),I.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z"}),I.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z"}),I.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z"}),I.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z"}),I.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z"}),I.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z"}),I.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z"}),I.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z"}),I.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z"}),I.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z"}),I.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z"}),I.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z"}),I.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z"}),I.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z"}),I.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z"}),I.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z"}),I.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z"}),I.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z"}),I.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z"}),I.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z"}),I.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z"}),I.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z"})]}),Cg=({className:n})=>I.jsx("svg",{className:n,width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z"})}),_g=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z"}),I.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z"}),I.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z"}),I.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z"}),I.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z"}),I.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z"}),I.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z"}),I.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z"}),I.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z"}),I.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z"}),I.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z"}),I.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z"}),I.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z"}),I.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z"}),I.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z"}),I.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z"}),I.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z"}),I.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z"})]}),Ig=({className:n})=>I.jsxs("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z"}),I.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z"}),I.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z"}),I.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z"}),I.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z"}),I.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z"}),I.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z"}),I.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z"}),I.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z"}),I.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z"}),I.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z"}),I.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z"}),I.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z"}),I.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z"}),I.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z"}),I.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z"}),I.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z"}),I.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z"}),I.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z"}),I.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z"})]}),bg=({className:n})=>I.jsxs("svg",{className:n,width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z"}),I.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z"}),I.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z"}),I.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z"}),I.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z"}),I.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z"}),I.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z"}),I.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z"}),I.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z"}),I.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z"}),I.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z"}),I.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z"}),I.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z"}),I.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z"}),I.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z"}),I.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z"}),I.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z"}),I.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z"}),I.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z"}),I.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z"})]}),wg=({className:n})=>I.jsx("svg",{className:n,width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z"})}),Eg=({className:n})=>I.jsx("svg",{className:n,width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z"})});function wl(n){const{type:r=a.BorderStyleTypes.THIN,className:e}=n;switch(r){case a.BorderStyleTypes.DASH_DOT:return I.jsx(Sg,{className:e});case a.BorderStyleTypes.DASH_DOT_DOT:return I.jsx(fg,{className:e});case a.BorderStyleTypes.DASHED:return I.jsx(vg,{className:e});case a.BorderStyleTypes.HAIR:return I.jsx(pg,{className:e});case a.BorderStyleTypes.MEDIUM:return I.jsx(Cg,{className:e});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return I.jsx(_g,{className:e});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return I.jsx(Ig,{className:e});case a.BorderStyleTypes.MEDIUM_DASHED:return I.jsx(bg,{className:e});case a.BorderStyleTypes.THICK:return I.jsx(wg,{className:e});case a.BorderStyleTypes.THIN:default:return I.jsx(Eg,{className:e})}}const Xo=`${Ka}_BORDER_PANEL_COMPONENT`,El=[{label:"borderLine.borderTop",icon:"UpBorderDoubleIcon",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorderDoubleIcon",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorderDoubleIcon",value:"left"},{label:"borderLine.borderRight",icon:"RightBorderDoubleIcon",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderIcon",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderIcon",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorderDoubleIcon",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorderDoubleIcon",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorderDoubleIcon",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorderDoubleIcon",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashIcon",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalIcon",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalIcon",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashIcon",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalIcon",value:"mltr_bctr"}],Tg=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function Tl(n){var l;const r=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:i}=n;function o(c,d){t==null||t({...i,[d]:c})}function s(c){const d=r.get(c);return d&&I.jsx(d,{className:"univer-fill-primary-600"})}return I.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[I.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2 univer-text-gray-600 dark:!univer-text-gray-200",children:El.map(c=>I.jsx("a",{className:X.clsx("univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-justify-self-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-200 dark:!univer-bg-gray-600":e.getBorderInfo().type===c.value}),onClick:d=>{d.stopPropagation(),o(c.value,"type")},children:s(c.icon)},c.value))}),I.jsx(X.Separator,{}),I.jsxs("div",{className:"univer-flex univer-items-center univer-gap-2",children:[I.jsx("div",{children:I.jsx(X.Dropdown,{overlay:I.jsx("div",{className:"univer-rounded-lg univer-p-4",children:I.jsx(X.ColorPicker,{onChange:c=>o(c,"color")})}),children:I.jsxs("button",{className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",type:"button",children:[I.jsx(ia,{className:"univer-fill-primary-600 dark:!univer-text-white",extend:{colorChannel1:(l=i==null?void 0:i.color)!=null?l:""}}),I.jsx(sn,{className:"dark:!univer-text-white"})]})})}),I.jsx("div",{children:I.jsx(X.Dropdown,{overlay:I.jsx("section",{className:"univer-rounded-lg univer-p-1.5",children:I.jsx("ul",{className:"univer-m-0 univer-grid univer-list-none univer-gap-1 univer-p-0",children:Tg.map(c=>I.jsx("li",{className:"univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-px-1 univer-py-2 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",onClick:()=>o(c.value,"style"),children:I.jsx(wl,{className:"univer-fill-gray-900 dark:!univer-fill-white",type:c.value})},c.value))})}),children:I.jsxs("button",{className:"univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded univer-border-none univer-bg-transparent univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",type:"button",children:[I.jsx(wl,{className:"univer-fill-gray-900 dark:!univer-fill-white",type:a.BorderStyleTypes.THIN}),I.jsx(sn,{className:"dark:!univer-text-white"})]})})})]})]})}const yl="sheets.component.cell-popup";var yg=Object.getOwnPropertyDescriptor,Rg=(n,r,e,t)=>{for(var i=t>1?void 0:t?yg(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Ft=(n,r)=>(e,t)=>r(e,t,n);y.SheetCanvasPopManagerService=class extends a.Disposable{constructor(e,t,i,o,s,l,c){super();T(this,"_popupMenuFeatureMap",new Map);T(this,"_isSelectionMoving",!1);this._globalPopupManagerService=e,this._renderManagerService=t,this._univerInstanceService=i,this._refRangeService=o,this._commandService=s,this._refSelectionsService=l,this._selectionManagerService=c,this._initMoving()}_initMoving(){this.disposeWithMe(this._refSelectionsService.selectionMoving$.subscribe(()=>{this._isSelectionMoving=!0})),this.disposeWithMe(this._refSelectionsService.selectionMoveEnd$.subscribe(()=>{this._isSelectionMoving=!1})),this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(()=>{this._isSelectionMoving=!0})),this.disposeWithMe(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{this._isSelectionMoving=!1}))}registerFeatureMenu(e,t){this._popupMenuFeatureMap.set(e,t)}getFeatureMenu(e,t,i,o){const s=this._popupMenuFeatureMap.get(o);if(s)return s(e,t,i,o)}dispose(){super.dispose(),this._popupMenuFeatureMap.clear()}_createHiddenRectObserver(e){const{row:t,column:i,worksheet:o,skeleton:s,currentRender:l}=e,c=()=>{var z,j;const g=o.getFreeze(),{startRow:S,startColumn:f,xSplit:v,ySplit:p}=g,C=S-p,b=f-v,{rowHeightAccumulation:w,columnWidthAccumulation:E,rowHeaderWidth:O,columnHeaderHeight:M}=s,P=O+(b===-1?0:E[b+v-1]-((z=E[b-1])!=null?z:0)),A=M+(C===-1?0:w[C+p-1]-((j=w[C])!=null?j:0)),k=l.engine.getCanvasElement(),N=k.getBoundingClientRect(),H=Yo(k.style.width),x=N.width/H,L=l.scene.getAncestorScale().scaleX,V=P*x*L,U=A*x*L,B={left:-1/0,top:-1/0,right:N.left+V,bottom:N.top+U},Y={left:N.left+V,top:-1/0,right:1/0,bottom:N.top+U},F={left:-1/0,top:N.top+U,right:N.left+V,bottom:1/0};return t<S&&i<f?[]:t<S?[B]:i<f?[B]:[B,Y,F]},d=c(),u=new D.BehaviorSubject(d),h=new a.DisposableCollection;return h.add(this._commandService.onCommandExecuted(g=>{g.id===m.SetFrozenMutation.id&&u.next(c())})),h.add(a.fromEventSubject(l.engine.onTransformChange$).pipe(D.throttleTime(16)).subscribe(()=>{u.next(c())})),{rects$:u,disposable:h}}_createPositionObserver(e,t,i,o){const s=()=>{const{scene:u}=t,h=cg(e,u,i,o),g=t.engine.getCanvasElement(),S=g.getBoundingClientRect(),f=Yo(g.style.width),v=S.width/f;return{left:h.left*v+S.left,right:h.right*v+S.left,top:h.top*v+S.top,bottom:h.bottom*v+S.top}},l=s(),c=new D.BehaviorSubject(l),d=new a.DisposableCollection;return d.add(this._commandService.onCommandExecuted(u=>{(u.id===Le.id||u.id===Ne.id)&&c.next(s())})),{position:l,position$:c,disposable:d}}attachPopupToObject(e,t){var w;const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=i.getActiveSheet();if(!o||this._isSelectionMoving&&!t.showOnSelectionMoving)return{dispose:()=>{},canDispose:()=>!0};const s=i.getUnitId(),l=o.getSheetId(),c=(w=this._renderManagerService.getRenderById(s))==null?void 0:w.with(y.SheetSkeletonManagerService).ensureSkeleton(l),d=this._renderManagerService.getRenderById(s);if(!d||!c)return{dispose:()=>{},canDispose:()=>!0};const{left:u,top:h,width:g,height:S}=e,f={left:u,right:u+g,top:h,bottom:h+S},{position:v,position$:p,disposable:C}=this._createPositionObserver(f,d,c,o),b=this._globalPopupManagerService.addPopup({...t,unitId:s,subUnitId:l,anchorRect:v,anchorRect$:p,canvasElement:d.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(b),p.complete(),C.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==b}}attachPopupByPosition(e,t,i){var C;const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet();if(!s)return null;const l=o.getUnitId(),c=s.getSheetId();if(l!==i.unitId||i.subUnitId!==c)return null;if(this._isSelectionMoving&&!t.showOnSelectionMoving)return;const d=(C=this._renderManagerService.getRenderById(l))==null?void 0:C.with(y.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:c}),u=this._renderManagerService.getRenderById(l);if(!u||!d)return null;const{position:h,position$:g,disposable:S}=this._createPositionObserver(e,u,d,s),{rects$:f,disposable:v}=this._createHiddenRectObserver({row:i.row,column:i.col,worksheet:s,skeleton:d,currentRender:u}),p=this._globalPopupManagerService.addPopup({...t,unitId:l,subUnitId:c,anchorRect:h,anchorRect$:g,hiddenRects$:f,canvasElement:u.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(p),g.complete(),S.dispose(),v.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==p}}attachPopupToAbsolutePosition(e,t,i,o){var f;const s=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet();if(!l)return null;const c=s.getUnitId(),d=l.getSheetId();if(i&&c!==i||o&&o!==d)return null;const u=(f=this._renderManagerService.getRenderById(c))==null?void 0:f.with(y.SheetSkeletonManagerService).ensureSkeleton(d),h=this._renderManagerService.getRenderById(c);if(!h||!u)return null;if(this._isSelectionMoving&&!t.showOnSelectionMoving)return;const g=new D.BehaviorSubject(e),S=this._globalPopupManagerService.addPopup({...t,unitId:c,subUnitId:d,anchorRect:e,anchorRect$:g.asObservable(),canvasElement:h.engine.getCanvasElement()});return{dispose:()=>{this._globalPopupManagerService.removePopup(S),g.complete()},canDispose:()=>this._globalPopupManagerService.activePopupId!==S}}attachPopupToCell(e,t,i,o,s,l){const c=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d=c.getActiveSheet();if(!d)return null;const u=c.getUnitId(),h=d.getSheetId();if(o&&u!==o||s&&h!==s)return null;const g=this._renderManagerService.getRenderById(u),S=g==null?void 0:g.with(y.SheetSkeletonManagerService).ensureSkeleton(h),f=g==null?void 0:g.with(ve);if(!g||!S||!f)return null;if(this._isSelectionMoving&&!i.showOnSelectionMoving)return;const v=l!=null?l:gl(e,t,g.scene,d);if(!v)return null;const{position:p,position$:C,disposable:b,updateRowCol:w}=this._createCellPositionObserver(e,t,g,S,v),{rects$:E,disposable:O}=this._createHiddenRectObserver({row:e,column:t,worksheet:d,skeleton:S,currentRender:g}),M=this._globalPopupManagerService.addPopup({...i,unitId:u,subUnitId:h,anchorRect:p,anchorRect$:C,canvasElement:g.engine.getCanvasElement(),hiddenRects$:E}),P=new a.DisposableCollection;P.add(b),P.add(a.toDisposable(()=>{this._globalPopupManagerService.removePopup(M),C.complete()})),P.add(O);const A={startRow:e,endRow:e,startColumn:t,endColumn:t};return P.add(this._refRangeService.watchRange(u,h,A,(k,N)=>{N?w(N.startRow,N.startColumn):P.dispose()})),{dispose(){P.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==M}}attachRangePopup(e,t,i,o,s,l=!1){const c=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),d=c.getActiveSheet();if(!d)return null;const u=c.getUnitId(),h=d.getSheetId();if(i&&u!==i||o&&h!==o)return null;const g=this._renderManagerService.getRenderById(u),S=g==null?void 0:g.with(y.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:h}),f=g==null?void 0:g.with(ve);if(!g||!S||!f)return null;if(f.selectionMoving&&!l)return;const v=s!=null?s:gl(e.startRow,e.startColumn,g.scene,d);if(!v)return null;const{position:p,position$:C,disposable:b,updateRowCol:w,topLeftPos$:E,rightBottomPos$:O}=this._createRangePositionObserver(e,g,S,v),{rects$:M,disposable:P}=this._createHiddenRectObserver({row:e.startRow,column:e.startColumn,worksheet:d,skeleton:S,currentRender:g}),A=this._globalPopupManagerService.addPopup({...t,unitId:u,subUnitId:h,anchorRect:p,anchorRect$:C,canvasElement:g.engine.getCanvasElement(),hiddenRects$:M}),k=new a.DisposableCollection;k.add(b),k.add(a.toDisposable(()=>{this._globalPopupManagerService.removePopup(A),E.complete(),O.complete()})),k.add(P);const N={...e};return k.add(this._refRangeService.watchRange(u,h,N,(H,x)=>{x?w(x.startRow,x.startColumn):k.dispose()})),{dispose(){k.dispose()},canDispose:()=>this._globalPopupManagerService.activePopupId!==A}}_createCellPositionObserver(e,t,i,o,s){let l=e,c=t;const d=this._calcCellPositionByCell(l,c,i,o,s),u=new D.BehaviorSubject(d),h=()=>u.next(this._calcCellPositionByCell(l,c,i,o,s)),g=new a.DisposableCollection;return g.add(i.engine.clientRect$.subscribe(()=>h())),g.add(a.fromEventSubject(i.engine.onTransformChange$).pipe(D.throttleTime(16)).subscribe(()=>h())),g.add(this._commandService.onCommandExecuted(f=>{if(f.id===m.SetWorksheetRowAutoHeightMutation.id&&f.params.rowsAutoHeightInfo.findIndex(p=>p.row===l)>-1){h();return}(m.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(f.id)>-1||f.id===Le.id||f.id===Ne.id)&&h()})),{position$:u,disposable:g,position:d,updateRowCol:(f,v)=>{l=f,c=v,h()}}}_calcCellPositionByCell(e,t,i,o,s){const{scene:l,engine:c}=i,d=o.getCellWithCoordByIndex(e,t),u=d.isMergedMainCell?d.mergeInfo:d,{scaleX:h,scaleY:g}=l.getAncestorScale(),S={x:s.viewportScrollX,y:s.viewportScrollY},f=c.getCanvasElement();if(!f)return{left:0,right:0,top:0,bottom:0};const v=f.getBoundingClientRect(),p=Yo(f.style.width),{top:C,left:b,width:w}=v,E=w/p;return{left:(u.startX-S.x)*E*h+b,right:(u.endX-S.x)*E*h+b,top:(u.startY-S.y)*E*g+C,bottom:(u.endY-S.y)*E*g+C}}_createRangePositionObserver(e,t,i,o){let{startRow:s,startColumn:l}=e;const c=this._calcCellPositionByCell(s,l,t,i,o),d=new D.BehaviorSubject(c),u=this._calcCellPositionByCell(e.endRow,e.endColumn,t,i,o),h=new D.BehaviorSubject(u),g=()=>{const C=this._calcCellPositionByCell(s,l,t,i,o),b=this._calcCellPositionByCell(e.endRow,e.endColumn,t,i,o);d.next(C),h.next(b)},S=new a.DisposableCollection;S.add(t.engine.clientRect$.subscribe(()=>g())),S.add(this._commandService.onCommandExecuted(C=>{if(C.id===m.SetWorksheetRowAutoHeightMutation.id&&C.params.rowsAutoHeightInfo.findIndex(w=>w.row===s)>-1){g();return}(m.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(C.id)>-1||C.id===Le.id||C.id===Ne.id)&&g()}));const f=(C,b)=>{s=C,l=b,g()},v=d.pipe(D.map(C=>{const b=this._calcCellPositionByCell(e.endRow,e.endColumn,t,i,o);return{top:C.top,left:C.left,right:b.right,bottom:b.bottom}})),p={top:c.top,left:c.left,right:u.right,bottom:u.bottom};return{position$:v,position:p,updateRowCol:f,topLeftPos$:d,rightBottomPos$:h,disposable:S}}},y.SheetCanvasPopManagerService=Rg([Ft(0,a.Inject(_.ICanvasPopupService)),Ft(1,R.IRenderManagerService),Ft(2,a.IUniverInstanceService),Ft(3,a.Inject(m.RefRangeService)),Ft(4,a.ICommandService),Ft(5,m.IRefSelectionsService),Ft(6,a.Inject(m.SheetsSelectionsService))],y.SheetCanvasPopManagerService);function Yo(n){return Number.parseInt(n.replace("px",""))}var Mg=Object.getOwnPropertyDescriptor,Pg=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mg(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Og=(n,r)=>(e,t)=>r(e,t,n);y.CellPopupManagerService=class extends a.Disposable{constructor(e){super();T(this,"_cellPopupMap",new Map);T(this,"_change$",new D.Subject);T(this,"change$",this._change$.asObservable());this._sheetCanvasPopManagerService=e}_ensureCellPopupMap(e,t){let i=this._cellPopupMap.get(e);i||(i=new Map,this._cellPopupMap.set(e,i));let o=i.get(t);return o||(o=new a.ObjectMatrix,i.set(t,o)),o}showPopup(e,t){var g,S;const{direction:i="horizontal"}=t,{unitId:o,subUnitId:s,row:l,col:c}=e,d=this._ensureCellPopupMap(o,s),u=(g=d.getValue(l,c))==null?void 0:g[i];t.id=(S=t.id)!=null?S:a.generateRandomId();const h=()=>{const f=d.getValue(l,c);if(!f)return;const v=f[i];if(!v)return;const p=v==null?void 0:v.popups.findIndex(C=>C.id===t.id&&C.componentKey===t.componentKey);v==null||v.popups.splice(p,1),v.popups.length===0&&(v.disposable.dispose(),f[i]=void 0),this._change$.next({...e,direction:i})};if(u)u.popups.push(t),u.popups.sort((f,v)=>f.priority-v.priority);else{const f=this._sheetCanvasPopManagerService.attachPopupToCell(l,c,{...t,direction:i,componentKey:yl,extraProps:{...e,direction:i},noPushMinimumGap:!0,autoRelayout:!1,zIndex:90},o,s);d.setValue(l,c,{...d.getValue(l,c),[i]:{disposable:f,popups:[t]}})}return this._change$.next({...e,direction:i}),a.toDisposable(h)}getPopups(e,t,i,o,s){var c,d;return((d=(c=this._ensureCellPopupMap(e,t).getValue(i,o))==null?void 0:c[s])==null?void 0:d.popups)||[]}},y.CellPopupManagerService=Pg([Og(0,a.Inject(y.SheetCanvasPopManagerService))],y.CellPopupManagerService);const Ag=n=>{const{popup:r}=n,e=r.extraProps,{row:t,col:i,direction:o,unitId:s,subUnitId:l}=e,c=_.useDependency(y.CellPopupManagerService);_.useObservable(W.useMemo(()=>c.change$.pipe(D.filter(h=>h.row===t&&h.col===i&&h.direction===o)),[c,t,i,o]));const d=c.getPopups(s,l,t,i,o),u=_.useDependency(_.ComponentManager);return I.jsx("div",{"data-u-comp":"cell-popup",className:"univer-ml-px univer-flex univer-flex-col",children:d.map(h=>{var S;const g=u.get(h.componentKey);return g?I.jsx(g,{popup:h},(S=h.id)!=null?S:h.componentKey):null})})},Rl=n=>{const{inputId:r,state:e=!1,type:t="range",confirm:i,cancel:o,name:s,formulaOrRefString:l,comment:c="",localSheetId:d=m.SCOPE_WORKBOOK_VALUE_DEFINED_NAME,hidden:u=!1,id:h}=n,S=_.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),f=_.useDependency(a.LocaleService),v=_.useDependency(K.IDefinedNamesService),p=_.useDependency(K.IFunctionService),C=_.useDependency(K.LexerTreeBuilder),b=_.useDependency(_.ComponentManager),w=W.useMemo(()=>b.get(Vr),[]),E=W.useMemo(()=>b.get(Di),[]);if(S==null)return;const O=W.useMemo(()=>S.getUnitId(),[]),M=W.useMemo(()=>S.getActiveSheet().getSheetId(),[]),[P,A]=W.useState(s),[k,N]=W.useState(l),[H,x]=W.useState(c),[L,V]=W.useState(d),[U,B]=W.useState(""),[Y,F]=W.useState(t),[z,j]=W.useState(!0),Q=[{label:f.t("definedName.scopeWorkbook"),value:m.SCOPE_WORKBOOK_VALUE_DEFINED_NAME}],ie=oe=>!K.isReferenceStrings(oe);W.useEffect(()=>{j(!0),A(s),x(c),V(d);let oe=l;l.substring(0,1)===K.operatorToken.EQUALS?F("formula"):ie(l)?(F("formula"),oe=K.operatorToken.EQUALS+l):F("range"),N(oe),B("")},[e]),S.getSheetOrders().forEach(oe=>{const ae=S.getSheetBySheetId(oe);Q.push({label:(ae==null?void 0:ae.getName())||"",value:oe})});const $=oe=>{N(oe)},se=oe=>{N(oe||"")},Z=()=>{if(P.length===0){B(f.t("definedName.nameEmpty"));return}if(v.getValueByName(O,P)!=null&&(h==null||h.length===0)){B(f.t("definedName.nameDuplicate"));return}if(!a.Tools.isValidParameter(P)||K.isReferenceStringWithEffectiveColumn(P)||!a.Tools.isStartValidPosition(P)&&!R.hasCJKText(P.substring(0,1))){B(f.t("definedName.nameInvalid"));return}if(S.getSheetOrders().map(te=>{var fe;return((fe=S.getSheetBySheetId(te))==null?void 0:fe.getName())||""}).includes(P)){B(f.t("definedName.nameSheetConflict"));return}if(k.length===0){B(f.t("definedName.formulaOrRefStringEmpty"));return}if(!z){B(f.t("definedName.formulaOrRefStringInvalid"));return}if(p.hasExecutor(P.toUpperCase())){B(f.t("definedName.nameConflict"));return}const ae=S.getActiveSheet().getName();i&&i({id:h||"",name:P,formulaOrRefString:C.convertRefersToAbsolute(k,a.AbsoluteRefType.ALL,a.AbsoluteRefType.ALL,ae),comment:H,localSheetId:L})},G=oe=>{const ae=oe;ae==="formula"?l[0]===K.operatorToken.EQUALS?N(l):N(`${K.operatorToken.EQUALS}`):l[0]===K.operatorToken.EQUALS?N(""):N(l),F(ae)},J=W.useRef(null),[re,ue]=W.useState(!1);return _.useSidebarClick(oe=>{var te;((te=J.current)==null?void 0:te.isClickOutSide(oe))&&ue(!1)}),I.jsxs("div",{className:X.clsx("univer-grid univer-space-y-2 univer-pb-1",X.borderBottomClassName,{"univer-hidden":!e}),children:[I.jsx("div",{children:I.jsx(X.Input,{className:"univer-w-full",placeholder:f.t("definedName.inputNamePlaceholder"),value:P,allowClear:!0,onChange:A})}),I.jsx("div",{children:I.jsxs(X.RadioGroup,{value:Y,onChange:G,children:[I.jsx(X.Radio,{value:"range",children:f.t("definedName.ratioRange")}),I.jsx(X.Radio,{value:"formula",children:f.t("definedName.ratioFormula")})]})}),Y==="range"?w&&I.jsx(w,{unitId:O,subUnitId:M,initialValue:k,onChange:(oe,ae)=>$(ae),supportAcrossSheet:!0}):E&&I.jsx("div",{className:"univer-relative univer-mt-4 univer-h-full",children:I.jsx("div",{className:"univer-relative univer-h-8 univer-select-none",children:I.jsx(E,{ref:J,className:X.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",X.borderClassName),initValue:k,unitId:O,subUnitId:M,isFocus:re,isSupportAcrossSheet:!0,onChange:(oe="")=>{se(oe||"")},onVerify:oe=>{j(oe)},onFocus:()=>ue(!0)})})}),I.jsx("div",{children:I.jsx(X.Select,{className:"univer-w-full",value:L,options:Q,onChange:V})}),I.jsx("div",{children:I.jsx(X.Input,{className:"univer-w-full",placeholder:f.t("definedName.inputCommentPlaceholder"),value:H,onChange:x})}),I.jsxs("div",{className:X.clsx("univer-items-center univer-gap-1 univer-text-sm univer-text-red-500",{"univer-hidden":U.length===0,"univer-flex":U.length!==0}),children:[I.jsx("span",{children:U}),I.jsx(to,{})]}),I.jsxs("div",{className:"univer-flex univer-gap-2",children:[I.jsx(X.Button,{onClick:()=>{o==null||o()},children:f.t("definedName.cancel")}),I.jsx(X.Button,{variant:"primary",onClick:Z,children:f.t("definedName.confirm")})]})]})},Ml=()=>{const n=_.useDependency(a.ICommandService),e=_.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=_.useDependency(a.LocaleService),i=_.useDependency(K.IDefinedNamesService),o=_.useDependency(m.SheetsSelectionsService);if(e==null)return;const s=e.getUnitId(),l=()=>{const H=i.getDefinedNameMap(s);return H?Array.from(Object.values(H)):[]},[c,d]=W.useState(!1),[u,h]=W.useState(l()),[g,S]=W.useState(null),[f,v]=W.useState();W.useEffect(()=>{const H=i.update$.subscribe(()=>{h(l())});return()=>{H.unsubscribe()}},[]);const p=H=>{const{name:x,formulaOrRefString:L,comment:V,localSheetId:U,hidden:B}=H;let Y=H.id;if(Y==null||Y.length===0)Y=a.Tools.generateRandomId(10),n.executeCommand(m.InsertDefinedNameCommand.id,{id:Y,unitId:s,name:x,formulaOrRefString:L,comment:V,localSheetId:U,hidden:B});else{const F={id:Y,unitId:s,name:x,formulaOrRefString:L,comment:V,localSheetId:U,hidden:B};n.executeCommand(m.SetDefinedNameCommand.id,F)}d(!1),S(null)},C=H=>{v(H)};function b(){v(null)}function w(H){const x=i.getValueById(s,H);n.executeCommand(m.RemoveDefinedNameCommand.id,{...x,unitId:s}),v(null)}const E=async H=>{const{formulaOrRefString:x,id:L}=H,V=i.getWorksheetByRef(s,x);if(!V)return;V.isSheetHidden()&&await n.executeCommand(m.SetWorksheetShowCommand.id,{unitId:s,subUnitId:V.getSheetId()}),i.focusRange(s,L)},O=()=>{const H=u.length+1,x=t.t("definedName.defaultName")+H;if(i.getValueByName(s,x)==null)return x;let L=H+1;for(;;){const V=t.t("definedName.defaultName")+L;if(i.getValueByName(s,V)==null)return V;L++}},M=()=>{var V;const H=(V=e.getActiveSheet())==null?void 0:V.getName();if(!H)return"";const x=o.getCurrentSelections();return x==null?"":x.map(U=>K.serializeRangeWithSheet(H,U.range)).join(",")},P=()=>{d(!1),S(null)},A=()=>{d(!0),S(null)},k=H=>{d(!1),S(H)},N=H=>{const x=e.getSheetBySheetId(H);return x==null?"":x.getName()};return I.jsx("div",{"data-u-comp":"defined-name-container",className:"univer-relative univer-box-border univer-w-full",children:I.jsxs("div",{className:X.clsx("univer-w-full univer-overflow-hidden univer-overflow-y-auto",X.scrollbarClassName),children:[I.jsxs("div",{className:"univer-mb-4",children:[I.jsxs(X.Button,{className:X.clsx("univer-w-full",{"univer-hidden":c}),onClick:A,children:[I.jsx(no,{}),I.jsx("span",{className:"univer-ml-1",children:t.t("definedName.addButton")})]}),c&&I.jsx(Rl,{confirm:p,cancel:P,state:c,inputId:"insertDefinedName",name:O(),formulaOrRefString:M()})]},"insertDefinedName"),u.map((H,x)=>I.jsxs("div",{className:"univer-divide-x-0 univer-divide-y univer-divide-solid univer-divide-gray-200 dark:!univer-divide-gray-600",children:[I.jsxs("div",{className:X.clsx("univer-group univer-relative univer-flex univer-cursor-default univer-select-none univer-items-center univer-justify-between univer-rounded-md univer-p-2 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-50",{"univer-hidden":H.id===g}),onClick:()=>{E(H)},children:[I.jsxs("div",{title:H.comment,children:[I.jsxs("div",{className:"univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-overflow-hidden univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",children:[H.name,I.jsx("span",{className:"univer-text-xxs univer-ml-1 univer-text-gray-400",children:H.localSheetId===m.SCOPE_WORKBOOK_VALUE_DEFINED_NAME||H.localSheetId==null?"":N(H.localSheetId)})]}),I.jsx("div",{className:"univer-my-1 univer-max-h-[100px] univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-text-gray-500",children:H.formulaOrRefString})]}),I.jsx(X.Tooltip,{title:t.t("definedName.updateButton"),placement:"top",children:I.jsx("a",{className:"univer-absolute univer-right-[60px] univer-top-1/2 univer-hidden -univer-translate-y-1/2 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-xs univer-text-primary-600 dark:hover:!univer-bg-gray-600 group-hover:univer-flex hover:univer-bg-gray-100",onClick:L=>{L.stopPropagation(),k(H.id)},children:I.jsx(oa,{})})}),I.jsx(X.Tooltip,{title:t.t("definedName.deleteButton"),placement:"top",children:I.jsx("a",{className:"univer-absolute univer-text-xs univer-text-error univer-right-5 univer-top-1/2 univer-hidden -univer-translate-y-1/2 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-p-1 univer-text-red-600 dark:hover:!univer-bg-gray-600 group-hover:univer-flex hover:univer-bg-gray-100",onClick:L=>{L.stopPropagation(),C(H.id)},children:I.jsx(zi,{})})})]}),I.jsx(X.Confirm,{visible:f===H.id,onClose:b,onConfirm:()=>{w(H.id)},children:t.t("definedName.deleteConfirmText")}),H.id===g&&I.jsx(Rl,{confirm:p,cancel:P,state:H.id===g,id:H.id,inputId:H.id+x,name:H.name,formulaOrRefString:H.formulaOrRefString,comment:H.comment,localSheetId:H.localSheetId})]},x))]})})};function Dg(n){const r=n.get(m.BorderStyleManagerService),e=ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]});return{id:m.SetBorderBasicCommand.id,icon:new D.Observable(t=>{const i="AllBorderIcon",o=n.get(m.BorderStyleManagerService),s=n.get(a.ICommandService).onCommandExecuted(l=>{var g;if(l.id!==m.SetBorderBasicCommand.id)return;const{type:d}=o.getBorderInfo(),u=El.find(S=>S.value===d),h=(g=u==null?void 0:u.icon)!=null?g:i;t.next(h)});return t.next(i),s.dispose}),tooltip:"toolbar.border.main",type:_.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:Xo,hoverable:!1,selectable:!1},value$:r.borderInfo$}],value$:r.borderInfo$,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:e}}const ar="sheet.menu.clear-selection";function jo(n){return{id:ar,type:_.MenuItemType.SUBITEMS,icon:"ClearFormatDoubleIcon",title:"rightClick.clearSelection",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Go(n){return{id:m.ClearSelectionContentCommand.id,type:_.MenuItemType.BUTTON,icon:"ClearFormatDoubleIcon",title:"rightClick.clearContent",disabled$:Nt(n,ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellValuePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Zo(n){return{id:m.ClearSelectionFormatCommand.id,type:_.MenuItemType.BUTTON,icon:"ClearFormatDoubleIcon",title:"rightClick.clearFormat",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function lr(n){return{id:m.ClearSelectionAllCommand.id,type:_.MenuItemType.BUTTON,icon:"ClearFormatDoubleIcon",title:"rightClick.clearAll",tooltip:"rightClick.clearAll",disabled$:Nt(n,ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellValuePermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Pl="sheet.menu.delete";function kg(n){return{id:Pl,type:_.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"ReduceDoubleIcon",hidden$:Nt(n,vn(n)),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission]})}}function Ol(n){return{id:Tn.id,type:_.MenuItemType.BUTTON,icon:"DeleteColumnDoubleIcon",title:"rightClick.deleteSelectedColumn",hidden$:$a(n,"col"),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetDeleteColumnPermission]})}}function Al(n){return{id:En.id,type:_.MenuItemType.BUTTON,icon:"DeleteRowDoubleIcon",title:"rightClick.deleteSelectedRow",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetDeleteRowPermission]}),hidden$:$a(n,"row")}}function Ng(n){return{id:_n.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeftDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"col")}}function Hg(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUpDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"row")}}function Vg(n){const r=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService);return{id:m.ToggleGridlinesCommand.id,type:_.MenuItemType.BUTTON,tooltip:"toolbar.toggleGridlines",icon:"HideGridlinesDoubleIcon",activated$:new D.Observable(t=>{const i=()=>{const s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);return s?s.getActiveSheet().getConfig().showGridlines===a.BooleanNumber.TRUE:!1},o=new a.DisposableCollection;return o.add(r.onCommandExecuted(s=>{(s.id===m.ToggleGridlinesMutation.id||s.id===m.SetWorksheetActiveOperation.id)&&t.next(i())})),o.add(e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(()=>{t.next(i())})),t.next(i()),()=>o.dispose()}),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission]})}}const Dl="sheet.menu.cell-insert";function Wg(n){return{id:Dl,type:_.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"InsertDoubleIcon",hidden$:Nt(n,vn(n)),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertColumnPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function xg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertRowBeforeCommand.id,type:_.MenuItemType.BUTTON,icon:"InsertRowAboveDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertRowsAbove",min:1,max:1e3,suffix:"rightClick.insertRowsAboveSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endRow)-(c==null?void 0:c.startRow)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:Ja(n,"row")}}function Lg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertColBeforeCommand.id,type:_.MenuItemType.BUTTON,icon:"LeftInsertColumnDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertColsLeft",min:1,max:1e3,suffix:"rightClick.insertColsLeftSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endColumn)-(c==null?void 0:c.startColumn)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertColumnPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:Ja(n,"col")}}function Ug(n){return{id:In.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRightDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"col")}}function Bg(n){return{id:Wt.id,type:_.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDownDoubleIcon",disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:nr(n,"row")}}function Fg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiRowsAfterCommand.id,type:_.MenuItemType.BUTTON,icon:"InsertRowBelowDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertRowsAfter",min:1,max:1e3,suffix:"rightClick.insertRowsAfterSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endRow)-(c==null?void 0:c.startRow)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function zg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiRowsAboveCommand.id,type:_.MenuItemType.BUTTON,icon:"InsertRowAboveDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertRowsAbove",min:1,max:1e3,suffix:"rightClick.insertRowsAboveSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endRow)-(c==null?void 0:c.startRow)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function Xg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiColsLeftCommand.id,type:_.MenuItemType.BUTTON,icon:"LeftInsertColumnDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertColsLeft",min:1,max:1e3,suffix:"rightClick.insertColsLeftSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endColumn)-(c==null?void 0:c.startColumn)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function Yg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),i=1;return{id:m.InsertMultiColsRightCommand.id,type:_.MenuItemType.BUTTON,icon:"RightInsertColumnDoubleIcon",label:{name:Ge,props:{prefix:"rightClick.insertColsRight",min:1,max:1e3,suffix:"rightClick.insertColsRightSuffix"}},value$:be(r,i,()=>new D.Observable(o=>{function s(){var u;const c=(u=e.getCurrentLastSelection())==null?void 0:u.range;let d=i;c&&(d=(c==null?void 0:c.endColumn)-(c==null?void 0:c.startColumn)+1),o.next(d)}const l=t.onCommandExecuted(c=>{if(c.id===m.SetSelectionsOperation.id)return s()});return s(),l.dispose})),disabled$:ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetInsertRowPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:vn(n)}}function jg(n){const r=Nt(n,ee(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellValuePermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})),e=Bm(n);return{id:gt.id,icon:"MergeAllIcon",tooltip:"toolbar.mergeCell.main",type:_.MenuItemType.SUBITEMS,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:r.pipe(D.combineLatestWith(e),D.map(([t,i])=>t||i))}}function Gg(n){return{id:Uo.id,type:_.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Zg(n){return{id:Bo.id,type:_.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Kg(n){return{id:Fo.id,type:_.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qg(n){return{id:m.RemoveWorksheetMergeCommand.id,type:_.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeIcon",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Qg(n){const e=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),t=n.get(a.UserManagerService);return D.combineLatest([e,t.currentUser$]).pipe(D.switchMap(([i,o])=>i?i.activeSheet$.pipe(D.switchMap(s=>{if(!s)return D.of(!0);const l=n.get(m.RangeProtectionRuleModel),c=n.get(m.WorksheetProtectionRuleModel),d=n.get(m.SheetsSelectionsService);return D.merge(d.selectionMoveEnd$,l.ruleChange$,c.ruleChange$).pipe(D.map(()=>{const u=i.getUnitId(),h=s.getSheetId(),g=l.getSubunitRuleList(u,h),S=d.getCurrentSelections(),f=S==null?void 0:S.map(C=>C.range),v=g.map(C=>C.ranges).flat();if(!f)return!1;const p=c.getRule(u,h);return p!=null&&p.permissionId?!0:f==null?void 0:f.some(C=>v.some(b=>a.Rectangle.intersects(C,b)))}))})):D.of(!0)))}function Jg(n){const r=n.get(a.IUniverInstanceService),e=n.get(m.RangeProtectionRuleModel),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{if(!l)return D.of(!0);const c=n.get(m.RangeProtectionRuleModel),d=n.get(m.WorksheetProtectionRuleModel),u=n.get(a.IPermissionService),h=n.get(m.SheetsSelectionsService);return D.merge(h.selectionMoveEnd$,c.ruleChange$,d.ruleChange$).pipe(D.map(()=>{var A,k;const g=o.getUnitId(),S=l.getSheetId(),f=e.getSubunitRuleList(g,S),v=(A=h.getCurrentSelections())==null?void 0:A.map(N=>N.range);if(f.map(N=>N.ranges).flat(),!(v!=null&&v.length)||v.length>1)return!0;const p=v[0];if((p==null?void 0:p.rangeType)===a.RANGE_TYPE.ALL||(p==null?void 0:p.rangeType)===a.RANGE_TYPE.COLUMN||(p==null?void 0:p.rangeType)===a.RANGE_TYPE.ROW)return!0;const C=d.getRule(g,S);if(C!=null&&C.permissionId)return((k=u.getPermissionPoint(new m.WorksheetManageCollaboratorPermission(g,S).id))==null?void 0:k.value)===!1;if(f.filter(N=>N.ranges.some(H=>a.Rectangle.intersects(H,p))).length!==1)return!0;const{startRow:w,endRow:E,startColumn:O,endColumn:M}=p,P=n.get(m.RangeProtectionCache);for(let N=w;N<=E;N++)for(let H=O;H<=M;H++){const x=P.getCellInfo(g,S,N,H);if(x)return x[m.UnitAction.ManageCollaborator]===!1}return!1}))})):D.of(!0)))}function $g(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{var f;if(!l)return D.of(!0);const c=o.getUnitId(),d=n.get(m.SheetsSelectionsService),u=n.get(m.RangeProtectionRuleModel),h=n.get(m.WorksheetProtectionRuleModel),g=(f=e.composePermission$([new m.WorkbookEditablePermission(c).id]).pipe(D.map(v=>v.every(p=>p.value))))!=null?f:D.of(!1),S=D.merge(u.ruleChange$,h.ruleChange$).pipe(D.startWith(null));return D.combineLatest([g,S,d.selectionMoveEnd$]).pipe(D.map(([v,p,C])=>{if(!v)return!0;const b=d.getCurrentSelections(),w=b==null?void 0:b.map(E=>E.range);return w!=null&&w.length?w.length>1:!1}))})):D.of(!0)))}function kl(n){var d;const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService),o=n.has(me)?n.get(me):null,l=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).pipe(D.startWith(!1),D.shareReplay(1)),c=(d=o==null?void 0:o.visible$.pipe(D.startWith(null),D.shareReplay(1)))!=null?d:D.of(null);return D.combineLatest([t,i.currentUser$,c,l]).pipe(D.switchMap(([u,h,g,S])=>!u||g!=null&&g.visible&&g.unitId===u.getUnitId()||S?D.of(!0):u.activeSheet$.pipe(D.switchMap(f=>{var A;if(!f)return D.of(!0);const p=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(D.startWith(!1)),C=u.getUnitId(),b=f.getSheetId(),w=n.get(m.RangeProtectionRuleModel),E=n.get(m.WorksheetProtectionRuleModel),O=n.get(m.SheetsSelectionsService),M=(A=e.composePermission$([new m.WorkbookCreateProtectPermission(C).id]).pipe(D.map(k=>k.every(N=>N.value))))!=null?A:D.of(!1),P=D.merge(w.ruleChange$,E.ruleChange$).pipe(D.startWith(null));return D.combineLatest([M,P,O.selectionMoveEnd$,p]).pipe(D.map(([k,N,H,x])=>{if(!k||x)return!0;const L=O.getCurrentSelections(),V=L==null?void 0:L.map(F=>F.range);if(!(V!=null&&V.length))return!0;const U=E.getRule(C,b);if(U!=null&&U.permissionId)return!0;const B=w.getSubunitRuleList(C,b);return V==null?void 0:V.some(F=>B.some(z=>z.ranges.some(j=>a.Rectangle.intersects(F,j))))}))}))))}function eS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{var f;if(!l)return D.of(!0);const c=o.getUnitId(),d=l.getSheetId(),u=n.get(m.RangeProtectionRuleModel),h=n.get(m.WorksheetProtectionRuleModel),g=(f=e.composePermission$([new m.WorkbookCreateProtectPermission(c).id]).pipe(D.map(v=>v.every(p=>p.value))))!=null?f:D.of(!1),S=D.merge(u.ruleChange$,h.ruleChange$).pipe(D.startWith(null));return D.combineLatest([g,S]).pipe(D.map(([v,p])=>{var w;if(!v)return!0;const C=h.getRule(c,d);return C!=null&&C.permissionId?!0:((w=u.getSubunitRuleList(c,d))==null?void 0:w.filter(E=>E==null?void 0:E.permissionId)).length>0}))})):D.of(!0)))}function tS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{if(!l)return D.of(!0);const c=o.getUnitId(),d=l.getSheetId(),u=n.get(m.WorksheetProtectionRuleModel);return u.ruleChange$.pipe(D.startWith(null)).pipe(D.map(()=>{var g;return u.getRule(c,d)?((g=e.getPermissionPoint(new m.WorksheetDeleteProtectionPermission(c,d).id))==null?void 0:g.value)===!1:!0}))})):D.of(!0)))}function nS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{var f;if(!l)return D.of(!0);const c=o.getUnitId(),d=n.get(m.RangeProtectionRuleModel),u=n.get(m.WorksheetProtectionRuleModel),h=(f=e.composePermission$([new m.WorkbookCreateProtectPermission(c).id,new m.WorkbookManageCollaboratorPermission(c).id]).pipe(D.map(v=>v.every(p=>p.value))))!=null?f:D.of(!1),g=u.ruleChange$.pipe(D.startWith(null)),S=d.ruleChange$.pipe(D.startWith(null));return D.combineLatest([h,g,S]).pipe(D.map(([v,p,C])=>{if(!v)return!0;const b=l.getSheetId(),w=u.getRule(c,b),E=d.getSubunitRuleList(c,b);return!(w||E.length)}))})):D.of(!0)))}function iS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService);return D.combineLatest([t,i.currentUser$]).pipe(D.switchMap(([o,s])=>o?o.activeSheet$.pipe(D.switchMap(l=>{if(!l)return D.of(!0);const c=o.getUnitId(),d=l.getSheetId(),u=n.get(m.SheetsSelectionsService),h=n.get(m.RangeProtectionRuleModel),g=n.get(m.WorksheetProtectionRuleModel),S=D.merge(h.ruleChange$,g.ruleChange$,u.selectionMoveEnd$).pipe(D.startWith(null));return D.combineLatest([S]).pipe(D.map(([f])=>{var k;const v=n.get(m.SheetsSelectionsService).getCurrentSelections(),p=v==null?void 0:v.map(N=>N.range);if(!(p!=null&&p.length)||p.length>1)return!0;const C=p[0];if((C==null?void 0:C.rangeType)===a.RANGE_TYPE.ALL||(C==null?void 0:C.rangeType)===a.RANGE_TYPE.COLUMN||(C==null?void 0:C.rangeType)===a.RANGE_TYPE.ROW)return!0;const b=g.getRule(c,d);if(b!=null&&b.permissionId)return((k=e.getPermissionPoint(new m.WorksheetDeleteProtectionPermission(c,d).id))==null?void 0:k.value)===!1;if(h.getSubunitRuleList(c,d).filter(N=>N.ranges.some(H=>a.Rectangle.intersects(H,C))).length!==1)return!0;const{startRow:E,endRow:O,startColumn:M,endColumn:P}=C,A=n.get(m.RangeProtectionCache);for(let N=E;N<=O;N++)for(let H=M;H<=P;H++){const x=A.getCellInfo(c,d,N,H);if(x)return x[m.UnitAction.Delete]===!1}return!1}))})):D.of(!0)))}function Nl(n){var d;const r=n.get(a.IUniverInstanceService),e=n.get(a.IPermissionService),t=r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),i=n.get(a.UserManagerService),o=n.has(me)?n.get(me):null,l=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR),c=(d=o==null?void 0:o.visible$)!=null?d:D.of(null);return D.combineLatest([t,i.currentUser$,c,l]).pipe(D.switchMap(([u,h,g,S])=>!u||g!=null&&g.visible&&g.unitId===u.getUnitId()||S?D.of(!0):u.activeSheet$.pipe(D.switchMap(f=>{var C,b;if(!f)return D.of(!0);const v=u.getUnitId();return((b=(C=e.getPermissionPoint$(new m.WorkbookEditablePermission(v).id))==null?void 0:C.pipe(D.map(w=>!!w.value)))!=null?b:D.of(!1)).pipe(D.map(w=>!w))}))))}const cr="sheet.contextMenu.permission";function rS(n){return{id:hi.id,type:_.MenuItemType.BUTTON,icon:Il,tooltip:"permission.toolbarMenu",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:kl(n)}}function Ko(n){return{id:cr,type:_.MenuItemType.SUBITEMS,title:"rightClick.protectRange",icon:bl,hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function qo(n){return{id:xt.id,type:_.MenuItemType.BUTTON,title:"rightClick.turnOnProtectRange",hidden$:Qg(n),disabled$:kl(n)}}function Qo(n){return{id:Bt.id,type:_.MenuItemType.BUTTON,title:"rightClick.editProtectRange",disabled$:$g(n),hidden$:Jg(n)}}function Jo(n){return{id:Ut.id,type:_.MenuItemType.BUTTON,title:"rightClick.removeProtectRange",disabled$:iS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function $o(n){return{id:Lt.id,type:_.MenuItemType.BUTTON,title:"rightClick.viewAllProtectArea",disabled$:Nl(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function oS(n){return{id:mi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.addProtectSheet",disabled$:eS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function sS(n){return{id:vi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.removeProtectSheet",disabled$:tS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function aS(n){return{id:pi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.changeSheetPermission",disabled$:nS(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function lS(n){return{id:gi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.viewAllProtectArea",disabled$:Nl(n),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function cS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.ICommandService),t=new D.Observable(o=>{const s=e.onCommandExecuted(l=>{const c=l.id;(c===m.RemoveSheetMutation.id||c===m.InsertSheetMutation.id||c===m.SetWorksheetHideMutation.id)&&dr(r,o)});return dr(r,o),s.dispose}),i=pn(n,[m.WorkbookEditablePermission,m.WorkbookDeleteSheetPermission]);return{id:Si.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.delete",disabled$:D.combineLatest([t,i]).pipe(D.map(([o,s])=>o||s)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function dS(n){return{id:m.CopySheetCommand.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.copy",disabled$:pn(n,[m.WorkbookEditablePermission,m.WorkbookCreateSheetPermission]),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function uS(n){return{id:Ci.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.rename",disabled$:pn(n,[m.WorkbookEditablePermission,m.WorkbookRenameSheetPermission]),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function hS(n){return{id:m.SetTabColorCommand.id,title:"sheetConfig.changeColor",type:_.MenuItemType.SELECTOR,selections:[{label:{name:_.COLOR_PICKER_COMPONENT,hoverable:!1}}],hidden$:pn(n,[m.WorkbookEditablePermission])}}function mS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.ICommandService);return{id:m.SetWorksheetHideCommand.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.hide",disabled$:new D.Observable(t=>{const i=e.onCommandExecuted(o=>{const s=o.id;(s===m.RemoveSheetMutation.id||s===m.InsertSheetMutation.id||s===m.SetWorksheetHideMutation.id)&&dr(r,t)});return dr(r,t),i.dispose}).pipe(D.combineLatestWith(pn(n,[m.WorkbookEditablePermission,m.WorkbookHideSheetPermission])),D.map(([t,i])=>t||i)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function gS(n){const r=n.get(a.IUniverInstanceService),e=n.get(a.ICommandService);return{id:fi.id,type:_.MenuItemType.BUTTON,title:"sheetConfig.unhide",disabled$:new D.Observable(t=>{function i(){const s=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),l=Array.from(s.values());t.next(l.length===1)}const o=e.onCommandExecuted(s=>{const l=s.id;(l===m.RemoveSheetMutation.id||l===m.InsertSheetMutation.id||l===m.SetWorksheetHideMutation.id)&&i()});return i(),o.dispose}).pipe(D.combineLatestWith(pn(n,[m.WorkbookEditablePermission,m.WorkbookHideSheetPermission])),D.map(([t,i])=>t||i)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function dr(n,r){const e=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getWorksheets(),t=Array.from(e.values()).filter(i=>i.getConfig().hidden===a.BooleanNumber.FALSE);r.next(t.length===1)}const Hl={[_.RibbonPosition.START]:{[_.RibbonStartGroup.HISTORY]:{[fn.id]:{order:2,menuItemFactory:lm},[m.ClearSelectionAllCommand.id]:{order:3,menuItemFactory:lr}},[_.RibbonStartGroup.FORMAT]:{[Jn.id]:{order:1,menuItemFactory:mm},[Qn.id]:{order:2,menuItemFactory:gm},[Ot.id]:{order:5,menuItemFactory:cm},[At.id]:{order:6,menuItemFactory:dm},[Dt.id]:{order:7,menuItemFactory:um},[kt.id]:{order:8,menuItemFactory:hm},[gn.id]:{order:9,menuItemFactory:fm,[m.ResetTextColorCommand.id]:{order:0,menuItemFactory:Sm}},[m.SetBackgroundColorCommand.id]:{order:10,menuItemFactory:pm,[m.ResetBackgroundColorCommand.id]:{order:0,menuItemFactory:vm}},[m.SetBorderBasicCommand.id]:{order:11,menuItemFactory:Dg}},[_.RibbonStartGroup.LAYOUT]:{[m.SetHorizontalTextAlignCommand.id]:{order:0,menuItemFactory:Cm},[m.SetVerticalTextAlignCommand.id]:{order:3,menuItemFactory:_m},[m.SetTextWrapCommand.id]:{order:6,menuItemFactory:Im},[m.SetTextRotationCommand.id]:{order:7,menuItemFactory:bm},[m.AddWorksheetMergeCommand.id]:{order:8,menuItemFactory:jg,[m.AddWorksheetMergeAllCommand.id]:{order:0,menuItemFactory:Gg},[m.AddWorksheetMergeVerticalCommand.id]:{order:1,menuItemFactory:Zg},[m.AddWorksheetMergeHorizontalCommand.id]:{order:2,menuItemFactory:Kg},[m.RemoveWorksheetMergeCommand.id]:{order:3,menuItemFactory:qg}}},[_.RibbonStartGroup.OTHERS]:{[hi.id]:{order:0,menuItemFactory:rS}}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.FORMAT]:{[Be.name]:{order:0,menuItemFactory:Cn},[Fe.name]:{order:2,menuItemFactory:wo},[oi]:{order:3,menuItemFactory:Eo,[un.id]:{order:0,menuItemFactory:To},[hn.id]:{order:1,menuItemFactory:yo},[Pt.id]:{order:2,menuItemFactory:Ro},[mn.id]:{order:3,menuItemFactory:Mo}},[ar]:{order:4,menuItemFactory:jo,[m.ClearSelectionContentCommand.id]:{order:0,menuItemFactory:Go},[m.ClearSelectionFormatCommand.id]:{order:1,menuItemFactory:Zo},[m.ClearSelectionAllCommand.id]:{order:2,menuItemFactory:lr}}},[_.ContextMenuGroup.LAYOUT]:{order:1,[Dl]:{order:0,menuItemFactory:Wg,[m.InsertRowBeforeCommand.id]:{order:0,menuItemFactory:xg},[m.InsertColBeforeCommand.id]:{order:1,menuItemFactory:Lg},[In.id]:{order:2,menuItemFactory:Ug},[Wt.id]:{order:3,menuItemFactory:Bg}},[Pl]:{order:0,menuItemFactory:kg,[Tn.id]:{order:0,menuItemFactory:Ol},[En.id]:{order:1,menuItemFactory:Al},[_n.id]:{order:2,menuItemFactory:Ng},[Vt.id]:{order:3,menuItemFactory:Hg}},[ol]:{order:2,menuItemFactory:Tm,[$e.id]:{order:0,menuItemFactory:Oo},[ti.id]:{order:1,menuItemFactory:ym},[ni.id]:{order:2,menuItemFactory:Rm},[m.CancelFrozenCommand.id]:{order:3,menuItemFactory:Ao}},[cr]:{order:3,menuItemFactory:Ko,[xt.id]:{order:0,menuItemFactory:qo},[Bt.id]:{order:1,menuItemFactory:Qo},[Ut.id]:{order:2,menuItemFactory:Jo},[Lt.id]:{order:3,menuItemFactory:$o}}},[_.ContextMenuGroup.DATA]:{order:2},[_.ContextMenuGroup.OTHERS]:{order:3}},[_.ContextMenuPosition.COL_HEADER]:{[_.ContextMenuGroup.FORMAT]:{[Be.name]:{order:0,menuItemFactory:Cn},[Fe.name]:{order:2,menuItemFactory:wo},[oi]:{order:3,menuItemFactory:Eo,[un.id]:{order:0,menuItemFactory:To},[hn.id]:{order:1,menuItemFactory:yo},[Pt.id]:{order:2,menuItemFactory:Ro},[mn.id]:{order:3,menuItemFactory:Mo}},[ar]:{order:4,menuItemFactory:jo,[m.ClearSelectionContentCommand.id]:{order:0,menuItemFactory:Go},[m.ClearSelectionFormatCommand.id]:{order:1,menuItemFactory:Zo},[m.ClearSelectionAllCommand.id]:{order:2,menuItemFactory:lr}}},[_.ContextMenuGroup.LAYOUT]:{order:1,[m.InsertMultiColsLeftCommand.id]:{order:0,menuItemFactory:Xg},[m.InsertMultiColsRightCommand.id]:{order:0,menuItemFactory:Yg},[qn.id]:{order:1,menuItemFactory:Pm},[m.SetSelectedColsVisibleCommand.id]:{order:2,menuItemFactory:Am},[Tn.id]:{order:2,menuItemFactory:Ol},[m.SetColWidthCommand.id]:{order:3,menuItemFactory:km},[ii.id]:{order:4,menuItemFactory:Em},[Po]:{order:5,menuItemFactory:sl,[$e.id]:{order:0,menuItemFactory:Oo},[m.CancelFrozenCommand.id]:{order:3,menuItemFactory:Ao}},[cr]:{order:6,menuItemFactory:Ko,[xt.id]:{order:0,menuItemFactory:qo},[Bt.id]:{order:1,menuItemFactory:Qo},[Ut.id]:{order:2,menuItemFactory:Jo},[Lt.id]:{order:3,menuItemFactory:$o}}},[_.ContextMenuGroup.DATA]:{order:2},[_.ContextMenuGroup.OTHERS]:{order:3}},[_.ContextMenuPosition.ROW_HEADER]:{[_.ContextMenuGroup.FORMAT]:{[Be.name]:{order:0,menuItemFactory:Cn},[Fe.name]:{order:2,menuItemFactory:wo},[oi]:{order:3,menuItemFactory:Eo,[un.id]:{order:0,menuItemFactory:To},[hn.id]:{order:1,menuItemFactory:yo},[Pt.id]:{order:2,menuItemFactory:Ro},[mn.id]:{order:3,menuItemFactory:Mo}},[ar]:{order:4,menuItemFactory:jo,[m.ClearSelectionContentCommand.id]:{order:0,menuItemFactory:Go},[m.ClearSelectionFormatCommand.id]:{order:1,menuItemFactory:Zo},[m.ClearSelectionAllCommand.id]:{order:2,menuItemFactory:lr}}},[_.ContextMenuGroup.LAYOUT]:{order:1,[m.InsertMultiRowsAboveCommand.id]:{order:0,menuItemFactory:zg},[m.InsertMultiRowsAfterCommand.id]:{order:1,menuItemFactory:Fg},[En.id]:{order:1,menuItemFactory:Al},[Kn.id]:{order:2,menuItemFactory:Mm},[m.SetSelectedRowsVisibleCommand.id]:{order:2,menuItemFactory:Om},[m.SetRowHeightCommand.id]:{order:3,menuItemFactory:Dm},[m.SetWorksheetRowIsAutoHeightCommand.id]:{order:4,menuItemFactory:wm},[Po]:{order:5,menuItemFactory:sl,[$e.id]:{order:0,menuItemFactory:Oo},[m.CancelFrozenCommand.id]:{order:3,menuItemFactory:Ao}},[cr]:{order:6,menuItemFactory:Ko,[xt.id]:{order:0,menuItemFactory:qo},[Bt.id]:{order:1,menuItemFactory:Qo},[Ut.id]:{order:2,menuItemFactory:Jo},[Lt.id]:{order:3,menuItemFactory:$o}}},[_.ContextMenuGroup.DATA]:{order:2},[_.ContextMenuGroup.OTHERS]:{order:3}},[_.ContextMenuPosition.FOOTER_TABS]:{[_.ContextMenuGroup.OTHERS]:{order:0,[Si.id]:{order:0,menuItemFactory:cS},[m.CopySheetCommand.id]:{order:1,menuItemFactory:dS},[Ci.id]:{order:2,menuItemFactory:uS},[m.SetTabColorCommand.id]:{order:3,menuItemFactory:hS},[m.SetWorksheetHideCommand.id]:{order:4,menuItemFactory:mS},[fi.id]:{order:6,menuItemFactory:gS},[mi.id]:{order:7,menuItemFactory:oS},[vi.id]:{order:8,menuItemFactory:sS},[pi.id]:{order:9,menuItemFactory:aS},[gi.id]:{order:10,menuItemFactory:lS}}},[_.ContextMenuPosition.FOOTER_MENU]:{[_.ContextMenuGroup.OTHERS]:{[m.ToggleGridlinesCommand.id]:{order:1,menuItemFactory:Vg}}}},Vl={id:m.SetRowHiddenCommand.id,preconditions:n=>le(n),binding:_.KeyCode.Digit9|_.MetaKeys.CTRL_COMMAND},Wl={id:m.SetColHiddenCommand.id,preconditions:n=>le(n),binding:_.KeyCode.Digit0|_.MetaKeys.CTRL_COMMAND|_.MetaKeys.SHIFT},xl={id:Re.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN,priority:100,preconditions:le,staticParameters:{direction:a.Direction.DOWN}},Ll={id:Re.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP,priority:100,preconditions:le,staticParameters:{direction:a.Direction.UP}},Ul={id:Re.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT,priority:100,preconditions:_a,staticParameters:{direction:a.Direction.LEFT}},Bl={id:Re.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT,priority:100,preconditions:_a,staticParameters:{direction:a.Direction.RIGHT}},Fl={id:Ye.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:_.KeyCode.TAB,priority:100,preconditions:le,staticParameters:{direction:a.Direction.RIGHT,keycode:_.KeyCode.TAB}},zl={id:Ye.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:_.KeyCode.TAB|_.MetaKeys.SHIFT,priority:100,preconditions:le,staticParameters:{direction:a.Direction.LEFT,keycode:_.KeyCode.TAB}},Xl={id:Ye.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:_.KeyCode.ENTER,priority:100,preconditions:le,staticParameters:{direction:a.Direction.DOWN,keycode:_.KeyCode.ENTER}},Yl={id:Ye.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:_.KeyCode.ENTER|_.MetaKeys.SHIFT,priority:100,preconditions:le,staticParameters:{direction:a.Direction.UP,keycode:_.KeyCode.ENTER}},jl={id:Re.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.DOWN,jumpOver:Xe.moveGap}},Gl={id:Re.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.UP,jumpOver:Xe.moveGap}},Zl={id:Re.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.LEFT,jumpOver:Xe.moveGap}},Kl={id:Re.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Xe.moveGap}},ql={id:Pe.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.DOWN}},Ql={id:Pe.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.UP}},Jl={id:Pe.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.LEFT}},$l={id:Pe.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT|_.MetaKeys.SHIFT,preconditions:le,staticParameters:{direction:a.Direction.RIGHT}},ec={id:Pe.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_DOWN|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.DOWN,jumpOver:Xe.moveGap}},tc={id:Pe.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_UP|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.UP,jumpOver:Xe.moveGap}},nc={id:Pe.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_LEFT|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.LEFT,jumpOver:Xe.moveGap}},ic={id:Pe.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:_.KeyCode.ARROW_RIGHT|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{direction:a.Direction.RIGHT,jumpOver:Xe.moveGap}},rc={id:Fn.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:_.KeyCode.A|_.MetaKeys.CTRL_COMMAND,preconditions:le,staticParameters:{expandToGapFirst:!0,loop:!0}},oc={id:Ot.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.B|_.MetaKeys.CTRL_COMMAND},sc={id:At.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.I|_.MetaKeys.CTRL_COMMAND},ac={id:Dt.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.U|_.MetaKeys.CTRL_COMMAND},lc={id:kt.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:n=>le(n),binding:_.KeyCode.X|_.MetaKeys.SHIFT|_.MetaKeys.CTRL_COMMAND},cc={id:m.ClearSelectionContentCommand.id,preconditions:n=>le(n),binding:_.KeyCode.DELETE,mac:_.KeyCode.BACKSPACE},SS={id:m.ClearSelectionContentCommand.id,preconditions:n=>le(n),mac:_.KeyCode.DELETE},fS={id:m.ClearSelectionContentCommand.id,preconditions:n=>le(n),binding:_.MetaKeys.SHIFT+_.KeyCode.BACKSPACE},vS={id:Ji.id,preconditions:n=>le(n),binding:_.MetaKeys.SHIFT+_.KeyCode.DELETE},dc={id:$t.id,description:"shortcut.sheet.zoom-in",binding:_.KeyCode.EQUAL|_.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:le,priority:1,staticParameters:{delta:.2}},uc={id:a.NilCommand.id,binding:_.KeyCode.EQUAL|_.MetaKeys.CTRL_COMMAND},hc={id:$t.id,description:"shortcut.sheet.zoom-out",binding:_.KeyCode.MINUS|_.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:le,priority:1,staticParameters:{delta:-.2}},mc={id:a.NilCommand.id,binding:_.KeyCode.MINUS|_.MetaKeys.CTRL_COMMAND},gc={id:$t.id,description:"shortcut.sheet.reset-zoom",binding:_.KeyCode.Digit0|_.MetaKeys.CTRL_COMMAND,preconditions:le,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},Sc={id:a.NilCommand.id,binding:_.KeyCode.Digit0|_.MetaKeys.CTRL_COMMAND};var pS=Object.getOwnPropertyDescriptor,CS=(n,r,e,t)=>{for(var i=t>1?void 0:t?pS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},ft=(n,r)=>(e,t)=>r(e,t,n);y.SheetUIController=class extends a.Disposable{constructor(r,e,t,i,o,s,l,c){super(),this._injector=r,this._componentManager=e,this._layoutService=t,this._commandService=i,this._shortcutService=o,this._menuManagerService=s,this._uiPartsService=l,this._configService=c,this._init()}_init(){this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Ge,qa)),this.disposeWithMe(r.register(Xo,Tl)),this.disposeWithMe(r.register(Yn,Ml)),this.disposeWithMe(r.register(yl,Ag)),this.disposeWithMe(r.register("HideGridlinesDoubleIcon",ta))}_initCommands(){[Uo,gt,Fo,Bo,$t,Pe,Re,Ye,Ci,Si,En,Tn,Kn,qn,Ue,Jr,Fn,Zi,m.SetBoldCommand,wt,ge,Wn,Ot,At,Dt,kt,_o,Io,Qn,Jn,gn,bo,m.SetItalicCommand,m.SetStrikeThroughCommand,m.SetFontFamilyCommand,m.SetFontSizeCommand,$n,tr,fn,ei,Le,nn,$e,ti,ni,$r,m.SetUnderlineCommand,en,Ne,fi,Vn,Wt,Vt,In,_n,Yi,ht,Qt,Ke,zo,hi,xt,Lt,mi,gi,pi,Ut,Bt,vi,ii,Ni,Hi].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}_initMenus(){this._menuManagerService.mergeMenu(Hl)}_initShortcuts(){[xl,Ll,Ul,Bl,Fl,zl,Xl,Yl,jl,Gl,Zl,Kl,ql,Ql,Jl,$l,ec,tc,nc,ic,rc,dc,hc,gc,Sc,uc,mc,oc,sc,ac,lc,cc,SS,fS,vS,...ba(),Ea,wa,Ta,Ra,Ma,ah,Pa,ya,sh,lh,Vl,Wl].forEach(r=>{this.disposeWithMe(this._shortcutService.registerShortcut(r))})}_initWorkbenchParts(){const r=this._uiPartsService,e=this._injector;this.disposeWithMe(r.registerComponent(_.BuiltInUIPart.HEADER,()=>_.connectInjector(Sa,e))),this.disposeWithMe(r.registerComponent(_.BuiltInUIPart.FOOTER,()=>_.connectInjector(ga,e))),this.disposeWithMe(r.registerComponent(_.BuiltInUIPart.CONTENT,()=>_.connectInjector(fa,e)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(a.UniverInstanceType.UNIVER_SHEET,r=>{const e=this._injector.get(R.IRenderManagerService),t=this._injector.get(a.IUniverInstanceService),i=R.getCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_DOC,t,e),o=i==null?void 0:i.with(q.DocSelectionRenderService);o==null||o.focus()}))}},y.SheetUIController=CS([ft(0,a.Inject(a.Injector)),ft(1,a.Inject(_.ComponentManager)),ft(2,_.ILayoutService),ft(3,a.ICommandService),ft(4,_.IShortcutService),ft(5,_.IMenuManagerService),ft(6,_.IUIPartsService),ft(7,a.IConfigService)],y.SheetUIController);const fc=(n=[])=>{const r=_.useDependency(Mt);W.useEffect(()=>{const e=n.map(t=>r.addShape({range:t,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:{startColumn:t.startColumn,endColumn:t.endColumn,startRow:t.startRow,endRow:t.endRow,actualRow:t.startRow,actualColumn:t.startColumn,isMerged:!1,isMergedMainCell:!1}}));return()=>{e.forEach(t=>{t&&r.removeShape(t)})}},[n])};var _S=Object.getOwnPropertyDescriptor,IS=(n,r,e,t)=>{for(var i=t>1?void 0:t?_S(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},vc=(n,r)=>(e,t)=>r(e,t,n);let _i=class extends a.Disposable{constructor(r,e){super();T(this,"_previousSheetIndex",-1);this._commandService=r,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{if(t.id===m.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(t)})),this.disposeWithMe(this._commandService.onCommandExecuted((t,i)=>{if(t.id===m.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(t);if(t.id===m.SetWorksheetHideMutation.id&&t.params.hidden)return this._adjustActiveSheetOnHideSheet(t);if(i!=null&&i.fromCollab)return!1;if(t.id===m.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(t);if(t.id===m.SetWorksheetHideMutation.id&&!t.params.hidden)return this._adjustActiveSheetOnShowSheet(t);if(t.id===m.SetSelectionsOperation.id)return this._adjustActiveSheetOnSelection(t)}))}_adjustActiveSheetOnHideSheet(r){var c;const{unitId:e,subUnitId:t}=r.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i||((c=i.getActiveSheet())==null?void 0:c.getSheetId())!==t)return;const s=i.getActiveSheetIndex(),l=pc(i,s);this._switchToNextSheet(e,l)}_beforeAdjustActiveSheetOnRemoveSheet(r){const{unitId:e,subUnitId:t}=r.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i)return;const o=i.getSheetBySheetId(t);o&&(this._previousSheetIndex=i.getSheetIndex(o))}_adjustActiveSheetOnRemoveSheet(r){if(this._previousSheetIndex===-1)return;const{unitId:e}=r.params,t=this._univerInstanceService.getUniverSheetInstance(e);if(!t)return;if(t.getActiveSheet().getSheetId()===r.params.subUnitId){const o=this._previousSheetIndex,s=o>=1?o-1:0,l=pc(t,s);this._switchToNextSheet(e,l)}}_adjustActiveSheetOnInsertSheet(r){const{unitId:e,sheet:t}=r.params;this._switchToNextSheet(e,t.id)}_adjustActiveSheetOnShowSheet(r){const{unitId:e,subUnitId:t}=r.params;this._switchToNextSheet(e,t)}_adjustActiveSheetOnSelection(r){var i;const{unitId:e,subUnitId:t}=r.params;t!==((i=this._univerInstanceService.getUnit(e))==null?void 0:i.getActiveSheet().getSheetId())&&this._switchToNextSheet(e,t)}_switchToNextSheet(r,e){this._commandService.executeCommand(m.SetWorksheetActiveOperation.id,{unitId:r,subUnitId:e})}};_i=IS([vc(0,a.ICommandService),vc(1,a.IUniverInstanceService)],_i);function pc(n,r){const e=n.getSheetSize();for(let t=r;t>-1;t--){const i=n.getSheetByIndex(t);if(!i.getConfig().hidden)return i.getSheetId()}for(let t=r;t<e;t++){const i=n.getSheetByIndex(t);if(!i.getConfig().hidden)return i.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var bS=Object.getOwnPropertyDescriptor,wS=(n,r,e,t)=>{for(var i=t>1?void 0:t?bS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},Cc=(n,r)=>(e,t)=>r(e,t,n),yn=(n=>(n[n.INFO=0]="INFO",n[n.WARNING=1]="WARNING",n[n.ERROR=2]="ERROR",n))(yn||{});y.CellAlertManagerService=class extends a.Disposable{constructor(e,t){super();T(this,"_currentAlert$",new D.Subject);T(this,"_currentAlert",new Map);T(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=e,this._cellPopupManagerService=t,this.disposeWithMe(()=>{this._currentAlert$.complete()})}get currentAlert(){return this._currentAlert}showAlert(e){let t=this._currentAlert.get(e.key);t&&t.dispose.dispose(),t?t.dispose.dispose():(t={alert:e,dispose:{dispose(){}}},this._currentAlert.set(e.key,t));const{location:i}=e,{row:o,col:s,unitId:l,subUnitId:c}=i;if(!this._renderManagerService.getRenderById(l))return;const u=this._cellPopupManagerService.showPopup({unitId:l,subUnitId:c,row:o,col:s},{componentKey:_c,direction:"horizontal",extraProps:{alert:e},priority:1});u&&(t.dispose=u),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}removeAlert(e){const t=this._currentAlert.get(e);t&&(this._currentAlert.delete(e),t==null||t.dispose.dispose(),this._currentAlert$.next(Array.from(this._currentAlert.entries())))}clearAlert(){this._currentAlert.forEach(e=>{e.dispose.dispose()}),this._currentAlert.clear(),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}},y.CellAlertManagerService=wS([Cc(0,R.IRenderManagerService),Cc(1,a.Inject(y.CellPopupManagerService))],y.CellAlertManagerService);function ES({popup:n}){var s;const r=(s=n.extraProps)==null?void 0:s.alert;if(!r)return null;const{type:e,title:t,message:i}=r,o={[yn.ERROR]:I.jsx(to,{className:"univer-mr-1.5 univer-text-red-500"}),[yn.INFO]:I.jsx(na,{className:"univer-mr-1.5 univer-text-blue-500"}),[yn.WARNING]:I.jsx(aa,{className:"univer-mr-1.5 univer-text-yellow-500"})};return I.jsxs("div",{className:"univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-white univer-px-2 univer-py-1 univer-text-gray-900 univer-shadow dark:!univer-bg-black dark:!univer-text-white",children:[I.jsxs("div",{className:"univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-text-sm univer-font-medium",children:[e?o[e]:null,t]}),I.jsx("div",{className:"univer-text-sm",children:i})]})}const _c="univer.sheet.cell-alert";var TS=Object.getOwnPropertyDescriptor,yS=(n,r,e,t)=>{for(var i=t>1?void 0:t?TS(r,e):r,o=n.length-1,s;o>=0;o--)(s=n[o])&&(i=s(i)||i);return i},RS=(n,r)=>(e,t)=>r(e,t,n);let ur=class extends a.Disposable{constructor(n,r){super(),this._context=n,this._componentManager=r,this._initComponent()}_initComponent(){this.disposeWithMe(this._componentManager.register(_c,ES))}};ur=yS([RS(1,a.Inject(_.ComponentManager))],ur);const Ic=2,MS=[{value:"DEFAULT_PASTE",label:"rightClick.paste"},{value:"SPECIAL_PASTE_VALUE",label:"rightClick.pasteValue"},{value:"SPECIAL_PASTE_FORMAT",label:"rightClick.pasteFormat"},{value:"SPECIAL_PASTE_COL_WIDTH",label:"rightClick.pasteColWidth"},{value:"SPECIAL_PASTE_BESIDES_BORDER",label:"rightClick.pasteBesidesBorder"},{value:"SPECIAL_PASTE_FORMULA",label:"formula.operation.pasteFormula"}],PS=n=>{var H,x,L,V,U;const r=_.useDependency(a.IUniverInstanceService),e=_.useDependency(R.IRenderManagerService),t=lt();if(!n||!t)return null;const i={startRow:n.rows[0],startCol:n.cols[0],endRow:n.rows[n.rows.length-1],endCol:n.cols[n.cols.length-1]};if(i.endRow<0||i.endCol<0)return null;const o=e.getRenderById(t.getUnitId()),s=o==null?void 0:o.with(y.SheetSkeletonManagerService),l=o==null?void 0:o.with(ve),c=ke(r,e);if(!c||!l)return null;const{scene:d}=c,u=s==null?void 0:s.getCurrentSkeleton(),h=l.getViewPort(),g=d==null?void 0:d.scaleX,S=d==null?void 0:d.scaleY,f=d==null?void 0:d.getViewportScrollXY(h),v=(H=d.getEngine())==null?void 0:H.getCanvas();if(!g||!d||!g||!S||!f)return null;const p=u==null?void 0:u.getNoMergeCellPositionByIndex(i.endRow,i.endCol),C=(x=p==null?void 0:p.endX)!=null?x:0,b=(L=p==null?void 0:p.endY)!=null?L:0,w=(V=R.convertTransformToOffsetX(C,g,f))!=null?V:-9999,E=(U=R.convertTransformToOffsetY(b,S,f))!=null?U:-9999,O=v==null?void 0:v.getWidth(),M=v==null?void 0:v.getHeight();if(!O||!M)return null;const P=w+50<=O,A=E+50<=M;let k=w,N=E;return P||(k=O-100),A||(N=M-100),{positionX:k,positionY:N}},OS=()=>{const n=_.useDependency(We),r=_.useObservable(n.showMenu$,!1),e=_.useObservable(n.pasteOptionsCache$,null),t=_.useDependency(a.LocaleService),i=_.useDependency(a.ICommandService),[o,s]=W.useState(!1),[l,c]=W.useState(!1),d=e==null?void 0:e.target.pastedRange,u=PS(d);if(!u||!r||u.positionX<50||u.positionY<30)return null;const h=o||l,g=S=>{c(!1),i.executeCommand(Ga.id,{type:S})};return I.jsx("div",{className:"univer-absolute univer-inset-0 univer-z-10 univer-size-0",children:I.jsx("div",{className:"univer-absolute",style:{left:u.positionX+Ic,top:u.positionY+Ic},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:I.jsx(X.DropdownMenu,{align:"start",items:MS.map(S=>({type:"checkbox",value:S.value,label:t.t(S.label),checked:(e==null?void 0:e.pasteType)===Se[S.value],onSelect:()=>g(S.value)})),open:l,onOpenChange:c,children:I.jsxs("div",{className:X.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",X.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":l,"univer-bg-white dark:!univer-bg-gray-900":!l}),children:[I.jsx(ra,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),h&&I.jsx(sn,{className:"dark:!univer-text-white"})]})})})})},AS=[ge.id,m.SetRangeValuesCommand.id,Ne.id,m.MoveRangeMutation.id,m.RemoveRowMutation.id,m.RemoveColMutation.id,m.InsertRowMutation.id,m.InsertColMutation.id,m.MoveRowsMutation.id,m.MoveColsMutation.id,m.SetWorksheetColWidthMutation.id,m.SetWorksheetRowHeightMutation.id,m.SetSelectionsOperation.id,a.UndoCommandId];function DS(n,r,e,t,i){const o=[],s=[];if(t.copyType===Je.CUT){const{undos:l,redos:c}=kS(n,r,i);o.push(...c),s.push(...l)}else{const{undos:l,redos:c}=Ec(r,e,i);o.push(...c),s.push(...l);const{undos:d,redos:u}=NS(r,e,i);o.push(...u),s.push(...d);const{undos:h,redos:g}=bc(r,n,e,i);o.push(...g),s.push(...h);const{undos:S,redos:f}=wc(r,n,e,i,!0);o.push(...f),s.push(...S);const{undos:v,redos:p}=es(r,e,i);o.push(...p),s.push(...v)}return{undos:s,redos:o}}function kS(n,r,e){let t=[],i=[];const{range:o,subUnitId:s,unitId:l}=n,{range:c,subUnitId:d}=r,u=c?ct(c):null,h=o?ct(o):null;if(h&&u){const g=e.get(a.IUniverInstanceService),S=e.get(m.SheetInterceptorService),f=g.getUniverSheetInstance(l),v=f==null?void 0:f.getSheetBySheetId(s),p=f==null?void 0:f.getSheetBySheetId(d);if(v&&p){const C=new a.ObjectMatrix,b=new a.ObjectMatrix,w=v.getCellMatrix(),E=p.getCellMatrix();a.Range.foreach(h,(F,z)=>{C.setValue(F,z,a.Tools.deepClone(w.getValue(F,z))),b.setValue(F,z,null)});const O=new a.ObjectMatrix;a.Range.foreach(u,(F,z)=>{O.setValue(F,z,a.Tools.deepClone(E.getValue(F,z)))});const M=new a.ObjectMatrix;a.Range.foreach(h,(F,z)=>{const j=a.cellToRange(F,z),Q=a.Rectangle.getRelativeRange(j,h),ie=a.Rectangle.getPositionRange(Q,u);M.setValue(ie.startRow,ie.startColumn,w.getValue(F,z))});const P={fromRange:h,toRange:u,from:{value:b.getMatrix(),subUnitId:s},to:{value:M.getMatrix(),subUnitId:d},unitId:l},A={fromRange:u,toRange:h,from:{value:C.getMatrix(),subUnitId:s},to:{value:O.getMatrix(),subUnitId:d},unitId:l},k=S.onCommandExecute({id:m.MoveRangeCommand.id,params:{toRange:u,fromRange:h}}),N=v.getMergeData(),H=p.getMergeData(),x=N.filter(F=>a.Rectangle.intersects(F,h)),L=H.filter(F=>a.Rectangle.intersects(F,u)),V=x.map(F=>a.Rectangle.getRelativeRange(F,h)).map(F=>a.Rectangle.getPositionRange(F,u)),U=m.getAddMergeMutationRangeByType(V),B=[{id:m.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:x}},{id:m.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:L}},{id:m.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:d,ranges:U}}],Y=[{id:m.RemoveWorksheetMergeMutation.id,params:{unitId:l,subUnitId:d,ranges:U}},{id:m.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:d,ranges:L}},{id:m.AddWorksheetMergeMutation.id,params:{unitId:l,subUnitId:s,ranges:x}}];t=[{id:m.MoveRangeMutation.id,params:P},...k.redos,...B,{id:m.SetSelectionsOperation.id,params:{unitId:l,subUnitId:d,selections:[{range:u}],type:m.SelectionMoveType.MOVE_END}}],i=[{id:m.MoveRangeMutation.id,params:A},...k.undos,...Y,{id:m.SetSelectionsOperation.id,params:{unitId:l,subUnitId:s,type:m.SelectionMoveType.MOVE_END,selections:[{range:h}]}}]}}return{undos:i,redos:t}}function bc(n,r,e,t){var f;const{unitId:i,subUnitId:o,range:s}=n,l=(f=t.get(a.IUniverInstanceService).getUniverSheetInstance(i))==null?void 0:f.getSheetBySheetId(o),c=[],d=[],{mapFunc:u}=dt([s]),h=new a.ObjectMatrix;e.forValue((v,p,C)=>{var O,M;const{row:b,col:w}=u(v,p),E={v:C.v,t:C.t};if(!C.p&&C.v&&!r){const P=l==null?void 0:l.getCellStyle(b,w);if(Oi.isTextFormat((O=P==null?void 0:P.n)==null?void 0:O.pattern))E.t=a.CellValueType.STRING;else{const A=String(C.v),k=a.numfmt.parseValue(A);(k==null?void 0:k.v)!==void 0&&typeof k.v=="number"&&(!k.z&&a.willLoseNumericPrecision(A)?E.t=a.CellValueType.FORCE_STRING:E.v=k.v)}}if((M=C.p)!=null&&M.body&&ho(C.p.body)){const P=a.Tools.deepClone({p:C.p,v:C.v});h.setValue(b,w,P)}else h.setValue(b,w,a.Tools.deepClone(E))});const g={unitId:i,subUnitId:o,cellValue:a.Tools.deepClone(h.getMatrix())};c.push({id:m.SetRangeValuesMutation.id,params:g});const S=m.SetRangeValuesUndoMutationFactory(t,g);return d.push({id:m.SetRangeValuesMutation.id,params:S}),{undos:d,redos:c}}function wc(n,r,e,t,i=!1){var v;const o=[],s=[],{unitId:l,subUnitId:c,range:d}=n,u=(v=t.get(a.IUniverInstanceService).getUniverSheetInstance(l))==null?void 0:v.getSheetBySheetId(c),h=new a.ObjectMatrix,{mapFunc:g}=dt([d]);e.forValue((p,C,b)=>{var A,k;const w={s:Object.assign({},{...a.DEFAULT_STYLES,pd:R.DEFAULT_PADDING_DATA,bg:null,cl:null},b.s)},E=w.s.bd;E&&(Object.keys(E).length>0||(w.s.bd={b:null,l:null,r:null,t:null}));const{row:O,col:M}=g(p,C),P=u==null?void 0:u.getCellStyle(O,M);if(b.v&&!r&&Oi.isTextFormat((A=P==null?void 0:P.n)==null?void 0:A.pattern))w.s||(w.s={}),w.s.n=P==null?void 0:P.n;else{const N=String(b.v),H=a.numfmt.parseValue(N);H!=null&&H.z&&(w.s||(w.s={}),typeof w.s=="object"&&((k=w.s)!=null&&k.n?w.s.n.pattern=H.z:w.s.n={pattern:H.z}))}h.setValue(O,M,w)});const S={unitId:l,subUnitId:c,cellValue:a.Tools.deepClone(h.getMatrix())};o.push({id:m.SetRangeValuesMutation.id,params:S});const f=m.SetRangeValuesUndoMutationFactory(t,S);return s.push({id:m.SetRangeValuesMutation.id,params:f}),{undos:s,redos:o}}function Ec(n,r,e){const t=[],i=[],o=new a.ObjectMatrix,{unitId:s,subUnitId:l,range:c}=n,{mapFunc:d}=dt([c]);if(r.forEach((u,h)=>{Object.keys(h).forEach(g=>{const S=Number(g),{row:f,col:v}=d(u,S);o.setValue(f,v,{s:null})})}),o.getLength()>0){const u={subUnitId:l,unitId:s,cellValue:a.Tools.deepClone(o.getMatrix())};t.push({id:m.SetRangeValuesMutation.id,params:u});const h=m.SetRangeValuesUndoMutationFactory(e,u);i.push({id:m.SetRangeValuesMutation.id,params:h})}return{undos:i,redos:t}}function NS(n,r,e){const t=[],i=[],o=new a.ObjectMatrix,{unitId:s,subUnitId:l,range:c}=n,{mapFunc:d}=dt([c]);if(r.forValue((u,h,g)=>{const{row:S,col:f}=d(u,h);o.setValue(S,f,{v:null,p:null})}),o.getLength()>0){const u={subUnitId:l,unitId:s,cellValue:a.Tools.deepClone(o.getMatrix())};t.push({id:m.SetRangeValuesMutation.id,params:u});const h=m.SetRangeValuesUndoMutationFactory(e,u);i.push({id:m.SetRangeValuesMutation.id,params:h})}return{undos:i,redos:t}}function es(n,r,e){const t=[],i=[],{unitId:o,subUnitId:s,range:l}=n,{startColumn:c,startRow:d,endColumn:u,endRow:h}=ct(l),g=[];r.forValue((b,w,E)=>{if(E.rowSpan&&E.rowSpan>1){const O=E.colSpan||1,M={startRow:d+b,endRow:d+b+E.rowSpan-1,startColumn:c+w,endColumn:c+w+O-1};g.push(M)}else if(E.colSpan&&E.colSpan>1){const O=E.rowSpan||1,M={startRow:d+b,endRow:d+b+O-1,startColumn:c+w,endColumn:c+w+E.colSpan-1};g.push(M)}});const f=e.get(a.IUniverInstanceService).getUniverSheetInstance(o),v=f==null?void 0:f.getSheetBySheetId(s);if(f&&v){const w=v.getMergeData().filter(M=>a.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},M)),E={unitId:o,subUnitId:s,ranges:w};t.push({id:m.RemoveWorksheetMergeMutation.id,params:E});const O=m.RemoveMergeUndoMutationFactory(e,E);i.push({id:m.AddWorksheetMergeMutation.id,params:O})}const p={unitId:o,subUnitId:s,ranges:g};g.length>0&&t.push({id:m.AddWorksheetMergeMutation.id,params:p});const C=m.AddMergeUndoMutationFactory(e,p);return g.length>0&&i.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),{undos:i,redos:t}}function HS(n){if(!n.includes("\r")&&a.Tools.isLegalUrl(n)){const t=a.generateRandomId(),i=`${n}`,o={startIndex:0,endIndex:i.length-1,rangeId:t,rangeType:a.CustomRangeType.HYPERLINK,properties:{url:n}};return{dataStream:`${i}\r
|
|
20
20
|
`,paragraphs:[{startIndex:i.length}],customRanges:[o]}}let r=n.replace(/(\r\n|\n)/g,"\r");r.endsWith(`\r
|
|
21
21
|
`)||(r+=`\r
|
|
22
22
|
`);const e=[];for(let t=0;t<r.length;t++)r[t]==="\r"&&e.push({startIndex:t});return{dataStream:r,paragraphs:e,sectionBreaks:[{startIndex:r.indexOf(`
|