@univerjs/preset-sheets-find-replace 0.16.1 → 0.17.0

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.
Files changed (2) hide show
  1. package/lib/umd/index.js +2 -2
  2. package/package.json +5 -5
package/lib/umd/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @univerjs/find-replace/index
2
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/design","@univerjs/ui","@univerjs/engine-render","rxjs","react","react/jsx-runtime"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverFindReplace={},c.UniverCore,c.UniverDesign,c.UniverUi,c.UniverEngineRender,c.rxjs,c.React,c.React))})(this,(function(c,o,f,l,re,m,p,h){"use strict";var at=Object.defineProperty;var rt=(c,o,f)=>o in c?at(c,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[o]=f;var u=(c,o,f)=>rt(c,typeof o!="symbol"?o+"":o,f);var j;const V="FIND_REPLACE_INPUT_FOCUS",K="FIND_REPLACE_DIALOG_FOCUS",H="FIND_REPLACE_REPLACE_REVEALED";var oe=Object.getOwnPropertyDescriptor,q=(i,e,n,t)=>{for(var s=t>1?void 0:t?oe(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(s=r(s)||s);return s},P=(i,e)=>(n,t)=>e(n,t,i);class ce extends o.Disposable{}const S=o.createIdentifier("find-replace.service");function le(i){return typeof i.findString<"u"||typeof i.inputtingFindString<"u"||typeof i.findDirection<"u"||typeof i.matchesTheWholeCell<"u"||typeof i.caseSensitive<"u"||typeof i.findScope<"u"||typeof i.findBy<"u"}c.FindReplaceModel=class extends o.Disposable{constructor(n,t,s,a){super();u(this,"currentMatch$",new m.BehaviorSubject(null));u(this,"replaceables$",new m.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=n,this._providers=t,this._univerInstanceService=s,this._commandService=a,this.disposeWithMe(this._state.stateUpdates$.pipe(m.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async r=>{const d=this._state.state;le(r)&&(d.findString!==""&&!d.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):r.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...$(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const n=await this._startSearching();return this._state.changeState({findCompleted:!0}),n}focusSelection(){var n;(n=this._matchingModel)==null||n.focusSelection()}async _startSearching(){if(!this._state.findString)return{results:[]};const n=Array.from(this._providers),t=this._findModels=(await Promise.all(n.map(a=>a.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(t);const s=this._matches=t.map(a=>a.getMatches()).flat();return this.replaceables$.next(s.filter(a=>a.replaceable)),s.length?(this._moveToInitialMatch(t),this._state.changeState({matchesCount:s.length}),{results:s}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var n;this._providers.forEach(t=>t.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(n=this._currentSearchingDisposables)==null||n.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(n){const t=this._currentSearchingDisposables=new o.DisposableCollection,s=m.combineLatest(n.map(a=>a.matchesUpdate$)).pipe(m.debounceTime(220)).subscribe(([...a])=>{const r=this._matches=a.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(d=>d.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});n.forEach(a=>t.add(o.toDisposable(a.activelyChangingMatch$.subscribe(r=>{const d=this._matches.findIndex(_=>_===r);this._state.changeState({matchesPosition:d+1})})))),t.add(o.toDisposable(s))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const n=await Promise.all(this._findModels.map(t=>t.replaceAll(this._state.replaceString))).then(t=>t.reduce((s,a)=>(s.success+=a.success,s.failure+=a.failure,s),{success:0,failure:0}));return n.failure===0&&this._stopSearching(),n}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(n){const t=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:t+1})}moveToNextMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,t=this._matchingModel.moveToNextMatch({loop:n});if(t)return this._markMatch(t),t;{const s=this._findModels.findIndex(a=>a===this._matchingModel);return this._moveToNextUnitMatch(s)}}_moveToNextUnitMatch(n){const t=this._findModels.length;for(let s=(n+1)%t;s!==n;){const a=this._findModels[s],r=a.moveToNextMatch({ignoreSelection:!0});if(r)return this._matchingModel=a,this._markMatch(r),r;s=(s+1)%t}if(this._matchingModel){const s=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return s&&this._markMatch(s),s}}moveToPreviousMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,t=this._matchingModel.moveToPreviousMatch({loop:n});if(t){const s=this._matches.findIndex(a=>a===t);return this.currentMatch$.next(t),this._state.changeState({matchesPosition:s+1}),t}else{const s=this._findModels.length,a=this._findModels.findIndex(d=>d===this._matchingModel);for(let d=(a-1+s)%s;d!==a;){const _=this._findModels[d],v=_.moveToPreviousMatch({ignoreSelection:!0});if(v)return this._matchingModel=_,this._markMatch(v),v;d=(d-1)%s}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return r&&this._markMatch(r),r}}_moveToInitialMatch(n,t=!1){var r;const s=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!s)return-1;const a=n.findIndex(d=>d.unitId===s);if(a!==-1){this._matchingModel=n[a];const d=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:t});if(d)return this._markMatch(d),a}return this._moveToNextUnitMatch(a),0}},c.FindReplaceModel=q([P(2,o.IUniverInstanceService),P(3,o.ICommandService)],c.FindReplaceModel);var E=(i=>(i.ROW="row",i.COLUMN="column",i))(E||{}),O=(i=>(i.VALUE="value",i.FORMULA="formula",i))(O||{}),N=(i=>(i.SUBUNIT="subunit",i.UNIT="unit",i))(N||{});function $(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Z{constructor(){u(this,"_stateUpdates$",new m.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new m.BehaviorSubject($()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let n=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let A=class extends o.Disposable{constructor(e,n){super();u(this,"_providers",new Set);u(this,"_state",new Z);u(this,"_model");u(this,"_currentMatch$",new m.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new m.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new m.Subject);u(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getProviders(){return this._providers}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}focusSelection(){var e;(e=this._model)==null||e.focusSelection()}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(c.FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const n=$();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(H,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(re.RENDER_RAW_FORMULA_KEY,e)}};A=q([P(0,o.Inject(o.Injector)),P(1,o.IContextService)],A);const U={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:i=>i.get(S).replace()},de="CONFIRM_REPLACE_ALL",x={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async i=>{const e=i.get(o.IConfirmService),n=i.get(o.LocaleService),t=i.get(l.IMessageService);if(!await e.confirm({id:de,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const a=await i.get(S).replaceAll(),{success:r,failure:d}=a;return d>0?(r===0?t.show({type:f.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):t.show({type:f.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${r}`,`${d}`)}),!1):(t.show({type:f.MessageType.Success,content:n.t("find-replace.replace.all-success",`${r}`)}),!0)}},I={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(S);return e.revealed?e.focusFindInput():e.start(),!0}},L={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(S);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},w={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:i=>(i.get(S).moveToNextMatch(),!0)},k={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:i=>(i.get(S).moveToPreviousMatch(),!0)},z={type:o.CommandType.OPERATION,id:"ui.operation.focus-selection",handler:i=>(i.get(S).focusSelection(),!0)};function Y({ref:i,...e}){const{icon:n,id:t,className:s,extend:a,...r}=e,d=`univerjs-icon univerjs-icon-${t} ${s||""}`.trim(),_=p.useRef(`_${pe()}`);return J(n,`${t}`,{defIds:n.defIds,idSuffix:_.current},{ref:i,className:d,...r},a)}function J(i,e,n,t,s){return p.createElement(i.tag,{key:e,...he(i,n,s),...t},(ue(i,n).children||[]).map((a,r)=>J(a,`${e}-${i.tag}-${r}`,n,void 0,s)))}function he(i,e,n){const t={...i.attrs};n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1),i.tag==="mask"&&t.id&&(t.id=t.id+e.idSuffix),Object.entries(t).forEach(([a,r])=>{a==="mask"&&typeof r=="string"&&(t[a]=r.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:s}=e;return!s||s.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(([a,r])=>{typeof r=="string"&&(t[a]=r.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),t}function ue(i,e){var t;const{defIds:n}=e;return!n||n.length===0?i:i.tag==="defs"&&((t=i.children)!=null&&t.length)?{...i,children:i.children.map(s=>typeof s.attrs.id=="string"&&n&&n.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+e.idSuffix}}:s)}:i}function pe(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const fe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.71899 1.36938C4.37604 1.36938 1.66602 4.07941 1.66602 7.42236C1.66602 10.7653 4.37604 13.4753 7.71899 13.4753C9.16744 13.4753 10.4971 12.9666 11.5389 12.118L13.6598 14.4109C13.8848 14.6542 14.2644 14.669 14.5077 14.444C14.7509 14.219 14.7657 13.8393 14.5407 13.5961L12.3906 11.2716C13.2536 10.2254 13.772 8.88442 13.772 7.42236C13.772 4.07941 11.0619 1.36938 7.71899 1.36938ZM2.86602 7.42236C2.86602 4.74215 5.03878 2.56938 7.71899 2.56938C10.3992 2.56938 12.572 4.74215 12.572 7.42236C12.572 10.1026 10.3992 12.2753 7.71899 12.2753C5.03878 12.2753 2.86602 10.1026 2.86602 7.42236Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Q=p.forwardRef(function(e,n){return p.createElement(Y,Object.assign({},e,{id:"search-icon",ref:n,icon:fe}))});Q.displayName="SearchIcon";function X(i){const{findCompleted:e,localeService:n,matchesCount:t,matchesPosition:s,initialFindString:a,findReplaceService:r,onChange:d,..._}=i,[v,C]=p.useState(a),D=e&&t===0?n.t("find-replace.dialog.no-result"):t===0?" ":void 0;function y(M){s===t&&M===1?r.moveToNextMatch():s===1&&M===t||M<s?r.moveToPreviousMatch():r.moveToNextMatch()}return h.jsx("div",{className:"univer-relative univer-flex univer-items-center univer-gap-2",onDrag:M=>M.stopPropagation(),children:h.jsx(f.Input,{"data-u-comp":"search-input",autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),value:v,onChange:M=>{C(M),d==null||d(M)},slot:h.jsx(f.Pager,{loop:!0,text:D,value:s,total:t,onChange:y}),..._})})}function ee(i,e){const n=p.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=p.useCallback(()=>{const s=document.querySelectorAll("[data-u-comp=find-replace-dialog] [data-u-comp=search-input]");return Array.from(s).some(a=>a===document.activeElement)},[]);return p.useImperativeHandle(e,()=>({focus:n,selectHasFocus:t})),p.useEffect(()=>{const s=i.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[i,n]),{focus:n,selectHasFocus:t}}const _e=p.forwardRef(function(e,n){const t=l.useDependency(o.LocaleService),s=l.useDependency(S),a=l.useDependency(o.ICommandService),r=l.useObservable(s.state$,void 0,!0),{findCompleted:d,findString:_,matchesCount:v,matchesPosition:C}=r,F=p.useCallback(()=>{a.executeCommand(L.id)},[a]),D=l.useDebounceFn(y=>s.changeFindString(y),500);return ee(s,n),h.jsxs(h.Fragment,{children:[h.jsx(X,{findCompleted:d,matchesCount:v,matchesPosition:C,findReplaceService:s,localeService:t,initialFindString:_,onChange:D}),h.jsx("div",{className:"univer-mt-4 univer-text-center",children:h.jsx("a",{className:"hover:univer-text-primary-500/80 univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors",onClick:F,children:t.t("find-replace.dialog.advanced-finding")})})]})}),ge=p.forwardRef(function(e,n){const t=l.useDependency(S),s=l.useDependency(o.LocaleService),a=l.useDependency(o.ICommandService),r=l.useDependency(l.IMessageService),d=l.useObservable(t.currentMatch$,void 0,!0),_=l.useObservable(t.replaceables$,void 0,!0),v=l.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:F,findString:D,inputtingFindString:y,replaceString:M,caseSensitive:ke,matchesTheWholeCell:Be,findDirection:We,findScope:je,findBy:Ge,findCompleted:G}=v,Ve=y.length===0,Ke=C===0||!(d!=null&&d.replaceable),He=_.length===0,qe=p.useCallback(g=>t.changeInputtingFindString(g),[t]),Ze=p.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ze}=ee(t,n),Ye=p.useCallback(()=>{D===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[D,y,t]),Je=p.useCallback(()=>a.executeCommand(U.id),[a]),Qe=p.useCallback(async()=>{await a.executeCommand(x.id),ze()},[a]),Xe=p.useCallback(g=>{t.changeFindDirection(g)},[t]),et=p.useCallback(g=>{t.changeFindScope(g)},[t]),tt=p.useCallback(g=>{t.changeFindBy(g)},[t]),it=ve(s),nt=Se(s),st=Ce(s);return p.useEffect(()=>{G&&C===0&&r.show({content:s.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,duration:5e3})},[G,C,r,s]),h.jsxs("div",{children:[h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find"),children:h.jsx(X,{findCompleted:G,className:"univer-find-input",matchesCount:C,matchesPosition:F,findReplaceService:t,localeService:s,initialFindString:y,onChange:qe})}),h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.replace"),children:h.jsx(f.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:M,onChange:g=>Ze(g)})}),h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:h.jsx(f.Select,{value:We,options:nt,onChange:Xe})}),h.jsx(f.FormDualColumnLayout,{children:h.jsxs(h.Fragment,{children:[h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:h.jsx(f.Select,{value:je,options:it,onChange:et})}),h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:h.jsx(f.Select,{value:Ge,options:st,onChange:tt})})]})}),h.jsx(f.FormDualColumnLayout,{children:h.jsxs(h.Fragment,{children:[h.jsx(f.FormLayout,{children:h.jsx(f.Checkbox,{checked:ke,onChange:g=>{t.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),h.jsx(f.FormLayout,{children:h.jsx(f.Checkbox,{checked:Be,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),h.jsxs("div",{className:"univer-mt-6 univer-flex univer-justify-between",children:[h.jsx(f.Button,{variant:"primary",onClick:Ye,disabled:Ve,children:s.t("find-replace.dialog.find")}),h.jsxs("span",{className:"univer-inline-flex univer-gap-2",children:[h.jsx(f.Button,{disabled:Ke,onClick:Je,children:s.t("find-replace.dialog.replace")}),h.jsx(f.Button,{disabled:He,onClick:Qe,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function me(){const i=l.useDependency(S),e=l.useDependency(l.ILayoutService),n=l.useDependency(o.IContextService),t=l.useObservable(i.state$,void 0,!0),s=p.useRef(null);p.useEffect(()=>{let _;return s.current&&(_=e.registerContainerElement(s.current)),()=>_==null?void 0:_.dispose()},[e]);const a=p.useRef(null),r=p.useCallback(_=>n.setContextValue(K,_),[n]),d=p.useCallback(_=>n.setContextValue(V,_),[n]);return p.useEffect(()=>{var v;const _=m.fromEvent(document,"focusin").subscribe(C=>{var F;C.target&&((F=s.current)!=null&&F.contains(C.target))?r(!0):r(!1),!a.current||!a.current.selectHasFocus()?d(!1):d(!0)});return(v=a.current)==null||v.focus(),r(!0),d(!0),()=>{_.unsubscribe(),r(!1)}},[r,d]),h.jsx("div",{ref:s,"data-u-comp":"find-replace-dialog",children:t.replaceRevealed?h.jsx(ge,{ref:a}):h.jsx(_e,{ref:a})})}function ve(i){const e=i.getCurrentLocale();return p.useMemo(()=>[{label:i.t("find-replace.dialog.find-scope.current-sheet"),value:N.SUBUNIT},{label:i.t("find-replace.dialog.find-scope.workbook"),value:N.UNIT}],[e])}function Se(i){const e=i.getCurrentLocale();return p.useMemo(()=>[{label:i.t("find-replace.dialog.find-direction.row"),value:E.ROW},{label:i.t("find-replace.dialog.find-direction.column"),value:E.COLUMN}],[e])}function Ce(i){const e=i.getCurrentLocale();return p.useMemo(()=>[{label:i.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:i.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function R(i){return i.getContextValue(K)}function Me(i){return i.getContextValue(H)}function te(i){return i.getContextValue(V)}const T="7_find-replace-shortcuts";function B(i){return i.getContextValue(o.FOCUSING_SHEET)}function W(i){return!i.getContextValue(o.EDITOR_ACTIVATED)}const be={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,group:T,preconditions(i){return!R(i)&&B(i)&&W(i)}},ye={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.F|l.MetaKeys.MAC_CTRL,preconditions(i){return!R(i)&&B(i)&&W(i)}},Fe={id:L.id,description:"find-replace.shortcut.open-replace-dialog",binding:l.KeyCode.H|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.H|l.MetaKeys.MAC_CTRL,group:T,preconditions(i){return B(i)&&W(i)&&(!R(i)||!Me(i))}},Ie={id:w.id,description:"find-replace.shortcut.go-to-next-match",binding:l.KeyCode.ENTER,group:T,priority:1e3,preconditions(i){return te(i)&&R(i)}},Re={id:k.id,description:"find-replace.shortcut.go-to-previous-match",binding:l.KeyCode.ENTER|l.MetaKeys.SHIFT,group:T,priority:1e3,preconditions(i){return te(i)&&R(i)}},De={id:z.id,description:"find-replace.shortcut.focus-selection",binding:l.KeyCode.ESC,group:T,priority:1e3,preconditions(i){return R(i)}};function Te(i){const e=i.get(o.IContextService);return{id:I.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:l.MenuItemType.BUTTON,hidden$:l.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET),disabled$:m.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(m.map(([n,t])=>n||!t))}}const Pe={[l.RibbonDataGroup.ORGANIZATION]:{[I.id]:{order:2,menuItemFactory:Te}}};var Ee=Object.getOwnPropertyDescriptor,Oe=(i,e,n,t)=>{for(var s=t>1?void 0:t?Ee(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(s=r(s)||s);return s},b=(i,e)=>(n,t)=>e(n,t,i);const ie="DESKTOP_FIND_REPLACE_DIALOG",ne=350,Ne=20,$e=64;c.FindReplaceController=class extends o.RxDisposable{constructor(n,t,s,a,r,d,_,v,C){super();u(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=t,this._shortcutService=s,this._commandService=a,this._findReplaceService=r,this._dialogService=d,this._layoutService=_,this._localeService=v,this._componentManager=C,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[I,L,w,k,x,U,z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[Fe,be,ye,Re,Ie,De].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){[["FindReplaceDialog",me],["SearchIcon",Q]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))}),this._menuManagerService.mergeMenu(Pe),this._findReplaceService.stateUpdates$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:ie,draggable:!0,width:ne,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,mask:!1,maskClosable:!1,defaultPosition:Le(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=o.toDisposable(this._univerInstanceService.focused$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(ie),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},c.FindReplaceController=Oe([b(0,o.IUniverInstanceService),b(1,l.IMenuManagerService),b(2,l.IShortcutService),b(3,o.ICommandService),b(4,S),b(5,l.IDialogService),b(6,l.ILayoutService),b(7,o.Inject(o.LocaleService)),b(8,o.Inject(l.ComponentManager))],c.FindReplaceController);function Le(){const{innerWidth:i}=window;return{x:i-ne-Ne,y:$e}}const Ae="find-replace.config",se={};var Ue=Object.getOwnPropertyDescriptor,xe=(i,e,n,t)=>{for(var s=t>1?void 0:t?Ue(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(s=r(s)||s);return s},ae=(i,e)=>(n,t)=>e(n,t,i);const we="UNIVER_FIND_REPLACE_PLUGIN";c.UniverFindReplacePlugin=(j=class extends o.Plugin{constructor(e=se,n,t){super(),this._config=e,this._injector=n,this._configService=t;const{...s}=o.merge({},se,this._config);this._configService.setConfig(Ae,s)}onStarting(){[[c.FindReplaceController],[S,{useClass:A}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(c.FindReplaceController)}},u(j,"pluginName",we),j),c.UniverFindReplacePlugin=xe([ae(1,o.Inject(o.Injector)),ae(2,o.IConfigService)],c.UniverFindReplacePlugin),c.FindBy=O,c.FindDirection=E,c.FindModel=ce,c.FindReplaceState=Z,c.FindScope=N,c.GoToNextMatchOperation=w,c.GoToPreviousMatchOperation=k,c.IFindReplaceService=S,c.OpenFindDialogOperation=I,c.OpenReplaceDialogOperation=L,c.ReplaceAllMatchesCommand=x,c.ReplaceCurrentMatchCommand=U,c.createInitFindReplaceState=$,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
2
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/design","@univerjs/ui","@univerjs/engine-render","rxjs","react","react/jsx-runtime"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverFindReplace={},c.UniverCore,c.UniverDesign,c.UniverUi,c.UniverEngineRender,c.rxjs,c.React,c.React))})(this,(function(c,o,f,l,oe,m,p,h){"use strict";var at=Object.defineProperty;var rt=(c,o,f)=>o in c?at(c,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[o]=f;var u=(c,o,f)=>rt(c,typeof o!="symbol"?o+"":o,f);var P;const V="FIND_REPLACE_INPUT_FOCUS",K="FIND_REPLACE_DIALOG_FOCUS",H="FIND_REPLACE_REPLACE_REVEALED";var ce=Object.getOwnPropertyDescriptor,q=(i,e,n,t)=>{for(var s=t>1?void 0:t?ce(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(s=r(s)||s);return s},E=(i,e)=>(n,t)=>e(n,t,i);class le extends o.Disposable{}const S=o.createIdentifier("find-replace.service");function de(i){return typeof i.findString<"u"||typeof i.inputtingFindString<"u"||typeof i.findDirection<"u"||typeof i.matchesTheWholeCell<"u"||typeof i.caseSensitive<"u"||typeof i.findScope<"u"||typeof i.findBy<"u"}c.FindReplaceModel=class extends o.Disposable{constructor(n,t,s,a){super();u(this,"currentMatch$",new m.BehaviorSubject(null));u(this,"replaceables$",new m.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=n,this._providers=t,this._univerInstanceService=s,this._commandService=a,this.disposeWithMe(this._state.stateUpdates$.pipe(m.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async r=>{const d=this._state.state;de(r)&&(d.findString!==""&&!d.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):r.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...L(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const n=await this._startSearching();return this._state.changeState({findCompleted:!0}),n}focusSelection(){var n;(n=this._matchingModel)==null||n.focusSelection()}async _startSearching(){if(!this._state.findString)return{results:[]};const n=Array.from(this._providers),t=this._findModels=(await Promise.all(n.map(a=>a.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(t);const s=this._matches=t.map(a=>a.getMatches()).flat();return this.replaceables$.next(s.filter(a=>a.replaceable)),s.length?(this._moveToInitialMatch(t),this._state.changeState({matchesCount:s.length}),{results:s}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var n;this._providers.forEach(t=>t.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(n=this._currentSearchingDisposables)==null||n.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(n){const t=this._currentSearchingDisposables=new o.DisposableCollection,s=m.combineLatest(n.map(a=>a.matchesUpdate$)).pipe(m.debounceTime(220)).subscribe(([...a])=>{const r=this._matches=a.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(d=>d.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});n.forEach(a=>t.add(o.toDisposable(a.activelyChangingMatch$.subscribe(r=>{const d=this._matches.findIndex(_=>_===r);this._state.changeState({matchesPosition:d+1})})))),t.add(o.toDisposable(s))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const n=await Promise.all(this._findModels.map(t=>t.replaceAll(this._state.replaceString))).then(t=>t.reduce((s,a)=>(s.success+=a.success,s.failure+=a.failure,s),{success:0,failure:0}));return n.failure===0&&this._stopSearching(),n}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(n){const t=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:t+1})}moveToNextMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,t=this._matchingModel.moveToNextMatch({loop:n});if(t)return this._markMatch(t),t;{const s=this._findModels.findIndex(a=>a===this._matchingModel);return this._moveToNextUnitMatch(s)}}_moveToNextUnitMatch(n){const t=this._findModels.length;for(let s=(n+1)%t;s!==n;){const a=this._findModels[s],r=a.moveToNextMatch({ignoreSelection:!0});if(r)return this._matchingModel=a,this._markMatch(r),r;s=(s+1)%t}if(this._matchingModel){const s=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return s&&this._markMatch(s),s}}moveToPreviousMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,t=this._matchingModel.moveToPreviousMatch({loop:n});if(t){const s=this._matches.findIndex(a=>a===t);return this.currentMatch$.next(t),this._state.changeState({matchesPosition:s+1}),t}else{const s=this._findModels.length,a=this._findModels.findIndex(d=>d===this._matchingModel);for(let d=(a-1+s)%s;d!==a;){const _=this._findModels[d],v=_.moveToPreviousMatch({ignoreSelection:!0});if(v)return this._matchingModel=_,this._markMatch(v),v;d=(d-1)%s}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return r&&this._markMatch(r),r}}_moveToInitialMatch(n,t=!1){var r;const s=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!s)return-1;const a=n.findIndex(d=>d.unitId===s);if(a!==-1){this._matchingModel=n[a];const d=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:t});if(d)return this._markMatch(d),a}return this._moveToNextUnitMatch(a),0}},c.FindReplaceModel=q([E(2,o.IUniverInstanceService),E(3,o.ICommandService)],c.FindReplaceModel);var O=(i=>(i.ROW="row",i.COLUMN="column",i))(O||{}),N=(i=>(i.VALUE="value",i.FORMULA="formula",i))(N||{}),$=(i=>(i.SUBUNIT="subunit",i.UNIT="unit",i))($||{});function L(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Z{constructor(){u(this,"_stateUpdates$",new m.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new m.BehaviorSubject(L()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let n=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let x=class extends o.Disposable{constructor(e,n){super();u(this,"_providers",new Set);u(this,"_state",new Z);u(this,"_model");u(this,"_currentMatch$",new m.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new m.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new m.Subject);u(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getProviders(){return this._providers}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}focusSelection(){var e;(e=this._model)==null||e.focusSelection()}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(c.FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const n=L();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(H,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(oe.RENDER_RAW_FORMULA_KEY,e)}};x=q([E(0,o.Inject(o.Injector)),E(1,o.IContextService)],x);const U={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:i=>i.get(S).replace()},he="CONFIRM_REPLACE_ALL",w={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async i=>{const e=i.get(o.IConfirmService),n=i.get(o.LocaleService),t=i.get(l.IMessageService);if(!await e.confirm({id:he,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const a=await i.get(S).replaceAll(),{success:r,failure:d}=a;return d>0?(r===0?t.show({type:f.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):t.show({type:f.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${r}`,`${d}`)}),!1):(t.show({type:f.MessageType.Success,content:n.t("find-replace.replace.all-success",`${r}`)}),!0)}},I={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(S);return e.revealed?e.focusFindInput():e.start(),!0}},A={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(S);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},k={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:i=>(i.get(S).moveToNextMatch(),!0)},B={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:i=>(i.get(S).moveToPreviousMatch(),!0)},z={type:o.CommandType.OPERATION,id:"ui.operation.focus-selection",handler:i=>(i.get(S).focusSelection(),!0)};function Y({ref:i,...e}){const{icon:n,id:t,className:s,extend:a,...r}=e,d=`univerjs-icon univerjs-icon-${t} ${s||""}`.trim(),_=p.useRef(`_${fe()}`);return J(n,`${t}`,{defIds:n.defIds,idSuffix:_.current},{ref:i,className:d,...r},a)}function J(i,e,n,t,s){return p.createElement(i.tag,{key:e,...ue(i,n,s),...t},(pe(i,n).children||[]).map((a,r)=>J(a,`${e}-${i.tag}-${r}`,n,void 0,s)))}function ue(i,e,n){const t={...i.attrs};n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1),i.tag==="mask"&&t.id&&(t.id=t.id+e.idSuffix),Object.entries(t).forEach(([a,r])=>{a==="mask"&&typeof r=="string"&&(t[a]=r.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:s}=e;return!s||s.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(([a,r])=>{typeof r=="string"&&(t[a]=r.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),t}function pe(i,e){var t;const{defIds:n}=e;return!n||n.length===0?i:i.tag==="defs"&&((t=i.children)!=null&&t.length)?{...i,children:i.children.map(s=>typeof s.attrs.id=="string"&&n&&n.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+e.idSuffix}}:s)}:i}function fe(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const _e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.71899 1.36938C4.37604 1.36938 1.66602 4.07941 1.66602 7.42236C1.66602 10.7653 4.37604 13.4753 7.71899 13.4753C9.16744 13.4753 10.4971 12.9666 11.5389 12.118L13.6598 14.4109C13.8848 14.6542 14.2644 14.669 14.5077 14.444C14.7509 14.219 14.7657 13.8393 14.5407 13.5961L12.3906 11.2716C13.2536 10.2254 13.772 8.88442 13.772 7.42236C13.772 4.07941 11.0619 1.36938 7.71899 1.36938ZM2.86602 7.42236C2.86602 4.74215 5.03878 2.56938 7.71899 2.56938C10.3992 2.56938 12.572 4.74215 12.572 7.42236C12.572 10.1026 10.3992 12.2753 7.71899 12.2753C5.03878 12.2753 2.86602 10.1026 2.86602 7.42236Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Q=p.forwardRef(function(e,n){return p.createElement(Y,Object.assign({},e,{id:"search-icon",ref:n,icon:_e}))});Q.displayName="SearchIcon";function ge(i){const e=i.get(o.IContextService);return{id:I.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:l.MenuItemType.BUTTON,hidden$:l.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET),disabled$:m.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(m.map(([n,t])=>n||!t))}}const me={[l.RibbonDataGroup.ORGANIZATION]:{[I.id]:{order:2,menuItemFactory:ge}}};function X(i){const{findCompleted:e,localeService:n,matchesCount:t,matchesPosition:s,initialFindString:a,findReplaceService:r,onChange:d,..._}=i,[v,C]=p.useState(a),D=e&&t===0?n.t("find-replace.dialog.no-result"):t===0?" ":void 0;function y(M){s===t&&M===1?r.moveToNextMatch():s===1&&M===t||M<s?r.moveToPreviousMatch():r.moveToNextMatch()}return h.jsx("div",{className:"univer-relative univer-flex univer-items-center univer-gap-2",onDrag:M=>M.stopPropagation(),children:h.jsx(f.Input,{"data-u-comp":"search-input",autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),value:v,onChange:M=>{C(M),d==null||d(M)},slot:h.jsx(f.Pager,{loop:!0,text:D,value:s,total:t,onChange:y}),..._})})}function ee(i,e){const n=p.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=p.useCallback(()=>{const s=document.querySelectorAll("[data-u-comp=find-replace-dialog] [data-u-comp=search-input]");return Array.from(s).some(a=>a===document.activeElement)},[]);return p.useImperativeHandle(e,()=>({focus:n,selectHasFocus:t})),p.useEffect(()=>{const s=i.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[i,n]),{focus:n,selectHasFocus:t}}const ve=p.forwardRef(function(e,n){const t=l.useDependency(o.LocaleService),s=l.useDependency(S),a=l.useDependency(o.ICommandService),r=l.useObservable(s.state$,void 0,!0),{findCompleted:d,findString:_,matchesCount:v,matchesPosition:C}=r,F=p.useCallback(()=>{a.executeCommand(A.id)},[a]),D=l.useDebounceFn(y=>s.changeFindString(y),500);return ee(s,n),h.jsxs(h.Fragment,{children:[h.jsx(X,{findCompleted:d,matchesCount:v,matchesPosition:C,findReplaceService:s,localeService:t,initialFindString:_,onChange:D}),h.jsx("div",{className:"univer-mt-4 univer-text-center",children:h.jsx("a",{className:"hover:univer-text-primary-500/80 univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors",onClick:F,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Se=p.forwardRef(function(e,n){const t=l.useDependency(S),s=l.useDependency(o.LocaleService),a=l.useDependency(o.ICommandService),r=l.useDependency(l.IMessageService),d=l.useObservable(t.currentMatch$,void 0,!0),_=l.useObservable(t.replaceables$,void 0,!0),v=l.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:F,findString:D,inputtingFindString:y,replaceString:M,caseSensitive:ke,matchesTheWholeCell:Be,findDirection:We,findScope:je,findBy:Ge,findCompleted:G}=v,Ve=y.length===0,Ke=C===0||!(d!=null&&d.replaceable),He=_.length===0,qe=p.useCallback(g=>t.changeInputtingFindString(g),[t]),Ze=p.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ze}=ee(t,n),Ye=p.useCallback(()=>{D===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[D,y,t]),Je=p.useCallback(()=>a.executeCommand(U.id),[a]),Qe=p.useCallback(async()=>{await a.executeCommand(w.id),ze()},[a]),Xe=p.useCallback(g=>{t.changeFindDirection(g)},[t]),et=p.useCallback(g=>{t.changeFindScope(g)},[t]),tt=p.useCallback(g=>{t.changeFindBy(g)},[t]),it=Me(s),nt=be(s),st=ye(s);return p.useEffect(()=>{G&&C===0&&r.show({content:s.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,duration:5e3})},[G,C,r,s]),h.jsxs("div",{children:[h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find"),children:h.jsx(X,{findCompleted:G,className:"univer-find-input",matchesCount:C,matchesPosition:F,findReplaceService:t,localeService:s,initialFindString:y,onChange:qe})}),h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.replace"),children:h.jsx(f.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:M,onChange:g=>Ze(g)})}),h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:h.jsx(f.Select,{value:We,options:nt,onChange:Xe})}),h.jsx(f.FormDualColumnLayout,{children:h.jsxs(h.Fragment,{children:[h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:h.jsx(f.Select,{value:je,options:it,onChange:et})}),h.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:h.jsx(f.Select,{value:Ge,options:st,onChange:tt})})]})}),h.jsx(f.FormDualColumnLayout,{children:h.jsxs(h.Fragment,{children:[h.jsx(f.FormLayout,{children:h.jsx(f.Checkbox,{checked:ke,onChange:g=>{t.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),h.jsx(f.FormLayout,{children:h.jsx(f.Checkbox,{checked:Be,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),h.jsxs("div",{className:"univer-mt-6 univer-flex univer-justify-between",children:[h.jsx(f.Button,{variant:"primary",onClick:Ye,disabled:Ve,children:s.t("find-replace.dialog.find")}),h.jsxs("span",{className:"univer-inline-flex univer-gap-2",children:[h.jsx(f.Button,{disabled:Ke,onClick:Je,children:s.t("find-replace.dialog.replace")}),h.jsx(f.Button,{disabled:He,onClick:Qe,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Ce(){const i=l.useDependency(S),e=l.useDependency(l.ILayoutService),n=l.useDependency(o.IContextService),t=l.useObservable(i.state$,void 0,!0),s=p.useRef(null);p.useEffect(()=>{let _;return s.current&&(_=e.registerContainerElement(s.current)),()=>_==null?void 0:_.dispose()},[e]);const a=p.useRef(null),r=p.useCallback(_=>n.setContextValue(K,_),[n]),d=p.useCallback(_=>n.setContextValue(V,_),[n]);return p.useEffect(()=>{var v;const _=m.fromEvent(document,"focusin").subscribe(C=>{var F;C.target&&((F=s.current)!=null&&F.contains(C.target))?r(!0):r(!1),!a.current||!a.current.selectHasFocus()?d(!1):d(!0)});return(v=a.current)==null||v.focus(),r(!0),d(!0),()=>{_.unsubscribe(),r(!1)}},[r,d]),h.jsx("div",{ref:s,"data-u-comp":"find-replace-dialog",children:t.replaceRevealed?h.jsx(Se,{ref:a}):h.jsx(ve,{ref:a})})}function Me(i){const e=i.getCurrentLocale();return p.useMemo(()=>[{label:i.t("find-replace.dialog.find-scope.current-sheet"),value:$.SUBUNIT},{label:i.t("find-replace.dialog.find-scope.workbook"),value:$.UNIT}],[e])}function be(i){const e=i.getCurrentLocale();return p.useMemo(()=>[{label:i.t("find-replace.dialog.find-direction.row"),value:O.ROW},{label:i.t("find-replace.dialog.find-direction.column"),value:O.COLUMN}],[e])}function ye(i){const e=i.getCurrentLocale();return p.useMemo(()=>[{label:i.t("find-replace.dialog.find-by.value"),value:N.VALUE},{label:i.t("find-replace.dialog.find-by.formula"),value:N.FORMULA}],[e])}function R(i){return i.getContextValue(K)}function Fe(i){return i.getContextValue(H)}function te(i){return i.getContextValue(V)}const T="7_find-replace-shortcuts";function W(i){return i.getContextValue(o.FOCUSING_SHEET)}function j(i){return!i.getContextValue(o.EDITOR_ACTIVATED)}const Ie={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,group:T,preconditions(i){return!R(i)&&W(i)&&j(i)}},Re={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:l.KeyCode.F|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.F|l.MetaKeys.MAC_CTRL,preconditions(i){return!R(i)&&W(i)&&j(i)}},De={id:A.id,description:"find-replace.shortcut.open-replace-dialog",binding:l.KeyCode.H|l.MetaKeys.CTRL_COMMAND,mac:l.KeyCode.H|l.MetaKeys.MAC_CTRL,group:T,preconditions(i){return W(i)&&j(i)&&(!R(i)||!Fe(i))}},Te={id:k.id,description:"find-replace.shortcut.go-to-next-match",binding:l.KeyCode.ENTER,group:T,priority:1e3,preconditions(i){return te(i)&&R(i)}},Pe={id:B.id,description:"find-replace.shortcut.go-to-previous-match",binding:l.KeyCode.ENTER|l.MetaKeys.SHIFT,group:T,priority:1e3,preconditions(i){return te(i)&&R(i)}},Ee={id:z.id,description:"find-replace.shortcut.focus-selection",binding:l.KeyCode.ESC,group:T,priority:1e3,preconditions(i){return R(i)}};var Oe=Object.getOwnPropertyDescriptor,Ne=(i,e,n,t)=>{for(var s=t>1?void 0:t?Oe(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(s=r(s)||s);return s},b=(i,e)=>(n,t)=>e(n,t,i);const ie="DESKTOP_FIND_REPLACE_DIALOG",ne=350,$e=20,Le=64;c.FindReplaceController=class extends o.RxDisposable{constructor(n,t,s,a,r,d,_,v,C){super();u(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=t,this._shortcutService=s,this._commandService=a,this._findReplaceService=r,this._dialogService=d,this._layoutService=_,this._localeService=v,this._componentManager=C,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[I,A,k,B,w,U,z].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[De,Ie,Re,Pe,Te,Ee].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){[["FindReplaceDialog",Ce],["SearchIcon",Q]].forEach(([n,t])=>{this.disposeWithMe(this._componentManager.register(n,t))}),this._menuManagerService.mergeMenu(me),this._findReplaceService.stateUpdates$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:ie,draggable:!0,width:ne,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,mask:!1,maskClosable:!1,defaultPosition:Ae(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=o.toDisposable(this._univerInstanceService.focused$.pipe(m.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(ie),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},c.FindReplaceController=Ne([b(0,o.IUniverInstanceService),b(1,l.IMenuManagerService),b(2,l.IShortcutService),b(3,o.ICommandService),b(4,S),b(5,l.IDialogService),b(6,l.ILayoutService),b(7,o.Inject(o.LocaleService)),b(8,o.Inject(l.ComponentManager))],c.FindReplaceController);function Ae(){const{innerWidth:i}=window;return{x:i-ne-$e,y:Le}}const se={name:"@univerjs/find-replace",version:"0.17.0"},xe="find-replace.config",ae={};var Ue=Object.getOwnPropertyDescriptor,we=(i,e,n,t)=>{for(var s=t>1?void 0:t?Ue(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(s=r(s)||s);return s},re=(i,e)=>(n,t)=>e(n,t,i);c.UniverFindReplacePlugin=(P=class extends o.Plugin{constructor(e=ae,n,t){super(),this._config=e,this._injector=n,this._configService=t;const{...s}=o.merge({},ae,this._config);this._configService.setConfig(xe,s)}onStarting(){[[c.FindReplaceController],[S,{useClass:x}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(c.FindReplaceController)}},u(P,"pluginName","UNIVER_FIND_REPLACE_PLUGIN"),u(P,"packageName",se.name),u(P,"version",se.version),P),c.UniverFindReplacePlugin=we([re(1,o.Inject(o.Injector)),re(2,o.IConfigService)],c.UniverFindReplacePlugin),c.FindBy=N,c.FindDirection=O,c.FindModel=le,c.FindReplaceState=Z,c.FindScope=$,c.GoToNextMatchOperation=k,c.GoToPreviousMatchOperation=B,c.IFindReplaceService=S,c.OpenFindDialogOperation=I,c.OpenReplaceDialogOperation=A,c.ReplaceAllMatchesCommand=w,c.ReplaceCurrentMatchCommand=U,c.createInitFindReplaceState=L,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
3
3
 
4
4
 
5
5
  // @univerjs/sheets-find-replace/index
6
- (function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/engine-render"),require("@univerjs/find-replace"),require("@univerjs/sheets-ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/engine-render","@univerjs/find-replace","@univerjs/sheets-ui","rxjs"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.UniverSheetsFindReplace={},f.UniverCore,f.UniverSheets,f.UniverEngineRender,f.UniverFindReplace,f.UniverSheetsUi,f.rxjs))})(this,(function(f,a,p,y,S,F,k){"use strict";var Se=Object.defineProperty;var me=(f,a,p)=>a in f?Se(f,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):f[a]=p;var m=(f,a,p)=>me(f,typeof a!="symbol"?a+"":a,p);const U={id:"sheet.command.replace",type:a.CommandType.COMMAND,handler:async(h,e)=>{const t=h.get(a.IUndoRedoService),i=h.get(a.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(c=>i.executeCommand(p.SetRangeValuesCommand.id,{unitId:n,subUnitId:c.subUnitId,value:c.value})));return s.dispose(),Y(o,r)}};function Y(h,e){let t=0,i=0;return h.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}class q extends y.Shape{constructor(t,i){super(t,i);m(this,"_activated",!1);m(this,"_inHiddenRange",!1);m(this,"_color");i&&this.setShapeProps(i)}setShapeProps(t){this._activated=!!t.activated,typeof t.inHiddenRange<"u"&&(this._inHiddenRange=t.inHiddenRange),typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){const i=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;y.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}function O(h,e){return h.startRow===e.startRow&&h.startColumn===e.startColumn}function A(h,e){return h.startRow<e.startRow||h.startRow===e.startRow&&h.startColumn<=e.startColumn}function D(h,e){return h.startColumn<e.startColumn||h.startColumn===e.startColumn&&h.startRow<=e.startRow}function K(h,e){return h.startRow>e.startRow||h.startRow===e.startRow&&h.startColumn>=e.startColumn}function Q(h,e){return h.startColumn>e.startColumn||h.startColumn===e.startColumn&&h.startRow>=e.startRow}function X(h,e){const{range:t}=h,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?a.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var z=Object.getOwnPropertyDescriptor,x=(h,e,t,i)=>{for(var n=i>1?void 0:i?z(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=s(n)||n);return n},C=(h,e)=>(t,i)=>e(t,i,h);f.SheetsFindReplaceController=class extends a.Disposable{constructor(t,i,n,r,s){super();m(this,"_provider");this._injector=t,this._findReplaceController=i,this._contextService=n,this._findReplaceService=r,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){const t=this._injector.createInstance(B);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(a.EDITOR_ACTIVATED).pipe(k.filter(i=>!!i)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[U].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}},f.SheetsFindReplaceController=x([C(0,a.Inject(a.Injector)),C(1,a.Inject(S.FindReplaceController)),C(2,a.IContextService),C(3,S.IFindReplaceService),C(4,a.ICommandService)],f.SheetsFindReplaceController);const J="sheets-find-replace-provider",Z=1e4;let P=class extends S.FindModel{constructor(e,t,i,n,r,s,o,c){super();m(this,"_matchesUpdate$",new k.Subject);m(this,"matchesUpdate$",this._matchesUpdate$.asObservable());m(this,"_activelyChangingMatch$",new k.Subject);m(this,"activelyChangingMatch$",this._activelyChangingMatch$.asObservable());m(this,"_matchesByWorksheet",new Map);m(this,"_matches",[]);m(this,"_matchesPosition",0);m(this,"_activeHighlightIndex",-1);m(this,"_highlightShapes",[]);m(this,"_currentHighlightShape",null);m(this,"_query",null);m(this,"_workbookSelections");this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=i,this._renderManagerService=n,this._commandService=r,this._contextService=s,this._themeService=o,this._workbookSelections=c.getWorkbookSelections(this.unitId)}get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===S.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case S.FindScope.UNIT:this.findInWorkbook(e);break;case S.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}focusSelection(){const e=this.currentMatch;e&&this._commandService.executeCommand(p.SelectRangeCommand.id,{unitId:e.unitId,subUnit:e.range.subUnitId,range:e.range.range})}_toggleDisplayRawFormula(e){this._contextService.setContextValue(y.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let i,n=!0;const r=()=>{const s=this._workbook.getSheets().filter(o=>!o.isSheetHidden()).map(o=>{const c=this._findInWorksheet(o,e,t),d=o.getSheetId(),{results:l}=c;return l.length?this._matchesByWorksheet.set(d,c.results):this._matchesByWorksheet.delete(d),c});this._matches=s.map(o=>o.results).flat(),this._updateFindHighlight(),n?(i={results:this._matches},n=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k.filter(([s,o])=>s.id===p.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet();if(!s)return;const o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k.filter(([s])=>s.type===a.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),k.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),i}_findNextMatchOnActiveSheetChange(e){let t,i,n=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._workbookSelections.getCurrentSelections();s!=null&&s.length?([t,n]=this._findNextMatchByRange(r,s[0].range),i=r.findIndex(o=>o===t)):(t=r[0],i=0,n=this._matches.findIndex(o=>o===t)),this._matchesPosition=n+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=i,this._updateFindHighlight(),this._updateCurrentHighlightShape(i)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),i=()=>{var u;const c=this._workbook.getActiveSheet();if(!c)return!1;const d=this._workbookSelections.getCurrentSelections();return(u=d==null?void 0:d.some(g=>!X(g,c)))!=null?u:!1};let n,r=!0,s=!1;const o=()=>{const c=this._workbook.getActiveSheet();if(!c)return{results:[]};const d=this.currentMatch;s=i();const l=this._workbookSelections.getCurrentSelections(),u=s?this._findInSelections(c,l,e,t):this._findInWorksheet(c,e,t);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(d,this._matches),r?(n=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(k.merge(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k.filter(([c])=>{if(c.type===a.CommandType.MUTATION&&c.params.unitId===this._workbook.getUnitId())return!0;if(c.id===p.SetSelectionsOperation.id&&c.params.unitId===t){const d=i();return d===!1&&s===!1?!1:(s=d,!0)}return!1})),this._workbook.activeSheet$.pipe(k.skip(1))).pipe(k.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),c=(t.findDirection===S.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);for(const d of c){const{row:l,col:u,colSpan:g,rowSpan:v,value:I}=d;if(r!=null&&r(l,u)||!I||e.getRowFiltered(l))continue;const{hit:w,replaceable:M,isFormula:R}=ee(e,l,u,t,I);if(w){const T={provider:J,unitId:n,replaceable:M,isFormula:R,range:{subUnitId:o,range:{startRow:l,startColumn:u,endColumn:u+(g!=null?g:1)-1,endRow:l+(v!=null?v:1)-1}}};s.push(T)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===S.FindDirection.ROW?A:D,o=new Set;return{results:t.map(d=>this._findInRange(e,i,d.range,n,(l,u)=>{const g=`${l}-${u}`;return o.has(g)?!0:(o.add(g),!1)}).results).flat().sort((d,l)=>s(d.range.range,l.range.range)?-1:1)}}_findInWorksheet(e,t,i){const n=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:n-1,endColumn:r-1};return this._findInRange(e,t,s,i)}_disposeHighlights(){var e;this._highlightShapes.forEach(t=>{var i;(i=t.getScene())==null||i.makeDirty(),t.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var u;this._disposeHighlights();const e=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(!e)return;const t=this._workbook.getUnitId(),i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:n}=i,r=this._matches,s=this._themeService.getColorFromTheme("yellow.400"),o=new a.ColorKit(s).toRgb(),c=this._workbook.getActiveSheet();if(!c)return;const d=c.getSheetId(),l=r.filter(g=>g.range.subUnitId===d).map((g,v)=>{const{startColumn:I,startRow:w,endColumn:M,endRow:R}=g.range.range,T=F.getCoordByCell(w,I,n,e),ae=F.getCoordByCell(R,M,n,e),{startX:V,startY:G}=T,{endX:le,endY:de}=ae;let H=!0;for(let b=w;b<=R;b++)if(c.getRowRawVisible(b)){H=!1;break}let E=!0;for(let b=I;b<=M;b++)if(c.getColVisible(b)){E=!1;break}const ue=H||E,ge=E?2:le-V,fe=H?2:de-G,_e={left:V,top:G,color:o,width:ge,height:fe,evented:!1,inHiddenRange:ue,zIndex:Z};return new q(`find-highlight-${v}`,_e)});n.addObjects(l),this._highlightShapes=l,n.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const i=this._highlightShapes[e];if(!i)return;this._currentHighlightShape=i,i.setShapeProps({activated:!0})}}_getSheetObject(){return F.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var i;const t=e.range.subUnitId;t!==((i=this._workbook.getActiveSheet())==null?void 0:i.getSheetId())&&this._commandService.executeCommand(p.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:t},{fromFindReplace:!0}),this._commandService.executeCommand(F.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;const{subUnitId:i}=e.range,{startColumn:n,startRow:r}=e.range.range,s=t.findIndex(o=>{if(i!==o.range.subUnitId)return!1;const{startColumn:c,startRow:d}=o.range.range;return c===n&&d===r});return s>-1?s+1:0}moveToNextMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findNextMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findPreviousMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c-1;if(!e&&d<0)return null;const l=this._matches.length,u=(d+l)%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n){const c=this._matches.length-1;return[this._matches[c],c]}if(this._query.findScope!==S.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,n.range);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findPreviousWorksheetThatHasAMatch(r,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findNextMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c+1,l=this._matches.length;if(!e&&d>=l)return null;const u=d%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n)return[this._matches[0],0];if(this._query.findScope!==S.FindScope.UNIT)return this._findNextMatchByRange(this._matches,n.range,t);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findNextWorksheetThatHasAMatch(r,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n+1):i.slice(0,n+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n):i.slice(n)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,i=!1){const n=this._query.findDirection===S.FindDirection.ROW;let r=e.findIndex(o=>{const c=o.range.range;if(!(n?A(t,c):D(t,c)))return!1;const l=O(t,c);return i?l:!l});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,i=!1){const n=this._query.findDirection===S.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const c=o.range.range;if(!(n?K(t,c):Q(t,c)))return!1;const l=O(t,c);return i?l:!l});r===-1&&(r=0);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const t=this.currentMatch.range,i=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),n=this._getReplacedCellData(this.currentMatch,i,this._query.findBy===S.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?"g":"ig"),r={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:n}}};return this._commandService.executeCommand(p.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:i,caseSensitive:n,findBy:r}=this._query,s=r===S.FindBy.FORMULA,o=n?"g":"ig",c=[];return a.groupBy(this._matches.filter(l=>l.replaceable),l=>l.range.subUnitId).forEach((l,u)=>{const g=new a.ObjectMatrix,v=this._workbook.getSheetBySheetId(u);l.forEach(I=>{const{startColumn:w,startRow:M}=I.range.range,R=this._getReplacedCellData(I,v,s,i,e,o);R&&g.setValue(M,w,R)}),c.push({count:l.length,subUnitId:u,value:g.getMatrix()})}),c?this._commandService.executeCommand(U.id,{unitId:t,replacements:c}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var v;const o=e.range.range,{startRow:c,startColumn:d}=o,l=t.getCellRaw(c,d);if(e.isFormula)return i?{f:l.f.replace(new RegExp(N(n),s),r),v:null}:null;if(!!((v=l.p)!=null&&v.body)){const I=a.Tools.deepClone(l.p);return a.replaceInDocumentBody(I.body,n,r,this._query.caseSensitive),{p:I}}return{v:l.v.toString().replace(new RegExp(N(n),s),r)}}};P=x([C(2,a.IUniverInstanceService),C(3,y.IRenderManagerService),C(4,a.ICommandService),C(5,a.IContextService),C(6,a.Inject(a.ThemeService)),C(7,a.Inject(p.SheetsSelectionsService))],P);function N(h){return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let B=class extends a.Disposable{constructor(e,t,i){super();m(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._renderManagerService=t,this._injector=i}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return[];const i=this._preprocessQuery(e),n=this._renderManagerService.getRenderById(t.getUnitId()).with(F.SheetSkeletonManagerService),r=this._injector.createInstance(P,t,n);return this._findModelsByUnitId.set(t.getUnitId(),r),r.start(i),[r]}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};B=x([C(0,a.IUniverInstanceService),C(1,y.IRenderManagerService),C(2,a.Inject(a.Injector))],B);const _={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function ee(h,e,t,i,n){const{findBy:r}=i,s=r===S.FindBy.FORMULA,o=h.getCellRaw(e,t);return _.rawData=o,!(o!=null&&o.f)?(_.isFormula=!1,W(n,i)?o?(_.hit=!0,_.replaceable=!0):(_.hit=!0,_.replaceable=!1):(_.hit=!1,_.replaceable=!1),_):(_.isFormula=!0,s?W({v:o.f},i)?(_.hit=!0,_.replaceable=!0,_):(_.hit=!1,_.replaceable=!1,_):(_.replaceable=!1,W(n,i)?_.hit=!0:_.hit=!1,_))}function W(h,e){let t=te(h);return t?e.matchesTheWholeCell?(t=ie(t),e.caseSensitive?t===e.findString:t.toLowerCase()===e.findString):e.caseSensitive?t.indexOf(e.findString)>-1:t.toLowerCase().indexOf(e.findString)>-1:!1}function te(h){var t,i,n;const e=(n=(i=(t=h==null?void 0:h.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:h==null?void 0:h.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function ie(h){return h.replace(/^ +/g,"").replace(/ +$/g,"")}const ne="sheets-find-replace.config",j={};var se=Object.defineProperty,re=Object.getOwnPropertyDescriptor,oe=(h,e,t)=>e in h?se(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t,he=(h,e,t,i)=>{for(var n=i>1?void 0:i?re(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=s(n)||n);return n},$=(h,e)=>(t,i)=>e(t,i,h),L=(h,e,t)=>oe(h,typeof e!="symbol"?e+"":e,t);const ce="SHEET_FIND_REPLACE_PLUGIN";f.UniverSheetsFindReplacePlugin=class extends a.Plugin{constructor(e=j,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...n}=a.merge({},j,this._config);this._configService.setConfig(ne,n)}onStarting(){[[f.SheetsFindReplaceController]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(f.SheetsFindReplaceController)}},L(f.UniverSheetsFindReplacePlugin,"pluginName",ce),L(f.UniverSheetsFindReplacePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),f.UniverSheetsFindReplacePlugin=he([a.DependentOn(p.UniverSheetsPlugin,p.UniverSheetsPlugin,S.UniverFindReplacePlugin),$(1,a.Inject(a.Injector)),$(2,a.IConfigService)],f.UniverSheetsFindReplacePlugin),f.SheetReplaceCommand=U,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
6
+ (function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/engine-render"),require("@univerjs/find-replace"),require("@univerjs/sheets-ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/engine-render","@univerjs/find-replace","@univerjs/sheets-ui","rxjs"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.UniverSheetsFindReplace={},f.UniverCore,f.UniverSheets,f.UniverEngineRender,f.UniverFindReplace,f.UniverSheetsUi,f.rxjs))})(this,(function(f,a,p,y,S,F,k){"use strict";var Se=Object.defineProperty;var me=(f,a,p)=>a in f?Se(f,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):f[a]=p;var m=(f,a,p)=>me(f,typeof a!="symbol"?a+"":a,p);const P={id:"sheet.command.replace",type:a.CommandType.COMMAND,handler:async(h,e)=>{const t=h.get(a.IUndoRedoService),i=h.get(a.ICommandService),{unitId:n,replacements:r}=e,s=t.__tempBatchingUndoRedo(n),o=await Promise.all(r.map(c=>i.executeCommand(p.SetRangeValuesCommand.id,{unitId:n,subUnitId:c.subUnitId,value:c.value})));return s.dispose(),q(o,r)}};function q(h,e){let t=0,i=0;return h.forEach((n,r)=>{const s=e[r].count;n?t+=s:i+=s}),{success:t,failure:i}}class K extends y.Shape{constructor(t,i){super(t,i);m(this,"_activated",!1);m(this,"_inHiddenRange",!1);m(this,"_color");i&&this.setShapeProps(i)}setShapeProps(t){this._activated=!!t.activated,typeof t.inHiddenRange<"u"&&(this._inHiddenRange=t.inHiddenRange),typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){const i=this._activated,n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, 0.35)`,r=`rgb(${this._color.r}, ${this._color.g}, ${this._color.b})`;y.Rect.drawWith(t,{width:this.width,height:this.height,fill:n,stroke:i?r:void 0,strokeWidth:i?2:0,evented:!1})}}function A(h,e){return h.startRow===e.startRow&&h.startColumn===e.startColumn}function D(h,e){return h.startRow<e.startRow||h.startRow===e.startRow&&h.startColumn<=e.startColumn}function N(h,e){return h.startColumn<e.startColumn||h.startColumn===e.startColumn&&h.startRow<=e.startRow}function Q(h,e){return h.startRow>e.startRow||h.startRow===e.startRow&&h.startColumn>=e.startColumn}function X(h,e){return h.startColumn>e.startColumn||h.startColumn===e.startColumn&&h.startRow>=e.startRow}function z(h,e){const{range:t}=h,{startRow:i,startColumn:n}=t,r=e.getMergedCell(i,n);return r?a.Rectangle.equals(t,r):t.endRow===t.startRow&&t.endColumn===t.startColumn}var J=Object.getOwnPropertyDescriptor,x=(h,e,t,i)=>{for(var n=i>1?void 0:i?J(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=s(n)||n);return n},C=(h,e)=>(t,i)=>e(t,i,h);f.SheetsFindReplaceController=class extends a.Disposable{constructor(t,i,n,r,s){super();m(this,"_provider");this._injector=t,this._findReplaceController=i,this._contextService=n,this._findReplaceService=r,this._commandService=s,this._init(),this._initCommands()}dispose(){super.dispose(),this._findReplaceController.closePanel(),this._provider.dispose()}_init(){const t=this._injector.createInstance(W);this._provider=t,this.disposeWithMe(this._findReplaceService.registerFindReplaceProvider(t)),this.disposeWithMe(this._contextService.subscribeContextValue$(a.EDITOR_ACTIVATED).pipe(k.filter(i=>!!i)).subscribe(()=>this._findReplaceController.closePanel()))}_initCommands(){[P].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t)))}},f.SheetsFindReplaceController=x([C(0,a.Inject(a.Injector)),C(1,a.Inject(S.FindReplaceController)),C(2,a.IContextService),C(3,S.IFindReplaceService),C(4,a.ICommandService)],f.SheetsFindReplaceController);const Z="sheets-find-replace-provider",ee=1e4;let B=class extends S.FindModel{constructor(e,t,i,n,r,s,o,c){super();m(this,"_matchesUpdate$",new k.Subject);m(this,"matchesUpdate$",this._matchesUpdate$.asObservable());m(this,"_activelyChangingMatch$",new k.Subject);m(this,"activelyChangingMatch$",this._activelyChangingMatch$.asObservable());m(this,"_matchesByWorksheet",new Map);m(this,"_matches",[]);m(this,"_matchesPosition",0);m(this,"_activeHighlightIndex",-1);m(this,"_highlightShapes",[]);m(this,"_currentHighlightShape",null);m(this,"_query",null);m(this,"_workbookSelections");this._workbook=e,this._sheetSkeletonManagerService=t,this._univerInstanceService=i,this._renderManagerService=n,this._commandService=r,this._contextService=s,this._themeService=o,this._workbookSelections=c.getWorkbookSelections(this.unitId)}get _matchesCount(){return this._matches.length}get unitId(){return this._workbook.getUnitId()}get matchesCount(){return this._matchesCount}get matchesPosition(){return this._matchesPosition}get currentMatch(){return this._matchesPosition>0?this._matches[this._matchesPosition-1]:null}dispose(){super.dispose(),this._disposeHighlights(),this._toggleDisplayRawFormula(!1)}getMatches(){return this._matches}start(e){switch(this._query=e,e.findBy===S.FindBy.FORMULA?this._toggleDisplayRawFormula(!0):this._toggleDisplayRawFormula(!1),e.findScope){case S.FindScope.UNIT:this.findInWorkbook(e);break;case S.FindScope.SUBUNIT:default:this.findInActiveWorksheet(e);break}}focusSelection(){const e=this.currentMatch;e&&this._commandService.executeCommand(p.SelectRangeCommand.id,{unitId:e.unitId,subUnit:e.range.subUnitId,range:e.range.range})}_toggleDisplayRawFormula(e){this._contextService.setContextValue(y.RENDER_RAW_FORMULA_KEY,e)}findInWorkbook(e){const t=this._workbook.getUnitId();let i,n=!0;const r=()=>{const s=this._workbook.getSheets().filter(o=>!o.isSheetHidden()).map(o=>{const c=this._findInWorksheet(o,e,t),d=o.getSheetId(),{results:l}=c;return l.length?this._matchesByWorksheet.set(d,c.results):this._matchesByWorksheet.delete(d),c});this._matches=s.map(o=>o.results).flat(),this._updateFindHighlight(),n?(i={results:this._matches},n=!1):this._matchesUpdate$.next(this._matches)};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._updateFindHighlight(),this._updateCurrentHighlightShape(this._activeHighlightIndex)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k.filter(([s,o])=>s.id===p.SetWorksheetActiveOperation.id&&!(o!=null&&o.fromFindReplace))).subscribe(()=>{const s=this._workbook.getActiveSheet();if(!s)return;const o=s.getSheetId();this._matchesByWorksheet.has(o)&&this._findNextMatchOnActiveSheetChange(s)})),this.disposeWithMe(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k.filter(([s])=>s.type===a.CommandType.MUTATION&&s.params.unitId===this._workbook.getUnitId()),k.throttleTime(600,void 0,{leading:!1,trailing:!0})).subscribe(()=>r())),r(),i}_findNextMatchOnActiveSheetChange(e){let t,i,n=0;const r=this._matchesByWorksheet.get(e.getSheetId()),s=this._workbookSelections.getCurrentSelections();s!=null&&s.length?([t,n]=this._findNextMatchByRange(r,s[0].range),i=r.findIndex(o=>o===t)):(t=r[0],i=0,n=this._matches.findIndex(o=>o===t)),this._matchesPosition=n+1,this._activelyChangingMatch$.next(t),this._activeHighlightIndex=i,this._updateFindHighlight(),this._updateCurrentHighlightShape(i)}findInActiveWorksheet(e){const t=this._workbook.getUnitId(),i=()=>{var u;const c=this._workbook.getActiveSheet();if(!c)return!1;const d=this._workbookSelections.getCurrentSelections();return(u=d==null?void 0:d.some(g=>!z(g,c)))!=null?u:!1};let n,r=!0,s=!1;const o=()=>{const c=this._workbook.getActiveSheet();if(!c)return{results:[]};const d=this.currentMatch;s=i();const l=this._workbookSelections.getCurrentSelections(),u=s?this._findInSelections(c,l,e,t):this._findInWorksheet(c,e,t);return this._matches=u.results,this._matchesPosition=this._tryRestoreLastMatchesPosition(d,this._matches),r?(n=u,r=!1):this._matchesUpdate$.next(this._matches),this._updateFindHighlight(),u};return this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>this._updateFindHighlight())),this.disposeWithMe(k.merge(a.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(k.filter(([c])=>{if(c.type===a.CommandType.MUTATION&&c.params.unitId===this._workbook.getUnitId())return!0;if(c.id===p.SetSelectionsOperation.id&&c.params.unitId===t){const d=i();return d===!1&&s===!1?!1:(s=d,!0)}return!1})),this._workbook.activeSheet$.pipe(k.skip(1))).pipe(k.debounceTime(200)).subscribe(()=>o())),o(),n}_findInRange(e,t,i,n,r){const s=[],o=e.getSheetId(),c=(t.findDirection===S.FindDirection.COLUMN?e.iterateByColumn:e.iterateByRow).bind(e)(i);for(const d of c){const{row:l,col:u,colSpan:g,rowSpan:v,value:I}=d;if(r!=null&&r(l,u)||!I||e.getRowFiltered(l))continue;const{hit:w,replaceable:M,isFormula:R}=te(e,l,u,t,I);if(w){const H={provider:Z,unitId:n,replaceable:M,isFormula:R,range:{subUnitId:o,range:{startRow:l,startColumn:u,endColumn:u+(g!=null?g:1)-1,endRow:l+(v!=null?v:1)-1}}};s.push(H)}}return{results:s}}_findInSelections(e,t,i,n){const{findDirection:r}=i,s=r===S.FindDirection.ROW?D:N,o=new Set;return{results:t.map(d=>this._findInRange(e,i,d.range,n,(l,u)=>{const g=`${l}-${u}`;return o.has(g)?!0:(o.add(g),!1)}).results).flat().sort((d,l)=>s(d.range.range,l.range.range)?-1:1)}}_findInWorksheet(e,t,i){const n=e.getRowCount(),r=e.getColumnCount(),s={startRow:0,startColumn:0,endRow:n-1,endColumn:r-1};return this._findInRange(e,t,s,i)}_disposeHighlights(){var e;this._highlightShapes.forEach(t=>{var i;(i=t.getScene())==null||i.makeDirty(),t.dispose()}),this._highlightShapes=[],(e=this._currentHighlightShape)==null||e.dispose(),this._currentHighlightShape=null}_updateFindHighlight(){var u;this._disposeHighlights();const e=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(!e)return;const t=this._workbook.getUnitId(),i=this._renderManagerService.getRenderById(t);if(i==null)return;const{scene:n}=i,r=this._matches,s=this._themeService.getColorFromTheme("yellow.400"),o=new a.ColorKit(s).toRgb(),c=this._workbook.getActiveSheet();if(!c)return;const d=c.getSheetId(),l=r.filter(g=>g.range.subUnitId===d).map((g,v)=>{const{startColumn:I,startRow:w,endColumn:M,endRow:R}=g.range.range,H=F.getCoordByCell(w,I,n,e),ae=F.getCoordByCell(R,M,n,e),{startX:G,startY:Y}=H,{endX:le,endY:de}=ae;let E=!0;for(let b=w;b<=R;b++)if(c.getRowRawVisible(b)){E=!1;break}let O=!0;for(let b=I;b<=M;b++)if(c.getColVisible(b)){O=!1;break}const ue=E||O,ge=O?2:le-G,fe=E?2:de-Y,_e={left:G,top:Y,color:o,width:ge,height:fe,evented:!1,inHiddenRange:ue,zIndex:ee};return new K(`find-highlight-${v}`,_e)});n.addObjects(l),this._highlightShapes=l,n.makeDirty()}_updateCurrentHighlightShape(e){var t;if((t=this._currentHighlightShape)==null||t.setShapeProps({activated:!1}),this._currentHighlightShape=null,e!==void 0){const i=this._highlightShapes[e];if(!i)return;this._currentHighlightShape=i,i.setShapeProps({activated:!0})}}_getSheetObject(){return F.getSheetObject(this._univerInstanceService,this._renderManagerService)}_focusMatch(e){var i;const t=e.range.subUnitId;t!==((i=this._workbook.getActiveSheet())==null?void 0:i.getSheetId())&&this._commandService.executeCommand(p.SetWorksheetActivateCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:t},{fromFindReplace:!0}),this._commandService.executeCommand(F.ScrollToCellCommand.id,{range:e.range.range},{fromFindReplace:!0})}_tryRestoreLastMatchesPosition(e,t){if(!e)return 0;const{subUnitId:i}=e.range,{startColumn:n,startRow:r}=e.range.range,s=t.findIndex(o=>{if(i!==o.range.subUnitId)return!1;const{startColumn:c,startRow:d}=o.range.range;return c===n&&d===r});return s>-1?s+1:0}moveToNextMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findNextMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}moveToPreviousMatch(e){var o,c,d,l,u;if(!this._matches.length)return null;const t=(o=e==null?void 0:e.loop)!=null?o:!1,i=(c=e==null?void 0:e.stayIfOnMatch)!=null?c:!1,n=(d=e==null?void 0:e.noFocus)!=null?d:!1,r=(l=e==null?void 0:e.ignoreSelection)!=null?l:!1,s=this._findPreviousMatch(t,i,r);if(s){const[g,v]=s;return this._matchesPosition=v+1,this._query.findScope===S.FindScope.UNIT?this._activeHighlightIndex=this._matchesByWorksheet.get(g.range.subUnitId).findIndex(I=>I===g):this._activeHighlightIndex=v,n||this._focusMatch(g),((u=this._workbook.getActiveSheet())==null?void 0:u.getSheetId())===g.range.subUnitId&&this._updateCurrentHighlightShape(this._activeHighlightIndex),g}return this._matchesPosition=0,this._updateCurrentHighlightShape(),null}_findPreviousMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c-1;if(!e&&d<0)return null;const l=this._matches.length,u=(d+l)%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n){const c=this._matches.length-1;return[this._matches[c],c]}if(this._query.findScope!==S.FindScope.UNIT)return this._findPreviousMatchByRange(this._matches,n.range);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findPreviousWorksheetThatHasAMatch(r,e);return s?this._findPreviousMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findNextMatch(e=!1,t=!1,i=!1){var o;if(this.currentMatch){const c=this._matches.findIndex(g=>g===this.currentMatch);if(t)return[this.currentMatch,c];const d=c+1,l=this._matches.length;if(!e&&d>=l)return null;const u=d%l;return[this._matches[u],u]}const n=this._workbookSelections.getCurrentLastSelection();if(i||!n)return[this._matches[0],0];if(this._query.findScope!==S.FindScope.UNIT)return this._findNextMatchByRange(this._matches,n.range,t);const r=(o=this._workbook.getActiveSheet())==null?void 0:o.getSheetId();if(!r)return null;const s=this._findNextWorksheetThatHasAMatch(r,e);return s?this._findNextMatchByRange(this._matchesByWorksheet.get(s),n.range):null}_findPreviousWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n+1):i.slice(0,n+1)).findLast(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextWorksheetThatHasAMatch(e,t=!1){const i=this._workbook.getSheetOrders(),n=i.findIndex(o=>o===e),s=(t?a.rotate(i,n):i.slice(n)).find(o=>this._matchesByWorksheet.has(o));return s!=null?s:null}_findNextMatchByRange(e,t,i=!1){const n=this._query.findDirection===S.FindDirection.ROW;let r=e.findIndex(o=>{const c=o.range.range;if(!(n?D(t,c):N(t,c)))return!1;const l=A(t,c);return i?l:!l});r===-1&&(r=e.length-1);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}_findPreviousMatchByRange(e,t,i=!1){const n=this._query.findDirection===S.FindDirection.ROW;let r=this._matches.findLastIndex(o=>{const c=o.range.range;if(!(n?Q(t,c):X(t,c)))return!1;const l=A(t,c);return i?l:!l});r===-1&&(r=0);const s=e[r];return[s,this._matches.findIndex(o=>o===s)]}async replace(e){if(this._matchesCount===0||!this.currentMatch||!this._query||!this.currentMatch.replaceable)return!1;const t=this.currentMatch.range,i=this._workbook.getSheetBySheetId(this.currentMatch.range.subUnitId),n=this._getReplacedCellData(this.currentMatch,i,this._query.findBy===S.FindBy.FORMULA,this._query.findString,e,this._query.caseSensitive?"g":"ig"),r={unitId:this.currentMatch.unitId,subUnitId:t.subUnitId,value:{[t.range.startRow]:{[t.range.startColumn]:n}}};return this._commandService.executeCommand(p.SetRangeValuesCommand.id,r)}async replaceAll(e){if(this._matchesCount===0||!this._query)return{success:0,failure:0};const t=this._workbook.getUnitId(),{findString:i,caseSensitive:n,findBy:r}=this._query,s=r===S.FindBy.FORMULA,o=n?"g":"ig",c=[];return a.groupBy(this._matches.filter(l=>l.replaceable),l=>l.range.subUnitId).forEach((l,u)=>{const g=new a.ObjectMatrix,v=this._workbook.getSheetBySheetId(u);l.forEach(I=>{const{startColumn:w,startRow:M}=I.range.range,R=this._getReplacedCellData(I,v,s,i,e,o);R&&g.setValue(M,w,R)}),c.push({count:l.length,subUnitId:u,value:g.getMatrix()})}),c?this._commandService.executeCommand(P.id,{unitId:t,replacements:c}):{success:0,failure:0}}_getReplacedCellData(e,t,i,n,r,s){var v;const o=e.range.range,{startRow:c,startColumn:d}=o,l=t.getCellRaw(c,d);if(e.isFormula)return i?{f:l.f.replace(new RegExp(j(n),s),r),v:null}:null;if(!!((v=l.p)!=null&&v.body)){const I=a.Tools.deepClone(l.p);return a.replaceInDocumentBody(I.body,n,r,this._query.caseSensitive),{p:I}}return{v:l.v.toString().replace(new RegExp(j(n),s),r)}}};B=x([C(2,a.IUniverInstanceService),C(3,y.IRenderManagerService),C(4,a.ICommandService),C(5,a.IContextService),C(6,a.Inject(a.ThemeService)),C(7,a.Inject(p.SheetsSelectionsService))],B);function j(h){return h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}let W=class extends a.Disposable{constructor(e,t,i){super();m(this,"_findModelsByUnitId",new Map);this._univerInstanceService=e,this._renderManagerService=t,this._injector=i}async find(e){this._terminate();const t=this._univerInstanceService.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return[];const i=this._preprocessQuery(e),n=this._renderManagerService.getRenderById(t.getUnitId()).with(F.SheetSkeletonManagerService),r=this._injector.createInstance(B,t,n);return this._findModelsByUnitId.set(t.getUnitId(),r),r.start(i),[r]}terminate(){this._terminate()}_terminate(){this._findModelsByUnitId.forEach(e=>e.dispose()),this._findModelsByUnitId.clear()}_preprocessQuery(e){let t=e.caseSensitive?e.findString:e.findString.toLowerCase();return t=t.trim(),{...e,findString:t}}};W=x([C(0,a.IUniverInstanceService),C(1,y.IRenderManagerService),C(2,a.Inject(a.Injector))],W);const _={hit:!1,replaceable:!1,isFormula:!1,rawData:null};function te(h,e,t,i,n){const{findBy:r}=i,s=r===S.FindBy.FORMULA,o=h.getCellRaw(e,t);return _.rawData=o,!(o!=null&&o.f)?(_.isFormula=!1,T(n,i)?o?(_.hit=!0,_.replaceable=!0):(_.hit=!0,_.replaceable=!1):(_.hit=!1,_.replaceable=!1),_):(_.isFormula=!0,s?T({v:o.f},i)?(_.hit=!0,_.replaceable=!0,_):(_.hit=!1,_.replaceable=!1,_):(_.replaceable=!1,T(n,i)?_.hit=!0:_.hit=!1,_))}function T(h,e){let t=ie(h);return t?e.matchesTheWholeCell?(t=ne(t),e.caseSensitive?t===e.findString:t.toLowerCase()===e.findString):e.caseSensitive?t.indexOf(e.findString)>-1:t.toLowerCase().indexOf(e.findString)>-1:!1}function ie(h){var t,i,n;const e=(n=(i=(t=h==null?void 0:h.p)==null?void 0:t.body)==null?void 0:i.dataStream)!=null?n:h==null?void 0:h.v;return typeof e=="number"?`${e}`:typeof e=="boolean"?e?"1":"0":e}function ne(h){return h.replace(/^ +/g,"").replace(/ +$/g,"")}const $={name:"@univerjs/sheets-find-replace",version:"0.17.0"},se="sheets-find-replace.config",L={};var re=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,he=(h,e,t)=>e in h?re(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t,ce=(h,e,t,i)=>{for(var n=i>1?void 0:i?oe(e,t):e,r=h.length-1,s;r>=0;r--)(s=h[r])&&(n=s(n)||n);return n},V=(h,e)=>(t,i)=>e(t,i,h),U=(h,e,t)=>he(h,typeof e!="symbol"?e+"":e,t);f.UniverSheetsFindReplacePlugin=class extends a.Plugin{constructor(e=L,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...n}=a.merge({},L,this._config);this._configService.setConfig(se,n)}onStarting(){[[f.SheetsFindReplaceController]].forEach(e=>this._injector.add(e))}onSteady(){this._injector.get(f.SheetsFindReplaceController)}},U(f.UniverSheetsFindReplacePlugin,"pluginName","SHEET_FIND_REPLACE_PLUGIN"),U(f.UniverSheetsFindReplacePlugin,"packageName",$.name),U(f.UniverSheetsFindReplacePlugin,"version",$.version),U(f.UniverSheetsFindReplacePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),f.UniverSheetsFindReplacePlugin=ce([a.DependentOn(p.UniverSheetsPlugin,p.UniverSheetsPlugin,S.UniverFindReplacePlugin),V(1,a.Inject(a.Injector)),V(2,a.IConfigService)],f.UniverSheetsFindReplacePlugin),f.SheetReplaceCommand=P,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
7
7
 
8
8
 
9
9
  // @univerjs/sheets-find-replace/facade
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-find-replace",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,16 +58,16 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/find-replace": "0.16.1",
62
- "@univerjs/sheets-find-replace": "0.16.1"
61
+ "@univerjs/find-replace": "0.17.0",
62
+ "@univerjs/sheets-find-replace": "0.17.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@univerjs/core": "0.16.1",
65
+ "@univerjs/core": "0.17.0",
66
66
  "react": "18.3.1",
67
67
  "react-dom": "18.3.1",
68
68
  "rxjs": "7.8.2",
69
69
  "typescript": "^5.9.3",
70
- "@univerjs-infra/shared": "0.16.1"
70
+ "@univerjs-infra/shared": "0.17.0"
71
71
  },
72
72
  "scripts": {
73
73
  "prebuild:preset": "tsx prepare.ts",