@lax-wp/editor 0.2.3 → 0.2.4
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.
|
@@ -6,6 +6,7 @@ export interface SidebarTool {
|
|
|
6
6
|
notVisible?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface ExpandableSidebarProps {
|
|
9
|
+
id: string;
|
|
9
10
|
tools: SidebarTool[];
|
|
10
11
|
position?: 'left' | 'right';
|
|
11
12
|
isExpanded?: boolean;
|
|
@@ -13,4 +14,4 @@ export interface ExpandableSidebarProps {
|
|
|
13
14
|
expandedWidth?: number;
|
|
14
15
|
toggleToolbar?: (isExpanded: boolean) => void;
|
|
15
16
|
}
|
|
16
|
-
export declare const ExpandableSidebar: ({ tools, position, isExpanded, defaultActiveTool, expandedWidth, toggleToolbar, }: ExpandableSidebarProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const ExpandableSidebar: ({ id, tools, position, isExpanded, defaultActiveTool, expandedWidth, toggleToolbar, }: ExpandableSidebarProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.es.js
CHANGED
|
@@ -73033,7 +73033,7 @@ const es = (e, t, n, r) => {
|
|
|
73033
73033
|
};
|
|
73034
73034
|
}, jm = !1, L2 = () => {
|
|
73035
73035
|
const { currentMode: e } = Wl(), { editorConfig: t } = Et(), { changes: n, acceptChange: r, rejectChange: i, navigateToChange: a, addComment: o, editComment: s, deleteComment: l, findChangeByMark: c, clearMarkHighlight: u } = Dh(), d = e === wi.SUGGESTING.value, [p, _] = K(null), [f, g] = K(/* @__PURE__ */ new Map()), [E, h] = K(null), S = Ke(/* @__PURE__ */ new Map()), y = Ce(() => {
|
|
73036
|
-
const T = /* @__PURE__ */ new Map(), w = document.querySelector("
|
|
73036
|
+
const T = /* @__PURE__ */ new Map(), w = document.querySelector("#editor-content-qwCfsdsfsd"), N = document.querySelector("#editor-sidebar-qwCfsdsfsd");
|
|
73037
73037
|
if (!w) return T;
|
|
73038
73038
|
const v = w.getBoundingClientRect();
|
|
73039
73039
|
let I = window.innerWidth;
|
|
@@ -73262,39 +73262,40 @@ const es = (e, t, n, r) => {
|
|
|
73262
73262
|
)
|
|
73263
73263
|
] });
|
|
73264
73264
|
}, P2 = ({
|
|
73265
|
-
|
|
73266
|
-
|
|
73267
|
-
|
|
73268
|
-
|
|
73269
|
-
|
|
73270
|
-
|
|
73265
|
+
id: e,
|
|
73266
|
+
tools: t,
|
|
73267
|
+
position: n = "right",
|
|
73268
|
+
isExpanded: r = !1,
|
|
73269
|
+
defaultActiveTool: i = null,
|
|
73270
|
+
expandedWidth: a = 320,
|
|
73271
|
+
toggleToolbar: o
|
|
73271
73272
|
}) => {
|
|
73272
|
-
const [
|
|
73273
|
-
(
|
|
73274
|
-
},
|
|
73275
|
-
|
|
73276
|
-
},
|
|
73277
|
-
return /* @__PURE__ */ m.jsxs("div", { className: `h-full flex ${
|
|
73278
|
-
/* @__PURE__ */ m.jsxs("div", { className: "h-full w-14 bg-white border border-neutral-200 flex flex-col relative z-10", children: [
|
|
73279
|
-
/* @__PURE__ */ m.jsx("div", { className: "flex-1 flex flex-col pt-3", children:
|
|
73273
|
+
const [s, l] = K(i), c = (_) => {
|
|
73274
|
+
(s !== _ || !r) && (o?.(!0), l(_));
|
|
73275
|
+
}, u = () => {
|
|
73276
|
+
o?.(!r), !r && !s && t.length > 0 ? l(t[0].id) : r && l(null);
|
|
73277
|
+
}, d = n === "left", p = t.find((_) => _.id === s);
|
|
73278
|
+
return /* @__PURE__ */ m.jsxs("div", { className: `h-full flex ${d ? "flex-row" : "flex-row-reverse"}`, children: [
|
|
73279
|
+
/* @__PURE__ */ m.jsxs("div", { id: e, className: "h-full w-14 bg-white border border-neutral-200 flex flex-col relative z-10", children: [
|
|
73280
|
+
/* @__PURE__ */ m.jsx("div", { className: "flex-1 flex flex-col pt-3", children: t.filter((_) => !_.notVisible).map((_) => /* @__PURE__ */ m.jsxs(
|
|
73280
73281
|
"button",
|
|
73281
73282
|
{
|
|
73282
|
-
onClick: () =>
|
|
73283
|
-
className: `w-full h-14 flex items-center justify-center transition-all duration-200 relative ${
|
|
73284
|
-
title:
|
|
73283
|
+
onClick: () => c(_.id),
|
|
73284
|
+
className: `w-full h-14 flex items-center justify-center transition-all duration-200 relative ${s === _.id && r ? "bg-blue-50 text-blue-600" : "text-gray-600 hover:bg-neutral-100 hover:text-neutral-900"}`,
|
|
73285
|
+
title: _.label,
|
|
73285
73286
|
children: [
|
|
73286
|
-
|
|
73287
|
-
/* @__PURE__ */ m.jsx("div", { className: `flex items-center justify-center ${
|
|
73287
|
+
s === _.id && r && /* @__PURE__ */ m.jsx("div", { className: `absolute ${d ? "right-0" : "left-0"} top-0 bottom-0 w-0.5 bg-primary-600` }),
|
|
73288
|
+
/* @__PURE__ */ m.jsx("div", { className: `flex items-center justify-center ${s === _.id && r ? "text-primary-400" : "text-neutral-400"} `, children: _.icon })
|
|
73288
73289
|
]
|
|
73289
73290
|
},
|
|
73290
|
-
|
|
73291
|
+
_.id
|
|
73291
73292
|
)) }),
|
|
73292
73293
|
/* @__PURE__ */ m.jsx(
|
|
73293
73294
|
"button",
|
|
73294
73295
|
{
|
|
73295
|
-
onClick:
|
|
73296
|
+
onClick: u,
|
|
73296
73297
|
className: "w-full h-12 flex items-center justify-center text-gray-600 hover:bg-neutral-100 hover:text-neutral-900 transition-colors",
|
|
73297
|
-
title:
|
|
73298
|
+
title: r ? "Collapse sidebar" : "Expand sidebar",
|
|
73298
73299
|
children: /* @__PURE__ */ m.jsx(oe, { name: "double-right-arrow", size: 16, strokeWidth: 2 })
|
|
73299
73300
|
}
|
|
73300
73301
|
)
|
|
@@ -73302,17 +73303,17 @@ const es = (e, t, n, r) => {
|
|
|
73302
73303
|
/* @__PURE__ */ m.jsx(
|
|
73303
73304
|
"div",
|
|
73304
73305
|
{
|
|
73305
|
-
className: `h-full bg-white ${
|
|
73306
|
+
className: `h-full bg-white ${d ? "border-r" : "border-l"} border-neutral-200 overflow-hidden transition-all duration-300 ease-in-out shadow-lg`,
|
|
73306
73307
|
style: {
|
|
73307
|
-
width:
|
|
73308
|
-
minWidth:
|
|
73308
|
+
width: r ? `${a}px` : "0px",
|
|
73309
|
+
minWidth: r ? `${a}px` : "0px"
|
|
73309
73310
|
},
|
|
73310
|
-
children:
|
|
73311
|
+
children: r && s && p && /* @__PURE__ */ m.jsx(
|
|
73311
73312
|
"div",
|
|
73312
73313
|
{
|
|
73313
|
-
className: `h-full transition-opacity duration-200 ${
|
|
73314
|
-
style: { width: `${
|
|
73315
|
-
children:
|
|
73314
|
+
className: `h-full transition-opacity duration-200 ${r ? "opacity-100 delay-100" : "opacity-0"}`,
|
|
73315
|
+
style: { width: `${a}px` },
|
|
73316
|
+
children: p.content
|
|
73316
73317
|
}
|
|
73317
73318
|
)
|
|
73318
73319
|
}
|
|
@@ -75077,6 +75078,7 @@ const { Dragger: X2 } = VS, Z2 = 200 * 1024 * 1024, J2 = ({
|
|
|
75077
75078
|
return /* @__PURE__ */ m.jsx(
|
|
75078
75079
|
P2,
|
|
75079
75080
|
{
|
|
75081
|
+
id: "editor-sidebar-qwCfsdsfsd",
|
|
75080
75082
|
tools: p,
|
|
75081
75083
|
position: e,
|
|
75082
75084
|
isExpanded: n,
|
|
@@ -75095,6 +75097,7 @@ const { Dragger: X2 } = VS, Z2 = 200 * 1024 * 1024, J2 = ({
|
|
|
75095
75097
|
{
|
|
75096
75098
|
className: `${i.enablePagination ? n : ""} editor-content`,
|
|
75097
75099
|
ref: e,
|
|
75100
|
+
id: "editor-content-qwCfsdsfsd",
|
|
75098
75101
|
children: [
|
|
75099
75102
|
/* @__PURE__ */ m.jsx(Gh, { editor: r }),
|
|
75100
75103
|
o && /* @__PURE__ */ m.jsx(s2, { editor: r })
|
package/dist/index.umd.js
CHANGED
|
@@ -112,11 +112,11 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
112
112
|
transition: zoom 0.2s ease;
|
|
113
113
|
}
|
|
114
114
|
`}),o&&m.jsx("div",{className:"editor-laser-pointer",style:{left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)"}})]})};var vu={},Ru={},no={exports:{}},ii={exports:{}},DM=ii.exports,TE;function MM(){return TE||(TE=1,(function(){var e,t,n,r,i,a;typeof performance<"u"&&performance!==null&&performance.now?ii.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(ii.exports=function(){return(e()-i)/1e6},t=process.hrtime,e=function(){var o;return o=t(),o[0]*1e9+o[1]},r=e(),a=process.uptime()*1e9,i=r-a):Date.now?(ii.exports=function(){return Date.now()-n},n=Date.now()):(ii.exports=function(){return new Date().getTime()-n},n=new Date().getTime())}).call(DM)),ii.exports}var yE;function kM(){if(yE)return no.exports;yE=1;for(var e=MM(),t=typeof window>"u"?Eh:window,n=["moz","webkit"],r="AnimationFrame",i=t["request"+r],a=t["cancel"+r]||t["cancelRequest"+r],o=0;!i&&o<n.length;o++)i=t[n[o]+"Request"+r],a=t[n[o]+"Cancel"+r]||t[n[o]+"CancelRequest"+r];if(!i||!a){var s=0,l=0,c=[],u=1e3/60;i=function(d){if(c.length===0){var p=e(),_=Math.max(0,u-(p-s));s=_+p,setTimeout(function(){var f=c.slice(0);c.length=0;for(var g=0;g<f.length;g++)if(!f[g].cancelled)try{f[g].callback(s)}catch(E){setTimeout(function(){throw E},0)}},Math.round(_))}return c.push({handle:++l,callback:d,cancelled:!1}),l},a=function(d){for(var p=0;p<c.length;p++)c[p].handle===d&&(c[p].cancelled=!0)}}return no.exports=function(d){return i.call(t,d)},no.exports.cancel=function(){a.apply(t,arguments)},no.exports.polyfill=function(d){d||(d=t),d.requestAnimationFrame=i,d.cancelAnimationFrame=a},no.exports}var ro={exports:{}},Nu,CE;function LM(){if(CE)return Nu;CE=1;var e=null,t=["Webkit","Moz","O","ms"];return Nu=function(r){e||(e=document.createElement("div"));var i=e.style;if(r in i)return r;for(var a=r.charAt(0).toUpperCase()+r.slice(1),o=t.length;o>=0;o--){var s=t[o]+a;if(s in i)return s}return!1},Nu}var Ou,vE;function PM(){if(vE)return Ou;vE=1,Ou=r;var e=/\s/,t=/(_|-|\.|:)/,n=/([a-z][A-Z]|[A-Z][a-z])/;function r(l){return e.test(l)?l.toLowerCase():t.test(l)?(a(l)||l).toLowerCase():n.test(l)?s(l).toLowerCase():l.toLowerCase()}var i=/[\W_]+(.|$)/g;function a(l){return l.replace(i,function(c,u){return u?" "+u:""})}var o=/(.)([A-Z]+)/g;function s(l){return l.replace(o,function(c,u,d){return u+" "+d.toLowerCase().split("").join(" ")})}return Ou}var Au,RE;function UM(){if(RE)return Au;RE=1;var e=PM();Au=t;function t(n){return e(n).replace(/[\W_]+(.|$)/g,function(r,i){return i?" "+i:""}).trim()}return Au}var Iu,NE;function BM(){if(NE)return Iu;NE=1;var e=UM();Iu=t;function t(n){return e(n).replace(/\s(\w)/g,function(r,i){return i.toUpperCase()})}return Iu}var xu,OE;function FM(){if(OE)return xu;OE=1;var e={animationIterationCount:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,stopOpacity:!0,strokeDashoffset:!0,strokeOpacity:!0,strokeWidth:!0};return xu=function(t,n){return typeof n=="number"&&!e[t]?n+"px":n},xu}var AE;function IE(){if(AE)return ro.exports;AE=1;var e=LM(),t=BM(),n={float:"cssFloat"},r=FM();function i(l,c,u){var d=n[c];if(typeof d>"u"&&(d=o(c)),d){if(u===void 0)return l.style[d];l.style[d]=r(d,u)}}function a(l,c){for(var u in c)c.hasOwnProperty(u)&&i(l,u,c[u])}function o(l){var c=t(l),u=e(c);return n[c]=n[l]=n[u]=u,u}function s(){arguments.length===2?typeof arguments[1]=="string"?arguments[0].style.cssText=arguments[1]:a(arguments[0],arguments[1]):i(arguments[0],arguments[1],arguments[2])}return ro.exports=s,ro.exports.set=s,ro.exports.get=function(l,c){return Array.isArray(c)?c.reduce(function(u,d){return u[d]=i(l,d||""),u},{}):i(l,c||"")},ro.exports}var wu={},xE;function GM(){return xE||(xE=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){return typeof n=="string"}})(wu)),wu}var Du={},wE;function HM(){return wE||(wE=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var t=IE(),n=r(t);function r(o){return o&&o.__esModule?o:{default:o}}var i=!1;function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;if(o&&i!==!1)return i;if(typeof document<"u"){var s=document.createElement("div");(0,n.default)(s,{width:100,height:100,position:"absolute",top:-9999,overflow:"scroll",MsOverflowStyle:"scrollbar"}),document.body.appendChild(s),i=s.offsetWidth-s.clientWidth,document.body.removeChild(s)}else i=0;return i||0}})(Du)),Du}var Mu={},DE;function YM(){return DE||(DE=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(){return!1}})(Mu)),Mu}var ku={},ME;function zM(){return ME||(ME=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){var r=n.clientWidth,i=getComputedStyle(n),a=i.paddingLeft,o=i.paddingRight;return r-parseFloat(a)-parseFloat(o)}})(ku)),ku}var Lu={},kE;function VM(){return kE||(kE=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;function t(n){var r=n.clientHeight,i=getComputedStyle(n),a=i.paddingTop,o=i.paddingBottom;return r-parseFloat(a)-parseFloat(o)}})(Lu)),Lu}var Wt={},LE;function $M(){return LE||(LE=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.containerStyleDefault={position:"relative",overflow:"hidden",width:"100%",height:"100%"},Wt.containerStyleAutoHeight={height:"auto"},Wt.viewStyleDefault={position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"scroll",WebkitOverflowScrolling:"touch"},Wt.viewStyleAutoHeight={position:"relative",top:void 0,left:void 0,right:void 0,bottom:void 0},Wt.viewStyleUniversalInitial={overflow:"hidden",marginRight:0,marginBottom:0},Wt.trackHorizontalStyleDefault={position:"absolute",height:6},Wt.trackVerticalStyleDefault={position:"absolute",width:6},Wt.thumbHorizontalStyleDefault={position:"relative",display:"block",height:"100%"},Wt.thumbVerticalStyleDefault={position:"relative",display:"block",width:"100%"},Wt.disableSelectStyle={userSelect:"none"},Wt.disableSelectStyleReset={userSelect:""}),Wt}var Lr={},PE;function WM(){if(PE)return Lr;PE=1,Object.defineProperty(Lr,"__esModule",{value:!0});var e=Object.assign||function(u){for(var d=1;d<arguments.length;d++){var p=arguments[d];for(var _ in p)Object.prototype.hasOwnProperty.call(p,_)&&(u[_]=p[_])}return u};Lr.renderViewDefault=a,Lr.renderTrackHorizontalDefault=o,Lr.renderTrackVerticalDefault=s,Lr.renderThumbHorizontalDefault=l,Lr.renderThumbVerticalDefault=c;var t=A,n=r(t);function r(u){return u&&u.__esModule?u:{default:u}}function i(u,d){var p={};for(var _ in u)d.indexOf(_)>=0||Object.prototype.hasOwnProperty.call(u,_)&&(p[_]=u[_]);return p}function a(u){return n.default.createElement("div",u)}function o(u){var d=u.style,p=i(u,["style"]),_=e({},d,{right:2,bottom:2,left:2,borderRadius:3});return n.default.createElement("div",e({style:_},p))}function s(u){var d=u.style,p=i(u,["style"]),_=e({},d,{right:2,bottom:2,top:2,borderRadius:3});return n.default.createElement("div",e({style:_},p))}function l(u){var d=u.style,p=i(u,["style"]),_=e({},d,{cursor:"pointer",borderRadius:"inherit",backgroundColor:"rgba(0,0,0,.2)"});return n.default.createElement("div",e({style:_},p))}function c(u){var d=u.style,p=i(u,["style"]),_=e({},d,{cursor:"pointer",borderRadius:"inherit",backgroundColor:"rgba(0,0,0,.2)"});return n.default.createElement("div",e({style:_},p))}return Lr}var UE;function qM(){return UE||(UE=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Object.assign||function(T){for(var D=1;D<arguments.length;D++){var N=arguments[D];for(var v in N)Object.prototype.hasOwnProperty.call(N,v)&&(T[v]=N[v])}return T},n=(function(){function T(D,N){for(var v=0;v<N.length;v++){var x=N[v];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(D,x.key,x)}}return function(D,N,v){return N&&T(D.prototype,N),v&&T(D,v),D}})(),r=kM(),i=R(r),a=IE(),o=R(a),s=A,l=lg(),c=R(l),u=GM(),d=R(u),p=HM(),_=R(p),f=YM(),g=R(f),E=zM(),h=R(E),S=VM(),y=R(S),C=$M(),b=WM();function R(T){return T&&T.__esModule?T:{default:T}}function M(T,D){var N={};for(var v in T)D.indexOf(v)>=0||Object.prototype.hasOwnProperty.call(T,v)&&(N[v]=T[v]);return N}function k(T,D){if(!(T instanceof D))throw new TypeError("Cannot call a class as a function")}function L(T,D){if(!T)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:T}function P(T,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);T.prototype=Object.create(D&&D.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(T,D):T.__proto__=D)}var F=(function(T){P(D,T);function D(N){var v;k(this,D);for(var x=arguments.length,B=Array(x>1?x-1:0),G=1;G<x;G++)B[G-1]=arguments[G];var w=L(this,(v=D.__proto__||Object.getPrototypeOf(D)).call.apply(v,[this,N].concat(B)));return w.getScrollLeft=w.getScrollLeft.bind(w),w.getScrollTop=w.getScrollTop.bind(w),w.getScrollWidth=w.getScrollWidth.bind(w),w.getScrollHeight=w.getScrollHeight.bind(w),w.getClientWidth=w.getClientWidth.bind(w),w.getClientHeight=w.getClientHeight.bind(w),w.getValues=w.getValues.bind(w),w.getThumbHorizontalWidth=w.getThumbHorizontalWidth.bind(w),w.getThumbVerticalHeight=w.getThumbVerticalHeight.bind(w),w.getScrollLeftForOffset=w.getScrollLeftForOffset.bind(w),w.getScrollTopForOffset=w.getScrollTopForOffset.bind(w),w.scrollLeft=w.scrollLeft.bind(w),w.scrollTop=w.scrollTop.bind(w),w.scrollToLeft=w.scrollToLeft.bind(w),w.scrollToTop=w.scrollToTop.bind(w),w.scrollToRight=w.scrollToRight.bind(w),w.scrollToBottom=w.scrollToBottom.bind(w),w.handleTrackMouseEnter=w.handleTrackMouseEnter.bind(w),w.handleTrackMouseLeave=w.handleTrackMouseLeave.bind(w),w.handleHorizontalTrackMouseDown=w.handleHorizontalTrackMouseDown.bind(w),w.handleVerticalTrackMouseDown=w.handleVerticalTrackMouseDown.bind(w),w.handleHorizontalThumbMouseDown=w.handleHorizontalThumbMouseDown.bind(w),w.handleVerticalThumbMouseDown=w.handleVerticalThumbMouseDown.bind(w),w.handleWindowResize=w.handleWindowResize.bind(w),w.handleScroll=w.handleScroll.bind(w),w.handleDrag=w.handleDrag.bind(w),w.handleDragEnd=w.handleDragEnd.bind(w),w.state={didMountUniversal:!1},w}return n(D,[{key:"componentDidMount",value:function(){this.addListeners(),this.update(),this.componentDidMountUniversal()}},{key:"componentDidMountUniversal",value:function(){var v=this.props.universal;v&&this.setState({didMountUniversal:!0})}},{key:"componentDidUpdate",value:function(){this.update()}},{key:"componentWillUnmount",value:function(){this.removeListeners(),(0,r.cancel)(this.requestFrame),clearTimeout(this.hideTracksTimeout),clearInterval(this.detectScrollingInterval)}},{key:"getScrollLeft",value:function(){return this.view?this.view.scrollLeft:0}},{key:"getScrollTop",value:function(){return this.view?this.view.scrollTop:0}},{key:"getScrollWidth",value:function(){return this.view?this.view.scrollWidth:0}},{key:"getScrollHeight",value:function(){return this.view?this.view.scrollHeight:0}},{key:"getClientWidth",value:function(){return this.view?this.view.clientWidth:0}},{key:"getClientHeight",value:function(){return this.view?this.view.clientHeight:0}},{key:"getValues",value:function(){var v=this.view||{},x=v.scrollLeft,B=x===void 0?0:x,G=v.scrollTop,w=G===void 0?0:G,U=v.scrollWidth,Y=U===void 0?0:U,q=v.scrollHeight,X=q===void 0?0:q,ee=v.clientWidth,de=ee===void 0?0:ee,te=v.clientHeight,re=te===void 0?0:te;return{left:B/(Y-de)||0,top:w/(X-re)||0,scrollLeft:B,scrollTop:w,scrollWidth:Y,scrollHeight:X,clientWidth:de,clientHeight:re}}},{key:"getThumbHorizontalWidth",value:function(){var v=this.props,x=v.thumbSize,B=v.thumbMinSize,G=this.view,w=G.scrollWidth,U=G.clientWidth,Y=(0,h.default)(this.trackHorizontal),q=Math.ceil(U/w*Y);return Y<=q?0:x||Math.max(q,B)}},{key:"getThumbVerticalHeight",value:function(){var v=this.props,x=v.thumbSize,B=v.thumbMinSize,G=this.view,w=G.scrollHeight,U=G.clientHeight,Y=(0,y.default)(this.trackVertical),q=Math.ceil(U/w*Y);return Y<=q?0:x||Math.max(q,B)}},{key:"getScrollLeftForOffset",value:function(v){var x=this.view,B=x.scrollWidth,G=x.clientWidth,w=(0,h.default)(this.trackHorizontal),U=this.getThumbHorizontalWidth();return v/(w-U)*(B-G)}},{key:"getScrollTopForOffset",value:function(v){var x=this.view,B=x.scrollHeight,G=x.clientHeight,w=(0,y.default)(this.trackVertical),U=this.getThumbVerticalHeight();return v/(w-U)*(B-G)}},{key:"scrollLeft",value:function(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.view&&(this.view.scrollLeft=v)}},{key:"scrollTop",value:function(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.view&&(this.view.scrollTop=v)}},{key:"scrollToLeft",value:function(){this.view&&(this.view.scrollLeft=0)}},{key:"scrollToTop",value:function(){this.view&&(this.view.scrollTop=0)}},{key:"scrollToRight",value:function(){this.view&&(this.view.scrollLeft=this.view.scrollWidth)}},{key:"scrollToBottom",value:function(){this.view&&(this.view.scrollTop=this.view.scrollHeight)}},{key:"addListeners",value:function(){if(!(typeof document>"u"||!this.view)){var v=this.view,x=this.trackHorizontal,B=this.trackVertical,G=this.thumbHorizontal,w=this.thumbVertical;v.addEventListener("scroll",this.handleScroll),(0,_.default)()&&(x.addEventListener("mouseenter",this.handleTrackMouseEnter),x.addEventListener("mouseleave",this.handleTrackMouseLeave),x.addEventListener("mousedown",this.handleHorizontalTrackMouseDown),B.addEventListener("mouseenter",this.handleTrackMouseEnter),B.addEventListener("mouseleave",this.handleTrackMouseLeave),B.addEventListener("mousedown",this.handleVerticalTrackMouseDown),G.addEventListener("mousedown",this.handleHorizontalThumbMouseDown),w.addEventListener("mousedown",this.handleVerticalThumbMouseDown),window.addEventListener("resize",this.handleWindowResize))}}},{key:"removeListeners",value:function(){if(!(typeof document>"u"||!this.view)){var v=this.view,x=this.trackHorizontal,B=this.trackVertical,G=this.thumbHorizontal,w=this.thumbVertical;v.removeEventListener("scroll",this.handleScroll),(0,_.default)()&&(x.removeEventListener("mouseenter",this.handleTrackMouseEnter),x.removeEventListener("mouseleave",this.handleTrackMouseLeave),x.removeEventListener("mousedown",this.handleHorizontalTrackMouseDown),B.removeEventListener("mouseenter",this.handleTrackMouseEnter),B.removeEventListener("mouseleave",this.handleTrackMouseLeave),B.removeEventListener("mousedown",this.handleVerticalTrackMouseDown),G.removeEventListener("mousedown",this.handleHorizontalThumbMouseDown),w.removeEventListener("mousedown",this.handleVerticalThumbMouseDown),window.removeEventListener("resize",this.handleWindowResize),this.teardownDragging())}}},{key:"handleScroll",value:function(v){var x=this,B=this.props,G=B.onScroll,w=B.onScrollFrame;G&&G(v),this.update(function(U){var Y=U.scrollLeft,q=U.scrollTop;x.viewScrollLeft=Y,x.viewScrollTop=q,w&&w(U)}),this.detectScrolling()}},{key:"handleScrollStart",value:function(){var v=this.props.onScrollStart;v&&v(),this.handleScrollStartAutoHide()}},{key:"handleScrollStartAutoHide",value:function(){var v=this.props.autoHide;v&&this.showTracks()}},{key:"handleScrollStop",value:function(){var v=this.props.onScrollStop;v&&v(),this.handleScrollStopAutoHide()}},{key:"handleScrollStopAutoHide",value:function(){var v=this.props.autoHide;v&&this.hideTracks()}},{key:"handleWindowResize",value:function(){(0,_.default)(!1),this.forceUpdate()}},{key:"handleHorizontalTrackMouseDown",value:function(v){v.preventDefault();var x=v.target,B=v.clientX,G=x.getBoundingClientRect(),w=G.left,U=this.getThumbHorizontalWidth(),Y=Math.abs(w-B)-U/2;this.view.scrollLeft=this.getScrollLeftForOffset(Y)}},{key:"handleVerticalTrackMouseDown",value:function(v){v.preventDefault();var x=v.target,B=v.clientY,G=x.getBoundingClientRect(),w=G.top,U=this.getThumbVerticalHeight(),Y=Math.abs(w-B)-U/2;this.view.scrollTop=this.getScrollTopForOffset(Y)}},{key:"handleHorizontalThumbMouseDown",value:function(v){v.preventDefault(),this.handleDragStart(v);var x=v.target,B=v.clientX,G=x.offsetWidth,w=x.getBoundingClientRect(),U=w.left;this.prevPageX=G-(B-U)}},{key:"handleVerticalThumbMouseDown",value:function(v){v.preventDefault(),this.handleDragStart(v);var x=v.target,B=v.clientY,G=x.offsetHeight,w=x.getBoundingClientRect(),U=w.top;this.prevPageY=G-(B-U)}},{key:"setupDragging",value:function(){(0,o.default)(document.body,C.disableSelectStyle),document.addEventListener("mousemove",this.handleDrag),document.addEventListener("mouseup",this.handleDragEnd),document.onselectstart=g.default}},{key:"teardownDragging",value:function(){(0,o.default)(document.body,C.disableSelectStyleReset),document.removeEventListener("mousemove",this.handleDrag),document.removeEventListener("mouseup",this.handleDragEnd),document.onselectstart=void 0}},{key:"handleDragStart",value:function(v){this.dragging=!0,v.stopImmediatePropagation(),this.setupDragging()}},{key:"handleDrag",value:function(v){if(this.prevPageX){var x=v.clientX,B=this.trackHorizontal.getBoundingClientRect(),G=B.left,w=this.getThumbHorizontalWidth(),U=w-this.prevPageX,Y=-G+x-U;this.view.scrollLeft=this.getScrollLeftForOffset(Y)}if(this.prevPageY){var q=v.clientY,X=this.trackVertical.getBoundingClientRect(),ee=X.top,de=this.getThumbVerticalHeight(),te=de-this.prevPageY,re=-ee+q-te;this.view.scrollTop=this.getScrollTopForOffset(re)}return!1}},{key:"handleDragEnd",value:function(){this.dragging=!1,this.prevPageX=this.prevPageY=0,this.teardownDragging(),this.handleDragEndAutoHide()}},{key:"handleDragEndAutoHide",value:function(){var v=this.props.autoHide;v&&this.hideTracks()}},{key:"handleTrackMouseEnter",value:function(){this.trackMouseOver=!0,this.handleTrackMouseEnterAutoHide()}},{key:"handleTrackMouseEnterAutoHide",value:function(){var v=this.props.autoHide;v&&this.showTracks()}},{key:"handleTrackMouseLeave",value:function(){this.trackMouseOver=!1,this.handleTrackMouseLeaveAutoHide()}},{key:"handleTrackMouseLeaveAutoHide",value:function(){var v=this.props.autoHide;v&&this.hideTracks()}},{key:"showTracks",value:function(){clearTimeout(this.hideTracksTimeout),(0,o.default)(this.trackHorizontal,{opacity:1}),(0,o.default)(this.trackVertical,{opacity:1})}},{key:"hideTracks",value:function(){var v=this;if(!this.dragging&&!this.scrolling&&!this.trackMouseOver){var x=this.props.autoHideTimeout;clearTimeout(this.hideTracksTimeout),this.hideTracksTimeout=setTimeout(function(){(0,o.default)(v.trackHorizontal,{opacity:0}),(0,o.default)(v.trackVertical,{opacity:0})},x)}}},{key:"detectScrolling",value:function(){var v=this;this.scrolling||(this.scrolling=!0,this.handleScrollStart(),this.detectScrollingInterval=setInterval(function(){v.lastViewScrollLeft===v.viewScrollLeft&&v.lastViewScrollTop===v.viewScrollTop&&(clearInterval(v.detectScrollingInterval),v.scrolling=!1,v.handleScrollStop()),v.lastViewScrollLeft=v.viewScrollLeft,v.lastViewScrollTop=v.viewScrollTop},100))}},{key:"raf",value:function(v){var x=this;this.requestFrame&&i.default.cancel(this.requestFrame),this.requestFrame=(0,i.default)(function(){x.requestFrame=void 0,v()})}},{key:"update",value:function(v){var x=this;this.raf(function(){return x._update(v)})}},{key:"_update",value:function(v){var x=this.props,B=x.onUpdate,G=x.hideTracksWhenNotNeeded,w=this.getValues();if((0,_.default)()){var U=w.scrollLeft,Y=w.clientWidth,q=w.scrollWidth,X=(0,h.default)(this.trackHorizontal),ee=this.getThumbHorizontalWidth(),de=U/(q-Y)*(X-ee),te={width:ee,transform:"translateX("+de+"px)"},re=w.scrollTop,ae=w.clientHeight,ue=w.scrollHeight,_e=(0,y.default)(this.trackVertical),Ie=this.getThumbVerticalHeight(),Q=re/(ue-ae)*(_e-Ie),Be={height:Ie,transform:"translateY("+Q+"px)"};if(G){var Nt={visibility:q>Y?"visible":"hidden"},yt={visibility:ue>ae?"visible":"hidden"};(0,o.default)(this.trackHorizontal,Nt),(0,o.default)(this.trackVertical,yt)}(0,o.default)(this.thumbHorizontal,te),(0,o.default)(this.thumbVertical,Be)}B&&B(w),typeof v=="function"&&v(w)}},{key:"render",value:function(){var v=this,x=(0,_.default)(),B=this.props;B.onScroll,B.onScrollFrame,B.onScrollStart,B.onScrollStop,B.onUpdate;var G=B.renderView,w=B.renderTrackHorizontal,U=B.renderTrackVertical,Y=B.renderThumbHorizontal,q=B.renderThumbVertical,X=B.tagName;B.hideTracksWhenNotNeeded;var ee=B.autoHide;B.autoHideTimeout;var de=B.autoHideDuration;B.thumbSize,B.thumbMinSize;var te=B.universal,re=B.autoHeight,ae=B.autoHeightMin,ue=B.autoHeightMax,_e=B.style,Ie=B.children,Q=M(B,["onScroll","onScrollFrame","onScrollStart","onScrollStop","onUpdate","renderView","renderTrackHorizontal","renderTrackVertical","renderThumbHorizontal","renderThumbVertical","tagName","hideTracksWhenNotNeeded","autoHide","autoHideTimeout","autoHideDuration","thumbSize","thumbMinSize","universal","autoHeight","autoHeightMin","autoHeightMax","style","children"]),Be=this.state.didMountUniversal,Nt=t({},C.containerStyleDefault,re&&t({},C.containerStyleAutoHeight,{minHeight:ae,maxHeight:ue}),_e),yt=t({},C.viewStyleDefault,{marginRight:x?-x:0,marginBottom:x?-x:0},re&&t({},C.viewStyleAutoHeight,{minHeight:(0,d.default)(ae)?"calc("+ae+" + "+x+"px)":ae+x,maxHeight:(0,d.default)(ue)?"calc("+ue+" + "+x+"px)":ue+x}),re&&te&&!Be&&{minHeight:ae,maxHeight:ue},te&&!Be&&C.viewStyleUniversalInitial),$={transition:"opacity "+de+"ms",opacity:0},Le=t({},C.trackHorizontalStyleDefault,ee&&$,(!x||te&&!Be)&&{display:"none"}),St=t({},C.trackVerticalStyleDefault,ee&&$,(!x||te&&!Be)&&{display:"none"});return(0,s.createElement)(X,t({},Q,{style:Nt,ref:function(be){v.container=be}}),[(0,s.cloneElement)(G({style:yt}),{key:"view",ref:function(be){v.view=be}},Ie),(0,s.cloneElement)(w({style:Le}),{key:"trackHorizontal",ref:function(be){v.trackHorizontal=be}},(0,s.cloneElement)(Y({style:C.thumbHorizontalStyleDefault}),{ref:function(be){v.thumbHorizontal=be}})),(0,s.cloneElement)(U({style:St}),{key:"trackVertical",ref:function(be){v.trackVertical=be}},(0,s.cloneElement)(q({style:C.thumbVerticalStyleDefault}),{ref:function(be){v.thumbVertical=be}}))])}}]),D})(s.Component);e.default=F,F.propTypes={onScroll:c.default.func,onScrollFrame:c.default.func,onScrollStart:c.default.func,onScrollStop:c.default.func,onUpdate:c.default.func,renderView:c.default.func,renderTrackHorizontal:c.default.func,renderTrackVertical:c.default.func,renderThumbHorizontal:c.default.func,renderThumbVertical:c.default.func,tagName:c.default.string,thumbSize:c.default.number,thumbMinSize:c.default.number,hideTracksWhenNotNeeded:c.default.bool,autoHide:c.default.bool,autoHideTimeout:c.default.number,autoHideDuration:c.default.number,autoHeight:c.default.bool,autoHeightMin:c.default.oneOfType([c.default.number,c.default.string]),autoHeightMax:c.default.oneOfType([c.default.number,c.default.string]),universal:c.default.bool,style:c.default.object,children:c.default.node},F.defaultProps={renderView:b.renderViewDefault,renderTrackHorizontal:b.renderTrackHorizontalDefault,renderTrackVertical:b.renderTrackVerticalDefault,renderThumbHorizontal:b.renderThumbHorizontalDefault,renderThumbVertical:b.renderThumbVerticalDefault,tagName:"div",thumbMinSize:30,hideTracksWhenNotNeeded:!1,autoHide:!1,autoHideTimeout:1e3,autoHideDuration:200,autoHeight:!1,autoHeightMin:0,autoHeightMax:200,universal:!1}})(Ru)),Ru}var BE;function KM(){return BE||(BE=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Scrollbars=void 0;var t=qM(),n=r(t);function r(i){return i&&i.__esModule?i:{default:i}}e.default=n.default,e.Scrollbars=n.default})(vu)),vu}var jM=KM();function QM({children:e}){return m.jsx(jM.Scrollbars,{autoHide:!0,autoHideTimeout:1e3,autoHideDuration:1e3,universal:!0,renderThumbVertical:t=>m.jsx("div",{...t,style:{backgroundColor:"rgba(100, 100, 100, 0.5)",borderRadius:"6px"}}),renderTrackVertical:t=>m.jsx("div",{...t,style:{backgroundColor:"rgba(0, 0, 0, 0.05)"},onMouseEnter:n=>n.currentTarget.style.backgroundColor="rgba(0,0,0,0.1)",onMouseLeave:n=>n.currentTarget.style.backgroundColor="rgba(0,0,0,0.05)"}),children:e})}const FE=({profilePic:e,name:t,size:n="md"})=>{const r={xs:"w-4 h-4 text-[7px] font-bold",sm:"w-6 h-6 text-[10px] font-bold",md:"w-9 h-9 text-[14px] font-semibold",lg:"w-12 h-12 text-[18px] font-semibold",xl:"w-16 h-16 text-[24px] font-semibold"},i=A.useRef({}),[a,o]=A.useState(!1),s=e?i.current[e]:void 0;return A.useEffect(()=>{if(e)if(i.current[e])o(!0);else{o(!1);const l=new Image;l.src=e,l.onload=()=>{i.current[e]=l.src,o(!0)},l.onerror=()=>{o(!1)}}else o(!1)},[e]),m.jsx("div",{className:`relative ${r[n]}`,children:s&&a?m.jsx("img",{src:s,alt:"Profile",className:"rounded-full border object-cover w-full h-full border-primary-200 dark:border-neutral-800",onError:()=>o(!1)}):t?m.jsx("div",{className:"bg-primary-100 text-primary-600 flex items-center justify-center rounded-full border dark:bg-black-700 w-full h-full border-primary-200 dark:border-neutral-800",children:yh(t)}):m.jsx("div",{className:"p-1 rounded-full bg-neutral-200 dark:bg-black-600 flex items-center justify-center border w-full h-full border-primary-200 dark:border-neutral-800",children:m.jsx(oe,{name:"person",className:"text-neutral-900"})})})},{TextArea:XM}=he.Input,GE=e=>{const t=new Date(e),n=Math.floor((Date.now()-t.getTime())/6e4);return n<1?"Just now":n<60?`${n} minute${n!==1?"s":""}`:n<1440?`${Math.floor(n/60)} hour${Math.floor(n/60)!==1?"s":""}`:t.toLocaleDateString()},HE=(e,t)=>e.length>t?`${e.substring(0,t)}...`:e,Pu=A.forwardRef(({change:e,onAccept:t,onReject:n,onNavigate:r,onAddComment:i,onEditComment:a,onDeleteComment:o,currentUser:s,isActive:l=!1,onSetActive:c,isSuggestingMode:u=!0,showComments:d=!0},p)=>{const _=e.type.includes("insertion"),f=e.type.includes("deletion"),g=e.type.includes("ai"),E=e.nodeType==="table",h=e.nodeType==="link"||!!e.linkData,S=!!e.formatChanges&&!h,[y,C]=A.useState(""),[b,R]=A.useState(null),[M,k]=A.useState(null),[L,P]=A.useState(""),[F,T]=A.useState(new Set),[D,N]=A.useState(!1),{editorConfig:v}=_t(),x=v.allUsers,B=A.useRef(null),G=150,w=()=>h?"text-[#2196F3]":S?"text-[#FF9800]":_?"text-[#4CAF50]":f?"text-[#F44336]":"text-gray-600",U=()=>{if(h&&e.linkData){if(e.linkData.action==="add")return"Add link:";if(e.linkData.action==="remove")return"Delete link:";if(e.linkData.action==="change")return"Change link:"}return E?`${_?"Add":f?"Delete":"Change"} Table`:e.formatChanges?"Format:":_?"Add:":f?"Delete:":"Change:"},Y=()=>{if(!e.formatChanges)return"";try{const $=JSON.parse(e.formatChanges),Le={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",superscript:"Superscript",subscript:"Subscript",color:"Text Color",backgroundColor:"Background",highlight:"Highlight",fontSize:"Font Size",fontFamily:"Font"};return Object.entries($).map(([mt,be])=>{if(mt==="link"){const Pt=be.old,mn=be.new;return!Pt||Pt===""||Pt==="off"?`Add link: with url "${mn}"`:!mn||mn===""||mn==="off"?`Delete link: with url "${Pt}"`:`Change link: from "${Pt}" to "${mn}"`}const Vi=Le[mt]||mt,Pr=be.old===null||be.old===!1?"off":be.old===!0?"on":be.old,ai=be.new===null||be.new===!1?"off":be.new===!0?"on":be.new;return`${Vi}: ${Pr} → ${ai}`}).join(", ")}catch{return"Format changes"}},q=()=>{if(h&&e.linkData){if(e.linkData.action==="add")return`with url "${e.linkData.url}"`;if(e.linkData.action==="remove")return`with url "${e.linkData.url}"`;if(e.linkData.action==="change")return`from "${e.linkData.oldUrl}" to "${e.linkData.url}"`}if(e.formatChanges)return Y();if(E&&e.tableData)return HE(e.tableData,150);if(e.content.trim().length===0){const $=e.content.length;return`${$} ${$===1?"space":"spaces"}`}return HE(e.content,100)},X=()=>{const $=y.trim();$&&(i(e.id,$),C(""))},ee=($,Le)=>{k($),P(Le),R(null)},de=$=>{const Le=L.trim();Le&&(a(e.id,$,Le),k(null),P(""))},te=()=>{k(null),P("")},re=$=>{o(e.id,$),R(null)},ae=$=>{T(Le=>{const St=new Set(Le);return St.has($)?St.delete($):St.add($),St})},ue=$=>$.length>G,_e=($,Le)=>!ue(Le)||F.has($)?Le:Le.substring(0,G)+"...",Ie=$=>{$.stopPropagation(),r(e.position,e.timestamp,e.userId),c?.()},Q=$=>$.stopPropagation();A.useEffect(()=>{const $=Le=>{B.current&&!B.current.contains(Le.target)&&R(null)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const Be=!!e.comments?.length,Nt=x?.find($=>$.id===e.userId),yt=g?"AI Assistant":Nt?.name||e.userName;return m.jsxs("div",{ref:p,className:`bg-white rounded-lg border p-4 mt-1 cursor-pointer transition-all duration-200 hover:shadow-[0_4px_12px_rgba(0,0,0,0.1)] hover:-translate-y-0.5 ${l?"border-[#2196F3] border-2":"border-gray-300 border-2"}`,onClick:Ie,children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(FE,{name:yt,profilePic:g?void 0:Nt?.profilePic||e.userProfilePic,size:"md"}),m.jsx("div",{className:"flex-1 min-w-0",children:m.jsxs("div",{className:"flex flex-col",children:[m.jsxs("div",{className:"w-full flex items-center justify-between",children:[m.jsx("span",{className:"text-sm font-semibold text-gray-900 whitespace-nowrap truncate",children:yt}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(ce,{size:"small",onClick:()=>n(e.id),className:"flex items-center gap-1 !text-[#F44336] hover:!bg-red-50 rounded-full",title:"Reject change",children:m.jsx(le.CloseRounded,{sx:{fontSize:16}})}),m.jsx(ce,{size:"small",onClick:()=>t(e.id),className:"flex items-center gap-1 !text-[#4CAF50] hover:!bg-green-50 rounded-full",title:"Accept change",children:m.jsx(le.CheckRounded,{sx:{fontSize:16}})})]})]}),m.jsx("span",{className:"text-xs text-gray-500 whitespace-nowrap",children:GE(e.timestamp)})]})})]}),m.jsxs("div",{className:"flex items-start gap-1.5 mt-2",children:[m.jsx("span",{className:`text-sm font-medium whitespace-nowrap ${w()}`,children:U()}),m.jsx("span",{className:"text-sm text-gray-800 break-words",children:q()})]}),Be&&d&&D&&l&&m.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 space-y-4",children:e.comments?.map($=>{const Le=M===$.id,mt=s?.id===$.userId&&!Le&&u;return m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx(FE,{name:$.userName,size:"sm"}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[m.jsx("span",{className:"text-sm font-semibold text-gray-900",children:$.userName}),m.jsx("span",{className:"text-xs text-gray-500",children:GE($.timestamp)}),mt&&m.jsxs("div",{className:"relative ml-auto",ref:b===$.id?B:null,children:[m.jsx("button",{onClick:be=>{be.stopPropagation(),R(b===$.id?null:$.id)},className:"p-1 hover:bg-gray-100 rounded transition-colors",title:"More options",children:m.jsx(oe,{name:"three-dots-vertical",size:12,className:"text-gray-400"})}),b===$.id&&m.jsxs("div",{className:"absolute right-0 top-8 bg-white border border-gray-200 rounded-lg shadow-lg z-10 min-w-[120px]",children:[m.jsxs("button",{onClick:be=>{be.stopPropagation(),ee($.id,$.text)},className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 text-gray-700",children:[m.jsx(le.EditOutlined,{sx:{fontSize:16}}),"Edit"]}),m.jsxs("button",{onClick:be=>{be.stopPropagation(),re($.id)},className:"w-full px-3 py-2 text-left text-sm hover:bg-gray-50 flex items-center gap-2 text-red-600",children:[m.jsx(le.DeleteOutline,{sx:{fontSize:16}}),"Delete"]})]})]})]}),Le?m.jsxs("div",{className:"space-y-2",children:[m.jsx(XM,{value:L,onChange:be=>P(be.target.value),rows:2,autoFocus:!0,onClick:Q,onKeyDown:be=>{be.key==="Enter"&&(be.metaKey||be.ctrlKey)&&de($.id),be.key==="Escape"&&te()}}),m.jsxs("div",{className:"flex gap-2 justify-end",onClick:Q,children:[m.jsx(ce,{size:"small",onClick:te,className:"text-gray-600 hover:bg-gray-50",children:"Cancel"}),m.jsxs(ce,{size:"small",onClick:()=>de($.id),className:"flex items-center gap-1 text-blue-600 hover:bg-blue-50",disabled:!L.trim(),children:[m.jsx(le.SendRounded,{sx:{fontSize:14}}),"Save"]})]})]}):m.jsxs("div",{children:[m.jsx("p",{className:"text-sm text-gray-700 break-words whitespace-pre-wrap",children:_e($.id,$.text)}),ue($.text)&&m.jsx("button",{onClick:be=>{be.stopPropagation(),ae($.id)},className:"text-xs text-blue-600 hover:text-blue-800 font-medium mt-1",children:F.has($.id)?"Show less":"Show more"})]})]})]},$.id)})}),l&&u&&d&&D&&m.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200",onClick:Q,children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"flex-1 relative",children:m.jsx("input",{type:"text",value:y,onChange:$=>C($.target.value),placeholder:"Add feedback...",className:"w-full px-4 py-3 pr-12 text-sm border border-gray-200 rounded-lg focus:outline-none focus:border-[#2196F3] focus:ring-1 focus:ring-[#2196F3] transition-colors",onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),X())}})}),m.jsx("button",{onClick:X,disabled:!y.trim(),className:`p-2 transition-colors ${y.trim()?"text-[#2196F3] hover:text-[#1976D2] cursor-pointer":"text-gray-300 cursor-not-allowed"}`,title:"Send feedback",children:m.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),m.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})})]})});Pu.displayName="RedlineItem";const xl=(e,t,n,r)=>{if(!e.isText||!e.text)return null;const i=e.marks.find(o=>o.type.name===n);if(!i)return null;const a={pos:t,endPos:t+e.text.length,text:e.text,type:r,userId:i.attrs.userId||(r.includes("ai")?"ai":"unknown"),userName:i.attrs.userName||(r.includes("ai")?"AI":"User"),timestamp:i.attrs.timestamp||new Date().toISOString(),nodeType:i.attrs.linkData?"link":"text"};return i.attrs.formatChanges&&(a.formatChanges=i.attrs.formatChanges),i.attrs.linkData&&(a.linkData=i.attrs.linkData),a},ZM=e=>{const t=[];return e.descendants(n=>{if(n.type.name==="tableCell"||n.type.name==="tableHeader"){const r=n.textContent.trim();r&&t.push(r)}}),t.join(" | ")},JM=(e,t)=>{if(e.type.name!=="table")return null;const n=e.attrs["data-redline-type"];if(!n)return null;const r=ZM(e);return{pos:t,endPos:t+e.nodeSize,text:"table",type:n,userId:e.attrs["data-redline-user-id"]||"unknown",userName:e.attrs["data-redline-user-name"]||"User",timestamp:e.attrs["data-redline-timestamp"]||new Date().toISOString(),nodeType:"table",tableData:r}},ek=(e,t)=>{const n=t.pos-e.endPos;return n>=0&&n<=4&&t.type===e.type&&t.userId===e.userId&&t.timestamp===e.timestamp?e.formatChanges||t.formatChanges?e.formatChanges===t.formatChanges:e.linkData||t.linkData?e.linkData===t.linkData:!0:!1},tk=e=>{const t=[];let n=0;for(;n<e.length;){const r=e[n];let i=r.text,a=r.endPos,o=n+1;for(;o<e.length;){const l=e[o];if(ek({...r,endPos:a},l))l.pos-a>0&&(i+=`
|
|
115
|
-
`),i+=l.text,a=l.endPos,o++;else break}const s={id:`${r.type}-${r.pos}-${r.timestamp}`,type:r.type,content:i,userId:r.userId,userName:r.userName,timestamp:r.timestamp,position:r.pos};if(r.nodeType==="table"&&(s.nodeType="table",s.tableData=r.tableData),r.nodeType==="link"&&r.linkData){s.nodeType="link";try{s.linkData=JSON.parse(r.linkData)}catch{}}r.formatChanges&&(s.formatChanges=r.formatChanges),t.push(s),n=o}return t},wl=(e,t,n)=>{const{state:r}=e,{tr:i}=r;if(t.nodeType==="table"){const d=t.position,p=r.doc.nodeAt(d);if(p&&p.type.name==="table")return t.type.includes("insertion")?n==="accept"?i.setNodeMarkup(d,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null}):i.delete(d,d+p.nodeSize):n==="accept"?i.delete(d,d+p.nodeSize):i.setNodeMarkup(d,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null}),i.docChanged?(e.view.dispatch(i),!0):!1}const a=!!t.formatChanges,o=[],s=t.type.includes("insertion"),l=t.type.includes("deletion"),c=t.type.includes("ai")?s?"aiInsertion":"aiDeletion":s?"userInsertion":"userDeletion",u=r.schema.marks[c];if(!u)return!1;if(r.doc.descendants((d,p)=>{if(!d.isText)return;d.marks.find(f=>f.type.name===c&&f.attrs.timestamp===t.timestamp&&f.attrs.userId===t.userId)&&d.text&&o.push({from:p,to:p+d.text.length})}),a){let d={};try{t.formatChanges&&(d=JSON.parse(t.formatChanges))}catch{console.error("Failed to parse format changes")}for(const p of o)if(n==="accept")i.removeMark(p.from,p.to,u);else{i.removeMark(p.from,p.to,u);const _={};let f=!1;const h=r.doc.nodeAt(p.from)?.marks.find(S=>S.type.name==="textStyle")?.attrs||{};if(Object.keys(d).forEach(S=>{const{old:y,new:C}=d[S];if(["bold","italic","underline","strike","superscript","subscript"].includes(S)){const R=r.schema.marks[S];R&&(C&&i.removeMark(p.from,p.to,R),y&&i.addMark(p.from,p.to,R.create()))}else["color","backgroundColor","fontSize","fontFamily"].includes(S)?(_[S]=y,f=!0):S==="highlight"&&r.schema.marks.highlight&&(i.removeMark(p.from,p.to,r.schema.marks.highlight),y&&y!==null&&i.addMark(p.from,p.to,r.schema.marks.highlight.create({color:y})))}),f&&r.schema.marks.textStyle){i.removeMark(p.from,p.to,r.schema.marks.textStyle);const S={...h,..._};Object.keys(S).forEach(y=>{(S[y]===null||S[y]===void 0)&&delete S[y]}),Object.keys(S).length>0&&i.addMark(p.from,p.to,r.schema.marks.textStyle.create(S))}}}else{(s&&n==="reject"||l&&n==="accept")&&o.sort((d,p)=>p.from-d.from);for(const d of o)s?n==="accept"?i.removeMark(d.from,d.to,u):i.delete(d.from,d.to):l&&(n==="accept"?i.delete(d.from,d.to):i.removeMark(d.from,d.to,u))}return i.docChanged?(e.view.dispatch(i),!0):!1},YE=()=>{const{editor:e,editorConfig:t}=_t(),[n,r]=A.useState([]),i=A.useCallback(()=>{if(!e)return;const{state:E}=e,{doc:h}=E,S=[];h.descendants((C,b)=>{const R=JM(C,b);if(R)return S.push(R),!1;const M=xl(C,b,"userInsertion","user-insertion");M&&S.push(M);const k=xl(C,b,"userDeletion","user-deletion");k&&S.push(k);const L=xl(C,b,"aiInsertion","ai-insertion");L&&S.push(L);const P=xl(C,b,"aiDeletion","ai-deletion");P&&S.push(P)}),S.sort((C,b)=>C.pos-b.pos);const y=tk(S);r(y)},[e]);A.useEffect(()=>{if(!e)return;i();const E=()=>i();return e.on("update",E),()=>{e.off("update",E)}},[e,i]);const a=A.useCallback(E=>{if(!e)return;const h=n.find(S=>S.id===E);h&&wl(e,h,"accept")},[e,n]),o=A.useCallback(E=>{if(!e)return;const h=n.find(S=>S.id===E);h&&wl(e,h,"reject")},[e,n]),s=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((h,S)=>S.position-h.position).forEach(h=>{wl(e,h,"accept")})},[e,n]),l=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((h,S)=>S.position-h.position).forEach(h=>{wl(e,h,"reject")})},[e,n]),c=A.useCallback((E,h,S)=>{if(e)try{e.commands.focus(),e.commands.setTextSelection(E),h!==void 0&&S!==void 0&&e.commands.highlightMark(h,S);const{view:y}=e,C=y.coordsAtPos(E);C&&document.elementFromPoint(C.left,C.top)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}catch(y){console.error("Error navigating to change:",y)}},[e]),u=A.useCallback((E,h)=>{if(e)try{e.commands.highlightMark(E,h)}catch(S){console.error("Error highlighting mark:",S)}},[e]),d=A.useCallback(()=>{if(e)try{e.commands.highlightMark(null,null)}catch(E){console.error("Error clearing mark highlight:",E)}},[e]),p=A.useCallback((E,h)=>{r(S=>S.map(y=>{if(y.id===E){const C={id:`comment-${Date.now()}-${Math.random()}`,userId:t.currentUser?.id||"unknown",userName:t.currentUser?.name||"User",timestamp:new Date().toISOString(),text:h};return{...y,comments:[...y.comments||[],C]}}return y}))},[t.currentUser]),_=A.useCallback((E,h,S)=>{r(y=>y.map(C=>C.id===E&&C.comments?{...C,comments:C.comments.map(b=>b.id===h?{...b,text:S}:b)}:C))},[]),f=A.useCallback((E,h)=>{r(S=>S.map(y=>y.id===E&&y.comments?{...y,comments:y.comments.filter(C=>C.id!==h)}:y))},[]),g=A.useCallback((E,h)=>n.find(S=>S.timestamp===E&&S.userId===h)||null,[n]);return{changes:n,acceptChange:a,rejectChange:o,acceptAllChanges:s,rejectAllChanges:l,navigateToChange:c,scanChanges:i,addComment:p,editComment:_,deleteComment:f,findChangeByMark:g,highlightMark:u,clearMarkHighlight:d}},zE=!1,nk=()=>{const{currentMode:e}=Tl(),{editorConfig:t}=_t(),{changes:n,acceptChange:r,rejectChange:i,navigateToChange:a,addComment:o,editComment:s,deleteComment:l,findChangeByMark:c,clearMarkHighlight:u}=YE(),d=e===di.SUGGESTING.value,[p,_]=A.useState(null),[f,g]=A.useState(new Map),[E,h]=A.useState(null),S=A.useRef(new Map),y=A.useCallback(()=>{const T=new Map,D=document.querySelector("
|
|
115
|
+
`),i+=l.text,a=l.endPos,o++;else break}const s={id:`${r.type}-${r.pos}-${r.timestamp}`,type:r.type,content:i,userId:r.userId,userName:r.userName,timestamp:r.timestamp,position:r.pos};if(r.nodeType==="table"&&(s.nodeType="table",s.tableData=r.tableData),r.nodeType==="link"&&r.linkData){s.nodeType="link";try{s.linkData=JSON.parse(r.linkData)}catch{}}r.formatChanges&&(s.formatChanges=r.formatChanges),t.push(s),n=o}return t},wl=(e,t,n)=>{const{state:r}=e,{tr:i}=r;if(t.nodeType==="table"){const d=t.position,p=r.doc.nodeAt(d);if(p&&p.type.name==="table")return t.type.includes("insertion")?n==="accept"?i.setNodeMarkup(d,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null}):i.delete(d,d+p.nodeSize):n==="accept"?i.delete(d,d+p.nodeSize):i.setNodeMarkup(d,void 0,{...p.attrs,"data-redline-type":null,"data-redline-user-id":null,"data-redline-user-name":null,"data-redline-timestamp":null}),i.docChanged?(e.view.dispatch(i),!0):!1}const a=!!t.formatChanges,o=[],s=t.type.includes("insertion"),l=t.type.includes("deletion"),c=t.type.includes("ai")?s?"aiInsertion":"aiDeletion":s?"userInsertion":"userDeletion",u=r.schema.marks[c];if(!u)return!1;if(r.doc.descendants((d,p)=>{if(!d.isText)return;d.marks.find(f=>f.type.name===c&&f.attrs.timestamp===t.timestamp&&f.attrs.userId===t.userId)&&d.text&&o.push({from:p,to:p+d.text.length})}),a){let d={};try{t.formatChanges&&(d=JSON.parse(t.formatChanges))}catch{console.error("Failed to parse format changes")}for(const p of o)if(n==="accept")i.removeMark(p.from,p.to,u);else{i.removeMark(p.from,p.to,u);const _={};let f=!1;const h=r.doc.nodeAt(p.from)?.marks.find(S=>S.type.name==="textStyle")?.attrs||{};if(Object.keys(d).forEach(S=>{const{old:y,new:C}=d[S];if(["bold","italic","underline","strike","superscript","subscript"].includes(S)){const R=r.schema.marks[S];R&&(C&&i.removeMark(p.from,p.to,R),y&&i.addMark(p.from,p.to,R.create()))}else["color","backgroundColor","fontSize","fontFamily"].includes(S)?(_[S]=y,f=!0):S==="highlight"&&r.schema.marks.highlight&&(i.removeMark(p.from,p.to,r.schema.marks.highlight),y&&y!==null&&i.addMark(p.from,p.to,r.schema.marks.highlight.create({color:y})))}),f&&r.schema.marks.textStyle){i.removeMark(p.from,p.to,r.schema.marks.textStyle);const S={...h,..._};Object.keys(S).forEach(y=>{(S[y]===null||S[y]===void 0)&&delete S[y]}),Object.keys(S).length>0&&i.addMark(p.from,p.to,r.schema.marks.textStyle.create(S))}}}else{(s&&n==="reject"||l&&n==="accept")&&o.sort((d,p)=>p.from-d.from);for(const d of o)s?n==="accept"?i.removeMark(d.from,d.to,u):i.delete(d.from,d.to):l&&(n==="accept"?i.delete(d.from,d.to):i.removeMark(d.from,d.to,u))}return i.docChanged?(e.view.dispatch(i),!0):!1},YE=()=>{const{editor:e,editorConfig:t}=_t(),[n,r]=A.useState([]),i=A.useCallback(()=>{if(!e)return;const{state:E}=e,{doc:h}=E,S=[];h.descendants((C,b)=>{const R=JM(C,b);if(R)return S.push(R),!1;const M=xl(C,b,"userInsertion","user-insertion");M&&S.push(M);const k=xl(C,b,"userDeletion","user-deletion");k&&S.push(k);const L=xl(C,b,"aiInsertion","ai-insertion");L&&S.push(L);const P=xl(C,b,"aiDeletion","ai-deletion");P&&S.push(P)}),S.sort((C,b)=>C.pos-b.pos);const y=tk(S);r(y)},[e]);A.useEffect(()=>{if(!e)return;i();const E=()=>i();return e.on("update",E),()=>{e.off("update",E)}},[e,i]);const a=A.useCallback(E=>{if(!e)return;const h=n.find(S=>S.id===E);h&&wl(e,h,"accept")},[e,n]),o=A.useCallback(E=>{if(!e)return;const h=n.find(S=>S.id===E);h&&wl(e,h,"reject")},[e,n]),s=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((h,S)=>S.position-h.position).forEach(h=>{wl(e,h,"accept")})},[e,n]),l=A.useCallback(()=>{if(!e||n.length===0)return;[...n].sort((h,S)=>S.position-h.position).forEach(h=>{wl(e,h,"reject")})},[e,n]),c=A.useCallback((E,h,S)=>{if(e)try{e.commands.focus(),e.commands.setTextSelection(E),h!==void 0&&S!==void 0&&e.commands.highlightMark(h,S);const{view:y}=e,C=y.coordsAtPos(E);C&&document.elementFromPoint(C.left,C.top)?.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}catch(y){console.error("Error navigating to change:",y)}},[e]),u=A.useCallback((E,h)=>{if(e)try{e.commands.highlightMark(E,h)}catch(S){console.error("Error highlighting mark:",S)}},[e]),d=A.useCallback(()=>{if(e)try{e.commands.highlightMark(null,null)}catch(E){console.error("Error clearing mark highlight:",E)}},[e]),p=A.useCallback((E,h)=>{r(S=>S.map(y=>{if(y.id===E){const C={id:`comment-${Date.now()}-${Math.random()}`,userId:t.currentUser?.id||"unknown",userName:t.currentUser?.name||"User",timestamp:new Date().toISOString(),text:h};return{...y,comments:[...y.comments||[],C]}}return y}))},[t.currentUser]),_=A.useCallback((E,h,S)=>{r(y=>y.map(C=>C.id===E&&C.comments?{...C,comments:C.comments.map(b=>b.id===h?{...b,text:S}:b)}:C))},[]),f=A.useCallback((E,h)=>{r(S=>S.map(y=>y.id===E&&y.comments?{...y,comments:y.comments.filter(C=>C.id!==h)}:y))},[]),g=A.useCallback((E,h)=>n.find(S=>S.timestamp===E&&S.userId===h)||null,[n]);return{changes:n,acceptChange:a,rejectChange:o,acceptAllChanges:s,rejectAllChanges:l,navigateToChange:c,scanChanges:i,addComment:p,editComment:_,deleteComment:f,findChangeByMark:g,highlightMark:u,clearMarkHighlight:d}},zE=!1,nk=()=>{const{currentMode:e}=Tl(),{editorConfig:t}=_t(),{changes:n,acceptChange:r,rejectChange:i,navigateToChange:a,addComment:o,editComment:s,deleteComment:l,findChangeByMark:c,clearMarkHighlight:u}=YE(),d=e===di.SUGGESTING.value,[p,_]=A.useState(null),[f,g]=A.useState(new Map),[E,h]=A.useState(null),S=A.useRef(new Map),y=A.useCallback(()=>{const T=new Map,D=document.querySelector("#editor-content-qwCfsdsfsd"),N=document.querySelector("#editor-sidebar-qwCfsdsfsd");if(!D)return T;const v=D.getBoundingClientRect();let x=window.innerWidth;N&&(x=N.getBoundingClientRect().left);const B=x-v.right,G=380,w=20,U=B<G+w*2,Y=4,q=[];return n.forEach(X=>{const ee=document.querySelector(`[data-timestamp="${X.timestamp}"][data-user-id="${X.userId}"]`);if(ee){const de=ee.getBoundingClientRect(),te=S.current.get(X.id),re=te?te.getBoundingClientRect().height:U?35:120,ae=v.right+w;let ue=de.top,_e=!0,Ie=0;const Q=20;for(;_e&&Ie<Q;){_e=!1,Ie++;for(const Be of q)if(ue<Be.bottom&&ue+re>Be.top){ue=Be.bottom+Y,_e=!0;break}}q.push({top:ue,bottom:ue+re}),T.set(X.id,{changeId:X.id,top:ue,left:ae,showCompact:U})}}),T},[n]);A.useEffect(()=>{const T=()=>{const v=y();g(v)};T(),window.addEventListener("scroll",T,!0),window.addEventListener("resize",T);const D=new MutationObserver(()=>{setTimeout(T,50)});D.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]});const N=setInterval(T,500);return()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T),D.disconnect(),clearInterval(N)}},[y]);const C=t.currentUser,b=T=>T.includes("insertion")?"Add":T.includes("deletion")?"Del":"Change",R=A.useCallback((T,D)=>{const N=document.querySelector(`[data-timestamp="${T}"][data-user-id="${D}"]`);if(!N)return null;const v=N.getBoundingClientRect(),x=380,B=400,G=10;let U=v.left+v.width/2-x/2;const Y=20;U<Y?U=Y:U+x>window.innerWidth-Y&&(U=window.innerWidth-x-Y);const q=v.top,X=window.innerHeight-v.bottom,ee=q<B+G&&X>=B+G;return{top:ee?v.bottom+G:v.top-G,left:U,showBelow:ee}},[]),M=A.useCallback(T=>{_(T);const D=f.get(T);if(D&&D.showCompact){const N=n.find(v=>v.id===T);if(N){const v=R(N.timestamp,N.userId);v&&h(v)}}},[f,n,R]);A.useEffect(()=>{const T=D=>{const N=D,{timestamp:v,userId:x}=N.detail,B=c(v,x);B&&M(B.id)};return window.addEventListener("redline:markClick",T),()=>{window.removeEventListener("redline:markClick",T)}},[c,M]),A.useEffect(()=>{const T=D=>{const N=D.target,v=N.closest("[data-redline-item]"),x=N.closest("[data-timestamp]");!v&&!x&&(_(null),h(null),u())};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[u]),A.useEffect(()=>{if(!p)return;const T=()=>{const D=n.find(N=>N.id===p);if(D){const N=R(D.timestamp,D.userId);N&&h(N)}};return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[p,n,R]);const k=A.useCallback(T=>{const D=n.find(N=>N.id===T);if(D){_(T);const N=f.get(T);if(N&&N.showCompact){const v=R(D.timestamp,D.userId);v&&h(v)}else h(null);a(D.position,D.timestamp,D.userId)}},[n,f,R,a]);if(n.length===0)return null;const L=p?n.find(T=>T.id===p):null,P=p?f.get(p):null,F=L&&E&&P?.showCompact;return m.jsxs(m.Fragment,{children:[Array.from(f.values()).map((T,D)=>{const N=n.find(x=>x.id===T.changeId);if(!N)return null;const v=p===N.id;return T.showCompact?m.jsx("div",{"data-redline-item":"true",className:"fixed pointer-events-auto",style:{top:`${T.top}px`,left:`${T.left}px`,zIndex:v?20:5},children:m.jsxs("button",{onClick:()=>k(N.id),className:`
|
|
116
116
|
flex items-center gap-2.5 px-1.5 py-0.5 rounded-lg
|
|
117
117
|
transition-all duration-200 hover:scale-105
|
|
118
118
|
${v?"bg-primary-50 border border-primary-300 shadow-[0px_12px_32px_0px_rgba(16,24,40,0.08)]":"bg-white border border-neutral-50 hover:border-gray-300"}
|
|
119
|
-
`,title:`${b(N.type)} change ${D+1}`,children:[m.jsx(oe,{name:"redline-item",size:20,className:v?"text-[#016DCF]":"text-neutral-600"}),m.jsx("span",{className:`text-base font-semibold mb-0.5 ${v?"text-[#016DCF]":"text-neutral-600"}`,children:D+1})]})},N.id):m.jsx("div",{"data-redline-item":"true",className:"fixed pointer-events-auto",style:{top:`${T.top}px`,left:`${T.left}px`,maxWidth:"380px",width:"380px",zIndex:v?20:5},children:m.jsx(Pu,{ref:x=>{x?S.current.set(N.id,x):S.current.delete(N.id)},change:N,onAccept:r,onReject:i,onNavigate:a,onAddComment:o,onEditComment:s,onDeleteComment:l,currentUser:C,isActive:v,onSetActive:()=>{_(N.id),h(null)},isSuggestingMode:d,showComments:zE})},N.id)}),F&&_o.createPortal(m.jsx("div",{"data-redline-item":"true",className:"fixed pointer-events-auto z-[10] rounded-lg shadow-[0px_12px_32px_0px_rgba(16,24,40,0.08)]",style:{top:`${E.top}px`,left:`${E.left}px`,maxWidth:"380px",width:"380px",transform:E.showBelow?"none":"translateY(-100%)"},children:m.jsx(Pu,{change:L,onAccept:r,onReject:i,onNavigate:a,onAddComment:o,onEditComment:s,onDeleteComment:l,currentUser:C,isActive:!0,onSetActive:()=>_(L.id),isSuggestingMode:d,showComments:zE})}),document.body)]})},rk=({
|
|
119
|
+
`,title:`${b(N.type)} change ${D+1}`,children:[m.jsx(oe,{name:"redline-item",size:20,className:v?"text-[#016DCF]":"text-neutral-600"}),m.jsx("span",{className:`text-base font-semibold mb-0.5 ${v?"text-[#016DCF]":"text-neutral-600"}`,children:D+1})]})},N.id):m.jsx("div",{"data-redline-item":"true",className:"fixed pointer-events-auto",style:{top:`${T.top}px`,left:`${T.left}px`,maxWidth:"380px",width:"380px",zIndex:v?20:5},children:m.jsx(Pu,{ref:x=>{x?S.current.set(N.id,x):S.current.delete(N.id)},change:N,onAccept:r,onReject:i,onNavigate:a,onAddComment:o,onEditComment:s,onDeleteComment:l,currentUser:C,isActive:v,onSetActive:()=>{_(N.id),h(null)},isSuggestingMode:d,showComments:zE})},N.id)}),F&&_o.createPortal(m.jsx("div",{"data-redline-item":"true",className:"fixed pointer-events-auto z-[10] rounded-lg shadow-[0px_12px_32px_0px_rgba(16,24,40,0.08)]",style:{top:`${E.top}px`,left:`${E.left}px`,maxWidth:"380px",width:"380px",transform:E.showBelow?"none":"translateY(-100%)"},children:m.jsx(Pu,{change:L,onAccept:r,onReject:i,onNavigate:a,onAddComment:o,onEditComment:s,onDeleteComment:l,currentUser:C,isActive:!0,onSetActive:()=>_(L.id),isSuggestingMode:d,showComments:zE})}),document.body)]})},rk=({id:e,tools:t,position:n="right",isExpanded:r=!1,defaultActiveTool:i=null,expandedWidth:a=320,toggleToolbar:o})=>{const[s,l]=A.useState(i),c=_=>{(s!==_||!r)&&(o?.(!0),l(_))},u=()=>{o?.(!r),!r&&!s&&t.length>0?l(t[0].id):r&&l(null)},d=n==="left",p=t.find(_=>_.id===s);return m.jsxs("div",{className:`h-full flex ${d?"flex-row":"flex-row-reverse"}`,children:[m.jsxs("div",{id:e,className:"h-full w-14 bg-white border border-neutral-200 flex flex-col relative z-10",children:[m.jsx("div",{className:"flex-1 flex flex-col pt-3",children:t.filter(_=>!_.notVisible).map(_=>m.jsxs("button",{onClick:()=>c(_.id),className:`w-full h-14 flex items-center justify-center transition-all duration-200 relative ${s===_.id&&r?"bg-blue-50 text-blue-600":"text-gray-600 hover:bg-neutral-100 hover:text-neutral-900"}`,title:_.label,children:[s===_.id&&r&&m.jsx("div",{className:`absolute ${d?"right-0":"left-0"} top-0 bottom-0 w-0.5 bg-primary-600`}),m.jsx("div",{className:`flex items-center justify-center ${s===_.id&&r?"text-primary-400":"text-neutral-400"} `,children:_.icon})]},_.id))}),m.jsx("button",{onClick:u,className:"w-full h-12 flex items-center justify-center text-gray-600 hover:bg-neutral-100 hover:text-neutral-900 transition-colors",title:r?"Collapse sidebar":"Expand sidebar",children:m.jsx(oe,{name:"double-right-arrow",size:16,strokeWidth:2})})]}),m.jsx("div",{className:`h-full bg-white ${d?"border-r":"border-l"} border-neutral-200 overflow-hidden transition-all duration-300 ease-in-out shadow-lg`,style:{width:r?`${a}px`:"0px",minWidth:r?`${a}px`:"0px"},children:r&&s&&p&&m.jsx("div",{className:`h-full transition-opacity duration-200 ${r?"opacity-100 delay-100":"opacity-0"}`,style:{width:`${a}px`},children:p.content})})]})},ik=({onExport:e,onClose:t})=>{const[n,r]=A.useState(null),i=()=>{n&&(e?.({fileType:n}),r(null))},a=()=>{r(null),t?.()},o=[{value:"pdf",label:"PDF"},{value:"text",label:"Text"},{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"markdown",label:"Markdown"}];return m.jsxs("div",{className:"h-full flex flex-col bg-white",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[m.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Export"}),t&&m.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 transition-colors",children:m.jsx(le.Close,{sx:{fontSize:20}})})]}),m.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m.jsx("div",{className:"space-y-6",children:m.jsxs("div",{children:[m.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2",children:"File Type"}),m.jsx(he.Select,{value:n,onChange:r,options:o,placeholder:"Select File Type",className:"w-full",size:"middle",style:{borderColor:"transparent",borderWidth:1,borderStyle:"solid"}})]})})}),m.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 flex items-center justify-between bg-white",children:[m.jsx("button",{onClick:a,className:"px-3 py-1.5 border border-neutral-300 text-sm font-medium text-neutral-900 hover:bg-neutral-100 rounded-lg transition-colors",children:"Cancel"}),m.jsx("button",{onClick:i,className:"px-3 py-1.5 text-sm font-medium text-white bg-[#016DCF] hover:bg-blue-700 rounded-lg transition-colors",disabled:!n,children:"Export"})]})]})},VE=50,ak=()=>{const{editor:e}=_t(),[t,n]=A.useState(""),[r,i]=A.useState([]),[a,o]=A.useState(0),s=(_,f,g=!0)=>{if(!e)return;const E=f||r;if(_<0||_>=E.length)return;const h=E[_];e.commands.setTextSelection({from:h.from,to:h.to}),g&&e.commands.focus(),o(_)},l=(_,f=!1)=>{if(!e||!_){i([]),o(0);return}const g=[],E=_.toLowerCase(),h=e.state.doc;h.descendants((S,y)=>{if(S.isText&&S.text){const C=S.text,b=C.toLowerCase();let R=0;for(;R<b.length;){const M=b.indexOf(E,R);if(M===-1)break;const k=y+M,L=k+_.length,P=h.content.size,F=Math.max(0,k-VE),T=Math.min(P-1,L+VE);let D="",N="";try{k>F&&(D=h.textBetween(F,k," "),F>0&&(D="... "+D)),L<T&&(N=h.textBetween(L,T," "),T<P-1&&(N=N+" ..."))}catch(v){console.error("Error extracting context:",v)}g.push({id:`match-${g.length}`,from:k,to:L,text:C.substring(M,M+_.length),contextBefore:D,contextAfter:N}),R=M+1}}}),i(g),o(g.length>0?0:-1),f&&g.length>0&&s(0,g,!1)},c=()=>{if(r.length===0)return;const _=a>0?a-1:r.length-1;s(_,void 0,!0)},u=()=>{if(r.length===0)return;const _=a<r.length-1?a+1:0;s(_,void 0,!0)},d=_=>{if(!e||r.length===0||a<0)return;const f=r[a];e.chain().focus().setTextSelection({from:f.from,to:f.to}).insertContent(_).run(),setTimeout(()=>{l(t,!1)},50)},p=_=>{if(!e||r.length===0)return;const f=[...r].sort((E,h)=>h.from-E.from),g=e.state.tr;f.forEach(E=>{g.replaceWith(E.from,E.to,e.schema.text(_))}),e.view.dispatch(g),e.commands.focus(),setTimeout(()=>{l(t,!1)},50)};return A.useEffect(()=>{t&&e?l(t,!1):(i([]),o(0))},[t,e]),{searchQuery:t,setSearchQuery:n,matches:r,currentMatchIndex:a,goToPrevious:c,goToNext:u,replaceCurrent:d,replaceAll:p,navigateToMatch:s}},$E=({options:e,value:t,onChange:n,className:r=""})=>m.jsx("div",{className:`flex bg-neutral-100 rounded-lg p-1 ${r}`,children:e.map(i=>{const a=t===i.value;return m.jsxs("button",{onClick:()=>n(i.value),className:`
|
|
120
120
|
flex-1 flex items-center justify-center gap-2 px-4 py-1 text-xs font-medium rounded-md
|
|
121
121
|
transition-all duration-200 whitespace-nowrap
|
|
122
122
|
${a?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-700"}
|
|
@@ -172,4 +172,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
172
172
|
</div>
|
|
173
173
|
</body>
|
|
174
174
|
</html>
|
|
175
|
-
`),S.close();const y=document.title;h.contentWindow&&(h.contentWindow.document.title=s),document.title=s,setTimeout(()=>{h.contentWindow&&(h.contentWindow.document.title=s),document.title=s},100),setTimeout(()=>{try{if(h.contentWindow)h.contentWindow.matchMedia&&h.contentWindow.matchMedia("print").addEventListener("change",function(b){b.matches||(document.title=y,document.body.removeChild(h))}),h.contentWindow.document.title=s||"Untitled document",h.contentWindow.focus(),h.contentWindow.print(),setTimeout(()=>{document.body.contains(h)&&document.body.removeChild(h),document.title=y},1e3);else throw new Error("Cannot access iframe content window")}catch(C){document.body.removeChild(h),document.title=y,he.message.error("Failed to export: "+String(C))}},1e3)}catch(s){he.message.error("Failed to export: "+String(s))}},[t]);return{downloadTextFile:n,downloadJsonFile:r,downloadMarkdownFile:i,downloadHtmlFile:a,downloadPdfFile:o}},kk=[{value:"A4",label:"A4 (210 × 297 mm)",description:"210 × 297 mm"},{value:"A3",label:"A3 (297 × 420 mm)",description:"297 × 420 mm"},{value:"Letter",label:"Letter (8.5 × 11 in)",description:"8.5 × 11 in"},{value:"Legal",label:"Legal (8.5 × 14 in)",description:"8.5 × 14 in"},{value:"Tabloid",label:"Tabloid (11 × 17 in)",description:"11 × 17 in"}],Lk=({onApply:e,onClose:t})=>{const{pageConfig:n,setPageConfig:r}=Tl(),{selectedBGColor:i,margins:a,inputValues:o,handleMarginInputChange:s,handleMarginInputBlur:l,handleMarginKeyDown:c,applyPresetMargins:u,handleSetPageBackgroundColor:d,applyMargins:p}=Of(),_=A.useRef(null),[f,g]=A.useState(!1);A.useEffect(()=>{_.current||(_.current={pageConfig:{...n},bgColor:i,margins:{...a}})},[]);const E=()=>{p(),_.current={pageConfig:{...n},bgColor:i,margins:{...a}},e?.(),t?.()},h=()=>{_.current&&(r(_.current.pageConfig),d(_.current.bgColor)),t?.()};return m.jsxs("div",{className:"h-full flex flex-col bg-white",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[m.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Export"}),t&&m.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 transition-colors",children:m.jsx(le.Close,{sx:{fontSize:20}})})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[m.jsxs("div",{className:"mb-4",children:[m.jsx("h4",{className:"text-xs font-medium mb-2",children:"Orientation"}),m.jsx($E,{options:[{value:"portrait",label:"PORTRAIT",icon:m.jsx(le.CropPortrait,{sx:{fontSize:18},className:"mb-0.5"})},{value:"landscape",label:"LANDSCAPE",icon:m.jsx(le.CropLandscape,{sx:{fontSize:18},className:"mb-px"})}],value:n.orientation,onChange:S=>r({...n,orientation:S}),className:"w-full"})]}),m.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[m.jsxs("div",{className:"flex-1",children:[m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Page Size"}),m.jsx(he.Select,{value:n.size,onChange:S=>r({...n,size:S}),options:kk,placeholder:"Select Page Size",className:"w-full",size:"middle",style:{borderColor:"transparent",borderWidth:1,borderStyle:"solid"},suffixIcon:f?m.jsx(le.ExpandLessOutlined,{sx:{fontSize:20}}):m.jsx(le.ExpandMoreOutlined,{sx:{fontSize:20}}),onOpenChange:S=>g(S)})]}),m.jsxs("div",{className:"w-20",children:[m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Page Color"}),m.jsx(RD,{selectedBGColor:i,setSelectedBGColor:d})]})]}),m.jsxs("div",{className:"mb-4",children:[m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Preset Margins"}),m.jsx("div",{className:"grid grid-cols-2 gap-1",children:Object.entries(Cf).map(([S])=>m.jsx("button",{className:"h-8 text-xs py-1.5 px-2 bg-neutral-50 border border-neutral-200 hover:bg-neutral-200 rounded",onClick:()=>u(S),children:S},S))})]}),m.jsx("div",{children:m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Margins"})}),m.jsx("div",{className:"mb-4 w-full bg-neutral-100 p-2 rounded border border-neutral-300",children:m.jsxs("div",{className:"w-full flex gap-2 items-center justify-center",children:[m.jsx("div",{className:"flex items-center gap-1 justify-end",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.left,onChange:S=>s("left",S.target.value),onKeyDown:S=>c(S,"left"),onBlur:()=>l("left"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Left"})})}),m.jsxs("div",{className:"flex flex-col items-center gap-2",children:[m.jsx("div",{className:"flex flex-col items-center gap-0.5",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.top,onChange:S=>s("top",S.target.value),onKeyDown:S=>c(S,"top"),onBlur:()=>l("top"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Top"})})}),m.jsx("div",{className:"flex items-center justify-center",children:m.jsx("div",{className:`relative ${n.orientation==="portrait"?"w-24 h-32":"w-32 h-24"} border border-gray-300 bg-white`,children:m.jsx("div",{className:"absolute bg-primary-100 border border-primary-300",style:{top:`${Math.min(a.top/10*100,80)}%`,left:`${Math.min(a.left/10*100,80)}%`,right:`${Math.min(a.right/10*100,80)}%`,bottom:`${Math.min(a.bottom/10*100,80)}%`}})})}),m.jsx("div",{className:"flex flex-col-reverse items-center gap-0.5",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.bottom,onChange:S=>s("bottom",S.target.value),onKeyDown:S=>c(S,"bottom"),onBlur:()=>l("bottom"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Bottom"})})})]}),m.jsx("div",{className:"flex flex-row-reverse items-center gap-1 justify-start",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.right,onChange:S=>s("right",S.target.value),onKeyDown:S=>c(S,"right"),onBlur:()=>l("right"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Right"})})})]})})]}),m.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 flex items-center justify-between bg-white",children:[m.jsx("button",{onClick:h,className:"px-3 py-1.5 border border-neutral-300 text-sm font-medium text-neutral-900 hover:bg-neutral-100 rounded-lg transition-colors",children:"Cancel"}),m.jsx("button",{onClick:E,className:"px-3 py-1.5 text-sm font-medium text-white bg-[#016DCF] hover:bg-blue-700 rounded-lg transition-colors",children:"Apply"})]})]})},Pk=({position:e="right",currentMode:t})=>{const[n,r]=A.useState(!1),{downloadTextFile:i,downloadJsonFile:a,downloadMarkdownFile:o,downloadHtmlFile:s,downloadPdfFile:l}=Mk(),c=_=>{switch(_.fileType){case"text":i();break;case"json":a();break;case"markdown":o();break;case"html":s();break;case"pdf":l();break;default:i();break}},u=_=>{console.log("Search:",_)},d=(_,f)=>{console.log("Replace:",_,"with",f)},p=[{id:"add",icon:m.jsx(oe,{name:"insert-icon",size:24}),label:"Add Element",content:m.jsx(yk,{onClose:()=>r(!1)}),notVisible:t==="viewing"},{id:"search",icon:m.jsx(oe,{name:"document-search",size:24}),label:"Find and Replace",content:m.jsx(ok,{currentMode:t,onSearch:u,onReplace:d,onClose:()=>r(!1)})},{id:"ai",icon:m.jsx(oe,{name:"ai-icon",size:24}),label:"AI Assistant",content:m.jsxs("div",{className:"h-full flex flex-col bg-white",children:[m.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:m.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"AI Assistant"})}),m.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m.jsx("p",{className:"text-sm text-gray-600",children:"AI Assistant features coming soon..."})})]}),notVisible:!0},{id:"page-settings",icon:m.jsx(oe,{name:"page-settings",size:20}),label:"Page Settings",content:m.jsx(Lk,{onApply:()=>console.log("Apply"),onClose:()=>r(!1)}),notVisible:t==="viewing"},{id:"export",icon:m.jsx(oe,{name:"download-rounded",size:18}),label:"Export Document",content:m.jsx(ik,{onExport:c,onClose:()=>r(!1)})}];return m.jsx(rk,{tools:p,position:e,isExpanded:n,expandedWidth:320,toggleToolbar:r})},Uk=({editorPageRef:e,isPresentationMode:t,pageClass:n})=>{const{editor:r,editorConfig:i}=_t(),{currentMode:a}=Tl(),o=i.editable&&!i.asViewer&&!t&&a!==di.VIEWING.value;return m.jsxs("div",{className:`${i.enablePagination?n:""} editor-content`,ref:e,children:[m.jsx(Kt.EditorContent,{editor:r}),o&&m.jsx(AM,{editor:r})]})},Bk=()=>{const{currentMode:e}=Tl();return e===di.VIEWING.value?null:m.jsx(CD,{})},Fk=()=>{const e=A.useRef(null),t=A.useRef(null),{editor:n,editorConfig:r}=_t(),{pageClass:i,pageConfig:a,setPageConfig:o}=Of(),{isPresentationMode:s,isLaserActive:l,onPresentationModeToggle:c,handleLaserToggle:u}=aD(n,t),{changes:d}=YE(),p=d.length>0&&!s;return A.useEffect(()=>{if(!n||!e.current)return;const _=f=>{if(e.current?.contains(f.target)){n.commands.focus();return}};return document.addEventListener("click",_),()=>{document.removeEventListener("click",_)}},[n]),m.jsx(vD,{editorConfig:r,onPresentationModeToggle:c,pageConfig:a,setPageConfig:o,children:m.jsxs("div",{ref:t,className:`h-full relative flex flex-col bg-neutral-200 editor-container ${s?"editor-presentation-mode":""} ${l?"laser-active":""}`,children:[m.jsx(Bk,{}),m.jsxs("div",{className:"flex flex-1 min-h-0",children:[m.jsx(QM,{children:m.jsx("div",{className:"flex-1 overflow-auto",children:m.jsx("div",{className:"min-h-full w-fit min-w-full flex justify-center items-start p-4",style:{paddingRight:p?"420px":"48px"},children:m.jsx(Uk,{editorPageRef:e,isPresentationMode:s,pageClass:i})})})}),!s&&!r?.asViewer&&m.jsx(Pk,{position:"left",currentMode:r?.mode||"viewing"}),!s&&m.jsx(nk,{})]}),!s&&m.jsx(IM,{onPresentationModeToggle:c}),s&&m.jsx(wM,{onPresentationModeToggle:c,onLaserToggle:u})]})})},Gk=({config:e={}})=>{const t={...Yh,...e},n=A.useRef(null),r=Kt.useEditor({extensions:iD(t),content:t.content,autofocus:!1,editable:!t.asViewer&&t.editable,onUpdate:({editor:i})=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{t.onContentChange&&t.onContentChange(i)},t.debounceTimeForContentChange)}});return A.useEffect(()=>()=>{r?.destroy()},[r]),r?m.jsx(jx,{editor:r,editorConfig:t,children:m.jsx(he.ConfigProvider,{prefixCls:"editor",children:m.jsx(Fk,{})})}):null};Oe.Editor=Gk,Object.defineProperty(Oe,Symbol.toStringTag,{value:"Module"})}));
|
|
175
|
+
`),S.close();const y=document.title;h.contentWindow&&(h.contentWindow.document.title=s),document.title=s,setTimeout(()=>{h.contentWindow&&(h.contentWindow.document.title=s),document.title=s},100),setTimeout(()=>{try{if(h.contentWindow)h.contentWindow.matchMedia&&h.contentWindow.matchMedia("print").addEventListener("change",function(b){b.matches||(document.title=y,document.body.removeChild(h))}),h.contentWindow.document.title=s||"Untitled document",h.contentWindow.focus(),h.contentWindow.print(),setTimeout(()=>{document.body.contains(h)&&document.body.removeChild(h),document.title=y},1e3);else throw new Error("Cannot access iframe content window")}catch(C){document.body.removeChild(h),document.title=y,he.message.error("Failed to export: "+String(C))}},1e3)}catch(s){he.message.error("Failed to export: "+String(s))}},[t]);return{downloadTextFile:n,downloadJsonFile:r,downloadMarkdownFile:i,downloadHtmlFile:a,downloadPdfFile:o}},kk=[{value:"A4",label:"A4 (210 × 297 mm)",description:"210 × 297 mm"},{value:"A3",label:"A3 (297 × 420 mm)",description:"297 × 420 mm"},{value:"Letter",label:"Letter (8.5 × 11 in)",description:"8.5 × 11 in"},{value:"Legal",label:"Legal (8.5 × 14 in)",description:"8.5 × 14 in"},{value:"Tabloid",label:"Tabloid (11 × 17 in)",description:"11 × 17 in"}],Lk=({onApply:e,onClose:t})=>{const{pageConfig:n,setPageConfig:r}=Tl(),{selectedBGColor:i,margins:a,inputValues:o,handleMarginInputChange:s,handleMarginInputBlur:l,handleMarginKeyDown:c,applyPresetMargins:u,handleSetPageBackgroundColor:d,applyMargins:p}=Of(),_=A.useRef(null),[f,g]=A.useState(!1);A.useEffect(()=>{_.current||(_.current={pageConfig:{...n},bgColor:i,margins:{...a}})},[]);const E=()=>{p(),_.current={pageConfig:{...n},bgColor:i,margins:{...a}},e?.(),t?.()},h=()=>{_.current&&(r(_.current.pageConfig),d(_.current.bgColor)),t?.()};return m.jsxs("div",{className:"h-full flex flex-col bg-white",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[m.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Export"}),t&&m.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 transition-colors",children:m.jsx(le.Close,{sx:{fontSize:20}})})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[m.jsxs("div",{className:"mb-4",children:[m.jsx("h4",{className:"text-xs font-medium mb-2",children:"Orientation"}),m.jsx($E,{options:[{value:"portrait",label:"PORTRAIT",icon:m.jsx(le.CropPortrait,{sx:{fontSize:18},className:"mb-0.5"})},{value:"landscape",label:"LANDSCAPE",icon:m.jsx(le.CropLandscape,{sx:{fontSize:18},className:"mb-px"})}],value:n.orientation,onChange:S=>r({...n,orientation:S}),className:"w-full"})]}),m.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[m.jsxs("div",{className:"flex-1",children:[m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Page Size"}),m.jsx(he.Select,{value:n.size,onChange:S=>r({...n,size:S}),options:kk,placeholder:"Select Page Size",className:"w-full",size:"middle",style:{borderColor:"transparent",borderWidth:1,borderStyle:"solid"},suffixIcon:f?m.jsx(le.ExpandLessOutlined,{sx:{fontSize:20}}):m.jsx(le.ExpandMoreOutlined,{sx:{fontSize:20}}),onOpenChange:S=>g(S)})]}),m.jsxs("div",{className:"w-20",children:[m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Page Color"}),m.jsx(RD,{selectedBGColor:i,setSelectedBGColor:d})]})]}),m.jsxs("div",{className:"mb-4",children:[m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Preset Margins"}),m.jsx("div",{className:"grid grid-cols-2 gap-1",children:Object.entries(Cf).map(([S])=>m.jsx("button",{className:"h-8 text-xs py-1.5 px-2 bg-neutral-50 border border-neutral-200 hover:bg-neutral-200 rounded",onClick:()=>u(S),children:S},S))})]}),m.jsx("div",{children:m.jsx("h4",{className:"text-xs font-medium mb-1",children:"Margins"})}),m.jsx("div",{className:"mb-4 w-full bg-neutral-100 p-2 rounded border border-neutral-300",children:m.jsxs("div",{className:"w-full flex gap-2 items-center justify-center",children:[m.jsx("div",{className:"flex items-center gap-1 justify-end",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.left,onChange:S=>s("left",S.target.value),onKeyDown:S=>c(S,"left"),onBlur:()=>l("left"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Left"})})}),m.jsxs("div",{className:"flex flex-col items-center gap-2",children:[m.jsx("div",{className:"flex flex-col items-center gap-0.5",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.top,onChange:S=>s("top",S.target.value),onKeyDown:S=>c(S,"top"),onBlur:()=>l("top"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Top"})})}),m.jsx("div",{className:"flex items-center justify-center",children:m.jsx("div",{className:`relative ${n.orientation==="portrait"?"w-24 h-32":"w-32 h-24"} border border-gray-300 bg-white`,children:m.jsx("div",{className:"absolute bg-primary-100 border border-primary-300",style:{top:`${Math.min(a.top/10*100,80)}%`,left:`${Math.min(a.left/10*100,80)}%`,right:`${Math.min(a.right/10*100,80)}%`,bottom:`${Math.min(a.bottom/10*100,80)}%`}})})}),m.jsx("div",{className:"flex flex-col-reverse items-center gap-0.5",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.bottom,onChange:S=>s("bottom",S.target.value),onKeyDown:S=>c(S,"bottom"),onBlur:()=>l("bottom"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Bottom"})})})]}),m.jsx("div",{className:"flex flex-row-reverse items-center gap-1 justify-start",children:m.jsx("div",{className:"flex items-center",children:m.jsx("input",{type:"text",value:o.right,onChange:S=>s("right",S.target.value),onKeyDown:S=>c(S,"right"),onBlur:()=>l("right"),className:"w-16 text-xs p-1 border border-gray-300 rounded",placeholder:"Right"})})})]})})]}),m.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 flex items-center justify-between bg-white",children:[m.jsx("button",{onClick:h,className:"px-3 py-1.5 border border-neutral-300 text-sm font-medium text-neutral-900 hover:bg-neutral-100 rounded-lg transition-colors",children:"Cancel"}),m.jsx("button",{onClick:E,className:"px-3 py-1.5 text-sm font-medium text-white bg-[#016DCF] hover:bg-blue-700 rounded-lg transition-colors",children:"Apply"})]})]})},Pk=({position:e="right",currentMode:t})=>{const[n,r]=A.useState(!1),{downloadTextFile:i,downloadJsonFile:a,downloadMarkdownFile:o,downloadHtmlFile:s,downloadPdfFile:l}=Mk(),c=_=>{switch(_.fileType){case"text":i();break;case"json":a();break;case"markdown":o();break;case"html":s();break;case"pdf":l();break;default:i();break}},u=_=>{console.log("Search:",_)},d=(_,f)=>{console.log("Replace:",_,"with",f)},p=[{id:"add",icon:m.jsx(oe,{name:"insert-icon",size:24}),label:"Add Element",content:m.jsx(yk,{onClose:()=>r(!1)}),notVisible:t==="viewing"},{id:"search",icon:m.jsx(oe,{name:"document-search",size:24}),label:"Find and Replace",content:m.jsx(ok,{currentMode:t,onSearch:u,onReplace:d,onClose:()=>r(!1)})},{id:"ai",icon:m.jsx(oe,{name:"ai-icon",size:24}),label:"AI Assistant",content:m.jsxs("div",{className:"h-full flex flex-col bg-white",children:[m.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:m.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"AI Assistant"})}),m.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m.jsx("p",{className:"text-sm text-gray-600",children:"AI Assistant features coming soon..."})})]}),notVisible:!0},{id:"page-settings",icon:m.jsx(oe,{name:"page-settings",size:20}),label:"Page Settings",content:m.jsx(Lk,{onApply:()=>console.log("Apply"),onClose:()=>r(!1)}),notVisible:t==="viewing"},{id:"export",icon:m.jsx(oe,{name:"download-rounded",size:18}),label:"Export Document",content:m.jsx(ik,{onExport:c,onClose:()=>r(!1)})}];return m.jsx(rk,{id:"editor-sidebar-qwCfsdsfsd",tools:p,position:e,isExpanded:n,expandedWidth:320,toggleToolbar:r})},Uk=({editorPageRef:e,isPresentationMode:t,pageClass:n})=>{const{editor:r,editorConfig:i}=_t(),{currentMode:a}=Tl(),o=i.editable&&!i.asViewer&&!t&&a!==di.VIEWING.value;return m.jsxs("div",{className:`${i.enablePagination?n:""} editor-content`,ref:e,id:"editor-content-qwCfsdsfsd",children:[m.jsx(Kt.EditorContent,{editor:r}),o&&m.jsx(AM,{editor:r})]})},Bk=()=>{const{currentMode:e}=Tl();return e===di.VIEWING.value?null:m.jsx(CD,{})},Fk=()=>{const e=A.useRef(null),t=A.useRef(null),{editor:n,editorConfig:r}=_t(),{pageClass:i,pageConfig:a,setPageConfig:o}=Of(),{isPresentationMode:s,isLaserActive:l,onPresentationModeToggle:c,handleLaserToggle:u}=aD(n,t),{changes:d}=YE(),p=d.length>0&&!s;return A.useEffect(()=>{if(!n||!e.current)return;const _=f=>{if(e.current?.contains(f.target)){n.commands.focus();return}};return document.addEventListener("click",_),()=>{document.removeEventListener("click",_)}},[n]),m.jsx(vD,{editorConfig:r,onPresentationModeToggle:c,pageConfig:a,setPageConfig:o,children:m.jsxs("div",{ref:t,className:`h-full relative flex flex-col bg-neutral-200 editor-container ${s?"editor-presentation-mode":""} ${l?"laser-active":""}`,children:[m.jsx(Bk,{}),m.jsxs("div",{className:"flex flex-1 min-h-0",children:[m.jsx(QM,{children:m.jsx("div",{className:"flex-1 overflow-auto",children:m.jsx("div",{className:"min-h-full w-fit min-w-full flex justify-center items-start p-4",style:{paddingRight:p?"420px":"48px"},children:m.jsx(Uk,{editorPageRef:e,isPresentationMode:s,pageClass:i})})})}),!s&&!r?.asViewer&&m.jsx(Pk,{position:"left",currentMode:r?.mode||"viewing"}),!s&&m.jsx(nk,{})]}),!s&&m.jsx(IM,{onPresentationModeToggle:c}),s&&m.jsx(wM,{onPresentationModeToggle:c,onLaserToggle:u})]})})},Gk=({config:e={}})=>{const t={...Yh,...e},n=A.useRef(null),r=Kt.useEditor({extensions:iD(t),content:t.content,autofocus:!1,editable:!t.asViewer&&t.editable,onUpdate:({editor:i})=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{t.onContentChange&&t.onContentChange(i)},t.debounceTimeForContentChange)}});return A.useEffect(()=>()=>{r?.destroy()},[r]),r?m.jsx(jx,{editor:r,editorConfig:t,children:m.jsx(he.ConfigProvider,{prefixCls:"editor",children:m.jsx(Fk,{})})}):null};Oe.Editor=Gk,Object.defineProperty(Oe,Symbol.toStringTag,{value:"Module"})}));
|