PageSourceSearch

https://paperpal.com/_next/static/chunks/8783.a6848638a1602975.js

js paperpal.com collected 2026-09-24 08:47:39 UTC 857,254 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8783],{844:(e,t,n)=>{"use strict";n.d(t,{kZ:()=>o,ku:()=>i});var r=n(30131),l=n(6359);let a=e=>{let t=[];return e.state.doc.descendants((e,n)=>{"text"===e.type.name&&e.marks.forEach(r=>{if(r.type.name===l.Gw){let l=r.attrs.label||"";t.push({pos:n,node:e,label:l})}})}),t.sort((e,t)=>e.pos-t.pos)},o=(e,t,n)=>{if(n<0||n>=t.length)return!1;try{let{state:l,view:a}=e,o=t[n];if(void 0===o||o<0||o>l.doc.content.size)return!1;let i=l.doc.resolve(o),s=i.parent.nodeAt(o-i.start());if(!s||"text"!==s.type.name)return!1;let c=o+s.nodeSize,d=l.tr.setSelection(r.U3.create(l.doc,o,c));return a.dispatch(d.setMeta("addToHistory",!1)),requestAnimationFrame(()=>{let{node:e}=a.domAtPos(o),t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;null==t||t.scrollIntoView({behavior:"smooth",block:"center"})}),!0}catch(e){return console.error("Failed to select failed citation:",e),!1}},i=e=>{let t=a(e);if(0===t.length)return;let n=t.map(e=>e.pos);return e.commands.setManualCitationPositions(n),{positions:n}}},1321:(e,t,n)=>{"use strict";n.d(t,{$s:()=>s,mf:()=>c});var r=n(11445),l=n(70178);let a=r.z.enum(["idle","connecting","streaming","done","copied","cancelled","error"]);var o=n(85858),i=n(72984);let s=r.z.record(r.z.string(),i.G).optional();r.z.object({cslJson:s});let c=r.z.record(r.z.string(),r.z.string());r.z.object({requestId:r.z.string(),submissionId:r.z.number(),balance:o.s,papers:r.z.array(l.qP).optional(),researchSummary:r.z.string().optional(),totalPapers:r.z.number().optional(),cslJsonMap:s,dyMessageId:r.z.string().optional(),dySessionId:r.z.string().optional()}),r.z.object({balance:o.s,submissionId:r.z.number(),dyMessageId:r.z.string().optional(),dySessionId:r.z.string().optional(),researchSummary:r.z.string().optional(),requestId:r.z.string()});let d=r.z.object({dyMessageId:r.z.string(),timeStamp:r.z.string().optional(),question:r.z.string(),answer:r.z.string(),relatedPapers:r.z.array(l.qP),summaryReferences:r.z.record(l.qP),isError:r.z.boolean().optional(),status:a.optional(),cslJsonMap:s.optional(),isAddedWhileConversing:r.z.boolean().optional()});r.z.object({dySessionId:r.z.string(),history:r.z.array(d),totalNoOfQuestions:r.z.number()}),r.z.object({submissionId:r.z.number(),papers:r.z.array(l.qP),cslJsonMap:s,totalPapers:r.z.number().optional()}),r.z.object({papers:r.z.array(l.qP),cslJsonMap:s,totalPapers:r.z.number().optional()})},3015:()=>{},3354:()=>{},4518:(e,t,n)=>{"use strict";n.d(t,{B:()=>o});var r=n(29132);n(80263);var l=n(53239);let a=(0,l.createContext)({});function o(e,t){let n,o,{singleTranslationFile:i}=(0,l.useContext)(a);return i?o={...t,keyPrefix:e}:(n=e,o=t),(0,r.Bd)(n,o)}},5675:()=>{},6101:()=>{},6359:(e,t,n)=>{"use strict";n.d(t,{Gw:()=>r,YT:()=>l,jE:()=>a});let r="FailedInlineCitation",l="InlineCitation",a="Cite via Paperpal"},6437:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(80263),l=n(9283),a=n(53239),o=n(16679);let i=(0,o.I4)((0,a.forwardRef)((e,t)=>{let{noGap:n}=e;return(0,r.jsxs)(x,{...e,ref:t,children:[(0,r.jsx)(b,{noGap:n}),e.children]})}));i.displayName="Popover.Anchor";let s=e=>{let{virtualRef:t}=e;return(0,r.jsx)(l.Mz,{virtualRef:t})};s.displayName="Popover.VirtualAnchor";let c=(0,o.I4)((0,a.forwardRef)((e,t)=>{let{align:n,hideArrow:a,arrowColor:o,container:i,...s}=e;return(0,r.jsx)(l.ZL,{container:i,children:(0,r.jsxs)(m,{ref:t,...s,align:e.align,arrowPadding:6*!a,children:[!a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f,{}),(0,r.jsx)(g,{style:{fill:null!=o?o:"white"}})]}),e.children]})})}));c.displayName="Popover.Popup";let d=e=>{let{children:t,modal:n=!0,...a}=e;return(0,r.jsx)(l.bL,{modal:n,...a,children:t})};d.displayName="Popover.Root";let u={Anchor:i,VirtualAnchor:s,Root:d,Popup:c},p=(0,o.i7)({from:{transform:"rotateX(-30deg) scale(0.9)",opacity:0}
1,to:{transform:"rotateX(0deg) scale(1)",opacity:1}}),h=(0,o.i7)({from:{transform:"rotateX(0deg) scale(1)",opacity:1},to:{transform:"rotateX(-10deg) scale(0.95)",opacity:0}}),m=(0,o.I4)(l.UC,{backgroundColor:"white",borderRadius:6,border:"1px solid ".concat(o.w4.colors.gray7),zIndex:1e3,transformOrigin:"top center",boxShadow:"0px 4px 4px rgba(0, 0, 0, 0.25)",height:"var(--radix-navigation-menu-viewport-height)",pointerEvents:"auto","@media only screen and (min-width: 600px)":{width:"var(--radix-navigation-menu-viewport-width)"},"@media (prefers-reduced-motion: no-preference)":{transition:"width, height, 300ms ease",'&[data-state="open"]':{animation:"".concat(p," 200ms ease")},'&[data-state="closed"]':{animation:"".concat(h," 200ms ease")}}}),g=(0,o.I4)(l.i3,{transform:"translateY(-2px)",zIndex:1e3}),f=(0,o.I4)(l.i3,{fill:o.w4.colors.gray7,zIndex:1e3}),x=(0,o.I4)("div",{position:"relative",display:"inline-block"}),b=(0,o.I4)(l.Mz,{position:"absolute",left:-6,right:-6,top:-6,bottom:-6,pointerEvents:"none",variants:{noGap:{true:{bottom:0}}}})},6985:()=>{},7437:(e,t,n)=>{"use strict";n.d(t,{DC:()=>r,rE:()=>l,ts:()=>a});let r={chrome:"https://chromewebstore.google.com/detail/paperpal-for-overleaf-bet/mhpjgcccinlocgiklkfllehilgmcnimp",edge:"https://microsoftedge.microsoft.com/addons/detail/paperpal-free-grammar-ch/bklfadmbfhfklnhmgndegeooghjbdkpi",word:"https://appsource.microsoft.com/en-us/product/office/wa200001361?exp=kyyw"},l=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"paperpal_web";try{let r=new URL(e);return r.searchParams.set("utm_source",n),r.searchParams.set("utm_medium","in_product_nudge"),r.searchParams.set("utm_campaign",t),r.toString()}catch(t){return e}},a=()=>{if("undefined"==typeof navigator)return"chrome";let e=navigator.userAgent;return/edg\//i.test(e)?"edge":/chrome|crios/i.test(e)?"chrome":"other"}},9080:(e,t,n)=>{"use strict";n.d(t,{o:()=>i});var r=n(78773),l=n(1321),a=n(53239),o=n(64014);let i=()=>{let{webApiClient:e}=(0,o.p)(),t=async t=>{var n;let r=await e.post("/api/v2/citation/csl",t);return null!=(n=l.mf.parse(r))?n:{}},n=(0,r.useMutation)({mutationKey:["get-citations-csl-response"],mutationFn:t,onError:e=>{console.error("Error in getting citation csl response",e)}});return{getCitationsCslResponse:(0,a.useCallback)(async e=>{let t=await n.mutateAsync(e);return null!=t?t:{}},[n])}}},11808:(e,t,n)=>{"use strict";n.d(t,{X:()=>m,c:()=>h});var r=n(80263),l=n(9283),a=n(77274),o=n(53239),i=n(16679),s=n(70077),c=n(18696),d=n(83264),u=n(67106),p=n(80415);function h(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=[];for(let l of e){var r;n.push({collection:l,depth:t}),(null==(r=l.children)?void 0:r.length)&&n.push(...h(l.children,t+1))}return n}let m=e=>{let{open:t,onClose:n,collections:c,onSubmit:m,onSuccess:L,isCreating:D,defaultParentId:_=null,isExtension:H=!1,rootContainer:P=null}=e,[O,z]=(0,o.useState)("New Collection"),[B,F]=(0,o.useState)(null),[V,U]=(0,o.useState)(!1),[W,G]=(0,o.useState)(""),[Z,q]=(0,o.useState)(null),$=(0,o.useRef)(null),K=(0,o.useRef)(null),{showToast:Y}=(0,p._)();(0,o.useLayoutEffect)(()=>{if(!H)return;if(P)return void q(P);let e=(0,a.M)();e&&q(e)},[H,P]);let X=(0,o.useMemo)(()=>h(c),[c]),J=(0,o.useMemo)(()=>W.trim().toLowerCase(),[W]),Q=(0,o.useMemo)(()=>X.filter(e=>{let t=e.collection.name.toLowerCase(),n=t.includes(J),r="paperpal documents"===t&&e.collection.locked;return n&&!r}),[X,J]),ee=(0,o.useMemo)(()=>{if(!B)return"My Library";let e=X.find(e=>e.collection.id===B);return e?e.collection.name:"My Library"},[B,X]);(0,o.useEffect)(()=>{t&&(z("New Collection"),F(_),U(!1),G(""),setTimeout(()=>{var e,t;null==(e=$.current)||e.focus(),null==(t=$.current)||t.select()},100))},[t,_]);let et=(0,o.useCallback)(e=>{U(e),e?setTimeout(()=>{var e;return null==(e=K.current)?void 0:e.focus({preventScroll:!0})},50):G("")},[]),en=(0,o.useCallback)(async e=>{e.preventDefault();let t=O.trim();if(t)try{let e=await m(t,B);Y({title:"".concat(O," collection created successfully."),color:"success"});let r=e&&"object"==typeof e&&"data"in e?e.data:void 0;r&&(null==L||L(r)),n()}catch(e){console.error("Error creating collection:",e,t,B),Y({title:"Failed to create ".concat(O," collection."),color:"danger"})}},[O,n,m,L,B,Y]);return(0,r.jsx)(d.lG,{open:t,setOpen:e=>!e&&n(),portalContainer:Z||void 0,isExtensionAddToNotes:H,children:(0,r.jsxs)(g,{"data-tiptap-cite-portal":"true",children:[(0,r.jsxs)(f,{children:[(0,r.jsxs)(x,{children:[(0,r.jsx)(b,{children:"Create Collection"}),(0,r.jsx)(C,{children:"Add a new collection to organize your papers"})]}),(0,r.jsx)(d.HM,{onClick:n})]}),(0,r.jsxs)(v,{onSubmit:en,children:[(0,r.jsx)(y,{children:"Collection Name"}),(0,r.jsx)(w,{ref:$,id:"collection-name-input",type:"text",value:O,onChange:e=>z(e.target.value),placeholder:"Collection name",disabled:D}),(0,r.jsx)(y,{css:{marginTop:(0,s.D)(16)},children:"Create in:"}),(0,r.jsxs)(l.bL,{open:V,onOpenChange:et,...H?{modal:!1}:{},children:[(0,r.jsx)(l.l9,{asChild:!0,children:(0,r.jsxs)(j,{type:"button",...H?{color:"secondary"}:{},css:H?{fontSize:(0,s.D)(14),padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(12)),boxShadow:"none"}:{},children:[(0,r.jsx)(I,{children:ee}),(0,r.jsx)(u.I,{name:V?"chevronUp":"chevronDown",variant:"regular",width:12,height:12})]})}),(0,r.jsx)(l.ZL,{container:Z||void 0,children:(0,r.jsxs)(k,{align:"start",sideOffset:4,"data-tiptap-cite-portal":"true",onOpenAutoFocus:e=>e.preventDefault(),style:{width:"var(--radix-popover-trigger-width)",zIndex:H?0x7fffffff:9999},children:[(0,r.jsx)(E,{children:(0,r.jsx)(w,{ref:K,id:"collection-
1parent-search",type:"text",placeholder:"Search collections...",value:W,onChange:e=>G(e.target.value),disabled:D})}),(0,r.jsxs)(N,{onWheel:e=>e.stopPropagation(),children:[!J&&(0,r.jsxs)(S,{type:"button",...H?{color:"secondary"}:{},"data-selected":null===B,onClick:()=>{F(null),U(!1)},children:[(0,r.jsx)(u.I,{name:"listTree",variant:"light",width:14,height:14}),"My Library"]}),Q.map(e=>(0,r.jsx)(S,{type:"button",...H?{color:"secondary"}:{},"data-selected":B===e.collection.id,css:{paddingLeft:"".concat(16*e.depth+12,"px")},onClick:()=>{F(e.collection.id),U(!1)},children:e.collection.name},e.collection.id)),0===Q.length&&(0,r.jsx)(M,{children:"No collections found"})]})]})})]}),(0,r.jsxs)(T,{children:[(0,r.jsx)(A,{type:"button",onClick:n,disabled:D,css:H?{fontSize:(0,s.D)(14),padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(16)),backgroundColor:"white",color:i.w4.colors.gray9,border:"1px solid ".concat(i.w4.colors.gray9),boxShadow:"none"}:{},children:"Cancel"}),(0,r.jsx)(R,{type:"submit",disabled:!O.trim()||D,css:H?{fontSize:(0,s.D)(14),padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(16)),boxShadow:"none"}:{},children:D?"Creating...":"Create Collection"})]})]})]})})},g=(0,i.I4)("div",{padding:(0,s.D)(24),width:(0,s.D)(450),maxWidth:"90vw"}),f=(0,i.I4)("div",{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:(0,s.D)(20)}),x=(0,i.I4)("div",{display:"flex",flexDirection:"column",gap:(0,s.D)(2)}),b=(0,i.I4)("h2",{fontSize:(0,s.D)(16),fontWeight:500,color:i.w4.colors.gray12,margin:0}),C=(0,i.I4)("p",{fontSize:(0,s.D)(12),color:i.w4.colors.gray11,margin:0}),v=(0,i.I4)("form",{display:"flex",flexDirection:"column"}),y=(0,i.I4)("label",{display:"block",fontSize:(0,s.D)(12),fontWeight:600,color:i.w4.colors.gray11,marginBottom:(0,s.D)(4),paddingLeft:(0,s.D)(8)}),w=(0,i.I4)("input",{width:"100%",padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(12)),border:"1px solid ".concat(i.w4.colors.gray7),borderRadius:(0,s.D)(8),fontSize:(0,s.D)(14),color:i.w4.colors.gray12,outline:"none",boxSizing:"border-box","&::placeholder":{color:i.w4.colors.gray9},"&:focus":{borderColor:i.w4.colors.blue9},"&:disabled":{opacity:.6}}),j=(0,i.I4)(c.$,{width:"100%",padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(12)),border:"1px solid ".concat(i.w4.colors.gray7),borderRadius:(0,s.D)(8),background:"white",fontSize:(0,s.D)(14),color:i.w4.colors.gray12,display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer","&:focus":{outline:"none",borderColor:i.w4.colors.blue9},'&[data-state="open"]':{borderColor:i.w4.colors.blue9}}),I=(0,i.I4)("span",{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),k=(0,i.I4)(l.UC,{background:"white",border:"1px solid ".concat(i.w4.colors.gray7),borderRadius:(0,s.D)(8),boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",overflow:"hidden"}),E=(0,i.I4)("div",{padding:(0,s.D)(8),borderBottom:"1px solid ".concat(i.w4.colors.gray5)}),N=(0,i.I4)("div",{overflowY:"auto",maxHeight:(0,s.D)(200)}),S=(0,i.I4)(c.$,{width:"100%",padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(12)),border:"none",background:"transparent",fontSize:(0,s.D)(13),color:i.w4.colors.gray12,display:"flex",alignItems:"center",gap:(0,s.D)(6),cursor:"pointer",textAlign:"left",boxShadow:"none","&:hover":{backgroundColor:i.w4.colors.blue3,border:"none",boxShadow:"none"},'&[data-selected="true"]':{backgroundColor:i.w4.colors.gray3,fontWeight:600}}),T=(0,i.I4)("div",{display:"flex",justifyContent:"flex-end",gap:(0,s.D)(8),marginTop:(0,s.D)(20)}),A=(0,i.I4)(c.$,{padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(16)),fontSize:(0,s.D)(14),fontWeight:600,borderRadius:(0,s.D)(8),border:"1px solid ".concat(i.w4.colors.gray9),background:"white",color:i.w4.colors.gray9,cursor:"pointer",minWidth:(0,s.D)(96),"&:hover":{backgroundColor:i.w4.colors.gray3},"&:disabled":{opacity:.5,cursor:"not-allowed"}}),R=(0,i.I4)(c.$,{padding:"".concat((0,s.D)(8)," ").concat((0,s.D)(16)),fontSize:(0,s.D)(14),fontWeight:600,borderRadius:(0,s.D)(8),border:"1px solid ".concat(i.w4.colors.blue9),background:i.w4.colors.blue9,color:"white",cursor:"pointer",minWidth:(0,s.D)(144),"&:hover":{opacity:.9},"&:disabled":{opacity:.5,cursor:"not-allowed"}}),M=(0,i.I4)("div",{padding:(0,s.D)(16),textAlign:"center",fontSize:(0,s.D)(13),color:i.w4.colors.gray9})},11918:(e,t,n)=>{"use strict";n.d(t,{M:()=>R});var r=n(80263),l=n(62764),a=n(53239),o=n(16679),i=n(70077),s=n(18696),c=n(67106),d=n(6437),u=n(38767),p=n(29404);let h=(0,o.I4)(s.$,{color:o.w4.colors.gray11,display:"flex",fontSize:(0,i.D)(14),paddingLeft:(0,i.D)(20),padding:(0,i.D)(12),fontWeight:"400",background:"none",boxShadow:"none",stroke:"transparent",width:"100%",border:"none","&:hover":{boxShadow:"none"}}),m=(0,o.I4)("div",{paddingLeft:(0,i.D)(12),variants:{color:{blue:{color:o.w4.colors.blue9}}}}),g=(0,o.I4)("div",{paddingLeft:(0,i.D)(20),paddingRight:(0,i.D)(80),fontWeight:"300"}),f=(0,o.I4)("div",{display:"flex",flexDirection:"column",width:"100%"}),x=(0,o.I4)("div",{overflow:"hidden",transition:"max-height 0.15s ease-out",variants:{expanded:{true:{maxHeight:"420px"},false:{maxHeight:"0px"}}}}),b=e=>{var t,n,l,a;let{action:o,inlineFlyout:i,isFlyoutOpen:s,expanded:u,onToggleExpand:p,onOpenFlyout:b,onCloseFlyout:j,onScheduleClose:I,onCancelScheduledClose:k,onCloseParentPopover:E,onSetKeepOpen:N,onAction:S}=e;return o.renderFlyout?i&&o.flyoutNoSplit?(0,r.jsxs)(f,{children:[(0,r.jsxs)(h,{onClick:e=>{e.stopPropagation(),p(o.id)},"data-test-id":o.id,trackingProperties:o.trackingProperties,children:[(0,r.jsx)(m,{color:"blue",children:o.icon}),(0,r.jsx)(g,{children:null!=(t=o.label)?t:o.toolTipText}),(0,r.jsx)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center"},children:(0,r.jsx)(c.I,{name:u?"chevronUp":"chevronDown",variant:"regular"})})]}),(0,r.jsx)(x,{expanded:u,children:o.renderFlyout({close:E,setKeepOpen:N})})]}):i&&!o.flyoutNoSplit?(0,r.jsxs)(f,{children:[(0,r.jsxs)(C,{children:[(0,r.jsxs)(v,{type:"button",onClick:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),S(o.id,async()=>{var t;await (null==(t=o.onClick)?void 0:t.call(o,e)),E()})},"data-test-id":o.id,children:[(0,r.jsx)(m,{children:o.icon}),(0,r.jsx)(g,{children:null!=(n=o.label)?n:o.toolTipText})]}),(0,r.jsx)(y,{}),(0,r.jsx)(w,{type:"button",onClick:e=>{e.stopPropagation(),p(o.id)},"data-test-id":"".concat(o.id,"-flyout-chevron"),children:(0,r.jsx)(c.I,{name:u?"chevronUp":"chevronDown",variant:"regular",width:12,height:12})})]}),(0,r.jsx)(x,{expanded:u,children:o.renderFlyout({close:E,setKeepOpen:N})})]}
1):(0,r.jsxs)(C,{onMouseEnter:o.flyoutNoSplit?()=>b(o.id):void 0,onMouseLeave:o.flyoutNoSplit?()=>I():void 0,children:[!o.flyoutNoSplit&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(v,{type:"button",onClick:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),S(o.id,async()=>{var t;await (null==(t=o.onClick)?void 0:t.call(o,e)),E()})},"data-test-id":o.id,children:[(0,r.jsx)(m,{children:o.icon}),(0,r.jsx)(g,{children:null!=(l=o.label)?l:o.toolTipText})]}),(0,r.jsx)(y,{})]}),(0,r.jsxs)(d.A.Root,{open:s,onOpenChange:e=>!e&&j(),modal:!1,children:[(0,r.jsx)(d.A.Anchor,{css:o.flyoutNoSplit?{display:"flex",flex:1,minWidth:0}:void 0,children:o.flyoutNoSplit?(0,r.jsxs)(v,{type:"button","data-test-id":o.id,css:{width:"100%"},children:[(0,r.jsx)(m,{children:o.icon}),(0,r.jsx)(g,{children:null!=(a=o.label)?a:o.toolTipText}),(0,r.jsx)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center"},children:(0,r.jsx)(c.I,{name:"ChevronRight",variant:"regular",width:12,height:12})})]}):(0,r.jsx)(w,{type:"button",onMouseEnter:e=>{e.stopPropagation(),b(o.id)},onMouseLeave:()=>I(),"data-test-id":"".concat(o.id,"-flyout-chevron"),children:(0,r.jsx)(c.I,{name:"ChevronRight",variant:"regular",width:12,height:12})})}),(0,r.jsx)(d.A.Popup,{side:"right",align:"start",hideArrow:!0,children:(0,r.jsx)("div",{onClick:e=>e.stopPropagation(),onMouseEnter:()=>k(),onMouseLeave:()=>I(),children:o.renderFlyout({close:()=>{j(),E()},setKeepOpen:N})})})]})]}):null},C=(0,o.I4)("div",{display:"flex",alignItems:"center",width:"100%"}),v=(0,o.I4)(s.$,{flex:1,display:"flex",alignItems:"center",gap:"6px",fontSize:(0,i.D)(14),fontWeight:"400",color:o.w4.colors.gray11,background:"none",border:"none",padding:(0,i.D)(12),cursor:"pointer",minWidth:0,outline:"none",transition:"background-color 0.2s",boxShadow:"none",borderRadius:"0px","&:hover":{backgroundColor:o.w4.colors.blue3},"&:disabled":{opacity:.5,cursor:"not-allowed"}}),y=(0,o.I4)("div",{width:"1px",height:"24px",backgroundColor:o.w4.colors.gray7,flexShrink:0}),w=(0,o.I4)("button",{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:(0,i.D)(32),minHeight:(0,i.D)(40),border:"none",background:"none",cursor:"pointer",color:o.w4.colors.gray11,outline:"none",transition:"background-color 0.2s",paddingInline:(0,i.D)(6),"&:hover":{backgroundColor:o.w4.colors.blue3}});var j=n(95152);let I=(0,o.I4)(s.$,{display:"flex",gap:"6px",alignItems:"center",fontSize:"0.875rem",lineHeight:"1.5rem",color:o.w4.colors.blue9,fontWeight:"500",borderRadius:"6px",background:"none",boxShadow:"none",padding:"6px",transition:"background-color 0.2s",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto",maxHeight:"40px","&:hover":{border:"1px solid ".concat(o.w4.colors.gray7),backgroundColor:"".concat(o.w4.colors.blue3)},"@maxWidth300":{gap:"4px",padding:"5px",fontSize:"0.75rem"},variants:{isMinimal:{true:{paddingBlock:(0,i.D)(8),paddingInline:(0,i.D)(12),gap:(0,i.D)(10)}}}}),k=(0,o.I4)("div",{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.25rem",marginTop:"16px",width:"100%",minWidth:0,overflow:"hidden",variants:{isMinimal:{true:{marginTop:(0,i.D)(12)}},isHeader:{true:{marginTop:(0,i.D)(0)}}}}),E=(0,o.I4)("div",{display:"flex",gap:"1rem",width:"100%",minWidth:0,overflow:"hidden",variants:{isMinimal:{true:{gap:(0,i.D)(12)}},isHeader:{true:{justifyContent:"end",gap:(0,i.D)(10)}}}}),N=(0,o.I4)("div",{height:"1px",background:o.w4.colors.gray6,margin:"8px 0"}),S=(0,o.I4)(s.$,{flexShrink:0,paddingInline:(0,i.D)(8),color:"".concat(o.w4.colors.gray11,"!important"),minWidth:(0,i.D)(40),width:(0,i.D)(40),height:(0,i.D)(40),display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:"".concat(o.w4.colors.blue3),border:"1px solid ".concat(o.w4.colors.gray7)}}),T=(e,t,n,r,l)=>{let a={visibleActions:[],overflowActions:[]};if(!e.length)return a;let o=n-(l?r:0),i=0;if(e.forEach((n,r)=>{n&&n.id&&(i+=t[n.id]||0,r<e.length-1&&(i+=16))}),i<=n)return{visibleActions:[...e],overflowActions:[]};let s=0;for(let n=0;n<e.length;n++){let r=e[n];if(!r||!r.id)continue;let l=t[r.id]||0,i=24*(n<e.length-1);if(s+l+i<=o)a.visibleActions.push(r),s+=l+i;else{a.overflowActions=e.slice(n);break}}return a},A=()=>{let[e,t]=(0,a.useState)({});return{states:e,handleAction:async(e,n)=>{t(t=>({...t,[e]:l.q.LOADING}));try{await n(),t(t=>({...t,[e]:l.q.IDLE}))}catch(n){t(t=>({...t,[e]:l.q.IDLE}))}}}},R=a.memo(e=>{let{actions:t,defaultOverflowActions:n=[],className:i="",containerWidth:s,isMinimal:C=!1,isHeader:v=!1,buttonCss:y,moreButtonCss:w,shouldShowBlinker:R,forceInlineFlyout:M}=e,[L,D]=(0,a.useState)(()=>{let e={};
1return[...t,...n].forEach(t=>{var n;((null==(n=t.subActions)?void 0:n.length)||t.renderFlyout&&t.flyoutNoSplit)&&(e[t.id]=!0)}),e}),_=(0,a.useCallback)(e=>{requestAnimationFrame(()=>{D(t=>({...t,[e]:!t[e]}))})},[]),H=(0,a.useCallback)(e=>!!L[e],[L]),{states:P,handleAction:O}=A(),[z,B]=(0,a.useState)({id:null,keepOpen:!1}),F=(0,a.useRef)(null),V=(0,a.useCallback)(()=>{F.current&&(clearTimeout(F.current),F.current=null)},[]),U=(0,a.useCallback)(e=>{V(),B({id:e,keepOpen:!1})},[V]),W=(0,a.useCallback)(()=>{V(),B(e=>e.keepOpen?e:{id:null,keepOpen:!1})},[V]),G=(0,a.useCallback)(()=>{V(),F.current=setTimeout(()=>{B(e=>e.keepOpen?e:{id:null,keepOpen:!1})},150)},[V]);(0,a.useEffect)(()=>V,[V]);let Z=(0,a.useCallback)(e=>{B(t=>({...t,keepOpen:e}))},[]),q=(0,a.useRef)(null),[$,K]=(0,a.useState)([]),[Y,X]=(0,a.useState)(n),[J,Q]=(0,a.useState)(!1),[ee,et]=(0,a.useState)(!1),en=(0,a.useRef)(null),er={};t.forEach((e,n)=>{let r=t[n];e.width&&r&&(er[r.id]=e.width)});let el=(0,a.useCallback)(()=>{if(!q.current&&!s)return;let{visibleActions:e,overflowActions:r}=T(t,er,s||q.current.offsetWidth,40,n.length>0);K(e),X(r),Q(!0)},[t,s]);(0,a.useEffect)(()=>{if(s||!q.current)return;let e=new ResizeObserver(()=>{el()});return e.observe(q.current),()=>{e.disconnect()}},[el,s]);let ea=(0,a.useCallback)(e=>{e.stopPropagation(),et(e=>!e)},[]),eo=(e,t)=>"loading"===t&&e.loadingComponent||(0,r.jsxs)(r.Fragment,{children:[e.icon,e.label]}),ei=(0,a.useCallback)((e,t)=>e.map(e=>{var n,a,i;if(null==(n=e.subActions)?void 0:n.length){let t=H(e.id);return(0,r.jsxs)(f,{children:[(0,r.jsxs)(h,{onClick:t=>{t.stopPropagation(),_(e.id)},"data-test-id":e.id,trackingProperties:e.trackingProperties,children:[(0,r.jsx)(m,{color:"blue",children:e.icon}),(0,r.jsx)(g,{children:e.label}),(0,r.jsx)("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center"},children:(0,r.jsx)(c.I,{name:t?"chevronUp":"chevronDown",variant:"regular"})})]}),(0,r.jsx)(x,{expanded:t,children:e.subActions.map(e=>{let t=e.actionState===l.q.LOADING||P[e.id]===l.q.LOADING;return(0,r.jsx)(h,{onClick:t=>{t.stopPropagation(),O(e.id,async()=>{var n;await (null==(n=e.onClick)?void 0:n.call(e,t))})},disabled:t,"data-test-id":e.id,trackingProperties:e.trackingProperties,children:(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:[(0,r.jsx)(m,{children:t?(null==e?void 0:e.loadingComponent)||(0,r.jsx)(u.y,{size:14,color:o.w4.colors.blue10}):e.icon}),(0,r.jsx)(g,{children:e.label})]})},e.id)})})]},e.id)}if(e.renderFlyout)return(0,r.jsx)(b,{action:e,inlineFlyout:null==t?void 0:t.inlineFlyout,isFlyoutOpen:z.id===e.id,expanded:null==(a=L[e.id])||a,onToggleExpand:_,onOpenFlyout:U,onCloseFlyout:W,onScheduleClose:G,onCancelScheduledClose:V,onCloseParentPopover:()=>et(!1),onSetKeepOpen:Z,onAction:O},e.id);let s=(0,r.jsxs)(h,{onClick:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),O(e.id,async()=>{var n;await (null==(n=e.onClick)?void 0:n.call(e,t)),et(!1)})},"data-test-id":e.id,trackingProperties:e.trackingProperties,children:[(0,r.jsx)(m,{children:e.icon}),(0,r.jsx)(g,{children:null!=(i=e.label)?i:e.toolTipText})]},e.id);return e.toolTipText?(0,r.jsx)(p.h,{tipInfo:e.toolTipText,children:s}):s}),[O,H,L,P,_,z,U,W,G,V,Z,et]),es=null!=M?M:n.length+Y.length===1;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(k,{ref:q,className:i,style:{visibility:J?"visible":"hidden"},isMinimal:C,isHeader:v,children:[(0,r.jsx)(E,{isMinimal:C,isHeader:v,children:$.map(e=>{var t;let n=e.actionState||P[e.id]||l.q.IDLE,o=n===l.q.LOADING||P[e.id]===l.q.LOADING;return e.renderCustomButton?(0,r.jsx)(a.Fragment,{children:e.renderCustomButton({actionState:n,onAction:t=>O(e.id,t),isLoading:o})},e.id):e.toolTipText?(0,r.jsx)(a.Fragment,{children:(0,r.jsx)(p.h,{tipInfo:e.toolTipText,children:(0,r.jsx)(I,{onClick:t=>{t.stopPropagation(),O(e.id,async()=>{var n;await (null==(n=e.onClick)?void 0:n.call(e,t))})},css:e.cssProperties?{...y,...e.cssProperties}:y,disabled:e.actionState===l.q.LOADING||P[e.id]===l.q.LOADING,"data-test-id":null!=(t=e.label)?t:e.toolTipText,isMinimal:C,trackingProperties:e.trackingProperties,children:eo(e,e.actionState||P[e.id]||l.q.IDLE)})})},e.id):(0,r.jsx)(I,{onClick:t=>{t.stopPropagation(),O(e.id,async()=>{var n;await (null==(n=e.onClick)?void 0:n.call(e,t))})},disabled:e.disabled||e.actionState===l.q.LOADING||P[e.id]===l.q.LOADING,"data-test-id":e.label,isMinimal:C,disableGa4Tracking:e.disableGa4Tracking,css:e.cssProperties?{...y,...e.cssProperties}:y,trackingProperties:e.trackingProperties,children:eo(e,e.actionState||P[e.id]||l.q.IDLE)},e.id)})}),(Y.length>0||n.length>0)&&(0,r.jsxs)(d.A.Root,{open:ee,onOpenChange:et,children:[(0,r.jsx)(d.A.Anchor,{ref:en,children:(0,r.jsx)(p.h,{tipInfo:"More options",children:(0,r.jsxs)(S,{size:"medium",variant:"link",onClick:ea,"data-test-id":"more-options-button",css:w,children:[(0,r.jsx)(c.I,{name:"ellipsisVertical",variant:"solid"}),R&&(0,r.jsx)(j.xw,{animate:!0,isResearch:!0})]})})}),(0,r.jsx)(d.A.Popup,{align:"end",hideArrow:!0,children:(0,r.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{maxHeight:"min(70vh, var(--radix-popover-content-available-height, 70vh))",overflowY:"auto"},children:[ei(n,{inlineFlyout:es}),n.length>0&&Y.length>0&&(0,r.jsx)(N,{}),ei(Y,{inlineFlyout:es})]})})]})]})})})},12457:(e,t,n)=>{"use strict";n.d(t,{N:()=>u});var r=n(80263),l=n(9283),a=n(53239),o=n(37034),i=n(16679),s=n(70077),c=n(18696);let d=[{field:"title",label:"Title"},{field:"createdAt",label:"Date Added"},{field:"updatedAt",label:"Date Modified"}];function u(e){var t,n;let{sortField:i,sortDirection:s,onSortChange:c,disabled:u,isMobileWeb:f,iconOnly:x,portalContainer:b}=e,[C,v]=(0,a.useState)(!1),y=null!=(n=null==(t=d.find(e=>e.field===i))?void 0:t.label)?n:"Date Modified";
1return(0,r.jsxs)(r.Fragment,{children:[f&&C&&(0,o.createPortal)((0,r.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:()=>v(!1)}),document.body),(0,r.jsxs)(l.bL,{open:C,onOpenChange:u?void 0:v,children:[(0,r.jsx)(l.l9,{asChild:!0,children:(0,r.jsxs)(p,{disabled:u,children:[!x&&(0,r.jsxs)(m,{children:["Sort by ",y]}),(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M6.96509 10.9647L4.56509 13.3647C4.25259 13.6772 3.74509 13.6772 3.43259 13.3647L1.03259 10.9647C0.720093 10.6522 0.720093 10.1447 1.03259 9.83224C1.34509 9.51974 1.85259 9.51974 2.16509 9.83224L3.20009 10.8672V3.19974C3.20009 2.75724 3.55759 2.39974 4.00009 2.39974C4.44259 2.39974 4.80009 2.75724 4.80009 3.19974V10.8672L5.83509 9.83224C6.14759 9.51974 6.65509 9.51974 6.96759 9.83224C7.28009 10.1447 7.28009 10.6522 6.96759 10.9647H6.96509ZM8.80009 2.39974H9.60009C10.0426 2.39974 10.4001 2.75724 10.4001 3.19974C10.4001 3.64224 10.0426 3.99974 9.60009 3.99974H8.80009C8.35759 3.99974 8.00009 3.64224 8.00009 3.19974C8.00009 2.75724 8.35759 2.39974 8.80009 2.39974ZM8.80009 5.59974H11.2001C11.6426 5.59974 12.0001 5.95724 12.0001 6.39974C12.0001 6.84224 11.6426 7.19974 11.2001 7.19974H8.80009C8.35759 7.19974 8.00009 6.84224 8.00009 6.39974C8.00009 5.95724 8.35759 5.59974 8.80009 5.59974ZM8.80009 8.79974H12.8001C13.2426 8.79974 13.6001 9.15724 13.6001 9.59974C13.6001 10.0422 13.2426 10.3997 12.8001 10.3997H8.80009C8.35759 10.3997 8.00009 10.0422 8.00009 9.59974C8.00009 9.15724 8.35759 8.79974 8.80009 8.79974ZM8.80009 11.9997H14.4001C14.8426 11.9997 15.2001 12.3572 15.2001 12.7997C15.2001 13.2422 14.8426 13.5997 14.4001 13.5997H8.80009C8.35759 13.5997 8.00009 13.2422 8.00009 12.7997C8.00009 12.3572 8.35759 11.9997 8.80009 11.9997Z",fill:"#5D6A81"})})]})}),(0,r.jsx)(l.ZL,{container:null!=b?b:void 0,children:(0,r.jsx)(l.UC,{align:"end",sideOffset:4,style:{zIndex:9999},className:"min-w-[180px] bg-white rounded-lg border border-gray-200 shadow-lg py-1",children:d.map(e=>(0,r.jsxs)(h,{selected:i===e.field,onClick:()=>{var t;(t=e.field)===i?c(t,"asc"===s?"desc":"asc"):c(t,"asc"),v(!1)},children:[e.label,i===e.field&&(0,r.jsxs)(g,{children:[" ","asc"===s?"↑":"↓"]})]},e.field))})})]})]})}let p=(0,i.I4)(c.$,{display:"flex",alignItems:"center",gap:"6px",height:(0,s.D)(32),padding:"0 10px",fontSize:"14px",fontWeight:500,fontFamily:"IBM Plex Sans, sans-serif",borderRadius:"6px",border:"1px solid ".concat(i.w4.colors.gray7),backgroundColor:i.w4.colors.white,cursor:"pointer",color:i.w4.colors.gray11,boxShadow:"none","&:hover":{backgroundColor:i.w4.colors.gray3},"&:disabled":{opacity:.4,cursor:"not-allowed",pointerEvents:"none"},variants:{open:{true:{backgroundColor:i.w4.colors.gray3}}}}),h=(0,i.I4)(c.$,{width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"14px",fontWeight:500,textAlign:"left",border:"none",cursor:"pointer",color:i.w4.colors.gray11,backgroundColor:"transparent",boxShadow:"none","&:hover":{backgroundColor:i.w4.colors.gray2,borderRadius:"0px",boxShadow:"none"},variants:{selected:{true:{color:i.w4.colors.blue11,fontWeight:600}}}}),m=(0,i.I4)("span",{"@sm":{display:"none"}}),g=(0,i.I4)("span",{marginLeft:"auto",fontSize:"12px",fontFamily:"IBM Plex Sans, sans-serif",color:i.w4.colors.gray9,fontWeight:500})},13837:()=>{},14813:(e,t,n)=>{"use strict";n.d(t,{HH:()=>s,Jp:()=>o,Rh:()=>c,UB:()=>r});let r={"image/*":"Images (PNG, JPG, GIF, etc.)","application/pdf":"PDF","text/markdown":"MD","application/msword":"DOC","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"DOCX","application/vnd.ms-excel":"XLS","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"XLSX","text/csv":"CSV","application/vnd.ms-powerpoint":"PPT","application/vnd.openxmlformats-officedocument.presentationml.presentation":"PPTX"},l={pdf:"application/pdf",md:"text/markdown",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",csv:"text/csv",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",heic:"image/heic",heif:"image/heif"},a=new Set(["PAPERPAL_DOCUMENT","CITATION","CITATION_WITH_ATTACHMENT"]);function o(e){return!!e&&!a.has(e.toUpperCase())}function i(e,t){if(!e)return!1;let n=function(e){var t;let n=e.trim().toLowerCase().replace(/^\./,"");return null!=(t=l[n])?t:n}(e);return t.some(e=>e.endsWith("/*")?n.startsWith(e.slice(0,-1)):e===n)}function s(e,t){return e.fileType&&i(e.fileType,t)?1:e.attachments.filter(e=>i(e.contentType,t)).length}function c(e,t){return e.attachments.filter(e=>i(e.contentType,t))}},15025:()=>{}
1,17288:(e,t,n)=>{"use strict";n.d(t,{r:()=>h});var r=n(80263),l=n(16679),a=n(70077),o=n(18696),i=n(59008),s=n(67106);let c=(0,l.I4)("div",{flex:1,minWidth:0,display:"flex",alignItems:"center",border:"1px solid ".concat(l.w4.colors.gray6),borderRadius:(0,a.D)(6),paddingInline:(0,a.D)(6),gap:(0,a.D)(6),background:"white","&:focus-within":{borderColor:l.w4.colors.blue9}}),d=(0,l.I4)("input",{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:l.w4.colors.blue12,fontWeight:500,fontSize:(0,a.D)(14),paddingBlock:(0,a.D)(10),"&::placeholder":{color:l.w4.colors.gray9,fontWeight:400},"@sm":{fontSize:(0,a.D)(16)},"&:disabled":{opacity:.5}}),u=(0,l.I4)("div",{display:"flex",alignItems:"center",gap:(0,a.D)(4),flexShrink:0}),p=(0,l.I4)("button",{display:"flex",alignItems:"center",justifyContent:"center",border:"none",padding:"4px 8px",background:"transparent",cursor:"pointer",color:l.w4.colors.gray6,backgroundColor:l.w4.colors.gray2,borderRadius:(0,a.D)(6),width:(0,a.D)(32),height:(0,a.D)(32),"&:hover":{color:l.w4.colors.blue9,backgroundColor:l.w4.colors.gray3},"&:disabled":{opacity:.4,backgroundColor:l.w4.colors.gray2},variants:{active:{true:{color:l.w4.colors.blue9,backgroundColor:l.w4.colors.blue3,"&:hover":{backgroundColor:l.w4.colors.blue4}}}}}),h=e=>{let{value:t,onChange:n,onCommit:l,onClear:a,placeholder:o="Search in Library...",isLoading:h=!1,disabled:g=!1,inputRef:f,showAddCitationButton:x=!1,updateRoute:b}=e;return(0,r.jsxs)(c,{children:[x&&(0,r.jsx)(m,{type:"button",id:"add-citation",onClick:b,"data-testid":"add-citation",children:(0,r.jsx)(i.X,{width:18,height:18})}),(0,r.jsx)(d,{ref:f,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"===e.key&&l()},placeholder:o,disabled:g}),(0,r.jsxs)(u,{children:[(0,r.jsx)(p,{type:"button",onClick:()=>{a?a():(n(""),l())},active:!0,"aria-label":"Clear search",css:{visibility:t?"visible":"hidden"},children:(0,r.jsx)(s.I,{name:"circleXmark",variant:"regular"})}),(0,r.jsx)(p,{type:"button",onClick:l,disabled:h,active:!!t,"aria-label":"Search",children:(0,r.jsx)(s.I,{name:"search",variant:"regular"})})]})]})},m=(0,l.I4)(o.$,{right:"4px",minHeight:"24px",height:"24px",minWidth:"24px",margin:"0 4px",padding:"2px",border:"none",borderRadius:"4px",backgroundColor:l.w4.colors.gray2,color:l.w4.colors.gray6,fontWeight:500,"&:hover":{backgroundColor:l.w4.colors.gray3,color:l.w4.colors.gray7}})},18740:()=>{},18865:(e,t,n)=>{"use strict";n.d(t,{Cj:()=>r,KB:()=>a,mK:()=>l});let r="https://cdn.paperpal.com/assets/images/library/library-illustration-rc.webp",l="Supported formats: BibTeX (.bib), RIS (.ris), and CSL JSON (csl.json).",a={filtered:{heading:"No results found.",subtext:"No items match your current search or filter.<br />Try adjusting your search terms or clearing filters."},empty:{heading:"Looks empty in here!",subtext:"Start with importing files to this collection!"}}},19185:()=>{},20214:(e,t,n)=>{"use strict";n.d(t,{M:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsxs)("g",{clipPath:"url(#clip0_768_30454)",children:[(0,r.jsx)("path",{d:"M15.4304 1H4.76342C4.58666 1 4.41713 1.07022 4.29214 1.19521C4.16714 1.32021 4.09692 1.48973 4.09692 1.6665V4.5L10.0969 6.25L16.0969 4.5V1.6665C16.0969 1.48973 16.0267 1.32021 15.9017 1.19521C15.7767 1.07022 15.6072 1 15.4304 1Z",fill:"#41A5EE"}),(0,r.jsx)("path",{d:"M16.0969 4.5H4.09692V8L10.0969 9.75L16.0969 8V4.5Z",fill:"#2B7CD3"}),(0,r.jsx)("path",{d:"M16.0969 8H4.09692V11.5L10.0969 13.25L16.0969 11.5V8Z",fill:"#185ABD"}),(0,r.jsx)("path",{d:"M16.0969 11.5H4.09692V14.3335C4.09692 14.5103 4.16714 14.6798 4.29214 14.8048C4.41713 14.9298 4.58666 15 4.76342 15H15.4304C15.6072 15 15.7767 14.9298 15.9017 14.8048C16.0267 14.6798 16.0969 14.5103 16.0969 14.3335V11.5Z",fill:"#103F91"}),(0,r.jsx)("path",{opacity:"0.1",d:"M8.43042 3.5H4.09692V13H8.43042C8.60703 12.9995 8.77625 12.9291 8.90113 12.8042C9.02601 12.6793 9.0964 12.5101 9.09692 12.3335V4.1665C9.0964 3.9899 9.02601 3.82068 8.90113 3.6958C8.77625 3.57092 8.60703 3.50053 8.43042 3.5Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.93042 4H4.09692V13.5H7.93042C8.10703 13.4995 8.27625 13.4291 8.40113 13.3042C8.52601 13.1793 8.5964 13.0101 8.59692 12.8335V4.6665C8.5964 4.4899 8.52601 4.32067 8.40113 4.1958C8.27625 4.07092 8.10703 4.000
153 7.93042 4Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.93042 4H4.09692V12.5H7.93042C8.10703 12.4995 8.27625 12.4291 8.40113 12.3042C8.52601 12.1793 8.5964 12.0101 8.59692 11.8335V4.6665C8.5964 4.4899 8.52601 4.32067 8.40113 4.1958C8.27625 4.07092 8.10703 4.00053 7.93042 4Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.43042 4H4.09692V12.5H7.43042C7.60703 12.4995 7.77625 12.4291 7.90113 12.3042C8.02601 12.1793 8.0964 12.0101 8.09692 11.8335V4.6665C8.0964 4.4899 8.02601 4.32067 7.90113 4.1958C7.77625 4.07092 7.60703 4.00053 7.43042 4Z",fill:"black"}),(0,r.jsx)("path",{d:"M0.763424 4H7.43042C7.60719 4 7.77672 4.07022 7.90171 4.19521C8.0267 4.32021 8.09692 4.48973 8.09692 4.6665V11.3335C8.09692 11.5103 8.0267 11.6798 7.90171 11.8048C7.77672 11.9298 7.60719 12 7.43042 12H0.763424C0.586657 12 0.41713 11.9298 0.292137 11.8048C0.167144 11.6798 0.0969238 11.5103 0.0969238 11.3335L0.0969238 4.6665C0.0969238 4.48973 0.167144 4.32021 0.292137 4.19521C0.41713 4.07022 0.586657 4 0.763424 4Z",fill:"#185ABD"}),(0,r.jsx)("path",{d:"M6.07183 10.5H5.17183L4.12183 7.05L3.02183 10.5H2.12183L1.12183 5.5H2.02183L2.72183 9L3.77183 5.6H4.52183L5.52183 9L6.22183 5.5H7.07183L6.07183 10.5Z",fill:"white"})]}),(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:"clip0_768_30454",children:(0,r.jsx)("rect",{width:"16.129",height:"16",fill:"white"})})})]})},20312:(e,t,n)=>{"use strict";n.d(t,{E:()=>l});var r=n(80263);let l=e=>{let{height:t=30,width:n=22}=e;return(0,r.jsxs)("svg",{width:n,height:t,viewBox:"0 0 22 30",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{opacity:"0.1",d:"M10.9586 29.9999C15.5931 29.9999 19.3501 29.7182 19.3501 29.3706C19.3501 29.023 15.5931 28.7412 10.9586 28.7412C6.32404 28.7412 2.56702 29.023 2.56702 29.3706C2.56702 29.7182 6.32404 29.9999 10.9586 29.9999Z",fill:"#0060FF"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.56979 0H10.9613L21.0312 10.0699V25.1747C21.0312 26.1016 20.2798 26.853 19.3529 26.853H2.56979C1.64288 26.853 0.891479 26.1016 0.891479 25.1747V1.67831C0.891479 0.751405 1.64288 0 2.56979 0Z",fill:"#0060FF"}),(0,r.jsxs)("g",{opacity:"0.1",children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.56979 0H10.9613V26.853H2.56979C1.64288 26.853 0.891479 26.1016 0.891479 25.1747V1.67831C0.891479 0.751405 1.64288 0 2.56979 0Z",fill:"url(#paint0_linear_2493_5982)"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.9606 0L21.0304 10.0699L10.9606 12.5873V0Z",fill:"url(#paint1_linear_2493_5982)"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.56979 0H10.9613L0.891479 10.0699V1.67831C0.891479 0.751406 1.64288 0 2.56979 0Z",fill:"url(#paint2_linear_2493_5982)"})]}),(0,r.jsx)("path",{opacity:"0.35",fillRule:"evenodd",clipRule:"evenodd",d:"M10.9606 0L21.0304 10.0699H12.6389C11.712 10.0699 10.9606 9.31846 10.9606 8.39156V0Z",fill:"white"}),(0,r.jsx)("path",{d:"M4.47834 16.7779C4.92552 16.3654 5.65056 16.3654 6.09775 16.7779C8.81266 19.2825 13.2144 19.2825 15.9293 16.7779C16.3765 16.3654 17.1015 16.3654 17.5487 16.7779C17.9959 17.1905 17.9959 17.8593 17.5487 18.2719C13.9394 21.6016 8.08762 21.6016 4.47834 18.2719C4.03115 17.8593 4.03115 17.1905 4.47834 16.7779Z",fill:"white"}),(0,r.jsxs)("defs",{children:[(0,r.jsxs)("linearGradient",{id:"paint0_linear_2493_5982",x1:"5.92641",y1:"13.4265",x2:"10.4278",y2:"25.4305",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.00084",stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"1"})]}),(0,r.jsxs)("linearGradient",{id:"paint1_linear_2493_5982",x1:"10.9606",y1:"12.5873",x2:"21.0304",y2:"12.5873",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.00084",stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"1"})]}),(0,r.jsxs)("linearGradient",{id:"paint2_linear_2493_5982",x1:"0.891479",y1:"0",x2:"10.9613",y2:"0",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.00084",stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"1"})]})]})]})}},20586:(e,t,n)=>{"use strict";n.d(t,{y:()=>a});var r=n(46208);let l=new r.A4;l.table=e=>{let{header:t,rows:n}=e,r=t.length?"<thead><tr>".concat(t.map(e=>'<th style="border: 1px solid #999; padding: 6px; background: #f5f5f5; text-align: left;">'.concat(l.parser.parseInline(e.tokens),"</th>")).join(""),"</tr></thead>"):"",a=n.length?"<tbody>".concat(n.map(e=>"<tr>".concat(e.map(e=>'<td style="border: 1px solid #999; padding: 6px;">'.concat(l.parser.parseInline(e.tokens),"</td>")).join(""),"</tr>")).join(""),"</tbody>"):"";return'<table border="1" cellpadding="6" cellspacing="0" style="border-collapse: collapse; border: 1px solid #999;">'.concat(r).concat(a,"</table>")},l.code=e=>{let{text:t}=e,n=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return'<pre style="background: #f5f5f5; padding: 12px; border-radius: 4px; font-family: monospace; white-space: pre-wrap; margin: 8px 0;"><code>'.concat(n,"</code></pre>")},l.codespan=e=>{let{text:t}=e;return'<code style="background: #f5f5f5; padding: 2px 4px; border-radius: 3px; font-family: monospace;">'.concat(t,"</code>")},l.blockquote=e=>{let{tokens:t}=e;return'<blockquote style="border-left: 3px solid #ccc; padding-left: 12px; margin: 8px 0; color: #555;">'.concat(l.parser.parse(t),"</blockquote>")};let a=async(e,t)=>{let{enriched:n,...a}=null!=t?t:{};if(n)try{return await r.xI.setOptions({...a,renderer:l}).parse(e)}catch(t){return e}return t?await r.xI.setOptions(a).parse(e):await r.xI.parse(e)}},20800:()=>{},20937:()=>{},21367:()=>{},21921:(e,t,n)=>{"use strict";n.d(t,{z:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"12",height:"16",viewBox:"0 0 12 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsx)("g",{clipPath:"url(#clip0_768_31379)",children:(0,r.jsx)("path",{d:"M0 2C0 0.896875 0.896875 0 2 0H6.67188C7.20312 0 7.7125 0.209375 8.0875 0.584375L11.4156 3.91563C11.7906 4.29063 12 4.8 12 5.33125V14C12 15.1031 11.1031 16 10 16H2C0.896875 16 0 15.1031 0 14V2ZM6.5 1.82812V4.75C6.5 5.16563 6.83437 5.5 7.25 5.5H10.1719L6.5 1.82812ZM4 8
1C4 7.73478 3.89464 7.48043 3.70711 7.29289C3.51957 7.10536 3.26522 7 3 7C2.73478 7 2.48043 7.10536 2.29289 7.29289C2.10536 7.48043 2 7.73478 2 8C2 8.26522 2.10536 8.51957 2.29289 8.70711C2.48043 8.89464 2.73478 9 3 9C3.26522 9 3.51957 8.89464 3.70711 8.70711C3.89464 8.51957 4 8.26522 4 8ZM2.89375 14H9.10625C9.6 14 10 13.6 10 13.1062C10 12.8781 9.9125 12.6562 9.75313 12.4906L6.72813 9.30937C6.54063 9.1125 6.27813 9 6.00313 9H5.99375C5.71875 9 5.45938 9.1125 5.26875 9.30937L2.24688 12.4906C2.0875 12.6562 2 12.8781 2 13.1062C2 13.6 2.4 14 2.89375 14Z",fill:"#0062FF"})}),(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:"clip0_768_31379",children:(0,r.jsx)("rect",{width:"12",height:"16",fill:"white"})})})]})},24323:(e,t,n)=>{"use strict";n.d(t,{x:()=>l});var r=n(64570);async function l(e,t,n){let l=new Blob([e],{type:"text/html"}),a=new Blob([t],{type:"text/plain"});"google-doc-add-on"===n?(0,r.v)(r.z.CopyTextToClipboard,{copyText:JSON.stringify({htmlContent:e,plainTextContent:t}),isSerialized:!0}):await navigator.clipboard.write([new ClipboardItem({"text/html":l,"text/plain":a})])}},25432:(e,t,n)=>{"use strict";n.d(t,{$6:()=>T,El:()=>P,Go:()=>C,MR:()=>W,Mu:()=>b,NB:()=>$,NC:()=>u,Rb:()=>p,Sh:()=>E,Vj:()=>L,WM:()=>G,Wo:()=>q,Xu:()=>f,ZE:()=>Z,_v:()=>R,aw:()=>m,b1:()=>g,by:()=>F,bz:()=>z,eY:()=>k,gu:()=>D,gz:()=>O,iQ:()=>Y,j2:()=>j,jH:()=>A,k5:()=>v,ko:()=>K,lA:()=>c,ls:()=>X,nV:()=>d,oJ:()=>N,oX:()=>x,ow:()=>_,r9:()=>V,rI:()=>M,tH:()=>I,uI:()=>S,vg:()=>U,w7:()=>H,x3:()=>B,xg:()=>w,xn:()=>y,yf:()=>J,zL:()=>h});var r=n(80263),l=n(74477),a=n(20677),o=n(68917),i=n(9835);let s=e=>t=>{let{className:n}=t;return(0,r.jsx)(i.g,{icon:e,className:n})},c=s(l.$3Z),d=s(l.rLo),u=s(l.Xbc),p=s(l.v_t);s(l.XYS),s(l.O_q),s(l.W1P);let h=s(l.Bwz),m=s(l.eST),g=s(l.nps),f=s(l.n2$),x=s(l.U1s);s(l.NWG);let b=s(l.el8),C=s(l.c3e);s(l.n_t);let v=s(l.A1W),y=s(l.Pop),w=s(l.pgj),j=s(l.vGi),I=s(l.XGd);s(l.USd);let k=s(l.E4g),E=s(l.GLP),N=s(l.UNK),S=s(l.QLR);s(l.X46),s(a.yHR),s(a.CeG),s(a.zQm),s(a.eZD),s(a.V3T),s(a.mCl);let T=s(a.JHe);s(a.U6Q),s(a.jot);let A=s(a.Hzw),R=s(a.okg),M=s(a.Jt$),L=s(a.XkK),D=s(a.Wzs),_=s(a.w2A),H=s(a.mEO);s(a.hP6);let P=s(a.Yj9),O=s(a.yYc),z=s(a.jPR);s(a.nx5),s(a.A4h),s(a.CQO),s(a.pch);let B=s(a.jyc),F=s(a.tXf);s(a.da3),s(a.Rvk),s(a.hpd);let V=s(a.zLW);s(a.ijD),s(a.ekB),s(a.JmV);let U=s(a.X46),W=s(a.Jyw);s(a.X_o);let G=s(a.sjs);s(a.Uec),s(a.vmR);let Z=s(a.lEd),q=s(a.mGv),$=s(o.zm_);s(o.APe);let K=s(o.IMq),Y=s(o.QRE);s(o.Cyq),s(o.oE6),s(o.yLS);let X=s(o.Uec),J=s(o.vmR)},26189:(e,t,n)=>{"use strict";function r(e){let t=[],n="";for(let r of e)!function(e){var t;let n=null!=(t=e.codePointAt(0))?t:0;return n>=19968&&n<=40959||n>=13312&&n<=19903||n>=131072&&n<=173791||n>=12352&&n<=12447||n>=12448&&n<=12543||n>=44032&&n<=55215||n>=4352&&n<=4607||n>=3584&&n<=3711}(r)?/\s/.test(r)?(n&&(t.push(n),n=""),t.length&&" "!==t[t.length-1]&&t.push(" ")):n+=r:(n&&(t.push(n),n=""),t.push(r));return n&&t.push(n),t.filter(Boolean)}function l(e,t){let n=e.trim(),l=t.replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/\s+/g," ").trim(),a=r(n),o=r(l);if(!a.length&&!o.length)return[];if(!a.length)return[{type:"add",text:l}];if(!o.length)return[{type:"remove",text:n}];let i=a.length,s=o.length;if(i*s>9e5)return console.error("Error in GenAI: Input too large : ",e),[{type:"keep",text:l}];let c=Array.from({length:i+1},()=>Array(s+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=s;t++)c[e][t]=a[e-1]===o[t-1]?c[e-1][t-1]+1:Math.max(c[e-1][t],c[e][t-1]);let d=[],u=i,p=s;for(;u>0||p>0;)0===u?(d.unshift({type:"add",token:o[p-1]}),p--):0===p?(d.unshift({type:"remove",token:a[u-1]}),u--):a[u-1]===o[p-1]?(d.unshift({type:"keep",token:a[u-1]}),u--,p--):c[u-1][p]>=c[u][p-1]?(d.unshift({type:"remove",token:a[u-1]}),u--):(d.unshift({type:"add",token:o[p-1]}),p--);let h=[];for(let{type:e,token:t}of d){let n=h[h.length-1];n&&n.type===e?n.text+=t:h.push({type:e,text:t})}return h}n.d(t,{o:()=>l})},26205:()=>{},26827:(e,t,n)=>{"use strict";n.d(t,{S:()=>i});var r=n(51378),l=n(53239),a=n(68162),o=n(44243);let i=e=>{let[t,n]=(0,o.Q)(),[i,s]=(0,l.useState)(""),c=i.trim().toLowerCase(),d=c.length>0,u=(0,l.useMemo)(()=>(function e(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=[];for(let o of t){var a;l.push({collection:o,depth:r}),(null==(a=o.children)?void 0:a.length)&&!n.has(o.id)&&l.push(...e(o.children,n,r+1))}return l})(e,t).filter(e=>!(0,a.b)(e.collection)),[e,t]),p=(0,l.useMemo)(()=>d?(0,r.c)(e).filter(e=>{let{collection:t}=e;return t.name.toLowerCase().includes(c)&&!(0,a.b)(t)}):[],[e,d,c]);return{search:i,setSearch:s,isSearching:d,collapsedIds:t,toggleExpand:n,rows:d?p:u}}},26897:(e,t,n)=>{"use strict";n.d(t,{w:()=>s});var r=n(78773),l=n(23501),a=n(53239),o=n(64014);let i=e=>{let{ENABLE_TWO_STEP_PLAN_SELECTION:t,ENABLE_TWO_STEP_PLAN_SELECTION_DIFF:n}=e;return!!n||t},s=function(){let{enabled:e,documentId:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{webApiClient:n}=(0,o.p)(),s=(0,a.useCallback)(async()=>{let e=await n.get(t?"/api/v1/capabilities/".concat(t):"/api/v1/capabilities"),r=l.x.parse(e),a=null==r?void 0:r.data;return a&&(a.ENABLE_TWO_STEP_PLAN_SELECTION=i(a)),a},[n,t]);return(0,r.useQuery)({queryKey:["capabilities",t],queryFn:s,cacheTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1,enabled:null==e||e})}},27267:(e,t,n)=>{"use strict";n.d(t,{M:()=>d});var r=n(80263),l=n(45476),a=n(21921),o=n(38825),i=n(44151),s=n(20214),c=n(67106);let d=e=>{let{type:t,height:n=16,width:d=16}=e;if(!t)return(0,r.jsx)(c.I,{name:"paperclip",variant:"regular",height:n,width:d});switch(!0){case t.includes("pdf"):return(0,r.jsx)(l.i,{height:n,width:d});case t.includes("image")||t.includes("png")||t.includes("jpg")||t.includes("jpeg")||t.includes("gif")||t.includes("bmp")||t.includes("svg"):return(0,r.jsx)(a.z,{height:n,width:d});case t.includes("pptx")||t.includes("ppt")||t.includes("presentation"):return(0,r.jsx)(o.V,{height:n,width:d});case t.includes("xls")||t.includes("xlsx")||t.includes("csv")||t.includes("spreadsheetml"):return(0,r.jsx)(i.z,{height:n,width:d});default:return(0,r.jsx)(s.M,{height:n,width:d})}}},27442:(e,t,n)=>{"use strict";n.d(t,{H:()=>o,L:()=>i});var r=n(78773),l=n(81761),a=n(64014);let o="library-collection-list";function i(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{webApiClient:n}=(0,a.p)();return(0,r.useQuery)({queryKey:[o,e],queryFn:async()=>{let t=await n.get("/api/v1/libraries/".concat(e,"/collections"));return l.E_.parse(t)},enabled:!!e&&t,retry:!1,refetchOnWindowFocus:!1,staleTime:3e5})}},27567:(e,t,n)=>{"use strict";n.d(t,{$b:()=>A,$z:()=>F,Ax:()=>w,B8:()=>x,En:()=>m,Es:()=>S,GQ:()=>B,H8:()=>M,Im:()=>I,L3:()=>L,R9:()=>O,Sc:()=>E,TT:()=>p,VK:()=>R,Y9:()=>h,Zb:()=>V,_y:()=>f,dk:()=>j,eG:()=>g,fI:()=>C,fq:()=>v,hE:()=>N,jn:()=>U,mO:()=>c,mW:()=>_,nB:()=>d,o$:()=>y,pV:()=>D,ph:()=>s,qH:()=>u,tj:()=>W,ux:()=>T,vB:()=>z,vw:()=>k,wI:()=>b,zd:()=>P});var r=n(16679),l=n(70077),a=n(18696);let o={scrollbarColor:"".concat(r.w4.colors.gray9," transparent"),scrollbarGutter:"stable","&::-webkit-scrollbar":{width:(0,l.D)(6)},"&::-webkit-scrollbar-thumb":{background:r.w4.colors.gray7,borderRadius:(0,l.D)(4)}},i=(0,r.AH)(o),s=()=>i().toString(),c=(0,r.I4)("div",{width:"100%",margin:"0 auto",background:r.w4.colors.white,fontFamily:"Inter, sans-serif",display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden"}),d=(0,r.I4)("div",{display:"flex",flexDirection:"row",flex:1,minHeight:0,overflow:"hidden"}),u=(0,r.I4)("div",{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0,overflow:"hidden"}),p=(0,l.D)(52),h=(0,r.I4)("div",{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",flexShrink:0,gap:"8px",padding:"10px 16px",background:r.w4.colors.gray2,borderTop:"1px solid ".concat(r.w4.colors.gray5),borderBottom:"1px solid ".concat(r.w4.colors.gray5),fontSize:"14px",fontFamily:"IBM Plex Sans, sans-serif",boxSizing:"border-box","@sm":{padding:"8px 10px"},"@media (min-width: 768px)":{height:p}}),m=(0,r.I4)("div",{display:"flex",gap:"8px",flexShrink:0,"@sm":{order:1,marginLeft:"auto"}}),g=(0,r.I4)("div",{display:"flex",alignItems:"center",gap:"8px",flex:"1 1 auto",minWidth:0,"@sm":{flexBasis:"100%"}});(0,r.I4)("div",{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",flexShrink:0});let f=(0,r.I4)("div",{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%",overflowY:"auto",...o,variants:{clipped:{true:{overflow:"hidden"}}}}),x=(0,r.I4)("div",{display:"flex",flexDirection:"column",padding:"0 0px",minHeight:0,variants:{empty:{true:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"auto"},false:{flexDirection:"column"}}},defaultVariants:{empty:!1}}),b=(0,r.I4)("div",{overflow:"hidden",flexShrink:0,variants:{cell:{checkbox:{width:"16px",height:"16px"},title:{width:"55%",height:"14px"},tag:{width:"56px",height:"18px"}}}}),C=(0,r.I4)("div",{position:"relative",display:"grid",gridTemplateColumns:"32px 1fr auto",gap:"8px",height:(0,l.D)(40),alignItems:"center",padding:"10px 16px",borderBottom:"1px solid ".concat(r.w4.colors.gray5),"& > :first-child":{justifySelf:"center"},"&:hover":{background:r.w4.colors.gray2},"@sm":{gridTemplateColumns:"32px 1fr auto",padding:"8px 10px"},variants:{disabled:{true:{opacity:.45}},isEmpty:{true:{display:"flex",flexDirection:"column",border:"none",justifyContent:"center",alignItems:"center","&:hover":{background:"transparent"}}}}}),v=(0,r.I4)("div",{width:"100%",maxWidth:(0,l.D)(416),flex:"1 1 0",minWidth:0,overflow:"visible","& > div":{paddingInline:0,marginTop:0},"& > div > button":{border:"1px solid ".concat(r.w4.colors.gray7),background:r.w4.colors.white,boxShadow:"none"},variants:{mobileOnly:{true:{"@media (min-width: 768px)":{display:"none"}}}}}),y=(0,r.I4)("div",{fontSize:"14px",fontFamily:"IBM Plex Sans, sans-serif",fontWeight:600,lineHeight:"24px",letterSpacing:"0px",color:r.w4.colors.gray12,overflow:"hidden",display:"flex",flexDirection:"column",gap:"2px"}),w=(0,r.I4)("div",{display:"flex",alignItems:"center",gap:"6px",minWidth:0,overflow:"hidden",flexShrink:0,"& > svg":{flexShrink:0}}),j=(0,r.I4)("div",{display:"flex",alignItems:"center",gap:"6px",justifyContent:"flex-end"}),I=(0,r.I4)("div",{display:"flex",gap:"4px",flexWrap:"wrap","@sm":{display:"none"}}),k=(0,r.I4)("span",{fontSize:"11px",padding:"3px 8px",borderRadius:"6px",fontWeight:500,fontFamily:"IBM Plex Sans, sans-serif"}),E=(0,r.I4)("input",{cursor:"pointer",color:r.w4.colors.blue2,width:"16px",height:"16px",o
1pacity:1,borderRadius:"3px",border:"1px solid ".concat(r.w4.colors.gray7),backgroundColor:r.w4.colors.blue2,flexShrink:0}),N=(0,r.I4)("span",{fontSize:"14px",fontWeight:600,fontFamily:"IBM Plex Sans, sans-serif",color:r.w4.colors.gray12}),S=(0,r.I4)("div",{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",flexShrink:0,gap:"8px",padding:"12px 0",backgroundColor:r.w4.colors.gray2,borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px"}),T=(0,r.I4)("div",{display:"none",width:"30%",minWidth:(0,l.D)(224),maxWidth:(0,l.D)(336),flexShrink:0,"@media (min-width: 768px)":{display:"block",marginRight:"-8px"}}),A=(0,r.I4)("span",{paddingLeft:"16px",fontSize:"14px",color:r.w4.colors.gray11,fontWeight:500,fontFamily:"IBM Plex Sans, sans-serif",lineHeight:"24px",letterSpacing:"0px",flexShrink:0,display:"flex",alignItems:"center",gap:"4px",whiteSpace:"nowrap","@sm":{paddingLeft:"10px"}}),R=(0,r.I4)("span",{display:"inline-flex","@sm":{display:"none"}}),M=(0,r.I4)("span",{display:"none",fontSize:"12px",fontWeight:400,color:r.w4.colors.gray11,fontFamily:"IBM Plex Sans, sans-serif",lineHeight:"16px","@sm":{display:"block",flexBasis:"100%",padding:"0 10px"}}),L=(0,r.I4)("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",padding:0,cursor:"pointer",color:r.w4.colors.gray9,lineHeight:0,flexShrink:0,width:"14px",height:"14px","&:hover":{color:r.w4.colors.gray11}}),D=(0,r.I4)("div",{position:"relative",display:"grid",gridTemplateColumns:"32px 1fr",gap:"8px",height:(0,l.D)(40),padding:"10px 16px",borderBottom:"1px solid ".concat(r.w4.colors.gray5),fontSize:"13px",fontFamily:"IBM Plex Sans, sans-serif",color:r.w4.colors.gray12,"& > :first-child":{justifySelf:"center"},"@sm":{padding:"8px 10px"},"&:hover":{background:r.w4.colors.gray2}}),_=(0,r.I4)("div",{display:"flex",alignItems:"center",gap:"8px",minWidth:0,overflow:"hidden",paddingLeft:"16px","& > img":{flexShrink:0}}),H={position:"absolute",left:"63px",pointerEvents:"none","@sm":{left:"57px"}},P=(0,r.I4)("span",{...H,top:"27px",bottom:0,borderLeft:"1px dotted ".concat(r.w4.colors.gray7)}),O=(0,r.I4)("span",{...H,top:0,borderLeft:"1px dotted ".concat(r.w4.colors.gray7),variants:{isLast:{true:{height:"50%"},false:{bottom:0}}}}),z=(0,r.I4)("span",{...H,top:"50%",width:"9px",borderTop:"1px dotted ".concat(r.w4.colors.gray7)}),B=(0,r.I4)(a.$,{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",padding:"2px",cursor:"pointer",color:r.w4.colors.gray9,lineHeight:0,"&:hover":{color:r.w4.colors.gray11}}),F=(0,r.I4)("div",{display:"flex",alignItems:"center",gap:"8px",flex:1,justifyContent:"flex-end",paddingRight:"16px","@sm":{paddingRight:"10px"}}),V=(0,r.I4)(a.$,{padding:"8px 16px",fontSize:"14px",flex:"1 1 auto",maxWidth:"170px",borderRadius:"8px",border:"1px solid ".concat(r.w4.colors.gray7),backgroundColor:r.
1w4.colors.white,color:r.w4.colors.gray11,fontFamily:"IBM Plex Sans, sans-serif",fontWeight:500,cursor:"pointer","&:hover":{backgroundColor:r.w4.colors.gray4}}),U=(0,r.I4)(a.$,{padding:"8px 16px",fontSize:"14px",flex:"1 1 auto",maxWidth:"170px",borderRadius:"8px",border:"none",fontFamily:"IBM Plex Sans, sans-serif",fontWeight:500,backgroundColor:r.w4.colors.blue9,color:r.w4.colors.white,cursor:"pointer","&:hover":{backgroundColor:r.w4.colors.blue10},"&:disabled":{opacity:.5,cursor:"not-allowed"}}),W=(0,r.I4)(a.$,{border:"none",boxShadow:"none",background:"transparent",padding:0,cursor:"pointer",color:r.w4.colors.blue9,fontSize:"inherit",fontWeight:"inherit",fontFamily:"inherit",lineHeight:"inherit",textDecoration:"underline","&:hover":{color:r.w4.colors.blue10,boxShadow:"none"},"&:focus":{boxShadow:"none"}});(0,r.I4)(a.$,{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",padding:"2px",cursor:"pointer",color:r.w4.colors.gray7,lineHeight:0,flexShrink:0,"&:hover":{color:r.w4.colors.blue7}})},29314:(e,t,n)=>{"use strict";n.d(t,{N:()=>r});let r={AF:"Afghanistan",AX:"Aland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BQ:"Bonaire, Saint Eustatius and Saba ",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",VG:"British Virgin Islands",BN:"Brunei",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos Islands",CO:"Colombia",KM:"Comoros",CK:"Cook Islands",CR:"Costa Rica",HR:"Croatia",CU:"Cuba",CW:"Curacao",CY:"Cyprus",CZ:"Czech Republic",CD:"Democratic Republic of the Congo",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",TL:"East Timor",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",CI:"Ivory Coast",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",XK:"Kosovo",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Laos",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia",MD:"Moldova",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",KP:"North Korea",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestinian Territory",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",CG:"Republic of the Congo",RE:"Reunion",RO:"Romania",RU:"Russia",RW:"Rwanda",BL:"Saint Barthelemy",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serb
1ia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",KR:"South Korea",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syria",TW:"Taiwan",TJ:"Tajikistan",TZ:"Tanzania",TH:"Thailand",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",VI:"U.S. Virgin Islands",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VA:"Vatican",VE:"Venezuela",VN:"Vietnam",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"}},29404:(e,t,n)=>{"use strict";n.d(t,{h:()=>a});var r=n(80263),l=n(90597);let a=e=>{let{tipInfo:t,children:n,isCustomStyled:a,delayDuration:o=0,skipDelayDuration:i=0,supportMobileTap:s=!0,side:c="bottom",css:d,sideOffset:u=4,hideArrow:p=!1}=e;return(0,r.jsx)(l.Bc,{delayDuration:o,skipDelayDuration:i,children:(0,r.jsxs)(l.sb,{supportMobileTap:s,children:[(0,r.jsx)(l.k$,{asChild:!0,children:n}),(0,r.jsx)(l.KL,{children:(0,r.jsxs)(l.ZI,{sideOffset:u,side:c,customStyled:a,css:{...d},children:["string"==typeof t?(0,r.jsx)("span",{children:t}):t,!p&&(0,r.jsx)(l.PR,{customStyled:a})]})})]})})}},29950:(e,t,n)=>{"use strict";n.d(t,{V:()=>p});var r=n(78773),l=n(50246),a=n(11445),o=n(64014);let i=a.z.object({content:a.z.any().optional(),success:a.z.boolean().optional(),message:a.z.string().optional()}),s=(e,t,n,a)=>{let{webApiClient:s,publicWebApiClient:c}=(0,o.p)(),d=t?c:s,u=(0,r.useMutation)({mutationFn:async t=>{let{uploadId:n,documentId:r,s3Key:l,requestId:o}=t;if(!e)throw Error("Editor instance not available");let s={fileId:n,...r&&{documentId:r},...o&&{requestId:o},s3FileKey:l,...a&&{feature:a}};try{let e=await d.post("/api/v1/import-to-editor",s);if(!e||"object"!=typeof e)return{success:!0};return i.parse(e)}catch(e){throw console.error("AI Detection error: Error importing content to editor:",JSON.stringify(e)),e}},onSuccess:async t=>{if((null==t?void 0:t.content)&&e){let n=function(e,t){let n=new Set(Object.keys(t.nodes)),r=new Set(Object.keys(t.marks));function l(e){if("text"===e.type)return e.text||"";let t=e.content;if(!t||0===t.length)return"";let n="";for(let e=0;e<t.length;e++)n+=l(t[e]);return n}function a(e){return{type:"paragraph",content:e?[{type:"text",text:e}]:[]}}let o=Array.isArray(e)?{type:"doc",content:e}:e;try{return function e(t){let o,i,s=t.marks,c=t.content;if(s&&s.length){let e=!1;for(let t=0;t<s.length;t++)if(!r.has(s[t].type)){e=!0;break}if(e){let e=s.filter(e=>r.has(e.type));o=e.length>0?e:void 0}else o=s}if(c&&c.length){i=[];for(let t=0;t<c.length;t++){let r=c[t];if(n.has(r.type)){i.push(e(r));continue}let o=l(r);o&&(console.warn('AI Detection warn: [sanitize] Converting unknown node "'.concat(r.type,'" to paragraph')),i.push(a(o)))}}let d={};for(let e in t)"marks"!==e&&"content"!==e&&(d[e]=t[e]);return o&&o.length>0&&(d.marks=o),void 0!==i&&(d.content=i),d}(o)}catch(e){console.error("AI Detection error: [sanitize] Failed to sanitize content, falling back:",JSON.stringify(e));try{let e=l(o);return{type:"doc",content:e?[a(e)]:[]}}catch(e){return{type:"doc",content:[]}}}}(t.content,e.schema);e.commands.setContent(n)}},onSettled:()=>{null==n||n()}});return{importContent:u.mutate,isImporting:u.isLoading,importingError:u.isError?(0,l.F)(u.error).errorReason:null,importingErrorCode:u.isError?(0,l.F)(u.error).errorCode:null,isImportingError:u.isError,isSuccess:u.isSuccess,data:u.data,resetImport:u.reset}};var c=n(16755),d=n(53239);let u={areFilesProcessing:!1,isImporting:!1,importingError:null,isImportingError:!1,currentFileName:null};function p(e){var t,n;let{editor:r,documentId:l,isPublic:a=!1,feature:o,enabled:i=!0,requestId:p}=e,{removeAllFiles:h,areFilesProcessing:m,fileCitationInfo:g,files:f}=(0,c.v)(),x=(0,d.useRef)(void 0),{importContent:b,isImporting:C,importingError:v,isImportingError:y,importingErrorCode:w,resetImport:j}=s(r,a,(0,d.useCallback)(()=>{h()}
1,[h]),o),I=(0,d.useRef)(m);return((0,d.useEffect)(()=>{i||(x.current=void 0,j())},[i,j]),(0,d.useEffect)(()=>{if(!i)return;if(!(I.current&&!m)||!g||0===g.length){I.current=m;return}let e=g[0],t=null==e?void 0:e.s3FileId,n=null==e?void 0:e.s3Key;t&&(x.current=t,b({uploadId:t,documentId:l||void 0,s3Key:n,requestId:p})),I.current=m},[m,g,l,i,p]),i)?{areFilesProcessing:m,isImporting:C,importingError:v,isImportingError:y,currentFileName:(null==(n=Object.values(f))||null==(t=n[0])?void 0:t.name)||null,uploadId:x.current,importingErrorCode:w}:u}},31042:(e,t,n)=>{"use strict";n.d(t,{h:()=>a}),n(80263),n(74787);var r=n(53239);let l=(0,r.createContext)(null),a=()=>{let e=(0,r.useContext)(l);if(!e)throw Error("useCiteproc must be used within CiteprocProvider");return e}},31353:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(80263),l=n(31740),a=n(60264),o=n(53239);let i=(0,o.forwardRef)((e,t)=>{let{accept:n,multiple:i,maxFiles:s,inputRef:c}=e,d=(0,o.useMemo)(()=>void 0!==i?i:(null!=s?s:1)>1,[i,s]),{getRootProps:u,getInputProps:p}
1=(0,l.V)({noClick:!0}),{getButtonProps:h,getInputProps:m}=(0,a.W)({multiple:d,accept:n});return(0,r.jsxs)("div",{className:"s3-input-container",children:[(0,r.jsx)("input",{...p(),style:{display:"none"}}),(0,r.jsxs)("div",{style:{height:"inherit"},...u(),children:[(0,r.jsx)("input",{...m(),ref:c,style:{opacity:0},className:"w-full"}),(0,r.jsx)("button",{...h(),ref:t,children:"Upload"})]})]})});i.displayName="S3UploadButton"},32549:()=>{},32585:()=>{},33278:(e,t,n)=>{"use strict";n.d(t,{y:()=>a});var r=n(7437),l=n(53239);let a=()=>{let[e,t]=(0,l.useState)("chrome");return(0,l.useEffect)(()=>{t((0,r.ts)())},[]),e}},33346:(e,t,n)=>{"use strict";n.d(t,{$:()=>h});var r=n(80263),l=n(69119),a=n(11230),o=n.n(a),i=n(53239),s=n(47791);let c={primary:"bg-blue-700 text-white hover:bg-blue-800",secondary:"border border-gray-11 text-gray-11 hover:!bg-gray-5",ghost:"text-gray-12 hover:bg-gray-3",ghostNoHover:"text-gray-12",danger:"text-red-600 hover:bg-red-50",filterTrigger:"appearance-none border border-solid border-gray-7 bg-white text-gray-11 shadow-none outline-none ring-0 hover:bg-gray-3 focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0"},d={sm:"px-2.5 py-1.5 text-xs font-medium rounded-md",md:"px-4 py-2 text-sm font-medium rounded-lg",lg:"px-4 py-3 text-sm font-medium rounded-lg",icon:"w-7 h-7 flex items-center justify-center rounded-md"},u=(0,i.forwardRef)((e,t)=>{let{id:n,variant:l="primary",size:a="md",className:i,children:u,tooltip:p,tooltipPosition:h="top",...m}=e,g=(0,r.jsx)("button",{ref:t,id:n,"data-test-id":n,className:o()("cursor-pointer transition-colors whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",c[l],d[a],i),...m,children:u});return p?(0,r.jsx)(s.m,{content:p,position:h,children:g}):g});u.displayName="BaseButton";let p=(0,l.j)(u),h=(0,i.memo)((0,i.forwardRef)((e,t)=>{let{children:n,...l}=e;return(0,r.jsx)(p,{ref:t,as:"button",...l,children:n})}))},34999:(e,t,n)=>{"use strict";n.d(t,{J:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsx)("svg",{viewBox:"0 0 14 10",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",...e,children:(0,r.jsx)("path",{d:"M13.125 1.25C13.125 1.49609 13.0156 1.71484 12.8516 1.87891L5.85156 8.87891C5.6875 9.04297 5.46875 9.125 5.25 9.125C5.00391 9.125 4.78516 9.04297 4.62109 8.87891L1.12109 5.37891C0.957031 5.21484 0.875 4.99609 0.875 4.75C0.875 4.25781 1.25781 3.875 1.75 3.875C1.96875 3.875 2.1875 3.98438 2.35156 4.14844L5.25 7.01953L11.6211 0.648438C11.7852 0.484375 12.0039 0.375 12.25 0.375C12.7148 0.375 13.125 0.757812 13.125 1.25Z"})})},36129:(e,t,n)=>{"use strict";n.d(t,{j:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsx)("path",{opacity:"0.1",d:"M21.6067 45C28.5583 45 34.1936 44.5777 34.1936 44.0566C34.1936 43.5356 28.5583 43.1132 21.6067 43.1132C14.6551 43.1132 9.01978 43.5356 9.01978 44.0566C9.01978 44.5777 14.6551 45 21.6067 45Z",fill:"#0060FF"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.01934 0H21.6062L36.713 15.1066V37.7655C36.713 39.157 35.5846 40.2829 34.1955 40.2829H9.01934C7.6279 40.2829 6.50195 39.1545 6.50195 37.7655V2.51738C6.50195 1.12594 7.63028 0 9.01934 0Z",fill:"#0060FF"}),(0,r.jsxs)("g",{opacity:"0.1",children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.01934 0H21.6062V40.2805H9.01934C7.6279 40.2805 6.50195 39.1521 6.50195 37.7631V2.51738C6.50195 1.12594 7.63028 0 9.01934 0Z",fill:"url(#paint0_linear_30_222)"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.6064 0L36.7131 15.1042L21.6064 18.8804V0Z",fill:"url(#paint1_linear_30_222)"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.01975 0H21.6066L6.5 15.1066V2.51975C6.5 1.12832 7.62832 0.00236912 9.01738 0.00236912L9.01975 0Z",fill:"url(#paint2_linear_30_222)"})]}),(0,r.jsx)("path",{opacity:"0.35",fillRule:"evenodd",clipRule:"evenodd",d:"M21.6064 0L36.7131 15.1066H24.1261C22.7347 15.1066 21.6088 13.9784 21.6088 12.5893V0.00236912L21.6064 0Z",fill:"white"}),(0,r.jsx)("path",{d:"M11.8836 25.1667C12.5544 24.5479 13.6424 24.5479 14.3132 25.1667C18.3856 28.9237 24.9896 28.9237 29.062 25.1667C29.7328 24.5479 30.8208 24.5479 31.4917 25.1667C32.1625 25.7853 32.1625 26.788 31.4917 27.4067C26.0776 32.4011 17.3 32.4011 11.8859 27.4067C11.2151 26.788 11.2151 25.7853 11.8859 25.1667H11.8836Z",fill:"white"}),(0,r.jsxs)("defs",{children:[(0,r.jsxs)("linearGradient",{id:"paint0_linear_30_222",x1:"14.0043",y1:"19.9945",x2:"21.1196",y2:"37.6046",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"1"})]}),(0,r.jsxs)("linearGradient",{id:"paint1_linear_30_222",x1:"21.514",y1:"9.37974",x2:"36.7605",y2:"9.37974",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"1"})]}),(0,r.jsxs)("linearGradient",{id:"paint2_linear_30_222",x1:"6.49526",y1:"7.49526",x2:"21.5142",y2:"7.49526",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"1"})]})]})]})},36932:(e,t,n)=>{"use strict";n.d(t,{Y:()=>B});var r=n(80263),l=n(78773),a=n(81761),o=n(64014),i=n(27442),s=n(44440),c=n(37786),d=n(4230),u=n(51378),p=n(53239),h=n(23013),m=n(16679),g=n(67106),f=n(44499),x=n(83672),b=n(79918),C=n(12457),v=n(47791),y=n(44243),w=n(68162),j=n(33346),I=n(26827),k=n(27567);let E=e=>{let{collections:t,isLoading:n,selectedCollection:l,onSelect:a,isExtension:o=!1}=e,{search:i,setSearch:s,isSearching:c,collapsedIds:d,toggleExpand:u,rows:h}=(0,I.S)(t),m=(0,p.useRef)(null),x=(0,p.useRef)(!1);(0,p.useEffect)(()=>{!n&&!x.current&&l&&m.current&&(m.current.scrollIntoView({block:"nearest"}),x.current=!0)},[n,l,h]);let b=(e,t)=>{t.stopPropagation(),u(e)};return(0,r.jsxs)("div",{className:"hidden md:flex flex-col min-h-0 w-[30%] min-w-[14rem] max-w-[21rem] shrink-0 overflow-hidden border-solid border-b border-t border-l-0 border-gray-5 bg-white",children:[(0,r.jsx)("div",{className:"flex items-center shrink-0 box-border bg-white pr-3 border-solid border-b border-t-0 border-l-0 border-r-0 border-gray-5",style:{height:k.TT},children:(0,r.jsxs)("div",{className:"flex items-center gap-2 w-full h-8 box-border bg-white",children:[(0,r.jsx)("input",{className:"flex-1 min-w-0 h-full border-none bg-transparent font-sans text-[14px] font-normal text-gray-12 outline-none placeholder:text-gray-11",style:{paddingLeft:"".concat(66,"px")},placeholder:"Search in Collections...",value:i,onChange:e=>s(e.target.value)}),(0,r.jsx)(j.$,{id:"search-collection",size:"icon","aria-label":"Search in collections",className:"inline-flex items-center justify-center shrink-0 w-8 h-8 border-none rounded-md bg-blue-11 text-white cursor-pointer hover:bg-blue-10",children:(0,r.jsx)(g.I,{name:"search",variant:"regular",width:14,height:14})})]})}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto ".concat((0,k.ph)()),...o&&{onWheel:e=>e.stopPropagation()},children:n?(0,r.jsx)("div",{className:"px-4 py-1",children:Array.from({length:8}).map((e,t)=>(0,r.jsx)("div",{className:"py-2",children:(0,r.jsx)(f.j,{height:"16px",width:"80%"})},t))}):0===h.length?(0,r.jsx)("div",{className:"p-4 text-center text-[13px] text-gray-9",children:"No collections foun
1d"}):h.map(e=>{var t;let{collection:n,depth:o}=e,i=!c&&!!(null==(t=n.children)?void 0:t.length),s=!d.has(n.id),u=(null==l?void 0:l.id)===n.id;return(0,r.jsxs)("div",{ref:u?m:void 0,onClick:()=>a(n),style:{paddingLeft:"".concat(16+16*o,"px")},className:"flex items-center gap-2 w-full h-10 py-[10px] pr-4 border-none cursor-pointer text-left font-sans text-[14px] font-medium text-gray-12 transition-colors ".concat(u?"bg-blue-2 hover:bg-blue-2":"bg-transparent hover:bg-gray-2"),children:[i?(0,r.jsx)("span",{role:"button",onClick:e=>b(n.id,e),style:{width:16,height:16},className:"inline-flex items-center justify-center shrink-0 text-gray-9 cursor-pointer rounded hover:text-gray-12",children:(0,r.jsx)(g.I,{name:s?"chevronDown":"ChevronRight",variant:"regular",width:12,height:12})}):(0,r.jsx)("span",{className:"shrink-0",style:{width:16}}),(0,r.jsx)("span",{className:"inline-flex items-center justify-center shrink-0 text-gray-11",style:{width:18},children:(0,r.jsx)(w.c,{collection:n,folderWidth:18,folderHeight:"16"})}),(0,r.jsx)("span",{className:"flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:n.name})]},n.id)})})]})};var N=n(18865),S=n(14813);let T=[{matches:e=>e.includes("pdf"),icon:"icon-pdf"},{matches:e=>e.includes("image")||e.includes("svg")||e.includes("jpg")||e.includes("jpeg")||e.includes("png")||e.includes("gif")||e.includes("bmp")||e.includes("tiff")||e.includes("webp"),icon:"icon-img"},{matches:e=>e.includes("word")||e.includes("document")||e.includes("docx")||e.includes("doc"),icon:"icon-word"},{matches:e=>e.includes("sheet"),icon:"icon-xlxs"},{matches:e=>e.includes("csv"),icon:"icon-csv"},{matches:e=>e.includes("presentation")||e.includes("powerpoint"),icon:"icon-ppt"},{matches:e=>["json","ris","bib"].some(t=>e.includes(t)),icon:"icon-file-lines"},{matches:e=>["reference"].some(t=>e.includes(t)),icon:"icon-subtitle"},{matches:e=>["md","markdown"].some(t=>e.includes(t)),icon:"icon-md"}];function A(e){var t,n;let r=e&&null!=(n=null==(t=T.find(t=>{let{matches:n}=t;return n(e)}))?void 0:t.icon)?n:"icon-file";return"".concat("https://cdn.paperpal.com/assets/images/icons","/").concat(r,".svg")}let R={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},M=(0,p.memo)(function(e){var t;let{item:n,supportedTypes:l,validCount:a,isItemSelected:o,selectedAttachmentSet:i,isExpanded:s,wouldExceedLimit:c,isAtCapacityForChild:d,onToggleExpand:u,onToggleItem:h,onToggleAllAttachments:m,onToggleAttachment:f,onLimitReached:x}=e,b=a>0,C=n.attachments.length>0,v=!C&&(0,S.Jp)(n.itemType)?n.fileType:void 0,y=(0,p.useMemo)(()=>C?(0,S.Rh)(n,l):[],[C,n,l]),w=y.filter(e=>i.has(e.id)).length,j=C?y.length>0&&w===y.length:o,I=C&&!j&&w>0,E=!j&&c,N=!j&&(!b||E&&!x);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.fI,{disabled:!b,children:[(0,r.jsx)(k.Sc,{type:"checkbox","aria-label":"Select ".concat(n.title||"Untitled"),checked:j,disabled:N||!b,ref:e=>{e&&(e.indeterminate=I)},css:N||!b||E?{opacity:.4,cursor:"not-allowed"}:{},onChange:()=>{if(b){if(E&&x)return void x();if(C)return void m(n.id,y.map(e=>e.id));h(n.id)}}}),(0,r.jsx)(k.o$,{children:(0,r.jsxs)(k.Ax,{children:[C&&(0,r.jsx)(k.L3,{type:"button","aria-label":s?"Collapse attachments":"Expand attachments",onClick:()=>u(n.id),children:(0,r.jsx)(g.I,{name:s?"chevronDown":"ChevronRight",size:"sm",variant:"regular"})}),!C&&v&&(0,r.jsx)("img",{width:22,height:22,src:A(v),alt:"file icon"}),(0,r.jsx)("span",{style:R,children:n.title||"Untitled"})]})}),(0,r.jsx)(k.dk,{children:(0,r.jsx)(k.Im,{children:null==(t=n.labels)?void 0:t.map(e=>(0,r.jsx)(k.vw,{css:{background:"".concat(e.color,"22"),color:e.color},children:e.name},e.id))})}),C&&s&&(0,r.jsx)(k.zd,{})]}),C&&s&&y.map((e,t)=>{var l,a,o,s,c,u;let p=i.has(e.id),h=!p&&d,m=h&&!x,g=null!=(l=e.contentType)?l:e.fileType,b=t===y.length-1;return(0,r.jsxs)(k.pV,{children:[(0,r.jsx)(k.Sc,{type:"checkbox","aria-label":"Select ".concat(null!=(o=null!=(a=e.filename)?a:e.title)?o:"attachment"),checked:p,disabled:m,css:m||h?{opacity:.4,cursor:"not-allowed"}:{},onChange:()=>{if(h&&x)return void x();f(n.id,e.id)}}),(0,r.jsxs)(k.mW,{children:[(0,r.jsx)("img",{width:22,height:22,src:A(g),alt:"file icon"}),(0,r.jsx)("span",{style:R,children:null!=(c=null!=(s=e.filename)?s:e.title)?c:"Untitled"})]}),(0,r.jsx)(k.R9,{isLast:b}),(0,r.jsx)(k.vB,{})]},null!=(u=e.id)?u:t)})]})}),L=e=>{let{isSearchOrFilterActive:t,content:n}=e;return(0,r.jsxs)(k.fI,{isEmpty:!0,children:[t?(0,r.jsx)("div",{className:"bg-gray-3 rounded-full aspect-square w-12 h-12 shrink-0 flex items-center justify-center mb-2 sm:mb-4",children:(0,r.jsx)(g.I,{name:"search",variant:"regular",color:"".concat(m.w4.colors.gray11)})}):(0,r.jsx)("img",{src:N.Cj,alt:"Empty state",className:"w-24 h-24 sm:w-32 sm:h-32 md:w-48 md:h-48 object-contain mb-4 sm:mb-6",style:{mixBlendMode:"darken"}}),(0,r.jsx)(k.hE,{css:{color:m.w4.colors.gray9},children:n.heading}),t&&(0,r.jsx)("p",{className:"text-base text-gray-10 mb-6 sm:mb-8 text-sm",dangerouslySetInnerHTML:{__html:n.subtext}})]})},D=e=>{let{selectedCount:t,maxFiles:n,supportedTypes:l,attachDisabled:a,onCancel:o,onAttach:i,attachIcon:s,upgradeCta:c}=e,d=l.map(e=>{var t;return null!=(t=S.UB[e])?t:e}).join(", ");return(0,r.jsxs)(k.Es,{children:[(0,r.jsxs)(k.H8,{children:[" ","Supported file types: ",d]}),(0,r.jsx)(k.ux,{}),(0,r.jsxs)(k.$b,{children:[(0,r.jsx)("span",{style:t>n?{color:"".concat(m.w4.colors.red9)}:void 0,children:t>n?"".concat(t," selected — only ").concat(n," allowed."):t>0?"".concat(t," / ").concat(n," file(s) selected."):"Select up to ".concat(n," files.")}),c&&(0,r.jsxs)("span",{children:[c.message," ",c.tooltip?(0,r.jsx)(v.m,{position:"top",delay:200,content:c.tooltip,contentClassName:"bg-blue-12 text-white text-[13px] shadow-sm max-w-[280px] !whitespace-normal text-center",children:(0,r.jsx)(k.tj,{onClick:c.onClick,children:c.ctaLabel})}):(0,r.jsx)(k.tj,{onClick:c.onClick,children:c.ctaLabel})]}),(0,r.jsx)(k.VK,{children:(0,r.jsx)(v.m,{position:"top",delay:200,content:(0,r.jsxs)("div",{className:"flex flex-col gap-1 text-[14px]",children:[(0,r.jsx)("span",{className:"font-semibold mb-3",children:"Supported file types"}),(0,r.jsx)("span",{className:"line-height-2.5",children:d})]}),contentClassName:"bg-blue-12 text-white text-[13px] shadow-sm max-w-[280px] !whitespace-normal text-center",children:(0,r.jsx)(k.GQ,{type:"button","aria-label":"Supported file types",children:(0,r.jsx)(g.I,{name:"circleInfo",variant:"regular",width:16,height:16})})})})]}),(0,r.jsxs)(k.$z,{children:[(0,r.jsx)(k.Zb,{onClick:o,children:"Cancel"}),(0,r.jsx)(k.jn,{disabled:a,onClick:i,leftIcon:s,children:"Attach File(s)"})]})]})};var _=n(40928);(0,m.I4)("div",{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1}),(0,m.I4)("div",{background:m.w4.colors.blue2,border:"1px solid ".concat(m.w4.colors.gray6),borderRadius:"10px",boxShadow:"0 10px 25px rgba(0,0,0,0.12)",padding:"16px",width:"100%",maxWidth:"360px",fontFamily:"IBM Plex Sans, sans-serif"}),(0,m.I4)("div",{display:"flex",alignItems:"center",gap:"10px",marginBottom:"10px"}),(0,m.I4)("div",{position:"relative",width:"40px",height:"40px",borderRadius:"8px",background:m.w4.colors.blue5,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}),(0,m.I4)("p",{fontSize:"14px",fontWeight:600,color:m.w4.colors.gray12,margin:0}),(0,m.I4)("p",{fontSize:"13px",color:m.w4.colors.gray11,marginBottom:"10px"}),(0,m.I4)("p",{fontSize:"12px",fontWeight:600,color:m.w4.colors.gray12,marginBottom:"6px"}),(0,m.I4)("ul",{listStyle:"none",padding:0,margin:0,marginBottom:"14px",display:"flex",flexDirection:"column",gap:"4px"}),(0,m.I4)("li",{fontSize:"12px",color:m.w4.colors.gray11,display:"flex",alignItems:"center",gap:"6px"});var H=n(51138),P=n(23727);let O=new Set,z=e=>(0,r.jsxs)(k.fI,{children:[(0,r.jsx)(k.wI,{cell:"checkbox",children:(0,r.jsx)(f.j,{height:"16px",width:"100%"})}),(0,r.jsx)(k.wI,{cell:"title",children:(0,r.jsx)(f.j,{height:"14px",width:"100%"})}),(0,r.jsx)(k.Im,{children:(0,r.jsx)(k.wI,{cell:"tag",children:(0,r.jsx)(f.j,{height:"18px",width:"100%"})})})]},e),B=e=>{var t,n,f;let{isActive:w=!0,searchQuery:j="",excludeFilterTypes:I,onAttach:T,onCancel:A,isMobileWeb:R,featureName:B,fileConfiguration:F={maxFiles:5,supportedTypes:c.kT.split(",")},attachmentItemTypes:V,isExtension:U=!1,portalContainer:W,onUploadLimitExceededChange:G,onLim
1itReached:Z,selectionCap:q,onSelectionChange:$,attachIcon:K,upgradeCta:Y,hideHeaderText:X=!1}=e,{maxFiles:J,supportedTypes:Q}=F,ee=null!=q?q:J,[et,en]=(0,p.useState)([]),[er,el]=(0,p.useState)([]),[ea,eo]=(0,p.useState)([]),[ei,es]=(0,p.useState)(void 0),[ec,ed]=(0,p.useState)("updatedAt"),[eu,ep]=(0,p.useState)("desc"),[eh,em]=(0,y.Q)(),{data:eg}=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],{webApiClient:t}=(0,o.p)();return(0,l.useQuery)({queryKey:["library-stats"],queryFn:async()=>{let e=await t.get("/api/v1/libraries/stats");return a.ek.parse(e)},enabled:e,retry:1,retryDelay:2e3,refetchOnWindowFocus:!1})}(),ef=null==eg||null==(t=eg.data)?void 0:t.libraryId,ex=function(e){return!(null==e?void 0:e.isPrimeUser)&&(null==e?void 0:e.monthlyFileUploadBalance)===0}(null==eg||null==(n=eg.data)?void 0:n.chatConfig);(0,p.useEffect)(()=>{null==G||G(ex)},[ex,G]);let{data:eb,isLoading:eC,refetch:ev}=(0,i.L)(ef),ey=(0,p.useMemo)(()=>{var e;return null!=(e=null==eb?void 0:eb.data)?e:[]},[null==eb?void 0:eb.data]),ew=P.env.NEXT_PUBLIC_EDIT_FOR_WEB_ORIGIN,ej=ew?"".concat(ew,"/library"):"/library",eI=(0,p.useMemo)(()=>(0,u.c)(ey).filter(e=>"Paperpal documents"!==e.collection.name),[ey]),ek=et.length>0||er.length>0||ea.length>0,eE=!!j||ek;(0,p.useEffect)(()=>{if(void 0===ei&&eI.length>0){var e;let t=eI.find(e=>"references"===e.collection.name.toLowerCase());es(null==(e=null!=t?t:eI[0])?void 0:e.collection)}},[eI,ei]);let eN=null==ei?void 0:ei.id,{selectedIds:eS,selectedIdsSet:eT,selectedAttachmentIds:eA,toggleItem:eR,toggleAllAttachmentsForItem:eM,toggleAttachment:eL,getSelectedItems:eD}=(0,H.v)(eN),e_=(0,p.useMemo)(()=>({itemTypes:et.length>0?et:void 0,labelIds:ea.length>0?ea:void 0,dateFilter:er[0]&&"CUSTOM_DATE_RANGE"!==er[0]?er[0]:void 0,fromYear:"CUSTOM_DATE_RANGE"===er[0]?er[1]:void 0,toYear:"CUSTOM_DATE_RANGE"===er[0]?er[2]:void 0}),[et,ea,er]),eH=(0,p.useMemo)(()=>({sortBy:ec,sortDir:eu}),[ec,eu]),{data:eP,isLoading:eO,isFetching:ez,isFetchingNextPage:eB,hasNextPage:eF,fetchNextPage:eV,refetch:eU}=(0,s.u)({libraryId:ef,collectionId:eN,size:10,filters:e_,sort:eH,searchQuery:j||void 0,includeExtractedText:B===d.A9.Enum.WRITE,attachmentItemTypes:V}),eW=(0,p.useRef)({libraryId:ef,hasCollection:!!eN,isFetching:ez});eW.current={libraryId:ef,hasCollection:!!eN,isFetching:ez};let eG=(0,p.useCallback)(()=>{let{libraryId:e,hasCollection:t,isFetching:n}=eW.current;e&&(ev(),t&&!n&&eU())},[eU,ev]),eZ=(0,p.useRef)(w);(0,p.useEffect)(()=>{let e=w&&!eZ.current;eZ.current=w,e&&eG()},[w,eG]);let eq=(0,p.useRef)(w);eq.current=w,(0,p.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&eq.current&&eG()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[eG]);let e$=eE?N.KB.filtered:N.KB.empty,eK=(0,p.useMemo)(()=>{var e;return null!=(e=null==eP?void 0:eP.pages.flatMap(e=>e.data.content))?e:[]},[eP]),eY=(0,p.useMemo)(()=>new Map(eK.map(e=>[e.id,e])),[eK]),eX=(0,p.useMemo)(()=>new Map(eK.map(e=>[e.id,(0,S.HH)(e,Q)])),[eK,Q]),eJ=(0,p.useMemo)(()=>eK.filter(e=>{var t;return(null!=(t=eX.get(e.id))?t:0)>0||eT.has(e.id)}),[eK,eX,eT]),eQ=!!eN,e0=!ef||eC||!eQ||eO&&!eB,e1=(null!=(f=null==eP?void 0:eP.pages.length)?f:0)>0,e2=(0,p.useMemo)(()=>{let e=new Map;return eK.forEach(t=>{var n;return null==(n=t.labels)?void 0:n.forEach(t=>{t.color&&!e.has(t.id)&&e.set(t.id,t)})}),Array.from(e.values())},[eK]),e4=(0,p.useMemo)(()=>eS.reduce((e,t)=>{var n;let r=eA[t];return r&&r.size>0?e+r.size:e+(null!=(n=eX.get(t))?n:0)},0),[eS,eA,eX]);(0,p.useEffect)(()=>{null==$||$(eD(eY))},[$,eD,eY]);let e5=(0,p.useCallback)(e=>{var t,n,r;let l=null!=(n=eX.get(e.id))?n:0,a=ee-(e4-(e.attachments.length>0?null!=(r=null==(t=eA[e.id])?void 0:t.size)?r:0:eT.has(e.id)?l:0));return{validCount:l,wouldExceedLimit:l>a,isAtCapacity:a<=0,isAtCapacityForChild:e4>=ee}},[eX,eA,eT,e4,ee]),e7=(0,p.useCallback)(()=>{eF&&!eB&&e1&&eV()},[eF,eB,e1,eV]);(0,p.useEffect)(()=>{e1&&!ez&&!eB&&eF&&0===eJ.length&&eV()},[e1,ez,eB,eF,eJ.length,eV]);let e3=(0,p.useCallback)((e,t,n)=>{en(e),el(t),eo(n)},[]),e9=(0,p.useCallback)(()=>{en([]),el([]),eo([])},[]),e6=(0,p.useCallback)((e,t)=>{ed(e),ep(t)},[]),e8=!e0&&!eB&&0===eJ.length;return(0,r.jsxs)(k.mO,{children:[(0,r.jsxs)(k.nB,{children:[(0,r.jsx)(E,{collections:ey,isLoading:eC,selectedCollection:ei,onSelect:es,isExtension:U}),(0,r.jsxs)(k.qH,{children:[(0,r.jsxs)(k.Y9,{children:[(0,r.jsx)(k.eG,{children:(0,r.jsx)(k.fq,{mobileOnly:!0,children:(0,r.jsx)(x.w,{collections:ey,isCollectionsLoading:eC,selectedCollection:ei,onSelect:es,isInline:!0})})}),(0,r.jsxs)("div",{className:"hidden md:flex flex-shrink-0 items-center gap-1.5",children:[(0,r.jsx)(v.m,{position:"bottom",delay:200,interactive:!0,content:(0,r.jsx)("span",{className:"text-[14px]",children:(0,r.jsx)(_.H,{libraryUrl:ej})}),contentClassName:"bg-blue-12 text-white shadow-sm max-w-[240px] !whitespace-normal text-center",children:(0,r.jsx)("span",{className:"inline-flex items-center cursor-pointer",children:(0,r.jsx)(g.I,{name:"circleInfo",variant:"regular",color:"".concat(m.w4.colors.gray11)})})}),(0,r.jsx)("span",{className:"hidden lg:inline text-gray-11 text-right whitespace-nowrap",style:{fontFamily:"IBM Plex Sans, sans-serif",fontWeight:500,fontSize:"14px",lineHeight:"24px",letterSpacing:"0px"},children:"Showing relevant files."})]}),(0,r.jsxs)(k.En,{children:[(0,r.jsx)(C.N,{sortField:ec,sortDirection:eu,onSortChange:e6,disabled:e0,isMobileWeb:R,portalContainer:W}),(0,r.jsx)(b.I,{activeTypes:et,activeDates:er,activeLabels:ea,coloredLabels:e2,onApply:e3,onReset:e9,disabled:e0,excludeTypes:I,isMobileWeb:R,hideHeaderText:B===d.A9.Enum.WRITE||B===d.A9.Enum.AI_CHAT||X,portalContainer:W,triggerHeight:32})]}),(0,r.jsxs)("div",{className:"flex md:hidden items-center flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"w-8 flex-shrink-0 flex items-center justify-center h-4",children:(0,r.jsx)(g.I,{name:"circleInfo",variant:"regular",width:14,height:14,color:"".concat(m.w4.colors.gray11)})}),(0,r.jsx)("span",{className:"flex-1 text-gray-11 text-left",style:{fontFamily:"IBM Plex Sans, sans-serif",fontWeight:400,fontSize:"12px",lineHeight:"16px",letterSpacing:"0px"},children:(0,r.jsx)(_.H,{libraryUrl:ej})})]})]}),e0||e8?(0,r.jsx)(k._y,{clipped:e0,...U&&{onWheel:e=>e.stopPropagation()},children:(0,r.jsx)(k.B8,{empty:e8,children:e0?Array.from({length:10}).map((e,t)=>z(t)):(0,r.jsx)(L,{isSearchOrFilterActive:eE,content:e$})})}):(0,r.jsx)(h.aY,{className:(0,k.ph)(),style:{flex:1,minHeight:0},overscan:200,data:eJ,computeItemKey:(e,t)=>t.id,endReached:e7,...U&&{onWheel:e=>e.stopPropagation()},components:{Footer:()=>eB?(0,r.jsx)(k.B8,{children:Array.from({length:3}).map((e,t)=>z("skeleton-next-".concat(t)))}):null},itemContent:(e,t)=>
1{var n;let{validCount:l,wouldExceedLimit:a,isAtCapacityForChild:o}=e5(t);return(0,r.jsx)(M,{item:t,supportedTypes:Q,validCount:l,isItemSelected:eT.has(t.id),selectedAttachmentSet:null!=(n=eA[t.id])?n:O,isExpanded:t.attachments.length>0&&!eh.has(t.id),wouldExceedLimit:a,isAtCapacityForChild:o,onToggleExpand:em,onToggleItem:eR,onToggleAllAttachments:eM,onToggleAttachment:eL,onLimitReached:Z?()=>Z(Math.max(0,ee-e4)):void 0})}})]})]}),(0,r.jsx)(D,{attachDisabled:0===e4,selectedCount:e4,maxFiles:J,supportedTypes:Q,onCancel:A,onAttach:()=>null==T?void 0:T(eD(eY)),attachIcon:K,upgradeCta:Y})]})}},37158:(e,t,n)=>{"use strict";function r(e){let[t,n]=e.split("-").slice(0,2);if(t&&n){let e=new Date(parseInt(t),parseInt(n)-1);return new Intl.DateTimeFormat("en-US",{month:"short",year:"numeric"}).format(e)}return e}function l(e){return new Date(null!=e?e:Date.now()).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric"}).replace(/ /g,"-")}n.d(t,{eN:()=>r,t7:()=>l})},37786:(e,t,n)=>{"use strict";n.d(t,{$s:()=>I,GU:()=>f,HR:()=>c,Mm:()=>i,O:()=>m,Oy:()=>d,Qf:()=>w,T4:()=>v,Xc:()=>y,Zk:()=>u,cR:()=>g,d7:()=>h,e1:()=>N,eJ:()=>C,fs:()=>o,hT:()=>E,kT:()=>j,ke:()=>l,ki:()=>s,sO:()=>x,ue:()=>p,un:()=>b,xW:()=>a,zr:()=>k});var r=n(11445);let l=r.z.enum(["KEEP_WRITING","EXPAND","COUNTERARGUMENT","TRANSITION","IMPACT"]),a=r.z.enum(["CONTRAST_THIS","MAKE_PROFESSIONAL","MAKE_CONCISE","EXPAND_FURTHUR","EXPLAIN_THIS"]),o=r.z.enum(["ACCEPT_OUTCOME","RETRY","DISCARD"]),i=r.z.enum(["CONCLUDING_STATEMENT","PROBLEM_STATEMENT","IMPACT_STATEMENT","SUPPORTIGN_STATEMENT","CONNECTING_SENTENCE","SUGGEST_OBJECTIVE","SUMMARIZE_TEXT","WRITE_INTRODUCTION","EXPLAIN_THIS","EXPAND_ON_THIS","KEEP_WRITING"]),s=r.z.enum(["WRITE_PARAGRAPH","EXTRACT_KEY_TAKEAWAYS","DRAFT_OUTLINE","DRAFT_LITERATURE_REVIEW","WRITE_CONCLUSION","WRITE_IDEA","THESIS_STATEMENT","GENERATE_SURVEY","WRITE_EMAIL","WRITE_GRATITUDE","BRAINSTORM_IDEAS","WRITE_SECTION_ON_TOPIC","BRAINSTORM_ON_TOPIC","GENERATE_DETAILED_OUTLINE"]),c="Upload up to 5 files (pdf, docx, pptx, xlsx, csv, png, jpg, jpeg, webp, gif). Max. 25 MB/file.",d={maxFiles:20,maxFileSize:100},u="Upload up to {{maxFiles}} files (pdf, docx, pptx, markdown). Max. {{maxFileSize}} MB/file.",p="You have reached the max. limit of {{maxFiles}} files for this chat. Start a new chat to upload more files/import files from your Library.",h={KEEP_WRITING:"Keep writing",EXPAND:"Expand on",COUNTERARGUMENT:"Write a counterargument",TRANSITION:"Write a transition sentence",IMPACT:"Write an impact statement"},m=e=>({WRITE_PARAGRAPH:e("write_paragraph_empty_prompt","Write a paragraph on"),EXTRACT_KEY_TAKEAWAYS:e("extract_key_takeaways_empty_prompt","Extract key takeaways"),DRAFT_OUTLINE:e("draft_outline_empty_prompt","Use notes and develop a structure"),DRAFT_LITERATURE_REVIEW:e("draft_literature_review_empty_prompt","Draft a literature review"),WRITE_CONCLUSION:e("write_conclusion_empty_prompt","Write a conclusion section"),WRITE_IDEA:e("write_idea_empty_prompt","Writing ideas on"),THESIS_STATEMENT:e("thesis_statement_empty_prompt","Suggest thesis statement ideas"),GENERATE_SURVEY:e("generate_survey_empty_prompt","Generate survey questions"),WRITE_EMAIL:e("write_email_empty_prompt","Write an email"),WRITE_GRATITUDE:e("write_gratitude_empty_prompt","Write a warm and personal thank-you note to recipient type eg: mentor who describe their support/contribution. Write it as if I'm talking to them over coffee—warm, genuine, and real. Make it feel natural and conversational—use contractions, avoid greeting card phrases, and keep it a bit emotional or imperfect rather than overly polished. The tone should be relatable, sincere, and thoughtful."),BRAINSTORM_IDEAS:e("brainstorm_ideas_empty_prompt","Brainstorm"),WRITE_SECTION_ON_TOPIC:e("write_section_on_topic_empty_prompt","Write a section on"),BRAINSTORM_ON_TOPIC:e("brainstorm_on_topic_empty_prompt","Brainstorm on a"),GENERATE_DETAILED_OUTLINE:e("generate_detailed_outline_empty_prompt","Generate a detailed outline for a")}),g={WRITE_PARAGRAPH:"Write a paragraph on add topic.",EXTRACT_KEY_TAKEAWAYS:"Extract key takeaways from the attached file ",DRAFT_OUTLINE:"Use notes and develop a structure that includes all key points",DRAFT_LITERATURE_REVIEW:"Using the attached file as context, draft a sample Literature Review on the topic",WRITE_CONCLUSION:"Draft a conclusion section based on the attached notes",WRITE_IDEA:"What more can I write on the topic of add topic.",THESIS_STATEMENT:"Provide 5 suggestions for a strong thesis statement on add topic.",GENERATE_SURVEY:"Help me draft a structured and hierarchical survey questionnaire on enter your survey topic with a suitable title",WRITE_EMAIL:"Write a leave application email to my professor",WRITE_GRATITUDE:"Write a warm and personal thank-you note to re
1cipient type eg: mentor who describe their support/contribution Write it as if I'm talking to them over coffee—warm, genuine, and real. Make it feel natural and conversational—use contractions, avoid greeting card phrases, and keep it a bit emotional or imperfect rather than overly polished. The tone should be relatable, sincere, and thoughtful.",BRAINSTORM_IDEAS:"I need your assistance in brainstorming the topic of add topic. Give me brainstorming points from multiple different and discrete perspectives on the topic to form a holistic view. Help me deliberate on this topic in detail. Be descriptive in your response and use the most appropriate structure/format in generating your response.",WRITE_SECTION_ON_TOPIC:"Write a section on topic for purpose.",BRAINSTORM_ON_TOPIC:"Brainstorm on a topic.",GENERATE_DETAILED_OUTLINE:"Generate a detailed outlines for a article type."},f={CONCLUDING_STATEMENT:"Generate concluding statements",PROBLEM_STATEMENT:"Suggest problem statements",IMPACT_STATEMENT:"Write an implication statement",SUPPORTIGN_STATEMENT:"Suggest supporting statements",CONNECTING_SENTENCE:"Give me connecting sentences",SUGGEST_OBJECTIVE:"Suggest aim/objective",SUMMARIZE_TEXT:"Summarize this text",WRITE_INTRODUCTION:"Write an Introduction",EXPLAIN_THIS:"Explain this",EXPAND_ON_THIS:"Expand on this",KEEP_WRITING:"Keep writing"},x={CONCLUDING_STATEMENT:"write a concluding paragraph/closing statements strictly based on the given context",PROBLEM_STATEMENT:"generate potential problem statements based on the given context",IMPACT_STATEMENT:"write an implication statement strictly based on the context of the input text",SUPPORTIGN_STATEMENT:"generate potential supporting statements based on the input text",CONNECTING_SENTENCE:"suggest potential connecting statements to improve the flow and connection between the given text",SUGGEST_OBJECTIVE:"suggest some aim/objective statements strictly within the context of the below text",SUMMARIZE_TEXT:"generate a concise summarize of this text",WRITE_INTRODUCTION:"write an introduction section based on the context of the given text",EXPLAIN_THIS:"explain the text in simple words",EXPAND_ON_THIS:"Expand on this text in 1-2 paragraphs",KEEP_WRITING:"Write the next 3 sentences based on the context of the below input text. Only give the required output. Do not give any opening preamble statement or filler text."},b=e=>({CONTRAST_THIS:e("contrast_this","Contrast this"),MAKE_PROFESSIONAL:e("make_professional","Make it professional"),ACCEPT_OUTCOME:e("accept_outcome","Accept"),RETRY:e("retry","Retry"),DISCARD:e("discard","Discard"),MAKE_CONCISE:e("make_concise","Make it concise"),EXPAND_FURTHUR:e("expand_further","Expand it further"),EXPLAIN_THIS:e("explain_this","Explain this")}),C=e=>({CONTRAST_THIS:e("contrast_this_followup_prompt","Write a contrast statement based on the input text provided. Only provide the contrast statement without any preamble/filler text."),MAKE_PROFESSIONAL:e("make_professional_followup_prompt","Improve the tone of the provided input text such that it sounds more formal/professional. Strictly preserve the original meaning."),MAKE_CONCISE:e("make_concise_followup_prompt","Make it more concise"),EXPAND_FURTHUR:e("expand_further_followup_prompt","Expand it to make it more longer"),EXPLAIN_THIS:e("explain_this_followup_prompt","Explain the text in simple words")}),v={WRITE_PARAGRAPH:["add topic"],EXTRACT_KEY_TAKEAWAYS:[],DRAFT_OUTLINE:[],DRAFT_LITERATURE_REVIEW:[],WRITE_CONCLUSION:[],WRITE_IDEA:["add topic"],THESIS_STATEMENT:["add topic"],GENERATE_SURVEY:["enter your survey topic"],WRITE_EMAIL:[],WRITE_GRATITUDE:["recipient type eg: mentor","describe their support/contribution"],BRAINSTORM_IDEAS:["add topic"],WRITE_SECTION_ON_TOPIC:["topic","purpose"],BRAINSTORM_ON_TOPIC:["topic"],GENERATE_DETAILED_OUTLINE:["article type"]},y={KEEP_WRITING:"Keep writing",EXPAND:"Expand this text further based on the context of the input text",COUNTERARGUMENT:"Write a counterargument",TRANSITION:"write a transition sentence that can be used after the input text",IMPACT:"write an impact statement based on the context of the input text"};r.z.enum(["ACCEPT","NEXT_SUGGESTION","PREVIOUS_SUGGESTION","REJECT"]);let w={maxFiles:5,maxTotalFileSize:0x4b00000,maxFileSize:0x1900000},j="image/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation",I="application/pdf,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation",k=".pdf,.md,.docx,.pptx",E={maxFiles:20,maxTotalFileSize:2097152e3,maxFileSize:0x6400000,allowedFileTypes:[...I.split(","),...k.split(",")]},N=1e4},38825:(e,t,n)=>{"use strict";n.d(t,{V:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsxs)("g",{clipPath:"url(#clip0_774_30256)",children:[(0,r.jsx)("path",{d:"M9.09772 1C7.24287 1.00541 5.46553 1.74464 4.15394 3.05623C2.84236 4.36781 2.10313 6.14515 2.09772 8L10.9662 9.8685L9.09772 1Z",fill:"#ED6C47"}),(0,r.jsx)("path",{d:"M9.09772 1C10.9526 1.00541 12.7299 1.74464 14.0415 3.05623C15.3531 4.36781 16.0923 6.1451
15 16.0977 8L12.5977 10.379L9.09772 8V1Z",fill:"#FF8F6B"}),(0,r.jsx)("path",{d:"M9.09772 15C10.9526 14.9946 12.7299 14.2554 14.0415 12.9438C15.3531 11.6322 16.0923 9.85485 16.0977 8H2.09772C2.10313 9.85485 2.84236 11.6322 4.15394 12.9438C5.46553 14.2554 7.24287 14.9946 9.09772 15Z",fill:"#D35230"}),(0,r.jsx)("path",{opacity:"0.1",d:"M8.43069 3.5H3.75069C2.60774 4.84667 2.01981 6.57767 2.10617 8.34188C2.19252 10.1061 2.94669 11.7714 4.21569 13H8.43069C8.60738 12.9996 8.77673 12.9293 8.90172 12.8044C9.02671 12.6795 9.09717 12.5102 9.09769 12.3335V4.1665C9.09717 3.98981 9.02671 3.82051 8.90172 3.69562C8.77673 3.57073 8.60738 3.5004 8.43069 3.5Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.93072 4H3.36772C2.33706 5.46238 1.90977 7.26578 2.17471 9.03514C2.43965 10.8045 3.37642 12.4036 4.79022 13.5H7.93122C8.10782 13.4995 8.27705 13.4291 8.40192 13.3042C8.5268 13.1793 8.59719 13.0101 8.59772 12.8335V4.6665C8.59719 4.48981 8.52673 4.32051 8.40175 4.19562C8.27676 4.07073 8.10741 4.0004 7.93072 4Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.93072 4H3.36772C2.47995 5.2587 2.03579 6.7768 2.10513 8.31552C2.17446 9.85424 2.75334 11.3262 3.75072 12.5H7.93122C8.10782 12.4995 8.27704 12.4291 8.40192 12.3042C8.5268 12.1793 8.59719 12.0101 8.59772 11.8335V4.6665C8.59719 4.48981 8.52673 4.32051 8.40175 4.19562C8.27676 4.07073 8.10741 4.0004 7.93072 4Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.43072 4H3.36772C2.47995 5.2587 2.03579 6.7768 2.10513 8.31552C2.17446 9.85424 2.75334 11.3262 3.75072 12.5H7.43122C7.60782 12.4995 7.77704 12.4291 7.90192 12.3042C8.0268 12.1793 8.09719 12.0101 8.09772 11.8335V4.6665C8.09719 4.48981 8.02673 4.32051 7.90175 4.19562C7.77676 4.07073 7.60741 4.0004 7.43072 4Z",fill:"black"}),(0,r.jsx)("path",{d:"M0.764217 4H7.43122C7.60798 4 7.77751 4.07022 7.9025 4.19521C8.0275 4.32021 8.09772 4.48973 8.09772 4.6665V11.3335C8.09772 11.5103 8.0275 11.6798 7.9025 11.8048C7.77751 11.9298 7.60798 12 7.43122 12H0.764217C0.58745 12 0.417924 11.9298 0.292931 11.8048C0.167938 11.6798 0.0977173 11.5103 0.0977173 11.3335L0.0977173 4.6665C0.0977173 4.48973 0.167938 4.32021 0.292931 4.19521C0.417924 4.07022 0.58745 4 0.764217 4Z",fill:"#C43E1C"}),(0,r.jsx)("path",{d:"M4.09622 5.49983C4.58856 5.46668 5.07668 5.60931 5.47372 5.90233C5.63656 6.04763 5.76421 6.22807 5.84703 6.42999C5.92984 6.63191 5.96564 6.85003 5.95172 7.06783C5.95718 7.35062 5.87453 7.62811 5.71522 7.86183C5.55306 8.12014 5.3197 8.32607 5.04322 8.45483C4.72712 8.60159 4.38165 8.67411 4.03322 8.66683H3.07822V10.4998H2.09772V5.49983H4.09622ZM3.07772 7.84133H3.92122C4.18866 7.861 4.45404 7.78202 4.66722 7.61933C4.75192 7.56484 4.82015 7.48827 4.86456 7.39787C4.90896 7.30747 4.92786 7.20667 4.91922 7.10633C4.91922 6.55333 4.59705 6.27683 3.95272 6.27683H3.07772V7.84133Z",fill:"#F9F7F7"})]}),(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:"clip0_774_30256",children:(0,r.jsx)("rect",{width:"16.142",height:"16",fill:"white"})})})]})},39953:()=>{},40576:()=>{},40653:(e,t,n)=>{"use strict";n.d(t,{a:()=>l,f:()=>r});let r=150,l={REWRITE_WORD_COUNT_LIMIT_EXCEEDED:"REWRITE_WORD_COUNT_LIMIT_EXCEEDED"}},40928:(e,t,n)=>{"use strict";n.d(t,{H:()=>a});var r=n(80263);let l={color:"inherit",textDecoration:"underline",cursor:"pointer"},a=e=>{let{libraryUrl:t}=e;return(0,r.jsxs)(r.Fragment,{children:["Only supported file types appear. Open"," ",(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:l,children:"Library"})," ","for all access"]})}},43011:(e,t,n)=>{"use strict";n.d(t,{j:()=>N});var r=n(80263),l=n(4518),a=n(18696),o=n(70077),i=n(83264),s=n(67669),c=n(67106),d=n(16679);let u=(0,d.I4)("div",{backgroundColor:d.w4.colors.white,position:"relative",fontFamily:"IBM Plex Sans",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",maxWidth:"28rem",width:"100%",overflow:"hidden"}),p=(0,d.I4)("div",{position:"absolute",left:"-0.5rem",top:0}),h=(0,d.I4)("div",{position:"relative",padding:"1.5rem",paddingTop:"2rem",paddingBottom:0}),m=(0,d.I4)(a.$,{cursor:"pointer",position:"absolute",top:"1rem",right:"1rem",border:0,width:"1.5rem",height:"1.5rem",borderRadius:"9999px",backgroundColor:"rgba(0, 0, 0, 0.4)",color:d.w4.colors.white,padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s","&:hover":{backgroundColor:"rgba(0, 0, 0, 1)"}}),g=(0,d.I4)("div",{paddingLeft:"2rem",paddingRight:"2rem"}),f=(0,d.I4)("div",{fontSize:(0,o.D)(28),fontWeight:700,color:d.w4.colors.blue12,marginBottom:(0,o.D)(10)}),x=(0,d.I4)("p",{color:d.w4.colors.gray11,fontSize:(0,o.D)(20),fontWeight:500,marginBottom:(0,o.D)(36)}),b=(0,d.I4)("div",{display:"flex",flexDirection:"column",gap:(0,o.D)(34),marginBottom:(0,o.D)(34)}),C=(0,d.I4)("div",{display:"flex",gap:"0.75rem"}),v=(0,d.I4)("div",{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}),y=(0,d.I4)("div",{flex:1}),w=(0,d.I4)("div",{fontSize:(0,o.D)(20),fontWeight:600,color:d.w4.colors.blue12,marginBottom:"0.25rem"}),j=(0,d.I4)("p",{fontSize:(0,o.D)(14),color:d.w4.colors.gray11,fontWeight:500,letterSpacing:0}),I=(0,d.I4)("div",{marginTop:"1rem",marginLeft:"-1.5rem",marginRight:"-1.5rem",display:"flex",alignItems:"center",backgroundColor:d.w4.colors.blue5,justifyContent:"space-between",gap:"1rem",paddingTop:"1rem",paddingBottom:"1rem",paddingLeft:"1.5rem",paddingRight:"1.5rem",borderRadius:0,fontWeight:600}),k=(0,d.I4)("span",{color:d.w4.colors.blue12,fontSize:(0,o.D)(20),lineHeight:(0,o.D)(24),letterSpacing:0,fontWeight:500}),E=(0,d.I4)(a.$,{cursor:"pointer",backgroundColor:d.w4.colors.blue9,border:0,width:(0,o.D)(224),color:d.w4.colors.white,paddingLeft:(0,o.D)(10),paddingRight:(0,o.D)(10),paddingTop:(0,o.D)(16),paddingBottom:(0,o.D)(16),borderRadius:(0,o.D)(12),fontWeight:600,transition:"background-color 0.2s","&:hover":{backgroundColor:d.w4.colors.blue10}});function N(e){let{onClose:t}=e,{t:n}=(0,l.B)("edit-feed");return(0,r.jsx)(i.lG,{setOpen:t,open:!0,closeOnEscape:!0,children:(0,r.jsxs)(u,{children:[(0,r.jsx)(p,{children:(0,r.jsx)(s.e,{src:"https://cdn.paperpal.com/assets/images/icons/flame.webp",alt:"flame",width:74,height:146})}),(0,r.jsxs)(h,{children:[(0,r.jsx)(m,{"aria-label":"Close",onClick:t,children:(0,r.jsx)(c.I,{name:"x",variant:"regular"})}),(0,r.jsxs)(g,{children:[(0,r.jsx)(f,{children:"What's new"}),(0,r.jsx)(x,{children:"Paperpal's top-tier editing mode is here and 
1you've got early access!"})]}),(0,r.jsxs)(b,{children:[(0,r.jsxs)(C,{children:[(0,r.jsx)(v,{children:(0,r.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{opacity:"0.4",d:"M6.75 31.5C6.75 33.9562 7.93125 36.1313 9.75 37.5C8.8125 38.7562 8.25 40.3125 8.25 42C8.25 46.1437 11.6062 49.5 15.75 49.5C15.8156 49.5 15.8719 49.5 15.9375 49.5C16.6031 52.0875 18.9563 54 21.75 54H24.75C26.4094 54 27.75 52.6594 27.75 51V34.875H22.5C21.8813 34.875 21.375 35.3813 21.375 36V36.4125C22.9219 37.125 24 38.6906 24 40.5C24 42.9844 21.9844 45 19.5 45C17.0156 45 15 42.9844 15 40.5C15 38.6813 16.0781 37.1156 17.625 36.4125V36C17.625 33.3094 19.8094 31.125 22.5 31.125H27.75V24.375H23.5875C22.875 25.9219 21.3094 27 19.5 27C17.0156 27 15 24.9844 15 22.5C15 20.0156 17.0156 18 19.5 18C21.3188 18 22.8844 19.0781 23.5875 20.625H27.75V9C27.75 7.34062 26.4094 6 24.75 6H22.5C19.6031 6 17.25 8.35313 17.25 11.25V13.5C13.1062 13.5 9.75 16.8562 9.75 21C9.75 22.4062 10.1344 23.7188 10.8 24.8344C8.39062 26.0812 6.75 28.5938 6.75 31.5ZM32.25 9V20.625H36.4125C37.125 19.0781 38.6906 18 40.5 18C42.9844 18 45 20.0156 45 22.5C45 24.9844 42.9844 27 40.5 27C38.6812 27 37.1156 25.9219 36.4125 24.375H32.25V43.125H37.5C38.1187 43.125 38.625 42.6188 38.625 42V41.5875C37.0781 40.875 36 39.3094 36 37.5C36 35.0156 38.0156 33 40.5 33C42.9844 33 45 35.0156 45 37.5C45 39.3187 43.9219 40.8844 42.375 41.5875V42C42.375 44.6906 40.1906 46.875 37.5 46.875H32.25V51C32.25 52.6594 33.5906 54 35.25 54H38.25C41.0438 54 43.3969 52.0875 44.0625 49.5C44.1281 49.5 44.1844 49.5 44.25 49.5C48.3937 49.5 51.75 46.1437 51.75 42C51.75 40.3125 51.1875 38.7562 50.25 37.5C52.0687 36.1313 53.25 33.9562 53.25 31.5C53.25 28.6031 51.6 26.0812 49.2 24.8344C49.8656 23.7094 50.25 22.3969 50.25 21C50.25 16.8562 46.8937 13.5 42.75 13.5V11.25C42.75 8.35313 40.3969 6 37.5 6H35.25C33.5906 6 32.25 7.34062 32.25 9Z",fill:"#B52749"}),(0,r.jsx)("path",{d:"M32.25 9.00006H27.75V20.6251H23.5875C22.875 19.0782 21.3094 18.0001 19.5 18.0001C17.0156 18.0001 15 20.0157 15 22.5001C15 24.9844 17.0156 27.0001 19.5 27.0001C21.3187 27.0001 22.8844 25.9219 23.5875 24.3751H27.75V31.1251H22.5C19.8094 31.1251 17.625 33.3094 17.625 36.0001V36.4126C16.0781 37.1251 15 38.6907 15 40.5001C15 42.9844 17.0156 45.0001 19.5 45.0001C21.9844 45.0001 24 42.9844 24 40.5001C24 38.6813 22.9219 37.1157 21.375 36.4126V36.0001C21.375 35.3813 21.8812 34.8751 22.5 34.8751H27.75V51.0001H32.25V46.8751H37.5C40.1906 46.8751 42.375 44.6907 42.375 42.0001V41.5876C43.9219 40.8751 45 39.3094 45 37.5001C45 35.0157 42.9844 33.0001 40.5 33.0001C38.0156 33.0001 36 35.0157 36 37.5001C36 39.3188 37.0781 40.8844 38.625 41.5876V42.0001C38.625 42.6188 38.1187 43.1251 37.5 43.1251H32.25V24.3751H36.4125C37.125 25.9219 38.6906 27.0001 40.5 27.0001C42.9844 27.0001 45 24.9844 45 22.5001C45 20.0157 42.9844 18.0001 40.5 18.0001C38.6812 18.0001 37.1156 19.0782 36.4125 20.6251H32.25V9.00006ZM40.5 24.0001C40.1022 24.0001 39.7206 23.842 39.4393 23.5607C39.158 23.2794 39 22.8979 39 22.5001C39 22.1022 39.158 21.7207 39.4393 21.4394C39.7206 21.1581 40.1022 21.0001 40.5 21.0001C40.8978 21.0001 41.2794 21.1581 41.5607 21.4394C41.842 21.7207 42 22.1022 42 22.5001C42 22.8979 41.842 23.2794 41.5607 23.5607C41.2794 23.842 40.8978 24.0001 40.5 24.0001ZM42 37.5001C42 37.8979 41.842 38.2794 41.5607 38.5607C41.2794 38.842 40.8978 39.0001 40.5 39.0001C40.1022 39.0001 39.7206 38.842 39.4393 38.5607C39.158 38.2794 39 37.8979 39 37.5001C39 37.1022 39.158 36.7207 39.4393 36.4394C39.7206 36.1581 40.1022 36.0001 40.5 36.0001C40.8978 36.0001 41.2794 36.1581 41.5607 36.4394C41.842 36.7207 42 37.1022 42 37.5001ZM21 40.5001C21 40.8979 20.842 41.2794 20.5607 41.5607C20.2794 41.842 19.8978 42.0001 19.5 42.0001C19.1022 42.0001 18.7206 41.842 18.4393 41.5607C18.158 41.2794 18 40.8979 18 40.5001C18 40.1022 18.158 39.7207 18.4393 39.4394C18.7206 39.1581 19.1022 39.0001 19.5 39.0001C19.8978 39.0001 20.2794 39.1581 20.5607 39.4394C20.842 39.7207 21 40.1022 21 40.5001ZM21 22.5001C21 22.8979 20.842 23.2794 20.5607 23.5607C20.2794 23.842 19.8978 24.0001 19.5 24.0001C19.1022 24.0001 18.7206 23.842 18.4393 23.5607C18.158 23.2794 18 22.8979 18 22.5001C18 22.1022 18.158 21.7207 18.4393 21.4394C18.7206 21.1581 19.1022 21.0001 19.5 21.0001C19.8978 21.0001 20.2794 21.1581 20.5607 21.4394C20.842 21.7207 21 22.1022 21 22.5001Z",fill:"#B52749"})]})}),(0,r.jsxs)(y,{children:[(0,r.jsx)(w,{children:"Our smartest editor yet"}),(0,r.jsxs)(j,{children:["Powered by state-of-the-art tech, '",n("expert_title","Expert"),"' is Paperpal's most intelligent language model yet."]})]})]}),(0,r.jsxs)(C,{children:[(0,r.jsx)(v,{children:(0,r.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{opacity:"0.4",d:"M15 41.2501C15 42.497 16.0031 43.5001 17.25 43.5001H33.75C34.9969 43.5001 36 42.497 36 41.2501C36 40.0032 34.9969 39.0001 33.75 39.0001H17.25C16.0031 39.0001 15 40.0032 15 41.2501ZM33 18.0001V24.0001H36C42.6281 24.0001 48 29.372 48 36.0001C48 42.6282 42.6281 48.0001 36 48.0001H49.4156C52.2656 44.8126 54 40.6126 54 36.0001C54 26.0626 45.9375 18.0001 36 18.0001H33Z",fill:"#F7B900"}),(0,r.jsx)("path",{d:"M22.5 5.99997C20.0156 5.99997 18 8.01559 18 10.5V30C18 32.4843 20.0156 34.5 22.5 34.5H28.5C30.9844 34.5 33 32.4843 33 30V10.5C33 8.01559 30.9844 5.99997 28.5 5.99997H22.5ZM9 48C7.34062 48 6 49.3406 6 51C6 52.6593 7.34062 54 9 54H51C52.6594 54 54 52.6593 54 51C54 49.3406 52.6594 48 51 48H9Z",fill:"#F7B900"})]})}),(0,r.jsxs)(y,{children:[(0,r.jsx)(w,{children:"Impressive domain expertise"}
1),(0,r.jsx)(j,{children:"Better niche-domain understanding, resulting in writing clarity with accurate terminology use."})]})]}),(0,r.jsxs)(C,{children:[(0,r.jsx)(v,{children:(0,r.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{opacity:"0.4",d:"M6 30C6 33.45 7.94062 36.45 10.7906 37.9594C9.84375 41.0438 10.5938 44.5312 13.0312 46.9688C15.4688 49.4062 18.9656 50.1562 22.0406 49.2094C23.55 52.0594 26.55 54 30 54C33.45 54 36.45 52.0594 37.9594 49.2094C41.0438 50.1562 44.5312 49.4062 46.9688 46.9688C49.4062 44.5312 50.1562 41.0344 49.2094 37.9594C52.0594 36.45 54 33.45 54 30C54 26.55 52.0594 23.55 49.2094 22.0406C50.1562 18.9563 49.4062 15.4688 46.9688 13.0312C44.5312 10.5938 41.0344 9.84375 37.9594 10.7906C36.45 7.94062 33.45 6 30 6C26.55 6 23.55 7.94062 22.0406 10.7906C18.9563 9.84375 15.4688 10.5938 13.0312 13.0312C10.5938 15.4688 9.84375 18.9656 10.7906 22.0406C7.94062 23.55 6 26.55 6 30ZM20.2781 33.9C19.4156 33.0094 19.4344 31.5844 20.3344 30.7219C21.225 29.8594 22.65 29.8875 23.5125 30.7781L26.8688 34.2469L36.8156 20.5781C37.5469 19.575 38.9531 19.35 39.9563 20.0812C40.9594 20.8125 41.1844 22.2188 40.4531 23.2219L28.9406 39.0656C28.5469 39.6 27.9375 39.9469 27.2719 39.9844C26.6062 40.0312 25.9594 39.7781 25.5 39.3L20.2781 33.9Z",fill:"#089738"}),(0,r.jsx)("path",{d:"M36.8156 20.5782C37.5469 19.5751 38.9531 19.3501 39.9563 20.0814C40.9594 20.8126 41.1844 22.2189 40.4531 23.222L28.9406 39.0657C28.5469 39.6001 27.9375 39.947 27.2719 39.9845C26.6063 40.0314 25.9594 39.7782 25.5 39.3001L20.2781 33.9001C19.4156 33.0095 19.4344 31.5845 20.3344 30.722C21.225 29.8595 22.65 29.8876 23.5125 30.7782L26.8688 34.247L36.8156 20.5782Z",fill:"#089738"})]})}),(0,r.jsxs)(y,{children:[(0,r.jsx)(w,{children:"Your meaning and intent preserved"}),(0,r.jsx)(j,{children:"Context-aware clearer, polished writing without changing what you mean."})]})]}),(0,r.jsxs)(C,{children:[(0,r.jsx)(v,{children:(0,r.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{opacity:"0.4",d:"M6.05636 51.5624C6.01886 52.9312 7.10636 54.0187 8.48449 53.9906C11.7189 53.9156 17.4001 53.3343 20.3345 50.3999C23.2876 47.4468 23.2876 42.6656 20.3345 39.7124C17.3814 36.7593 12.6001 36.7593 9.64699 39.7124C6.71261 42.6468 6.13136 48.3374 6.05636 51.5624ZM8.77511 28.4531C7.57511 30.4593 9.00949 32.9999 11.3439 32.9999H21.047C22.3782 26.6812 24.2626 21.7781 26.4939 17.9999H17.5876C16.0032 17.9999 14.5407 18.8249 13.7251 20.1843L8.77511 28.4531ZM11.3626 47.3906C11.4282 46.1906 11.7095 44.4656 12.647 43.5187C13.7157 42.4499 15.4595 42.4499 16.5282 43.5187C17.597 44.5874 17.597 46.3312 16.5282 47.3999C15.5814 48.3468 13.8564 48.6187 12.6564 48.6843C11.9064 48.7312 11.3157 48.1312 11.3532 47.3812L11.3626 47.3906ZM27.047 38.9999V48.7031C27.047 51.0374 29.5876 52.4718 31.5939 51.2718L39.8626 46.3124C41.222 45.4968 42.047 44.0343 42.047 42.4499V33.5437C38.2689 35.7749 33.3657 37.6593 27.047 38.9906V38.9999Z",fill:"#0054F1"}),(0,r.jsx)("path",{d:"M21.0467 33C26.6342 6.45936 42.0467 4.97811 51.3842 6.34686C52.5842 6.52498 53.5217 7.46248 53.6905 8.65311C55.0592 17.9906 53.578 33.4031 27.0374 38.9906C27.0374 35.6812 24.3467 32.9906 21.0374 32.9906L21.0467 33ZM46.5467 18C46.5467 16.8065 46.0726 15.6619 45.2287 14.818C44.3848 13.9741 43.2402 13.5 42.0467 13.5C40.8533 13.5 39.7087 13.9741 38.8647 14.818C38.0208 15.6619 37.5467 16.8065 37.5467 18C37.5467 19.1935 38.0208 20.3381 38.8647 21.182C39.7087 22.0259 40.8533 22.5 42.0467 22.5C43.2402 22.5 44.3848 22.0259 45.2287 21.182C46.0726 20.3381 46.5467 19.1935 46.5467 18Z",fill:"#0054F1"})]})}),(0,r.jsxs)(y,{children:[(0,r.jsx)(w,{children:"5x better editor performance"}),(0,r.jsx)(j,{children:"Faster, smoother, more reliable editing across Web and Word."})]})]})]}),(0,r.jsxs)(I,{children:[(0,r.jsx)(k,{children:"Ready to try it?"}),(0,r.jsx)(E,{onClick:t,children:"Try Now"})]})]})]})})}},44151:(e,t,n)=>{"use strict";n.d(t,{z:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsx)("path",{opacity:"0.2",d:"M14.8 1.25H4.2C3.8134 
11.25 3.5 1.5634 3.5 1.95V14.55C3.5 14.9366 3.8134 15.25 4.2 15.25H14.8C15.1866 15.25 15.5 14.9366 15.5 14.55V1.95C15.5 1.5634 15.1866 1.25 14.8 1.25Z",fill:"black"}),(0,r.jsx)("path",{d:"M15.5 11.5V14.3C15.5 14.6878 15.1875 15 14.8 15H4.2C3.81225 15 3.5 14.6878 3.5 14.3V7.75H9.25L9.5 8L15.5 11.5Z",fill:"#185C37"}),(0,r.jsx)("path",{d:"M4.2 1H9.5L15.5 4.5V8.25H9.75L9.5 8L3.5 4.5V1.7C3.5 1.3122 3.81225 1 4.2 1Z",fill:"#21A366"}),(0,r.jsx)("path",{d:"M9.5 1H14.8C15.1875 1 15.5 1.3122 15.5 1.7V4.5H9.5V1Z",fill:"#33C481"}),(0,r.jsx)("path",{d:"M9.5 8H15.5V11.5H9.5V8ZM3.5 4.5H9.5V8H3.5V4.5Z",fill:"#107C41"}),(0,r.jsx)("path",{opacity:"0.1",d:"M3.5 4.5H15.5V4.75H3.5V4.5ZM3.5 8H15.5V8.25H3.5V8ZM3.5 11.5H15.5V11.75H3.5V11.5Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M4.20025 1C3.8125 1 3.5 1.3124 3.5 1.7002V1.9502C3.5 1.5624 3.8125 1.25 4.20025 1.25H14.8C15.1875 1.25 15.5 1.5624 15.5 1.9502V1.7002C15.5 1.3124 15.1875 1 14.8 1H4.20025Z",fill:"white"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.8 4.25H1.2C0.813401 4.25 0.5 4.5634 0.5 4.95V11.55C0.5 11.9366 0.813401 12.25 1.2 12.25H7.8C8.1866 12.25 8.5 11.9366 8.5 11.55V4.95C8.5 4.5634 8.1866 4.25 7.8 4.25Z",fill:"black"}),(0,r.jsx)("path",{d:"M7.8 4H1.2C0.813401 4 0.5 4.3134 0.5 4.7V11.3C0.5 11.6866 0.813401 12 1.2 12H7.8C8.1866 12 8.5 11.6866 8.5 11.3V4.7C8.5 4.3134 8.1866 4 7.8 4Z",fill:"#0E6F3A"}),(0,r.jsx)("path",{d:"M2.26672 10.5L3.8845 7.993L2.40272 5.5H3.59525L4.5575 7.43175L5.6 5.5H6.695L5.17475 7.979L6.73325 10.5H5.56875L4.50875 8.516L3.43825 10.5H2.26672Z",fill:"white"})]})},44243:(e,t,n)=>{"use strict";n.d(t,{Q:()=>l});var r=n(53239);let l=e=>{let[t,n]=(0,r.useState)(()=>null!=e?e:new Set);return[t,(0,r.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),n]}},44440:(e,t,n)=>{"use strict";n.d(t,{l:()=>o,u:()=>i});var r=n(78773),l=n(81761),a=n(64014);let o="library-collection-items";function i(e){var t,n,i;let{libraryId:s,collectionId:c,size:d=25,filters:u,sort:p,searchQuery:h,includeExtractedText:m=!1,includePaper:g=!1,attachmentItemTypes:f}=e,{webApiClient:x}=(0,a.p)(),b=!!(null==h?void 0:h.trim()),C=b?"items/search":"items";return(0,r.useInfiniteQuery)({queryKey:[o,s,c,d,u,null==u||null==(t=u.collectionIds)?void 0:t.length,null==u||null==(n=u.itemTypes)?void 0:n.length,null==p?void 0:p.sortBy,null==p?void 0:p.sortDir,h,b,C,m,g,f],queryFn:async e=>{var t,n,r;let{pageParam:a=0}=e,o=new URLSearchParams({page:String(a),size:String(d)});(null==u||null==(t=u.collectionIds)?void 0:t.length)?u.collectionIds.forEach(e=>o.append("collectionId",String(e))):void 0!==c&&o.set("collectionId",String(c)),b&&o.set("q",h.trim()),u&&(null==(n=u.itemTypes)||n.forEach(e=>o.append("itemTypes",e)),null==(r=u.labelIds)||r.forEach(e=>o.append("labelIds",String(e))),u.dateFilter&&"CUSTOM_DATE_RANGE"!==u.dateFilter?o.set("dateFilter",u.dateFilter):"CUSTOM_DATE_RANGE"===u.dateFilter&&(u.fromYear&&o.set("fromYear",u.fromYear),u.toYear&&o.set("toYear",u.toYear))),f&&(null==f||f.forEach(e=>o.append("itemTypes",e))),(null==p?void 0:p.sortBy)&&o.set("sortBy",p.sortBy),(null==p?void 0:p.sortDir)&&o.set("sortDir",p.sortDir),m&&o.set("includeExtractedText","true"),g&&o.set("includePaper","true");let i=await x.get("/api/v1/libraries/".concat(s,"/").concat(C,"?").concat(o.toString()));return l.dc.parse(i)},getNextPageParam:e=>e.data.last?void 0:e.data.page+1,enabled:!!s&&(!!c||!!(null==u||null==(i=u.collectionIds)?void 0:i.length)),retry:!1,refetchOnWindowFocus:!1,staleTime:0})}},44499:(e,t,n)=>{"use strict";n.d(t,{j:()=>s});var r=n(80263),l=n(16679);let a=(0,l.i7)({"100%":{transform:"translateX(100%)"}}),o=(0,l.I4)("div",{overflow:"hidden",position:"relative","&:after":{transform:"translateX(-100%)",position:"absolute",top:"0px",right:"0px",bottom:"0px",left:"0px",animation:"".concat(a," 3s infinite"),background:"linear-gradient( 90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.2) 20%, rgba(255, 255, 255, 0.5) 60%, rgba(255, 255, 255, 0))",content:""}}),i=(0,l.I4)("span",{background:l.w4.colors.gray3,display:"block",borderRadius:"4px",variants:{size:{medium:{width:"100vw !important",height:"100vh"},small:{width:"100vw !important",height:"100vh"}}}}),s=e=>{let{height:t,width:n,background:a}=e;return(0,r.jsx)(o,{className:"skeleton",children:(0,r.jsx)(i,{style:{width:n,height:t,background:a||l.w4.colors.gray3.value},size:{"@sm":"small","@md":"medium"}})})}}
1,45004:(e,t,n)=>{"use strict";n.d(t,{J:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsxs)("g",{clipPath:"url(#clip0_1263_24988)",children:[(0,r.jsx)("path",{d:"M15.4304 1H4.76342C4.58666 1 4.41713 1.07022 4.29214 1.19521C4.16714 1.32021 4.09692 1.48973 4.09692 1.6665V4.5L10.0969 6.25L16.0969 4.5V1.6665C16.0969 1.48973 16.0267 1.32021 15.9017 1.19521C15.7767 1.07022 15.6072 1 15.4304 1Z",fill:"#41A5EE"}),(0,r.jsx)("path",{d:"M16.0969 4.5H4.09692V8L10.0969 9.75L16.0969 8V4.5Z",fill:"#2B7CD3"}),(0,r.jsx)("path",{d:"M16.0969 8H4.09692V11.5L10.0969 13.25L16.0969 11.5V8Z",fill:"#185ABD"}),(0,r.jsx)("path",{d:"M16.0969 11.5H4.09692V14.3335C4.09692 14.5103 4.16714 14.6798 4.29214 14.8048C4.41713 14.9298 4.58666 15 4.76342 15H15.4304C15.6072 15 15.7767 14.9298 15.9017 14.8048C16.0267 14.6798 16.0969 14.5103 16.0969 14.3335V11.5Z",fill:"#103F91"}),(0,r.jsx)("path",{opacity:"0.1",d:"M8.43042 3.5H4.09692V13H8.43042C8.60703 12.9995 8.77625 12.9291 8.90113 12.8042C9.02601 12.6793 9.0964 12.5101 9.09692 12.3335V4.1665C9.0964 3.9899 9.02601 3.82068 8.90113 3.6958C8.77625 3.57092 8.60703 3.50053 8.43042 3.5Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.93042 4H4.09692V13.5H7.93042C8.10703 13.4995 8.27625 13.4291 8.40113 13.3042C8.52601 13.1793 8.5964 13.0101 8.59692 12.8335V4.6665C8.5964 4.4899 8.52601 4.32067 8.40113 4.1958C8.27625 4.07092 8.10703 4.00053 7.93042 4Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.93042 4H4.09692V12.5H7.93042C8.10703 12.4995 8.27625 12.4291 8.40113 12.3042C8.52601 12.1793 8.5964 12.0101 8.59692 11.8335V4.6665C8.5964 4.4899 8.52601 4.32067 8.40113 4.1958C8.27625 4.07092 8.10703 4.00053 7.93042 4Z",fill:"black"}),(0,r.jsx)("path",{opacity:"0.2",d:"M7.43042 4H4.09692V12.5H7.43042C7.60703 12.4995 7.77625 12.4291 7.90113 12.3042C8.02601 12.1793 8.0964 12.0101 8.09692 11.8335V4.6665C8.0964 4.4899 8.02601 4.32067 7.90113 4.1958C7.77625 4.07092 7.60703 4.00053 7.43042 4Z",fill:"black"}),(0,r.jsx)("path",{d:"M0.763424 4H7.43042C7.60719 4 7.77672 4.07022 7.90171 4.19521C8.0267 4.32021 8.09692 4.48973 8.09692 4.6665V11.3335C8.09692 11.5103 8.0267 11.6798 7.90171 11.8048C7.77672 11.9298 7.60719 12 7.43042 12H0.763424C0.586657 12 0.41713 11.9298 0.292137 11.8048C0.167144 11.6798 0.0969238 11.5103 0.0969238 11.3335L0.0969238 4.6665C0.0969238 4.48973 0.167144 4.32021 0.292137 4.19521C0.41713 4.07022 0.586657 4 0.763424 4Z",fill:"#185ABD"}),(0,r.jsx)("path",{d:"M6.07183 10.5H5.17183L4.12183 7.05L3.02183 10.5H2.12183L1.12183 5.5H2.02183L2.72183 9L3.77183 5.6H4.52183L5.52183 9L6.22183 5.5H7.07183L6.07183 10.5Z",fill:"white"})]}),(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:"clip0_1263_24988",children:(0,r.jsx)("rect",{width:"16.129",height:"16",fill:"white"})})})]})},45476:(e,t,n)=>{"use strict";n.d(t,{i:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsx)("rect",{width:"16",height:"16",rx:"3",fill:"#C80A0A"}),(0,r.jsx)("path",{d:"M3 11.4538C3.05385 11.1308 3.26923 10.9154 3.48462 10.7C3.75385 10.4308 4.07692 10.2692 4.45385 10.0538C4.83077 9.83846 5.20769 9.67692 5.58461 9.51538C5.63846 9.51538 5.69231 9.46154 5.69231 9.40769C6.01538 8.76154 6.33846 8.11538 6.60769 7.46923C6.76923 7.09231 6.87692 6.71538 7.03846 6.33846V6.28462C6.87692 5.90769 6.71538 5.47692 6.66154 5.04615C6.55385 4.61538 6.55385 4.18462 6.60769 3.75385C6.66154 3.48462 6.82308 3.26923 7.03846 3.05385C7.09231 3 7.2 3 7.30769 3H7.73846C7.84615 3 7.95385 3.05385 8.00769 3.16154C8.16923 3.26923 8.27692 3.43077 8.38461 3.59231C8.49231 3.80769 8.49231 4.02308 8.54615 4.23846C8.54615 4.88462 8.43846 5.47692 8.33077 6.06923C8.27692 6.28461 8.22308 6.44615 8.16923 6.66154V6.71538C8.49231 7.30769 8.92308 7.84615 9.35384 8.33077C9.40769 8.38461 9.40769 8.38461 9.51538 8.38461C10.1077 8.27692 10.7 8.27692 11.2385 8.27692C11.5615 8.27692 11.9385 8.33077 12.2615 8.49231C12.4231 8.6 12.5846 8.70769 12.6923 8.86923C12.74
162 8.97692 12.8 9.08461 12.8 9.19231V9.56923C12.8 9.67692 12.7462 9.78461 12.6385 9.83846C12.5308 9.94615 12.4231 10.1077 12.2077 10.1077C12.1 10.1077 11.9385 10.1615 11.8308 10.1615C10.9692 10.2154 10.2692 9.94615 9.56923 9.46154C9.46154 9.35385 9.3 9.24615 9.19231 9.13846C9.13846 9.13846 9.13846 9.08461 9.08461 9.08461C8.76154 9.13846 8.43846 9.19231 8.11538 9.3C7.68461 9.40769 7.25385 9.56923 6.82308 9.67692C6.76923 9.67692 6.76923 9.73077 6.71538 9.73077C6.44615 10.2154 6.12308 10.7 5.8 11.1308C5.53077 11.4538 5.20769 11.7769 4.88462 12.0462C4.72308 12.1538 4.50769 12.2615 4.29231 12.3154H3.86154C3.75385 12.3154 3.7 12.3154 3.59231 12.2615C3.32308 12.1538 3.10769 11.9385 3.05385 11.6692C3 11.6692 3 11.5615 3 11.4538ZM7.73846 7.68461C7.57692 8.11538 7.36154 8.54615 7.2 8.97692L8.49231 8.65385C8.22308 8.33077 7.95385 7.95385 7.73846 7.68461ZM10.0538 9.08461C10.3769 9.3 10.7538 9.46154 11.1308 9.56923C11.2923 9.62308 11.4 9.56923 11.5077 9.51538C11.6154 9.46154 11.6692 9.3 11.5615 9.24615C11.5615 9.19231 11.5077 9.19231 11.4538 9.19231C11.3462 9.13846 11.1846 9.13846 11.0231 9.08461C10.7 9.03077 10.3769 9.03077 10.0538 9.08461ZM4.99231 10.5923C4.66923 10.7538 4.34615 10.9692 4.07692 11.1846C3.91538 11.2923 3.80769 11.4538 3.7 11.6154V11.7231C3.75385 11.7769 3.75385 11.7769 3.80769 11.7769C3.96923 11.6692 4.07692 11.5615 4.18462 11.5077C4.50769 11.2385 4.72308 10.9154 4.99231 10.5923ZM7.30769 5.15385C7.36154 5.15385 7.36154 5.15385 7.30769 5.15385C7.41538 4.83077 7.46923 4.50769 7.46923 4.23846C7.46923 4.07692 7.46923 3.91538 7.41538 3.75385C7.41538 3.7 7.36154 3.7 7.30769 3.7C7.25385 3.7 7.25385 3.75385 7.2 3.75385C7.09231 3.91538 7.09231 4.07692 7.09231 4.29231C7.09231 4.45385 7.09231 4.56154 7.14615 4.72308C7.25385 4.83077 7.25385 4.99231 7.30769 5.15385Z",fill:"white"})]})},46349:()=>{},46593:(e,t,n)=>{"use strict";n.d(t,{T8:()=>l,rz:()=>a});var r=n(6359);let l=(e,t)=>{let n=new Set,r=new Set;return null==e||e.forEach(e=>{var l;let a=null===e.ppref||void 0===e.ppref?NaN:parseInt(e.ppref,10),o=isNaN(a)||null==(l=t[a])?void 0:l.sources;"completed"===e.status?null==o||o.forEach(e=>{let t=(null==e?void 0:e.dyson_id)||(null==e?void 0:e.id);t&&n.add(String(t))}):"failed"===e.status&&((null==o?void 0:o.some(e=>(null==e?void 0:e.dyson_id)||(null==e?void 0:e.id)))||r.add(e.label.trim()))}),{importedSourceCount:n.size,unresolvedFailedCount:r.size}},a=e=>{let t=[];return e.state.doc.descendants((e,n)=>{"text"===e.type.name&&e.marks.forEach(l=>{if(l.type.name===r.YT){let r=(e.text||"").replace(/^ppref:\d+:\s*/,""),a=l.attrs.ppref||null;t.push({pos:n,node:e,label:r,ppref:a,editorText:r})}})}),t.sort((e,t)=>e.pos-t.pos)}},46685:(e,t,n)=>{"use strict";n.d(t,{$n:()=>b,e2:()=>C});var r=n(80263);n(58060),n(19185),n(74067);var l=n(90802),a=n(28553),o=n(44020);n(78401);var i=n(53239);let s=(0,i.createContext)(null);function c(){let e=(0,i.useContext)(s);if(null===e)throw Error("Tooltip components must be wrapped in <TooltipProvider />");return e}function d(e){var t,n;let{children:c,...d}=e,u=function(){let{initialOpen:e=!1,placement:t="top",open:n,onOpenChange:r,delay:s=600,closeDelay:c=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[d,u]=(0,i.useState)(e),p=null!=n?n:d,h=null!=r?r:u,m=(0,l.we)({placement:t,open:p,onOpenChange:h,whileElementsMounted:a.ll,middleware:[(0,o.cY)(4),(0,o.UU)({crossAxis:t.includes("-"),fallbackAxisSideDirection:"start",padding:4}),(0,o.BN)({padding:4})]}),g=m.context,f=(0,l.Mk)(g,{mouseOnly:!0,move:!1,restMs:s,enabled:!n,delay:{close:c}}),x=(0,l.iQ)(g,{enabled:!n}),b=(0,l.s9)(g),C=(0,l.It)(g,{role:"tooltip"}),v=(0,l.bv)([f,x,b,C]);return(0,i.useMemo)(()=>({open:p,setOpen:h,...v,...m}),[p,h,v,m])}(d);return d.useDelayGroup?(0,r.jsx)(l.T3,{delay:{open:null!=(t=d.delay)?t:0,close:null!=(n=d.closeDelay)?n:0},timeoutMs:d.timeout,children:(0,r.jsx)(s.Provider,{value:u,children:c})}):(0,r.jsx)(s.Provider,{value:u,children:c})}let u=(0,i.forwardRef)(function(e,t){let{children:n,asChild:a=!1,...o}=e,s=c(),d=(0,i.isValidElement)(n)?parseInt(i.version,10)>=19?n.props.ref:n.ref:void 0,u=(0,l.SV)([s.refs.setReference,t,d]);if(a&&(0,i.isValidElement)(n)){let e={"data-tooltip-state":s.open?"open":"closed"};return(0,i.cloneElement)(n,s.getReferenceProps({ref:u,...o,..."object"==typeof n.props?n.props:{},...e}))}return(0,r.jsx)("button",{ref:u,"data-tooltip-state":s.open?"open":"closed",...s.getReferenceProps(o),children:n})}),p=(0,i.forwardRef)(function(e,t){let{style:n,children:a,portal:o=!0,portalProps:i={},...s}=e,d=c(),u=(0,l.SV)([d.refs.setFloating,t]);if(!d.open)return null;let p=(0,r.jsx)("div",{ref:u,style:{...d.floatingStyles,...n},...d.getFloatingProps(s),className:"tiptap-tooltip",children:a});return o?(0,r.jsx)(l.XF,{...i,children:p}):p});d.displayName="Tooltip",u.displayName="TooltipTrigger",p.displayName="TooltipContent";var h=n(64451),m=n(69119);let g=e=>{let{shortcuts:t}=e;return 0===t.length?null:(0,r.jsx)("div",{children:t.map((e,t)=>(0,r.jsxs)(i.Fragment,{children:[t>0&&(0,r.jsx)("kbd",{children:"+"}),(0,r.jsx)("kbd",{children:e})]},t))})},f=(0,i.forwardRef)((e,t)=>{let{className:n,children:l,tooltip:a,showTooltip:o=!0,shortcutKeys:s,"aria-label":c,...m}=e,f=(0,i.useMemo)(()=>(0,h.wi)({shortcutKeys:s}),[s]),x=(0,r.jsx)("button",{ref:t,className:(0,h.cn)("tiptap-button",n),"aria-label":c,"data-test-id":m.id,...m,children:l});return o&&a?(0,r.jsxs)(d,{children:[(0,r.jsx)(u,{asChild:!0,children:x}),(0,r.jsxs)(p,{children:[a,f.length>0&&(0,r.jsx)(g,{shortcuts:f})]})]}):x});f.displayName="BaseButton";let x=(0,m.j)(f),b=(0,i.memo)((0,i.forwardRef)((e,t)=>{let{children:n,...l}=e;return(0,r.jsx)(x,{ref:t,...l,children:n})}));b.displayName="Button";let C=(0,i.forwardRef)((e,t)=>{let{className:n,children:l,orientation:a="vertical",...o}=e;return(0,r.jsx)("div",{ref:t,className:(0,h.cn)("tiptap-button-group",n),"data-orientation":a,role:"group",...o,children:l})});C.displayName="ButtonGroup"},47791:(e,t,n)=>{"use strict";n.d(t,{m:()=>s});var r=n(80263),l=n(11230),a=n.n(l),o=n(53239),i=n(37034);
1function s(e){let{content:t,children:n,position:l="top",delay:s=400,className:c,contentClassName:d,arrowClassName:u,interactive:p=!1}=e,[h,m]=(0,o.useState)(null),g=(0,o.useRef)(null),f=(0,o.useRef)(null),x=(0,o.useRef)(null),b=(0,o.useRef)(null),[C,v]=(0,o.useState)(0),y=(0,o.useCallback)(()=>{b.current&&(clearTimeout(b.current),b.current=null)},[]),w=(0,o.useCallback)(()=>{if(!g.current)return null;let e=g.current.getBoundingClientRect();return"bottom"===l?{top:e.bottom+6,left:e.left+e.width/2}:"top"===l?{top:e.top-6,left:e.left+e.width/2}:"right"===l?{top:e.top+e.height/2,left:e.right+6}:{top:e.top+e.height/2,left:e.left-6}},[l]),j=(0,o.useCallback)(()=>{y(),h||(x.current=setTimeout(()=>{m(w())},s))},[y,w,h,s]),I=(0,o.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null),y(),m(null),v(0)},[y]),k=(0,o.useCallback)(()=>{if(!p)return void I();x.current&&(clearTimeout(x.current),x.current=null),y(),b.current=setTimeout(I,120)},[y,I,p]);(0,o.useEffect)(()=>()=>I(),[I]);let E=null!==h;(0,o.useEffect)(()=>{if(!E)return;let e=()=>m(w());return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[E,w]),(0,o.useLayoutEffect)(()=>{if(!h||!f.current||"left"===l||"right"===l)return;let e=f.current.getBoundingClientRect(),t=0;e.left<8?t=8-e.left:e.right>window.innerWidth-8&&(t=window.innerWidth-8-e.right),v(t)},[h,l]);let N={top:"-translate-x-1/2 -translate-y-full",bottom:"-translate-x-1/2",left:"-translate-x-full -translate-y-1/2",right:"-translate-y-1/2"}[l],S={top:"left-1/2 -translate-x-1/2 top-full border-x-transparent border-b-transparent border-x-4 border-t-4 border-b-0",bottom:"left-1/2 -translate-x-1/2 bottom-full border-x-transparent border-t-transparent border-x-4 border-b-4 border-t-0",right:"top-1/2 -translate-y-1/2 right-full border-y-transparent border-l-transparent border-y-4 border-r-4 border-l-0",left:"top-1/2 -translate-y-1/2 left-full border-y-transparent border-r-transparent border-y-4 border-l-4 border-r-0"}[l],T=null!=u?u:({top:"border-t-blue-12",bottom:"border-b-blue-12",right:"border-r-blue-12",left:"border-l-blue-12"})[l];return(0,r.jsxs)("span",{ref:g,className:a()("relative inline-flex",c),onMouseEnter:j,onMouseLeave:k,children:[n,h&&t&&(0,i.createPortal)((0,r.jsxs)("span",{ref:f,role:"tooltip",className:a()("fixed z-[9999]",p?"pointer-events-auto":"pointer-events-none","px-2 py-1 text-xs font-medium rounded-md whitespace-nowrap",d||"bg-blue-12 text-white shadow-sm",N),style:{top:h.top,left:h.left+C},...p&&{onMouseEnter:y,onMouseLeave:I},children:[t,(0,r.jsx)("span",{className:a()("absolute w-0 h-0 border-solid",S,T),style:C&&("top"===l||"bottom"===l)?{left:"calc(50% - ".concat(C,"px)")}:void 0})]}),document.body)]})}},48276:()=>{},49389:()=>{},49587:(e,t,n)=>{"use strict";n.d(t,{S:()=>p});var r=n(80263),l=n(544),a=n(53239),o=n(69119),i=n(16679),s=n(34999);let c=(0,i.I4)(l.bL,{all:"initial",color:i.w4.colors.gray1,borderRadius:"3px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"&[data-state=unchecked]":{backgroundColor:i.w4.colors.gray1,border:"1px solid ".concat(i.w4.colors.gray8),"&:active":{backgroundColor:i.w4.colors.gray3}},"&[data-state=checked]":{backgroundColor:i.w4.colors.blue9,"&:active":{backgroundColor:i.w4.colors.blue10},"&[data-disabled]":{opacity:.5,pointerEvents:"none"}},"&:focus-visible":{outline:"".concat(i.w4.colors.yellow8," solid 2px"),outlineOffset:"2px"},variants:{error:{false:{},true:{"&[data-state=unchecked]":{backgroundColor:i.w4.colors.red1,borderColor:i.w4.colors.red8}}},variant:{default:{},yellow:{"&[data-state=checked]":{backgroundColor:i.w4.colors.yellow8,"&:active":{backgroundColor:i.w4.colors.yellow9}}}},size:{default:{"&[data-state=unchecked]":{width:"22px",height:"22px"},"&[data-state=checked]":{width:"24px",height:"24px"}},small:{"&[data-state=unchecked]":{width:"16px",height:"16px"},"&[data-state=checked]":{width:"18px",height:"18px"}}}},defaultVariants:{error:"false",variant:"default",size:"default"}}),d=(0,i.I4)(l.C1,{width:"14px"}),u=(0,o.j)(c),p=(0,a.forwardRef)((e,t)=>(0,r.jsx)(u,{ref:t,trackingProperties:{typeofCTA:"checkbox"},...e,children:(0,r.jsx)(d,{children:(0,r.jsx)(s.J,{})})}))},50108:(e,t,n)=>{"use strict";n.d(t,{G:()=>K});var r=n(80263),l=n(78773),a=n(98414),o=n(53239),i=n(90597),s=n(4518),c=n(73991),d=n(16679),u=n(52602),p=n(95424),h=n(29525),m=n(70077);let g=(0,d.I4)("div",{display:"flex",alignItems:"center",gap:(0,m.D)(4),minHeight:45}),f=(0,d.I4)(c.P.div,{display:"flex",alignItems:"center",flex:1,justifyContent:"center",gap:(0,m.D)(4)}),x=(0,d.I4)(c.P.div,{display:"flex",gap:(0,m.D)(4),"@smallHeight":{paddingBlock:(0,m.D)(4)},variants:{isChatPdf:{true:{backgroundColor:d.w4.colors.blue2}},selected:{true:{backgroundColor:d.w4.colors.gray2,borderRadius:(0,m.D)(6)}},isMinimalScreen:{true:{paddingLeft:(0,m.D)(8),paddingRight:(0,m.D)(0)}}}});var b=function(e){return e.Intro="intro",e.Comment="comment",e.Success="success",e.Error="error",e}({}),C=n(65676),v=n(67106),y=n(69492),w=n(66008),j=n(49587);let I=(0,d.I4)("div",{display:"flex",alignItems:"center",gap:(0,m.D)(12),paddingBlock:(0,m.D)(12),borderBottom:"1px solid ".concat(d.w4.colors.gray4),variants:{isLast:{true:{borderBottom:"none"}}}}),k=(0,d.I4)("label",{cursor:"pointer",flex:1}),E=(0,d.I4)("div",{display:"flex",alignItems:"center",gap:(0,m.D)(8)}),N=(0,d.I4)("button",{all:"unset",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:(0,m.D)(4),borderRadius:(0,m.D)(4),variants:{isLast:{true:{borderBottom:"none"}}},"&:hover":{backgroundColor:d.w4.colors.gray3}}),S=e=>{let{options:t,handleBack:n,selectedOptions:l,onToggle:a}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(E,{children:[(0,r.jsx)(N,{onClick:n,children:(0,r.jsx)(v.I,{name:"arrowLeft",variant:"regular"})}),(0,r.jsx)(h.OH,{css:{fontSize:(0,m.D)(14)},children:"Tell us what didn't work"})]}),(0,r.jsx)(w.h,{height:8}),t.map((e,n)=>(0,r.jsxs)(I,{isLast:n===t.length-1,children:[(0,r.jsx)(j.S,{size:"small",variant:"yellow",checked:l.includes(e),onCheckedChange:()=>a(e)}),(0,r.jsx)(k,{onClick:()=>a(e),children:(0,r.jsx)(h.P,{size:"small",children:e})})]},n))]})},T="Something else?",A=e=>{let{like:t,dislike:n,commentText:l,likeOrDislike:a,setCommentText:i,comment:c,title:d="Take a moment to let us know what you think!",likeText:p,dislikeText:g,dislikeOptions:f,resetLikeDislike:x}=e,{t:b}=(0,s.B)("design-system"),[j,I]=(0,o.useState)([]),k="dislike"===a&&f&&f.length>0,E=k?[...f,T]:[],N="none"===a?b("share_feedback_placeholder","Share your insights here"):"like"===a?"Love it"===p?"Tell us why you love it":"Tell us why you like it":"Not good"===g?k?"Please elaborate":"Tell us why you dislike it":"What can we do to improve?";return(0,r.jsxs)(C.Z.Container,{color:"white",selected:!0,children:[!k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(C.Z.Header,{color:"yellow",children:[(0,r.jsx)(C.Z.HeaderIcon,{icon:(0,r.jsx)(v.I,{name:"star",variant:"solid"})}),(0,r.jsx)(C.Z.Title,{children:(0,r.jsx)(h.OH,{children:b("share_feedback","Share your feedback")})})]}),(0,r.jsx)(C.Z.Body,{children:d}),(0,r.jsx)(w.h,{height:12}),(0,r.jsx)(C.Z.Actions,{color:"yellow",orientation:"vertical",actions:[{content:[(0,r.jsx)(v.I,{name:"thumbsUp",variant:"solid"}),p],onClick:()=>{t()},state:"like"===a?"selected":"idle"},{content:[(0,r.jsx)(v.I,{name:"thumbsDown",variant:"solid"}),g],onClick:()=>{n()},state:"dislike"===a?"selected":"idle"}]}),(0,r.jsx)(C.Z.ActionsSeparator,{orientation:"horizontal"})]}),(0,r.jsxs)(u.az,{css:{paddingBlockStart:(0,m.D)(12),paddingInline:(0,m.D)(12)},children:[k&&(0,r.jsx)(S,{options:E,selectedOptions:j,onToggle:e=>{I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},handleBack:()=>{I([]),i(""),null==x||x()}}),!k&&(0,r.jsx)(w.h,{height:8}),(0,r.jsx)(u.az,{css:{paddingLeft:k?(0,m.D)(24):0}
1,children:(0,r.jsx)(y.pd,{name:"feedback-text",type:"text",onChange:e=>{if(i(e.target.value),!e.target.value)return void I(e=>e.filter(e=>e!==T));k&&I(e=>e.includes(T)?e:[...e,T])},placeholder:N})})]}),(0,r.jsx)(C.Z.Actions,{color:"yellow",orientation:"horizontal",actions:[{state:k&&!j.length||"none"===a?"disabled":"idle",content:[(0,r.jsx)(v.I,{name:"paperPlane",variant:"solid"}),b("send","Send")],onClick:()=>{k?c(l,j.filter(e=>e!==T)):c(l)}}]})]})};var R=n(90100),M=n(18696),L=n(38767);let D=e=>{let{reset:t}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.az,{as:"span",css:{color:d.w4.colors.red11.value},children:(0,r.jsx)(v.I,{name:"exclamationCircle",variant:"regular"})}),(0,r.jsx)(h.P,{css:{color:d.w4.colors.red11.value},children:"Whoops, something went wrong,"}),(0,r.jsx)(M.$,{onClick:t,variant:"link",children:"Try again."})]})},_=()=>(0,r.jsxs)(O,{color:"white",selected:!0,children:[(0,r.jsxs)(C.Z.Header,{color:"yellow",children:[(0,r.jsx)(C.Z.HeaderIcon,{icon:(0,r.jsx)(L.y,{size:12})}),(0,r.jsx)(C.Z.Title,{children:(0,r.jsx)(h.OH,{children:"Sending feedback"})})]}),(0,r.jsx)(w.h,{height:12})]}),H=()=>(0,r.jsxs)(O,{color:"white",selected:!0,children:[(0,r.jsxs)(C.Z.Header,{color:"green",children:[(0,r.jsx)(C.Z.HeaderIcon,{icon:(0,r.jsx)(v.I,{name:"check",variant:"solid",label:"Check"})}),(0,r.jsx)(C.Z.Title,{children:(0,r.jsx)(h.OH,{children:"Feedback sent"})})]}),(0,r.jsx)(w.h,{height:12})]}),P=e=>{let{children:t,delay:n}=e;return(0,r.jsx)(f,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0,transition:{delay:n}},children:t})},O=(0,d.I4)(C.Z.Container,{border:"none",boxShadow:"none !important"}),z=e=>{let{commentText:t,setCommentText:n,likeOrDislike:l,comment:m,like:g,screen:f,dislike:C,loading:v,status:y,closeDialog:w,dialogStatus:j,setDialogStatus:I,hideText:k,isChatPdf:E,buttonContainerStyle:N,isMobileWeb:S=!1,toggleBottomDrawer:T,isExtension:M=!1,disableGa4Tracking:L=!1,feedbackTitle:D,dislikeOptions:P,resetLikeDislike:O}=e,{t:z}=(0,s.B)("design-system");return(0,o.useEffect)(()=>{T&&(f===b.Comment||f===b.Error||f===b.Success?T(.95):T(.5))},[f,T]),(0,r.jsxs)(r.Fragment,{children:["intro"===f&&(0,r.jsxs)(a.N,{mode:"sync",children:[k?null:(0,r.jsx)(c.P.div,{style:{overflow:"hidden",whiteSpace:"nowrap"},exit:{width:0,opacity:0},transition:{type:"linear"},animate:{width:"auto",opacity:1},children:(0,r.jsx)(h.P,{size:"small",children:z("help_us_improve_label","Help us improve")})},"rate-result"),(0,r.jsx)(x,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},isChatPdf:E,css:{...N,backgroundColor:(null==N?void 0:N.backgroundColor)||d.w4.colors.white},children:(0,r.jsxs)(i.Bc,{children:[(0,r.jsx)(c.P.div,{children:(0,r.jsx)(R.K,{selected:"like"===l,onClick:g,label:"Like",disabled:v||"idle"!==y,name:"thumbsUp",variant:"like"===l?"solid":"regular","aria-label":"Positive feedback",disableGa4Tracking:L})},"like-button"),(0,r.jsx)(c.P.div,{children:(0,r.jsx)(R.K,{selected:"dislike"===l,onClick:C,disabled:v||"idle"!==y,label:"Dislike",name:"thumbsDown",variant:"dislike"===l?"solid":"regular","aria-label":"Negative feedback",disableGa4Tracking:L})},"dislike-button")]})},"buttons")]}),(f===b.Comment||f===b.Error||f===b.Success)&&(0,r.jsx)(p.y,{onClose:()=>{w()},style:S?"bottomSheetOverlay":"popover",shadowDOMCompatMode:M,children:(0,r.jsx)(u.az,{css:{maxWidth:"360px"},children:"sending"===j?(0,r.jsx)(_,{}):"sent"===j?(0,r.jsx)(H,{}):(0,r.jsx)(A,{like:g,dislike:C,likeOrDislike:l,setCommentText:n,commentText:t,comment:(e,t)=>{I("sending"),m({comment:e,like:"like"===l,checklist:t})},title:D||z("share_feedback_title","Take a moment to let us know what you think!"),likeText:z("like","Love it"),dislikeText:z("dislike","Not good"),dislikeOptions:P,resetLikeDislike:O})})})]})};var B=n(77274),F=n(6437),V=n(74425);let U=e=>{let{commentText:t,setCommentText:n,likeOrDislike:l,comment:s,like:c,screen:d,dislike:u,loading:p,status:h,dialogStatus:g,setDialogStatus:f,isChatPdf:b,isMinimalScreen:C,isExtension:v=!1,disableGa4Tracking:y=!1,isComingOnModal:w=!1,isMobileWeb:j=!1}=e,I=(0,o.useRef)(null),[k,E]=(0,o.useState)(!1),[N,S]=(0,o.useState)(null);(0,o.useLayoutEffect)(()=>{if(!v)return;let e=(0,B.M)();e&&S(e)},[v]);let T=(0,r.jsx)(a.N,{mode:"sync",children:(0,r.jsx)(x,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},isChatPdf:b,isMinimalScreen:C,selected:"like"===l||"dislike"===l,children:(0,r.jsxs)(i.Bc,{children:[(0,r.jsx)(R.K,{selected:"like"===l,onClick:()=>{c(),E(!0)},label:"Like",disabled:p||"idle"!==h,name:"thumbsUp",variant:"like"===l?"duotone":"regular",isMinimalScreen:C,"aria-label":"Positive feedback",disableGa4Tracking:y,supportMobileTap:!j}),(0,r.jsx)(R.K,{selected:"dislike"===l,onClick:()=>{u(),E(!0)},disabled:p||"idle"!==h,label:"Dislike",name:"thumbsDown",variant:"dislike"===l?"duotone":"regular",isMinimalScreen:C,"aria-label":"Negative feedback",disableGa4Tracking:y,supportMobileTap:!j})]})},"buttons")}),A="sending"===g?(0,r.jsx)(_,{}):"sent"===g?(0,r.jsx)(H,{}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V.f,{name:"feedback-text",onChange:e=>{n(e.target.value)},placeholder:"like"===l?"Tell us what you liked":"Tell us what didn't work",css:j?{fontSize:(0,m.D)(16)}:void 0}),(0,r.jsx)(M.$,{css:j?{marginTop:(0,m.D)(8),width:"100%",minHeight:(0,m.D)(44)}:{marginTop:(0,m.D)(16)},onClick:()=>{f("sending"),s({comment:t,like:"like"===l})},disableGa4Tracking:!0,children:"Send Feedback"})]});return"comment"!==d&&"intro"!==d&&"error"!==d&&"success"!==d?null:j?(0,r.jsxs)("div",{children:[T,(0,r.jsx)(a.N,{children:k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(G,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},onClick:()=>E(!1)},"mobile-backdrop"),(0,r.jsxs)(Z,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:25,stiffness:300},children:[(0,r.jsx)(q,{}),A]},"mobile-bottom-sheet")]})})]}):(0,r.jsx)(F.A.Root,{open:k,onOpenChange:()=>{E(e=>!e)},...v&&{modal:!1},children:(0,r.jsxs)("div",{style:{position:"relative"},children:[(0,r.jsx)(F.A.Anchor,{ref:I,children:T}),(0,r.jsx)($,{hideArrow:!0,align:"end",container:N||void 0,isCustomContainer:!!N,isComingOnModal:w,children:(0,r.jsx)(W,{isMinimalScreen:C,id:"feedback-container",children:A})})]})})},W=(0,d.I4)("div",{display:"flex",flexDirection:"column",paddingInline:(0,m.D)(8),paddingBlock:(0,m.D)(16),borderRadius:(0,m.D)(6),background:d.w4.colors.gray2,border:"none",maxWidth:"100%",minWidth:"350px",variants:{isMinimalScreen:{true:{minWidth:"250px",paddingInline:(0,m.D)(4),paddingBlock:(0,m.D)(8)}}}}),G=(0,d.I4)(c.P.div,{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.4)",zIndex:999}),Z=(0,d.I4)(c.P.div,{position:"fixed",bottom:0,left:0,right:0,zIndex:1e3,background:d.w4.colors.white,borderTopLeftRadius:(0,m.D)(16),borderTopRightRadius:(0,m.D)(16),padding:"".concat((0,m.D)(8)," ").concat((0,m.D)(16)," ").concat((0,m.D)(24)),display:"flex",flexDirection:"column",gap:(0,m.D)(12),boxShadow:"0 -4px 20px rgba(0, 0, 0, 0.1)"}),q=(0,d.I4)("div",{width:(0,m.D)(36),height:(0,m.D)(4),borderRadius:(0,m.D)(2),background:d.w4.colors.gray6,alignSelf:"center",marginBottom:(0,m.D)(4)}),$=(0,d.I4)(F.A.Popup,{border:"none !important",boxShadow:"none !important",variants:{isCustomContainer:{true:{zIndex:0x7fffffff}},isComingOnModal:{true:{zIndex:1e9}}}}),K=e=>{let[t,n]=(0,o.useState)(""),[s,c]=(0,o.useState)("none"),[d,u]=(0,o.useState)("idle"),{mutate:p}=(0,l.useMutation)({mutationFn:e.onLike,onMutate:()=>{c("like")}}),{mutate:h}=(0,l.useMutation)({mutationFn:e.onDislike,onMutate:()=>{c("dislike")}}),{mutate:m,status:f,reset:x,isLoading:C}=(0,l.useMutation)({mutationFn:e.onComment}),v=f===b.Error?b.Error:f===b.Success?b.Success:"none"===s?e.showComment?b.Comment:b.Intro:b.Comment,[y,w]=(0,o.useState)(b.Intro);return(0,o.useEffect)(()=>{w(v),"success"===v&&(u("sent"),setTimeout(()=>{u("done")},1500))},[v]),(0,r.jsx)(i.Bc,{delayDuration:500,skipDelayDuration:0,children:(0,r.jsx)(g,{children:(0,r.jsxs)(a.N,{mode:"wait",children:[y===b.Error&&(0,r.jsx)(P,{children:(0,r.jsx)(D,{reset:x})},"feedback-received-error"),(y===b.Comment||y===b.Intro||y===b.Success)&&"done"!==d&&(0,r.jsx)(P,{delay:1,children:e.showFeedbackModal?(0,r.jsx)(z,{screen:v,like:p,dislike:h,comment:m,isChatPdf:e.isChatPdf,commentText:t,setCommentText:n,status:f,likeOrDislike:s,loading:C,closeDialog:()=>{e.onClose&&e.onClose(),c("none")},dialogStatus:d,setDialogStatus:e=>{u(e)},hideText:e.hideText,buttonContainerStyle:e.buttonContainerStyle,isMobileWeb:e.isMobileWeb,toggleBottomDrawer:e.toggleBottomDrawer,isExtension:e.isExtension,disableGa4Tracking:null==e?void 0:e.disableGa4Tracking,feedbackTitle:null==e?void 0:e.feedbackTitle,dislikeOptions:null==e?void 0:e.dislikeOptions,resetLikeDislike:()=>c("none")}):(0,r.jsx)(U,{screen:v,like:p,dislike:h,comment:m,isChatPdf:e.isChatPdf,commentText:t,setCommentText:n,status:f,likeOrDislike:s,loading:C,dialogStatus:d,setDialogStatus:e=>{u(e)},isMinimalScreen:e.isMinimalScreen,isExtension:e.isExtension,disableGa4Tracking:null==e?void 0:e.disableGa4Tracking,isComingOnModal:null==e?void 0:e.isComingOnModal,isMobileWeb:e.isMobileWeb})},"comment")]})})})}},50595:(e,t,n)=>{"use strict";n.d(t,{H:()=>u});var r=n(80263),l=n(73991),a=n(53239),o=n(63556),i=n(94834),s=n(16679);let c=(0,s.I4)(l.P.div,{overflow:"hidden"}),d=(0,s.I4)("div",{}),u=(0,a.forwardRef)((e,t)=>{let[n,{height:l}]=(0,o.A)({polyfill:i.A});return(0,r.jsx)(c,{ref:t,animate:{height:l},children:(0,r.jsx)(d,{ref:n,children:e.children})})})},50737:()=>{},51138:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(53239);let l=e=>{let[t,n]=(0,r.useState)([]),[l,a]=(0,r.useState)({}),o=(0,r.useMemo)(()=>new Set(t),[t]);(0,r.useEffect)(()=>{n([]),a({})},[e]);let i=(0,r.useCallback)((e,t)=>{n(n=>{let r=n.includes(e);return t&&!r?[...n,e]:!t&&r?n.filter(t=>t!==e):n})},[]),s=(0,r.useCallback)(e=>{n(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),c=(0,r.useCallback)(e=>{let t=[],r={};for(let{itemId:n,attachmentIds:l}of e)t.push(n),l.length>0&&(r[n]=new Set(l));n(t),a(r)},[]),d=(0,r.useCallback)(()=>{n([]),a({})},[]),u=(0,r.useCallback)((e,t)=>{a(n=>{var r;let l=null!=(r=n[e])?r:new Set,a=t.length>0&&t.every(e=>l.has(e))?new Set:new Set(t);if(i(e,a.size>0),0===a.size){let t={...n};return delete t[e],t}return{...n,[e]:a}})},[i]),p=(0,r.useCallback)((e,t)=>{a(n=>{var r;let l=new Set(null!=(r=n[e])?r:[]);if(l.has(t)?l.delete(t):l.add(t),i(e,l.size>0),0===l.size){let t={...n};return delete t[e],t}return{...n,[e]:l}})},[i]),h=(0,r.useCallback)(e=>t.reduce((t,n)=>{let r=e.get(n);if(!r)return t;let a=l[n];return a&&a.size>0?t.push({...r,attachments:r.attachments.filter(e=>a.has(e.id))}):t.push(r),t},[]),[t,l]);return{selectedIds:t,selectedIdsSet:o,selectedAttachmentIds:l,setSelectedIds:n,toggleItem:s,toggleAllAttachmentsForItem:u,toggleAttachment:p,selectAll:c,clearSelection:d,getSelectedItems:h}}},51378:(e,t,n)=>{"use strict";n.d(t,{c:()=>function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];for(let a of t){var l;r.push({collection:a,depth:n}),(null==(l=a.children)?void 0:l.length)&&r.push(...e(a.children,n+1))}return r}})},52370:(e,t,n)=>{"use strict";n.d(t,{p:()=>a});var r=n(80263),l=n(53239);let a=(e,t,n,a,o,i,s,c,d,u)=>{var p,h;let m=null==e?void 0:e.freeCreditsBalanceDtoList,g=(null!=(p=null==e?void 0:e.totalBalance)?p:0)-(null!=(h=null==e?void 0:e.usedBalance)?h:0),f=!!i&&"paperpal-free-trial-7-days"!==s,x=e=>{if(!e)return;let{usedFeatureLimit:t,featureLimit:n}=e,r=n-t;if(t!==n)return"\uD83C\uDF81 ".concat(r,"/").concat(n," claimed uses left today")};return(0,l.useMemo)(()=>
1{if(c&&d)return{message:(0,r.jsx)("span",{style:{fontSize:"14px",lineHeight:"20px",color:"#5D6A81",fontWeight:500},children:"Unlimited scans \xb7 Limited-time access"}),toolTipMessage:(0,r.jsx)(r.Fragment,{children:"You are enjoying unlimited AI detection scans today, after which you will be shifted to the free plan."})};if(a)return{message:"".concat(null==o?void 0:o.toLocaleString("en-US")," words left for this month"),toolTipMessage:f?"Your ".concat(u," word limit will renew on the 1st of every month."):"Your 7,000 word limit will renew on the 1st of every month."};if(c)return{message:(0,r.jsx)("p",{style:{fontSize:"14px",lineHeight:"22px",color:"#5D6A81",fontWeight:500},children:"Don’t stop now, get more checks"})};if((!m||0===m.length)&&e&&e.usedBalance<e.totalBalance)return f?{message:n("uses_left",{remainingBalance:g,totalBalance:e.totalBalance,defaultValue:"{{remainingBalance}}/{{totalBalance}} uses left"}),toolTipMessage:n("monthly_uses_refill",{defaultValue:"Your limit refreshes on the 1st of every month. Get more with Pro."})}:{message:(null==e?void 0:e.daysForRefill)&&e.daysForRefill<=1?n("free_uses_left_today",{remainingBalance:g,totalBalance:e.totalBalance,defaultValue:"{{remainingBalance}}/{{totalBalance}} free uses left today"}):n("free_uses_left",{remainingBalance:g,totalBalance:e.totalBalance,defaultValue:"{{remainingBalance}}/{{totalBalance}} free uses left"}),toolTipMessage:e.daysForRefill&&e.daysForRefill<=1?n("free_uses_refill_tomorrow",{dailyTotalBalance:t,defaultValue:"Your {{dailyTotalBalance}} free uses refill tomorrow"}):n("next_refill_of_free_uses",{dailyTotalBalance:t,balanceDaysForRefill:null==e?void 0:e.daysForRefill,defaultValue:"Next refill of {{dailyTotalBalance}} free uses in {{balanceDaysForRefill}} days"})};if(m)for(let e of m){var l;let{featuresAndLimits:n}=e;if(n&&n.length>0&&(null==(l=n[0])?void 0:l.featureName)==="GENAI"&&n[0].usedFeatureLimit<n[0].featureLimit){let e=x(n[0]);if(e)return{message:e,toolTipMessage:"Your claimed uses expire today. Your daily ".concat(t," free uses refill tomorrow.")}}}return{message:f?n("monthly_limit_reached_footer",{defaultValue:"Monthly usage limit reached"}):"No free uses left",toolTipMessage:f?n("monthly_uses_refill",{defaultValue:"Your limit refreshes on the 1st of every month. Get more with Pro."}):(null==e?void 0:e.daysForRefill)&&e.daysForRefill<=1?n("free_uses_refill_tomorrow",{dailyTotalBalance:t,defaultValue:"Your {{dailyTotalBalance}} free uses refill tomorrow"}):n("next_refill_of_free_uses",{dailyTotalBalance:t,balanceDaysForRefill:null==e?void 0:e.daysForRefill,defaultValue:"Next refill of {{dailyTotalBalance}} free uses in {{balanceDaysForRefill}} days"})}},[t,m,a,o,e,g,c,d,f,n,u])}},53729:()=>{},54541:(e,t,n)=>{"use strict";n.d(t,{L5:()=>d,QP:()=>o,nj:()=>u,nn:()=>s,p6:()=>i,vu:()=>c});var r=n(16679),l=n(70077),a=n(18696);let o=(0,r.I4)("div",{position:"absolute",left:0,zIndex:1,top:0,display:"flex",width:"100%",alignItems:"center",paddingTop:(0,l.D)(8),variants:{showBackDropFilter:{true:{backdropFilter:"blur(1px)",left:2,top:2,borderRadius:12,width:"calc(100% - 4px)"}},isOnDashboardBackDrop:{true:{height:"46px",top:"auto",bottom:0,justifyContent:"flex-start",width:"auto",left:40,right:"auto",backdropFilter:"none","& > div":{width:"fit-content"},paddingTop:0}},isUngated:{true:{}},shouldShowPaywall:{true:{}},stackAbove:{true:{}}},compoundVariants:[{isOnDashboardBackDrop:!0,isUngated:!0,css:{"@sm":{right:60,"& > div":{width:"100%"}}}},{isOnDashboardBackDrop:!0,shouldShowPaywall:!0,css:{left:40,right:"auto"}}]}),i=(0,r.I4)("div",{gap:(0,l.D)(8),display:"flex",width:"100%",paddingLeft:0}),s=(0,r.I4)("div",{display:"flex",gap:(0,l.D)(8),alignItems:"center",overflowX:"auto",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}}),c=(0,r.I4)("div",{maxWidth:100,flexShrink:0,display:"flex",alignItems:"center",gap:(0,l.D)(4),backgroundColor:r.
1w4.colors.white,borderRadius:6,padding:(0,l.D)(3),paddingLeft:(0,l.D)(3),fontSize:(0,l.D)(12),fontWeight:500,color:r.w4.colors.gray12,cursor:"pointer",border:"1px solid ".concat(r.w4.colors.gray5),transition:"background 0.2s ease",maxHeight:32,"&:hover":{backgroundColor:r.w4.colors.blue3},span:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",display:"block"},"&:first-child":{marginLeft:(0,l.D)(10)},"&:last-child":{marginRight:(0,l.D)(5)},variants:{variant:{default:{},loading:{color:r.w4.colors.blue12,backgroundColor:r.w4.colors.blue2},error:{color:r.w4.colors.blue9,backgroundColor:r.w4.colors.red2}}}}),d=(0,r.I4)("div",{width:(0,l.D)(20),height:(0,l.D)(20),minWidth:(0,l.D)(20),display:"flex",alignItems:"center",justifyContent:"center",fontSize:(0,l.D)(12),position:"relative",color:r.w4.colors.white,variants:{variant:{add:{background:r.w4.colors.white,border:"1px solid ".concat(r.w4.colors.gray10),color:r.w4.colors.gray12,fontSize:(0,l.D)(16)},doc:{}}}}),u=(0,r.I4)(a.$,{background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:r.w4.colors.gray12,borderRadius:4,boxShadow:"none","&:hover":{background:r.w4.colors.gray6,opacity:.7}})},55270:(e,t,n)=>{"use strict";n.d(t,{$C:()=>i,H_:()=>c,N3:()=>d,QP:()=>s});var r=n(80263),l=n(29525),a=n(16679),o=n(70077);let i=e=>{let{chunk:t}=e;return"replace"===t.type?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s,{"data-insertion-type":"ai-generated","data-feature-name":"LanguageSuggestion",children:t.with}),(0,r.jsx)(c,{children:t.text})]}):"add"===t.type?(0,r.jsx)(s,{"data-insertion-type":"ai-generated","data-feature-name":"LanguageSuggestion",children:t.text}):"remove"===t.type?(0,r.jsx)(c,{children:t.text}):(0,r.jsx)("span",{children:t.text})},s=(0,a.I4)("span",{backgroundColor:a.w4.colors.green5,color:a.w4.colors.blue12,paddingInline:(0,o.D)(2)}),c=(0,a.I4)("span",{backgroundColor:a.w4.colors.red5,color:a.w4.colors.blue12,paddingInline:(0,o.D)(2),textDecoration:"line-through",textDecorationThickness:"2px",textDecorationColor:a.w4.colors.redAlpha9}),d=(0,a.I4)(l.P,{fontSize:(0,o.D)(16),color:a.w4.colors.blue12,wordBreak:"break-word",variants:{size:{tiny:{fontSize:(0,o.D)(12),lineHeight:(0,o.D)(24)}}}})},56789:(e,t,n)=>{"use strict";n.d(t,{w:()=>a,z:()=>o});var r=n(78773),l=n(64014);function a(e,t){var n;return{libraryId:e.libraryId,itemType:null!=(n=t.docType)?n:"article",sourceDocId:t.sourceDocId,citationItem:t,source:"RESEARCH",title:t.title,collections:[e.id],csl:"",labels:[],notes:[],attachments:[],isUnknownSource:!1}}function o(){let{webApiClient:e}=(0,l.p)();return(0,r.useMutation)({mutationFn:async t=>{let{libraryId:n,...r}=t;return await e.post("/api/v1/libraries/".concat(n,"/items"),r)}})}},57379:()=>{},57485:()=>{},58060:()=>{}
1,58212:(e,t,n)=>{"use strict";n.d(t,{y:()=>a});var r=n(80263);function l(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?"".concat(e,"px"):"".concat(e/16,"rem")}let a=e=>{var t;let{color:n,size:a}=e,o=a/2-2,i=a/2,s=a/2;return(0,r.jsx)("svg",{className:"animate-spin",width:l(a),height:l(a),viewBox:"0 0 ".concat(a," ").concat(a),children:(0,r.jsx)("path",{d:"\n          M ".concat(i-o,", ").concat(s,"\n          a ").concat(o,",").concat(o," 0 1,0 ").concat(2*o,",0\n        "),fill:"transparent",stroke:null!=(t=null==n?void 0:n.value)?t:"currentColor",strokeWidth:2})})}},58759:(e,t,n)=>{"use strict";function r(e){if(e)try{let{hostname:t}=new URL(e);return t.replace(/^www\./,"")}catch(e){return}}n.d(t,{BF:()=>r})},59008:(e,t,n)=>{"use strict";n.d(t,{X:()=>l});var r=n(80263);n(53239);let l=e=>{let{color:t="#0062FF",width:n=18,height:l=18,...a}=e;return(0,r.jsx)("svg",{width:n,height:l,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a,children:(0,r.jsx)("path",{d:"M3.5998 4.9501C3.3523 4.9501 3.1498 5.1526 3.1498 5.4001V12.6001C3.1498 12.8476 3.3523 13.0501 3.5998 13.0501H14.3998C14.6473 13.0501 14.8498 12.8476 14.8498 12.6001V5.4001C14.8498 5.1526 14.6473 4.9501 14.3998 4.9501H3.5998ZM1.7998 5.4001C1.7998 4.40729 2.60699 3.6001 3.5998 3.6001H14.3998C15.3926 3.6001 16.1998 4.40729 16.1998 5.4001V12.6001C16.1998 13.5929 15.3926 14.4001 14.3998 14.4001H3.5998C2.60699 14.4001 1.7998 13.5929 1.7998 12.6001V5.4001ZM8.9998 6.3001C9.37387 6.3001 9.67481 6.60103 9.67481 6.9751V8.3251H11.0248C11.3989 8.3251 11.6998 8.62603 11.6998 9.0001C11.6998 9.37416 11.3989 9.6751 11.0248 9.6751H9.67481V11.0251C9.67481 11.3992 9.37387 11.7001 8.9998 11.7001C8.62574 11.7001 8.3248 11.3992 8.3248 11.0251V9.6751H6.9748C6.60074 9.6751 6.2998 9.37416 6.2998 9.0001C6.2998 8.62603 6.60074 8.3251 6.9748 8.3251H8.3248V6.9751C8.3248 6.60103 8.62574 6.3001 8.9998 6.3001Z",stroke:t,strokeWidth:"0.25",fill:t})})}},59925:()=>{},61712:()=>{},62590:(e,t,n)=>{"use strict";n.d(t,{M:()=>h});var r=n(80263),l=n(16679),a=n(70077),o=n(86527),i=n(38767),s=n(29525);let c=(0,l.I4)("div",{display:"flex",alignItems:"flex-start",gap:(0,a.D)(8),paddingInline:(0,a.D)(16)}),d=(0,l.i7)({"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}),u=(0,l.I4)(s.P,{background:"linear-gradient(\n    90deg,\n    rgba(125, 138, 161, 1) 0%,\n    rgba(125, 138, 161, 1) 35%,\n    rgba(255, 255, 255, 0.5) 50%,\n    rgba(125, 138, 161, 1) 65%,\n    rgba(125, 138, 161, 1) 100%\n  )",backgroundSize:"200% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",WebkitTextFillColor:"transparent",color:"transparent",fontSize:(0,a.D)(14),animation:"".concat(d," 7s linear 2s infinite")}),p=e=>{let{src:t}=e;return(0,r.jsx)(o.j,{width:150,height:150,src:t})},h=e=>{let{showLottie:t}=e;return(0,r.jsxs)(r.Fragment,{children:[t&&(0,r.jsx)("div",{style:{overflow:"hidden",height:150,width:150,minHeight:150,maxHeight:150,marginInline:"auto"},children:(0,r.jsx)(p,{src:"https://cdn.paperpal.com/assets/lottie-animation/edit/trim-loading-2.lottie"})}),(0,r.jsxs)(c,{children:[(0,r.jsx)("div",{style:{marginTop:"2px"},children:(0,r.jsx)(i.y,{size:18})}),(0,r.jsx)(u,{children:"Thinking through the perfect trim. Time for a quick stretch..."})]})]})}},62764:(e,t,n)=>{"use strict";n.d(t,{q:()=>r});var r=function(e){return e.IDLE="idle",e.LOADING="loading",e.SUCCESS="success",e.ERROR="error",e.QUEUED="queued",e}({})},63681:()=>{},64187:()=>{},65676:(e,t,n)=>{"use strict";n.d(t,{Z:()=>S,m:()=>E});var r=n(80263),l=n(53239),a=n(73991),o=n(50595),i=n(87987),s=n(72140),c=n(73825),d=n(29525),u=n(16679),p=n(70077);let h={initialGrow:{translateX:"calc(0% + 0px)",height:0,opacity:0},grow:{height:"auto",transition:{duration:.1}},show:{opacity:1,transition:{duration:.2,delay:.2}},collapse:{height:0,transition:{duration:.1,delay:.4}},defaultExit:{translateX:"calc(0 + 0px)",opacity:0,transition:{duration:.2}},acceptExit:{translateX:"calc(-100% - 25px)",transition:{duration:.4}},rejectExit:{translateX:"calc(100% + 25px)",transition:{duration:.4}}},m=l.forwardRef((e,t)=>{let{children:n,id:o,exitAnimation:i,initialState:s,smooth:c}=e,d="none"===i?"defaultExit":"accept"===i?"acceptExit":"rejectExit",u=l.useMemo(()=>c?{...h,grow:{height:"auto",transition:{duration:.2,ease:"easeOut"}},show:{opacity:1,transition:{duration:.15}},collapse:{height:0,transition:"none"===i?{duration:.18,ease:"easeIn"}:{duration:.1,delay:.4}},defaultExit:{translateX:"calc(0 + 0px)",opacity:0,transition:{duration:.12}}}:h,[c,i]);return(0,r.jsx)(a.P.div,{ref:t,variants:u,initial:s||"initialGrow",animate:["grow","show","default"],exit:[d,"collapse"],children:n},o)}),g=(0,u.I4)("span",{display:"flex",alignItems:"center",justifyContent:"center",alignSelf:"flex-start",marginTop:"3px",flexShrink:0,width:(0,p.D)(1
15),height:(0,p.D)(15),lineHeight:(0,p.D)(15),fontSize:(0,p.D)(15),"@maxWidth300":{fontSize:(0,p.D)(14)}}),f=(0,u.I4)(d.EY,{fontSize:(0,p.D)(15),lineHeight:(0,p.D)(20),color:u.w4.colors.gray11,["".concat(d.OH)]:{fontWeight:u.w4.fontWeights.medium},"@maxWidth300":{fontSize:(0,p.D)(14),lineHeight:(0,p.D)(18)},variants:{size:{tiny:{fontSize:(0,p.D)(12),lineHeight:(0,p.D)(16)}},multiline:{true:{},false:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",wordBreak:"break-all"}}},defaultVariants:{multiline:"false"}}),x=(0,u.I4)("div",{display:"flex",flexDirection:"row",gap:(0,p.D)(8),alignItems:"center",paddingBlockStart:(0,p.D)(12),paddingInline:(0,p.D)(12),["& ".concat(g)]:{color:u.w4.colors.gray11},variants:{color:{lightBlue:{["& ".concat(f," ").concat(d.OH)]:{color:u.w4.colors.blue1},["& ".concat(g)]:{color:u.w4.colors.blue1}},blue:{["& ".concat(f," ").concat(d.OH)]:{color:u.w4.colors.blue11},["& ".concat(g)]:{color:u.w4.colors.blue7}},yellow:{["& ".concat(f," ").concat(d.OH)]:{color:u.w4.colors.yellow8},["& ".concat(g)]:{color:u.w4.colors.yellow7}},green:{["& ".concat(f," ").concat(d.OH)]:{color:u.w4.colors.green10},["& ".concat(g)]:{color:u.w4.colors.green10}},red:{["& ".concat(f," ").concat(d.OH)]:{color:u.w4.colors.red10},["& ".concat(g)]:{color:u.w4.colors.red10}},primaryBlue:{["& ".concat(f," ").concat(d.OH)]:{color:u.w4.colors.blue12},["& ".concat(g)]:{color:u.w4.colors.blue12}}},template:{default:{},minimal:{}}},compoundVariants:[{template:"minimal",css:{paddingInline:(0,p.D)(0)}}]}),b=(0,u.I4)("div",{display:"flex",flexDirection:"column",paddingBlock:(0,p.D)(12),paddingInline:(0,p.D)(12),variants:{template:{default:{},minimal:{paddingInline:(0,p.D)(0),paddingTop:(0,p.D)(4),paddingBottom:(0,p.D)(12)}}}}),C=l.forwardRef((e,t)=>{let{color:n,orientation:a,actions:o,cardTemplate:i="default",...s}=e;return(0,r.jsxs)(v,{ref:t,orientation:a,cardTemplate:i,...s,children:["minimal"===i&&"vertical"===a?(0,r.jsx)(w,{orientation:"horizontal"}):null,o.map((e,t)=>(0,r.jsxs)(l.Fragment,{children:[(0,r.jsx)(k,{"data-test-id":e.id,blinking:e.blinking,variant:e.variant,color:n,"data-state":e.state,id:e.id,onClick:"idle"===e.state||"dimmed"===e.state?e.onClick:()=>{},css:{...e.css},disabled:"disabled"===e.state,leftCorner:"minimal"!==i&&("horizontal"===a?0===t:t===o.length-1),rightCorner:"minimal"!==i&&t===o.length-1,trackingName:e.trackingName,trackingProperties:e.trackingProperties,className:e.id,disableTracking:e.disableTracking,disableGa4Tracking:null==s?void 0:s.disableGa4Tracking,children:e.content.map((e,t)=>(0,r.jsx)(y,{children:e},t))},t),"minimal"!==i&&t<o.length-1&&"none"!==a?(0,r.jsx)(w,{orientation:"horizontal"===a?"vertical":"horizontal"}):null]},t))]})}),v=(0,u.I4)("div",{display:"flex",borderBottomLeftRadius:(0,p.D)(8),borderBottomRightRadius:(0,p.D)(8),variants:{orientation:{horizontal:{},vertical:{flexDirection:"column"},none:{}},cardTemplate:{minimal:{gap:(0,p.D)(16)},default:{}}}}),y=(0,u.I4)("span",{}),w=e=>{let{orientation:t}=e;return(0,r.jsx)(c.w,{"data-orientation":t,css:{..."vertical"===t?{height:"unset!important"}:{},backgroundColor:u.w4.colors.gray5}})},j=(0,u.i7)({"70%":{backgroundColor:u.w4.colors.white,borderColor:u.w4.colors.gray5},"85%":{backgroundColor:u.w4.colors.blue4,borderColor:u.w4.colors.blue5},"100%":{backgroundColor:u.w4.colors.white}}),I=(0,u.i7)({"70%":{backgroundColor:u.w4.colors.blue5,borderColor:u.w4.colors.blue12},"85%":{backgroundColor:u.w4.colors.blue12,borderColor:u.w4.colors.blue5},"100%":{backgroundColor:u.w4.colors.blue10,borderColor:u.w4.colors.blue10}}),k=(0,u.I4)(i.J,{display:"flex",gap:(0,p.D)(8),justifyContent:"center",alignItems:"center",fontSize:(0,p.D)(14),lineHeight:(0,p.D)(24),paddingBlock:(0,p.D)(12),paddingInline:(0,p.D)(12),flexGrow:1,animation:"none",fontWeight:u.w4.fontWeights.medium,"&:disabled":{cursor:"unset","&:hover":{background:"unset"}},'&[data-state="dimmed"]':{color:u.w4.colors.gray8},'&[data-state="selected"]':{cursor:"unset"},variants:{blinking:{true:{animation:"3s cubic-bezier(0, 0, 0.44, 0) infinite normal none running ".concat(j)}},color:{blue:{color:u.w4.colors.blue9,'&:hover, &[data-state="selected"], &:active':{backgroundColor:u.w4.colors.blue3},"&:disabled":{color:u.w4.colors.blue7}},gray:{color:u.w4.colors.gray10,'&:hover, &[data-state="selected"], &:active':{backgroundColor:u.w4.colors.gray3},"&:disabled":{color:u.w4.colors.blue7}},yellow:{color:u.w4.colors.yellow8,'&:hover, &[data-state="selected"], &:active':{backgroundColor:u.w4.colors.yellow2},"&:disabled":{color:u.w4.colors.yellow6}},prime:{color:u.w4.colors.yellow9,'&:hover, &[data-state="selected"], &:active':{},"&:disabled":{color:u.w4.colors.yellow6}},primary:{color:u.w4.colors.gray1,background:u.w4.colors.blue9,borderRadius:(0,p.D)(8),'&:hover, &[data-state="selected"], &:active':{backgroundColor:u.w4.colors.blue10},"&:disabled":{color:u.w4.colors.blue7}}},leftCorner:{true:{borderBottomLeftRadius:(0,p.D)(8)}},rightCorner:{true:{borderBottomRightRadius:(0,p.D)(8)}},variant:{solid:{paddingInline:(0,p.D)(0)},outline:{paddingInline:(0,p.D)(0)},default:{}}},compoundVariants:[{color:"blue",variant:"solid",css:{color:u.w4.colors.white,backgroundColor:u.w4.colors.blue10,'&:hover, &[data-state="selected"], &:active':{backgroundColor:u.w4.colors.blue9},"&:disabled":{color:u.w4.colors.blueAlpha6,backgroundColor:u.w4.colors.blue4,borderColor:u.w4.colors.blueAlpha5,cursor:"not-allowed",opacity:.6},borderRadius:(0,p.D)(6)}},{color:"blue",variant:"outline",css:{color:u.w4.colors.blue9,backgroundColor:u.w4.colors.white,'&:hover, &[data-state="selected"], &:active':{backgroundColor:u.w4.colors.blue3},"&:disabled":{color:u.w4.colors.blueAlpha6,backgroundColor:u.w4.colors.blue2,borderColor:u.w4.colors.blue4,cursor:"not-allowed",opacity:.8},borderWidth:"1px",borderStyle:"solid",borderRadius:(0,p.D)(6),borderColor:u.w4.colors.blue10}},{blinking:!0,variant:"solid",css:{animation:"3s cubic-bezier(0, 0, 0.44, 0) infinite normal none running ".concat(I
1)}}],"&:focus-visible":{outline:"2px solid ".concat(u.w4.colors.yellow8),outlineOffset:"-2px"},"@sm":{paddingBlock:(0,p.D)(6),paddingInline:(0,p.D)(6)},"@md":{paddingBlock:(0,p.D)(6),paddingInline:(0,p.D)(6)}}),E=l.forwardRef((e,t)=>{let{children:n,animation:l,blinking:a,template:i="default",...s}=e;return(0,r.jsx)(N,{ref:t,...s,blinking:a,template:i,children:null==l||l?(0,r.jsx)(o.H,{children:n}):n})}),N=(0,u.I4)("div",{position:"relative",borderRadius:(0,p.D)(10),borderWidth:"2px",borderStyle:"solid",variants:{blinking:{true:{animation:"".concat(j," 2s linear infinite")}},color:{white:{backgroundColor:u.w4.colors.gray1,borderColor:u.w4.colors.gray5},blue:{backgroundColor:u.w4.colors.gray1,borderColor:u.w4.colors.blue5},prime:{background:u.w4.colors.primeGradient,borderColor:u.w4.colors.primeBlue}},selected:{true:{},false:{}},template:{default:{},minimal:{}}},compoundVariants:[{color:"white",selected:!0,template:"default",css:{boxShadow:"0px 4px 16px -6px ".concat(u.w4.colors.grayAlpha6)}},{color:"blue",selected:!0,template:"default",css:{boxShadow:"0px 4px 16px -6px ".concat(u.w4.colors.blueAlpha6)}},{color:"white",template:"minimal",selected:!0,css:{boxShadow:"none",border:"none",borderRadius:(0,p.D)(0),marginInline:-10}},{color:"blue",selected:!0,template:"minimal",css:{boxShadow:"none",border:"none",borderRadius:(0,p.D)(0),marginInline:-10}},{color:"white",template:"minimal",selected:!1,css:{boxShadow:"none",border:"none",borderRadius:(0,p.D)(0),marginInline:-10}}]}),S={Animation:m,Container:E,HeaderButton:e=>{let{template:t,...n}=e;return(0,r.jsx)(s.u,{onPress:n.onPress,title:n.title,css:{..."default"===t&&{borderRadius:(0,p.D)(8)},..."minimal"===t&&{paddingInline:(0,p.D)(10)},"&:hover":{backgroundColor:u.w4.colors.blue3},"&:focus-visible":{outlineOffset:"-2px"},...n.css},children:n.children})},Header:x,HeaderIcon:e=>{let{icon:t}=e;return(0,r.jsx)(g,{children:t})},Title:f,Body:b,Actions:C,ActionsSeparator:w}},67449:(e,t,n)=>{"use strict";n.d(t,{Z:()=>g});var r=n(80263),l=n(31740),a=n(60264),o=n(53239),i=n(16679),s=n(70077),c=n(18696),d=n(16755);let u=(0,i.I4)("div",{flex:1,minHeight:0,position:"relative",border:"2px dashed ".concat(i.w4.colors.blue9),borderRadius:(0,s.D)(6),padding:(0,s.D)(16),textAlign:"center",overflow:"hidden",cursor:"pointer",background:"linear-gradient(90deg, #CEDEFE 0%, #F5F8FF 35.66%)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center","&:hover":{borderStyle:"solid"}}),p=(0,i.I4)("div",{position:"absolute",left:0,top:0,bottom:0,width:(0,s.D)(160),pointerEvents:"none",zIndex:0,backgroundImage:'url("https://cdn.paperpal.com/assets/images/library-view/ImportLibrary.webp")',backgroundPosition:"left bottom",backgroundRepeat:"no-repeat",backgroundSize:"auto 100%","@sm":{display:"none"}}),h=(0,i.I4)(c.$,{border:"1px solid transparent",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"8px",backgroundColor:"".concat(i.w4.colors.blue11),color:"".concat(i.w4.colors.white),padding:"8px 16px",fontSize:"14px",fontWeight:500,justifyContent:"center",borderRadius:"12px",width:"143px",height:"41px","&:hover":{backgroundColor:"".concat(i.w4.colors.blue10)}}),m=e=>{let{fileSizeLimit:t,maxFiles:n,fileCount:l,fileInputProps:a={}}=e,i=(0,o.useRef)(null),s=Math.max(n-l,0);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("img",{src:"https://cdn.paperpal.com/assets/images/library-view/CreateCollection.webp",alt:"multi-upload-box",width:213,height:213,loading:"lazy",className:"mx-auto my-[-20px] mix-blend-multiply"}),(0,r.jsx)("input",{...a,ref:i,style:{display:"none"}}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 justify-center",children:[(0,r.jsx)("p",{className:"text-gray-11 dark:text-white font-semibold text-sm",children:"Drag and Drop a file or"}),(0,r.jsxs)(h,{type:"button",disabled:0===s,onClick:()=>{var e;return null==(e=i.current)?void 0:e.click()},children:[(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,r.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Upload"]})]}),(0,r.jsx)("p",{className:"text-xs font-medium text-gray-11 pt-2",children:"Maximum size ".concat(t/1048576," MB")}
1)]})},g=e=>{let{fileConfiguration:t,onFilesAdded:n}=e,{maxFileSize:i,maxFiles:s,supportedTypes:c}=t,{getRootProps:h,getInputProps:g}=(0,l.V)({noClick:!0}),{getInputProps:f}=(0,a.W)({accept:c.join(","),multiple:s>1}),{files:x}=(0,d.v)(),b=Object.keys(x).length,C=(0,o.useRef)(b);return(0,o.useEffect)(()=>{b>C.current&&(null==n||n()),C.current=b},[b,n]),(0,r.jsxs)(u,{...h(),children:[(0,r.jsx)("input",{...g(),style:{display:"none"}}),(0,r.jsx)(p,{}),(0,r.jsx)(m,{fileSizeLimit:i,fileInputProps:f(),maxFiles:s,fileCount:b})]})}},67669:(e,t,n)=>{"use strict";n.d(t,{e:()=>o});var r=n(80263);let l=e=>{let{src:t,alt:n,width:l,height:a,...o}=e;return(0,r.jsx)("img",{src:t,alt:n,style:{width:l,height:a},...o})},a=null;try{a=n(83931).default}catch(e){}let o=e=>a?(0,r.jsx)(a,{...e}):(0,r.jsx)(l,{...e})},68048:(e,t,n)=>{"use strict";n.d(t,{_:()=>v,T:()=>C});var r=n(80263),l=n(93903),a=n(37158),o=n(53239),i=n(67106),s=n(29525),c=n(29404),d=n(90981),u=n(81993),p=n(16679),h=n(70224),m=n(95152);let g=e=>{let{displayConfigParams:t,docType:n,isOpenAccess:l,citationsCountDyson:a,handleFavourite:s,refererenceArticle:g,isFavourite:f,cardType:x,isUploadedByUser:b,isMinimal:C,isRetracted:v,sourceOrigin:y,sjr_best_quartile:w}=e,{sourceField:j,sourceTooltip:I}=(0,o.useMemo)(()=>(0,d.l)(y||g.source),[y,g.source]);return(0,r.jsx)(m.aR,{isMinimal:C&&"full"!==x,children:(n||l||a||v||j||b&&!C||t.favourite&&s)&&(0,r.jsxs)(m.d7,{cardType:x,children:[j&&(0,r.jsx)(c.h,{tipInfo:I,children:(0,r.jsxs)(m.$K,{size:"small",color:"Document Import"===j?"yellow":"Imported"===j?"blue":"green","data-test-id":"citation-source-origin-badge",children:[(0,r.jsx)(i.I,{name:"Document Import"===j?"fileChartColumn":"Imported"===j?"arrowDownBracket":"user",variant:"regular",size:"xs"}),j]})}),b&&!C&&(0,r.jsx)(c.h,{tipInfo:"Uploaded By User",children:(0,r.jsxs)(m.$K,{size:"small",color:"green","data-test-id":"pdf-uploaded-by-user",children:[(0,r.jsx)(i.I,{name:"user",variant:"light",size:"xs"}),(0,r.jsx)(m.AW,{children:"User added PDF"})]})}),v&&(0,r.jsx)(c.h,{tipInfo:"This paper is considered unreliable for citation",children:(0,r.jsxs)(m.$K,{size:"small",color:"red",isMinimal:C,children:[(0,r.jsx)(i.I,{name:"exclamationCircle",variant:"solid",size:"xs"}),"RETRACTED"]})}),n&&(0,r.jsx)(c.h,{tipInfo:"Document type",children:(0,r.jsx)(m.$K,{size:"small",color:"gray",isMinimal:C,children:(0,r.jsx)(m.AW,{children:n})})}),l&&(0,r.jsxs)(m.$K,{size:"small",color:"orange",children:[(0,r.jsx)(h.P,{fontSize:12}),(0,r.jsx)(m.AW,{children:"Open Access"})]}),a&&(0,r.jsx)(c.h,{tipInfo:"Citations",children:(0,r.jsxs)(m.$K,{size:"small",color:"yellow",children:[(0,r.jsx)(i.I,{name:"quoteRight",variant:"solid",size:"xs"}),a]})}),w&&(0,r.jsx)(c.h,{tipInfo:(0,r.jsxs)("div",{style:{fontSize:12},children:["SCImago Journal Rank",(0,r.jsx)("br",{}),(0,r.jsx)("div",{style:{textAlign:"center"},children:(0,r.jsx)("b",{children:(0,u.Q)(w.value)})})]}),children:(0,r.jsx)(m.$K,{size:"small",color:"purple",children:w.value})}),t.favourite&&s&&(0,r.jsx)(c.h,{tipInfo:"Favourite",children:(0,r.jsx)(m.oZ,{css:{color:p.w4.colors.gray11},size:"medium",variant:"link",onClick:e=>{e.stopPropagation(),s(g)},"data-test-id":"favourite-button",children:(0,r.jsx)(i.I,{name:"bookmark",variant:f?"solid":"regular"})})})]})})};var f=n(11918);let x=e=>
1{let{cardType:t,readMoreAction:n,getModifiedActions:l,baseActions:a,overflowActions:o,isMinimal:i=!1,forceInlineFlyout:s}=e;return(0,r.jsxs)(m.vn,{cardType:t,children:[n&&(0,r.jsx)(m.OS,{onClick:n.onClick,"data-test-id":"read-more",children:"loading"===n.actionState?n.loadingComponent||"Redirecting...":n.label}),(0,r.jsx)(f.M,{actions:l?l(a):a,defaultOverflowActions:l?l(o):o,isMinimal:i,forceInlineFlyout:s})]})},b={default:{abstract:!1,referenceNo:!1,copyDOI:!1,favourite:!1},library:{abstract:!1,referenceNo:!0,copyDOI:!1,favourite:!0},"reference-paper":{abstract:!1,referenceNo:!0,copyDOI:!1,favourite:!1},"related-paper":{abstract:!1,referenceNo:!0,copyDOI:!1,favourite:!1},full:{abstract:!0,referenceNo:!1,copyDOI:!0,favourite:!1}},C=(0,o.forwardRef)((e,t)=>{let{index:n,refererenceArticle:d,baseActions:u,overflowActions:p,readMoreAction:h,togglePreviewPaper:f,cardType:C="default",handleCopyDOI:v,handleFavourite:y,handleScroll:w,scrollToBottom:j,showScrollIndicator:I,getModifiedActions:k,displayConfig:E={},toggleScrollIndicator:N,isMinimal:S=!1,onMinimalCardClick:T,cslJsonResponse:A,forceInlineFlyout:R}=e,{key:M,docType:L,isRetracted:D,isOpenAccess:_,citationsCountDyson:H,title:P,authors:O,publicationDate:z,journalName:B,abstractText:F,doi:V,isFavourite:U,isUploadedByUser:W,sourceDocId:G,sourceOrigin:Z,date:q,publicationTitle:$,sjr_best_quartile:K}=d,Y=(0,o.useMemo)(()=>({...b[C],...E}),[C,E]),X=(0,o.useMemo)(()=>{let e=O;return A&&(e=(0,l.Y)(A)),(null==e?void 0:e.length)&&(null==e?void 0:e.length)>2?null==e?void 0:e.map(e=>e.full_name).join(", "):void 0},[O,A]),J=(0,o.useMemo)(()=>{let e=O;if(A&&(e=(0,l.Y)(A)),!(null==e?void 0:e.length))return(0,r.jsx)("span",{className:"italic",children:"Author data not available"});if("full"===C)return(0,r.jsx)(r.Fragment,{children:null==e?void 0:e.map(e=>e.full_name).join(", ")});{let t=e.slice(0,2),n=e.length-t.length;return(0,r.jsxs)(r.Fragment,{children:[t.map((e,n)=>(0,r.jsxs)("span",{children:[e.full_name,n<t.length-1?", ":""]},n)),n>0&&(0,r.jsx)(c.h,{tipInfo:(0,r.jsx)(m.Yv,{children:X}),children:(0,r.jsxs)(s.OH,{children:[" +",n]})})]})}},[O,C,A,X]);return(0,o.useEffect)(()=>{Y.abstract&&(null==N||N())},[Y.abstract]),(0,r.jsxs)(m.U7,{"data-id":M||"paper_".concat(G),cardType:C,onClick:e=>{e.preventDefault(),null==f||f(d)},isMinimal:S,"data-insertion-type":"ai-generated","data-feature-name":"Research","data-req-id":G,children:[(0,r.jsxs)(m.NQ,{cardType:C,ref:t,onScroll:w,"data-id":M,isMinimal:S,children:[(0,r.jsx)(g,{index:n,displayConfigParams:Y,docType:L,isOpenAccess:_,citationsCountDyson:H,handleFavourite:y,isFavourite:U,isUploadedByUser:W,refererenceArticle:d,cardType:C,isMinimal:S,isRetracted:D,sourceOrigin:Z,sjr_best_quartile:K}),(0,r.jsxs)(m.hE,{"aria-label":"title",children:["".concat(P," "),(null==d?void 0:d.newTag)&&(0,r.jsx)(m.$K,{size:"small",color:"green",isMinimal:S,children:"New"}),S&&"full"!==C&&(0,r.jsx)(m.Nc,{onClick:T,id:"read-abstract",ariaLabel:"read-abstract",children:"Read Abstract"})]}),(0,r.jsxs)(m.X6,{children:[(0,r.jsx)(m.hh,{children:(0,r.jsx)(i.I,{name:"user",variant:"regular"})}),J]}),(z||B||$||q)&&(0,r.jsxs)(m.X6,{children:[(z||q)&&(0,r.jsxs)(m.cl,{children:[(0,r.jsx)(m.hh,{children:(0,r.jsx)(i.I,{name:"Calendar",variant:"regular"})}),(0,a.eN)(null!=z?z:q)]}),(B||$)&&(0,r.jsxs)(m.r6,{children:[(0,r.jsx)(m.r2,{children:(0,r.jsx)(m.cL,{})}),null!=B?B:$]})]}),Y.copyDOI&&v&&V&&(0,r.jsx)(m.eq,{onClick:e=>{e.stopPropagation(),v(V)},"data-test-id":"copy-doi",children:"Copy DOI"}),Y.abstract&&F&&(0,r.jsxs)(m.Gp,{children:[(0,r.jsx)(m.ln,{children:"Abstract"}),(0,r.jsx)(m.CO,{children:F})]}),(0,r.jsx)(m.ie,{visible:I,onClick:e=>{e.preventDefault(),e.stopPropagation(),null==j||j()},"data-test-id":"scroll-floating-arrow",children:(0,r.jsx)(i.I,{name:"ArrowDown",variant:"regular",size:"xs"})})]}),(0,r.jsx)(x,{cardType:C,readMoreAction:"USER_ADDED"===Z||"DOCUMENT_IMPORT"===d.source?void 0:h,getModifiedActions:k,baseActions:u,overflowActions:p,isMinimal:S,forceInlineFlyout:R})]},M||"paper_".concat(G))}),v=(0,o.memo)(C)},68162:(e,t,n)=>{"use strict";n.d(t,{c:()=>c,b:()=>d});var r=n(80263),l=n(81761),a=function(e){return e.REFERENCES="references",e.PAPERPAL_DOCS="paperpalDocs",e.UPLOADS="uploads",e.FOLDER="folder",e}({});let o=(e,t)=>{var n,r,a;if(!(null!=(a=null!=(r=null==t?void 0:t.locked)?r:e.locked)&&a))return"folder";switch(null==(n=e.name)?void 0:n.trim().toLowerCase()){case l.Oh.REFERENCES:return"references";case l.Oh.PAPERPAL_DOCUMENTS:return"paperpalDocs";case l.Oh.UPLOADS:return"uploads";default:return"folder"}};var i=n(67106);n(53239);let s=e=>(0,r.jsx)("svg",{width:e.width||"21",height:e.height||"16",viewBox:"0 0 21 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",color:"currentcolor",...e,children:(0,r.jsx)("path",{d:"M2.44875 13.8L4.32375 7.8H18.5512L16.6762 13.8H2.44875ZM9.6 15.6H16.68C17.4675 15.6 18.165 15.09 18.3975 14.3362L20.2725 8.33625C20.6362 7.1775 19.77 6 18.555 6H4.3275C3.54 6 2.8425 6.51 2.61 7.26375L1.8 9.84V2.4C1.8 2.07 2.07 1.8 2.4 1.8H7.60125C7.7325 1.8 7.85625 1.84125 7.96125 1.92L9.40125 3C9.91875 3.39 10.5525 3.6 11.2012 3.6H15.6C15.93 3.6 16.2 3.87 16.2 4.2H18C18 2.87625 16.9237 1.8 15.6 1.8H11.2012C10.9425 1.8 10.6875 1.7175 10.4812 1.56L9.04125 0.48C8.625 0.16875 8.1225 0 7.60125 0H2.4C1.07625 0 0 1.07625 0 2.4V13.2C0 14.5237 1.07625 15.6 2.4 15.6H9.6Z",fill:e.color||"#5D6A81"})}),c=e=>{let{collection:t,folderWidth:n,folderHeight:l}=e;switch(o(t)){case a.REFERENCES:return(0,r.jsx)(i.I,{name:"IconReference",variant:"regular"});case a.PAPERPAL_DOCS:return(0,r.jsx)(i.I,{name:"paperpalDocs",variant:"regular"});case a.UPLOADS:return(0,r.jsx)(i.I,{name:"paperclipVertical",variant:"regular"});case a.FOLDER:return(0,r.jsx)(s,{width:n,height:l})}},d=e=>{var t;return!!e.locked&&(null==(t=e.name)?void 0:t.trim().toLowerCase())===l.Oh.PAPERPAL_DOCUMENTS}},70224:(e,t,n)=>{"use strict";n.d(t,{P:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"7",height:"12",viewBox:"0 0 7 12",fill:"none",...e,children:[(0,r.jsx)("path",{d:"M3.6499 9.014C4.17004 9.014 4.59164 8.57898 4.59164 8.04242C4.59164 7.50554 4.17004 7.07047 3.6499 7.07047C3.12981 7.07047 2.70821 7.50554 2.70821 8.04242C2.70821 8.57898 3.12981 9.014 3.6499 9.014Z",fill:"#BB570F"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.795023 3.84284V3.44114C0.795023 1.81943 2.07383 0.5 3.64542 0.5C5.21705 0.5 6.49576 1.81943 6.49576 3.44114V6.2065C6.81531 6.73703 6.99999 7.36264 6.99999 8.03192C6.99999 9.94404 5.49217 11.5 3.63893 11.5C1.78573 11.5 0.277771 9.94408 0.277771 8.03192C0.277771 6.11958 1.78573 4.56376 3.63893 4.56376C4.26507 4.56376 4.85177 4.74135 5.35422 5.0503V3.44114C5.35422 2.46883 4.58759 1.67784 3.64542 1.67784C2.70319 1.67784 1.93652 2.46883 1.93652 3.44114V3.84284H0.795023ZM3.63897 5.74164C2.41505 5.74164 1.41926 6.76903 1.41926 8.03192C1.41926 9.29468 2.41505 10.3223 3.63897 10.3223C4.8628 10.3223 5.85846 9.29472 5.85846 8.03192C5.85846 6.76903 4.8628 5.74164 3.63897 5.74164Z",fill:"#BB570F"})]})},71382:(e,t,n)=>{"use strict";n.d(t,{G:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"30",height:"30",fill:"none",viewBox:"0 0 30 30",...e,children:[(0,r.jsxs)("g",{clipPath:"url(#clip0_3365_2825)",children:[(0,r.jsx)("path",{fill:"url(#paint0_linear_3365_2825)",d:"M27.076 22.329q-.6.313-1.235.552c-1.345.503-2.77.76-4.207.757-5.545 0-10.376-3.815-10.376-8.71a3.69 3.69 0 0 1 1.926-3.2c-5.016.211-6.305 5.438-6.305 8.5 0 8.657 7.98 9.535 9.698 9.535.927 0 2.325-.27 3.164-.534l.154-.052A15.04 15.04 0 0 0 27.7 22.99a.468.468 0 0 0-.624-.661"}),(0,r.jsx)("path",{fill:"url(#paint1_radial_3365_2825)",d:"M27.076 22.329q-.6.313-1.235.552c-1.345.503-2.77.76-4.207.757-5.545 0-10.376-3.815-10.376-8.71a3.69 3.69 0 0 1 1.926-3.2c-5.016.211-6.305 5.438-6.305 8.5 0 8.657 7.98 9.535 9.698 9.535.927 0 2.325-.27 3.164-.534l.154-.052A15.04 15.04 0 0 0 27.7 22.99a.468.468 0 0 0-.624-.661",opacity:"0.35"}),(0,r.jsx)("path",{fill:"url(#paint2_linear_3365_2825)",d:"M12.388 28.292a9.3 9.3 0 0 1-2.665-2.501 9.46 9.46 0 0 1 3.46-14.063c.366-.
1172.99-.484 1.822-.468a3.79 3.79 0 0 1 3.01 1.523c.473.632.734 1.397.745 2.187 0-.025 2.867-9.328-9.375-9.328-5.144 0-9.375 4.882-9.375 9.165a15.25 15.25 0 0 0 1.42 6.562 15 15 0 0 0 18.325 7.865 8.85 8.85 0 0 1-7.357-.938z"}),(0,r.jsx)("path",{fill:"url(#paint3_radial_3365_2825)",d:"M12.388 28.292a9.3 9.3 0 0 1-2.665-2.501 9.46 9.46 0 0 1 3.46-14.063c.366-.172.99-.484 1.822-.468a3.79 3.79 0 0 1 3.01 1.523c.473.632.734 1.397.745 2.187 0-.025 2.867-9.328-9.375-9.328-5.144 0-9.375 4.882-9.375 9.165a15.25 15.25 0 0 0 1.42 6.562 15 15 0 0 0 18.325 7.865 8.85 8.85 0 0 1-7.357-.938z",opacity:"0.41"}),(0,r.jsx)("path",{fill:"url(#paint4_radial_3365_2825)",d:"M17.849 17.445c-.095.123-.387.293-.387.663 0 .306.2.6.553.847 1.685 1.172 4.862 1.017 4.87 1.017a7 7 0 0 0 3.548-.978 7.19 7.19 0 0 0 3.566-6.197c.03-2.626-.938-4.372-1.33-5.146C26.188 2.794 20.827 0 14.999 0a15 15 0 0 0-15 14.79c.056-4.283 4.312-7.741 9.375-7.741.41 0 2.749.04 4.921 1.18 1.915 1.005 2.918 2.22 3.616 3.423.724 1.25.853 2.83.853 3.46s-.321 1.561-.914 2.333"}),(0,r.jsx)("path",{fill:"url(#paint5_radial_3365_2825)",d:"M17.849 17.445c-.095.123-.387.293-.387.663 0 .306.2.6.553.847 1.685 1.172 4.862 1.017 4.87 1.017a7 7 0 0 0 3.548-.978 7.19 7.19 0 0 0 3.566-6.197c.03-2.626-.938-4.372-1.33-5.146C26.188 2.794 20.827 0 14.999 0a15 15 0 0 0-15 14.79c.056-4.283 4.312-7.741 9.375-7.741.41 0 2.749.04 4.921 1.18 1.915 1.005 2.918 2.22 3.616 3.423.724 1.25.853 2.83.853 3.46s-.321 1.561-.914 2.333"})]}),(0,r.jsxs)("defs",{children:[(0,r.jsxs)("radialGradient",{id:"paint1_radial_3365_2825",cx:"0",cy:"0",r:"1",gradientTransform:"matrix(11.1773 0 0 10.6185 18.422 20.913)",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.72",stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"0.95",stopOpacity:"0.53"}),(0,r.jsx)("stop",{offset:"1"})]}),(0,r.jsxs)("radialGradient",{id:"paint3_radial_3365_2825",cx:"0",cy:"0",r:"1",gradientTransform:"matrix(2.51789 -16.6181 -13.4288 -2.01431 8.27 23.322)",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.76",stopOpacity:"0"}),(0,r.jsx)("stop",{offset:"0.95",stopOpacity:"0.5"}),(0,r.jsx)("stop",{offset:"1"})]}),(0,r.jsxs)("radialGradient",{id:"paint4_radial_3365_2825",cx:"0",cy:"0",r:"1",gradientTransform:"matrix(-.9489 23.7223 50.5284 1.89778 3.028 5.552)",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#35C1F1"}),(0,r.jsx)("stop",{offset:"0.11",stopColor:"#34C1ED"}),(0,r.jsx)("stop",{offset:"0.23",stopColor:"#2FC2DF"}),(0,r.jsx)("stop",{offset:"0.31",stopColor:"#2BC3D2"}),(0,r.jsx)("stop",{offset:"0.67",stopColor:"#36C752"})]}),(0,r.jsxs)("radialGradient",{id:"paint5_radial_3365_2825",cx:"0",cy:"0",r:"1",gradientTransform:"matrix(3.19397 10.9508 8.89748 -2.62362 28.131 9.071)",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#66EB6E"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#66EB6E",stopOpacity:"0"})]}),(0,r.jsxs)("linearGradient",{id:"paint0_linear_3365_2825",x1:"6.879",x2:"27.778",y1:"20.748",y2:"20.748",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#0C59A4"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#114A8B"})]}),(0,r.jsxs)("linearGradient",{id:"paint2_linear_3365_2825",x1:"17.897",x2:"4.843",y1:"11.683",y2:"25.901",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#1B9DE2"}),(0,r.jsx)("stop",{offset:"0.16",stopColor:"#1595DF"}),(0,r.jsx)("stop",{offset:"0.67",stopColor:"#0680D7"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#0078D4"})]}),(0,r.jsx)("clipPath",{id:"clip0_3365_2825",children:(0,r.jsx)("path",{fill:"#fff",d:"M0 0h30v30H0z"})})]})]})},72140:(e,t,n)=>{"use strict";n.d(t,{u:()=>s});var r=n(80263),l=n(53239),a=n(85346),o=n(16679),i=n(87987);let s=e=>{let{children:t,disabled:n,onPress:o,title:i,css:s}=e,d=(0,l.useRef)(null),{buttonProps:u}=(0,a.s)({onPress:o,elementType:"div",isDisabled:n},d);return(0,r.jsx)("div",{...u,title:i,className:c({css:s}),ref:d,children:t})},c=(0,o.AH)(i.d)},72984:(e,t,n)=>{"use strict";n.d(t,{G:()=>m,JL:()=>o});var r=n(11445);let l={csl:{types:{article:["preprint"],"article-journal":["journalArticle"],"article-magazine":["magazineArticle"],"article-newspaper":["newspaperArticle"],bill:["bill"],book:["book"],broadcast:["podcast","tvBroadcast","radioBroadcast"],chapter:["bookSection"],dataset:["dataset"],document:["document","attachment","note"],"entry-dictionary":["dictionaryEntry"],"entry-encyclopedia":["encyclopediaArticle"],graphic:["artwork"],hearing:["hearing"],interview:["interview"],legal_case:["case"],legislation:["statute"],manuscript:["manuscript"],map:["map"],motion_picture:["film","videoRecording"],other:["other"],"paper-conference":["conferencePaper"],patent:["patent"],personal_communication:["letter","email","instantMessage"],post:["forumPost"],"post-weblog":["blogPost"],report:["report"],software:["computerProgram"],song:["audioRecording"],speech:["presentation"],standard:["standard"],thesis:["thesis"],webpage:["webpage"]},fields:{text:{abstract:["abstractNote"],archive:["archive"],archive_location:["archiveLocation"],authority:["authority"],"call-number":["callNumber","applicationNumber"],"chapter-number":["session"],"citation-key":["citationKey"],"collection-number":["seriesNumber"],"collection-title":["seriesTitle","series"],"container-title":["publicationTitle","reporter","code"],dimensions:["artworkSize","runningTime"],DOI:["DOI"],edition:["edition"],"event-place":["eventPlace"],"event-title":["meetingName","conferenceName"],genre:["type","programmingLanguage"],ISBN:["ISBN"],ISSN:["ISSN"],issue:["issue","priorityNumbers"],journalAbbreviation:["journalAbbreviation"],language:["language"],license:["rights"],medium:["medium","system"],note:["extra"],number:["number"],"number-of-pages":["numPages"],"number-of-volumes":["numberOfVolumes"],"original-publisher":["originalPublisher"],"original-publisher-place":["originalPlace"],"part-number":["partNumber"],"part-title":["partTitle"],page:["pages"],PMID:["PMID"],PMCID:["PMCID"],publisher:["publisher"],"publisher-place":["place"],references:["history","references"],scale:["scale"],section:["section","committee"],shortTitle:["shortTitle"],source:["libraryCatalog"],status:["status"],title:["title"],"title-short":["shortTitle"],URL:["url"],version:["versionNumber"],volume:["volume","codeNumber"]},date:{accessed:"accessDate",issued:"date",submitted:"filingDate","original-date":"originalDate"}},names:{author:"author",bookAuthor:"container-author",chair:"chair",castMember:"performer",composer:"composer",contributor:"contributor",creator:"author",director:"director",editor:"editor",executiveProducer:"executive-producer",guest:"guest",host:"host",interviewer:"interviewer",narrator:"narrator",originalCreator:"original-author",organizer:"organizer",podcaster:"host",producer:"producer",recipient:"recipient",reviewedAuthor:"reviewed-author",seriesCreator:"series-creator",seriesEditor:"collection-editor",scriptwriter:"script-writer",translator:"translator",cosponsor:"cosponsor"}}},a=r.z.object({family:r.z.string().optional(),given:r.z.string().optional(),literal:r.z.string().optional()}),o=Object.freeze(Array.from(new Set(Object.values(l.csl.names)))),i=r.z.object(Object.fromEntries(o.map(e=>[e,r.z.array(a).optional()]))),s=Object.freeze(Object.keys(l.csl.types));r.z.enum(s);let c=Object.freeze(Object.keys(l.csl.fields.date)),d=r.z.object({"date-parts":r.z.array(r.z.array(r.z.string())).optional(),literal:r.z.string().optional()}),u=r.z.object(Object.fromEntries(c.map(e=>[e,d.optional()]))),p=Object.freeze(Object.keys(l.csl.fields.text)),h=r.z.object(Object.fromEntries(p.map(e=>[e,r.z.string().optional()]))),m=r.z.object({id:r.z.string(),dyson_id:r.z.string(),itemType:r.z.string().optional(),abstract:r.z.string().optional(),abstractNote:r.z.string().optional(),type:r.z.string().optional(),source_origin:r.z.string().optional(),publisher:r.z.string().optional(),retracted:r.z.boolean().optional(),"short-container-title":r.z.array(r.z.string()).optional(),"container-title-short":r.z.string().optional(),creators:r.z.array(r.z.object({creatorType:r.z.string().optional(),firstName:r.z.string().optional(),lastName:r.z.string().optional()})).optional()}).extend(i.shape).extend(u.shape).extend(h.shape)},73010:()=>{},73171:()=>{},74067:()=>{},74425:(e,t,n)=>{"use strict";n.d(t,{f:()=>p});var r=n(80263),l=n(53239),a=n(29525),o=n(16679),i=n(69492),s=n(91921),c=n(92261),d=n(52602),u=n(66008);let p=l.forwardRef((e,t)=>
1{let{label:n,error:l,css:a,infoTextColor:o,...i}=e;return(0,r.jsxs)(d.az,{css:{display:"flex",flexDirection:"column"},children:[n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c.l,{disabled:i.disabled,htmlFor:i.id||i.name,style:i.labelStyle,children:n}),(0,r.jsx)(u.h,{height:8})]}):null,(0,r.jsx)(h,{id:i.name,defaultValue:i.defaultValue,...i,state:l?"error":"default",ref:t}),l?(0,r.jsx)(s.d,{error:l}):(0,r.jsx)(m,{size:"tiny",style:{color:o},children:i.info})]})}),h=(0,o.I4)("textarea",i.cO),m=(0,o.I4)(a.P,{fontSize:"14px",fontWeight:500,lineHeight:"18px"})},76487:()=>{},76705:()=>{},78401:()=>{},79918:(e,t,n)=>{"use strict";n.d(t,{I:()=>k});var r=n(80263),l=n(9283),a=n(53239),o=n(37034);let i=[{value:"PAPERPAL_DOCUMENT",label:"Paperpal Document"},{value:"CITATION",label:"References"},{value:"CITATION_WITH_ATTACHMENT",label:"References with Attachment"}],s=new Date().getFullYear(),c=[{value:"TODAY",label:"Today"},{value:"LAST_7_DAYS",label:"Last 7 Days"},{value:"LAST_30_DAYS",label:"Last 30 Days"},{value:"THIS_YEAR",label:"This Year (".concat(s,")")},{value:"CUSTOM_DATE_RANGE",label:"Custom Year Range"}];function d(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}let u=new Date().getFullYear(),p="CUSTOM_DATE_RANGE";function h(e){if(!/^\d{4}$/.test(e))return!1;let t=Number(e);return t>=1900&&t<=u}function m(e){return e.replace(/\D/g,"").slice(0,4)}function g(e){var t,n,l;let{localDates:o,setLocalDates:i,onDateInvalidChange:s}=e,d=null!=(t=o[0])?t:"",g=d===p,f=null!=(n=o[1])?n:"",x=null!=(l=o[2])?l:"",b=g&&(""===f||""!==f&&!h(f)),C=g&&(""===x||""!==x&&!h(x)),v=g&&4===f.length&&4===x.length&&h(f)&&h(x)&&Number(f)>Number(x),y=b||C||v;return(0,a.useEffect)(()=>{null==s||s(y)},[y,s]),(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3",children:"Date"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-3",children:c.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 pr-2 cursor-pointer group",children:[(0,r.jsx)("input",{type:"radio",name:"filter-date",value:e.value,checked:d===e.value,onChange:()=>{var t;(t=e.value)===p?i([p,"",""]):i([t])},className:"w-4 h-4 border-gray-300 text-blue-600 focus:ring-blue-500 cursor-pointer"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 group-hover:text-gray-900 whitespace-nowrap",children:e.label})]},e.value))}),g&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-3",onPointerDown:e=>e.stopPropagation(),children:[(0,r.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:4,placeholder:"1900",value:f,onChange:e=>{i([p,m(e.target.value),x])},className:"w-24 rounded-md border px-2 py-1 text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:ring-1 ".concat(b&&""!==f?"border-red-500 focus:ring-red-500":"border-grey-11 focus:ring-blue-500")}),(0,r.jsx)("span",{className:"text-sm text-gray-500",children:"to"}),(0,r.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:4,placeholder:String(u),value:x,onChange:e=>{i([p,f,m(e.target.value)])},className:"w-24 rounded-md border px-2 py-1 text-sm text-gray-700 placeholder-gray-400 focus:outline-none focus:ring-1 ".concat(C&&""!==x?"border-red-500 focus:ring-red-500":"border-grey-8 focus:ring-blue-500")})]}),y&&(0,r.jsx)("p",{className:"text-xs text-red-600 mt-1",children:""===f||""===x?"Please enter both years for custom date range":v?"From year must be less than or equal to To year":"Please enter valid years between ".concat(1900," and ").concat(u)})]})}var f=n(67106);function x(e){let{coloredLabels:t,localLabels:n,setLocalLabels:l}=e;if(0===t.length)return null;let a=[...t].sort((e,t)=>!n.includes(e.id)-!n.includes(t.id));return(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3",children:"Labels"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>{let t=n.includes(e.id);return(0,r.jsxs)("button",{type:"button",onClick:()=>l(d(n,e.id)),className:"flex items-center gap-1 px-3 py-1 rounded-md text-sm font-medium text-white border-0 cursor-pointer ".concat(t?"ring-2 ring-offset-1":""),style:{backgroundColor:e.color},children:[e.name,t&&(0,r.jsx)(f.I,{name:"check",size:"xs",variant:"regular"})]},e.id)})})]})}function b(e){let{label:t,checked:n,onChange:l}=e;return(0,r.jsxs)("label",{className:"flex items-center gap-2 pr-2 cursor-pointer group",children:[(0,r.jsx)("input",{type:"checkbox",checked:n,onChange:l,className:"w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500 cursor-pointer"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 group-hover:text-gray-900 whitespace-nowrap",children:t})]})}function C(e){let{localTypes:t,setLocalTypes:n,excludeTypes:l=[],typeOptions:a=i}=e,o=l.length?a.filter(e=>!l.includes(e.value)):a;return 0===o.length?null:(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3",children:"Type"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-3",children:o.map(e=>(0,r.jsx)(b,{label:e.label,checked:t.includes(e.value),onChange:()=>n(d(t,e.value))},e.value))})]})}
1function v(e){let{coloredLabels:t,localTypes:n,localDates:l,localLabels:a,setLocalTypes:o,setLocalDates:i,setLocalLabels:s,excludeTypes:c,typeOptions:d,onDateInvalidChange:u}=e;return(0,r.jsxs)("div",{className:"overflow-y-auto flex-1 px-3 sm:px-6 pb-4 min-h-0",children:[(0,r.jsx)(C,{localTypes:n,setLocalTypes:o,excludeTypes:c,typeOptions:d}),(0,r.jsx)(x,{coloredLabels:t,localLabels:a,setLocalLabels:s}),(0,r.jsx)(g,{localDates:l,setLocalDates:i,onDateInvalidChange:u})]})}var y=n(33346);function w(e){let{localTotalSelected:t,onReset:n,onApply:l,disabled:a=!1}=e;return(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 sm:gap-4 px-3 sm:px-6 py-3 sm:py-4 border-t border-gray-200 flex-shrink-0",children:[(0,r.jsx)(y.$,{id:"filter-reset-button",variant:"secondary",size:"sm",onClick:n,className:"px-2 py-1 text-xs sm:px-4 sm:py-2 sm:text-sm border-none",children:"Reset All"}),(0,r.jsxs)(y.$,{id:"filter-apply-button",variant:"primary",size:"sm",onClick:l,disabled:a,className:"px-2 py-1 text-xs sm:px-4 sm:py-2 sm:text-sm border-none",children:["Apply Filters",t>0?" (".concat(t,")"):""]})]})}function j(e){let{localTotalSelected:t,onClose:n,hideText:l=!1}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-6 pt-3 pb-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"Filters"}),t>0&&(0,r.jsx)("span",{className:"inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white rounded-full",style:{backgroundColor:"var(--colors-red9, #e5484d)"},children:t})]}),(0,r.jsx)(y.$,{type:"button",onClick:n,className:"p-1 rounded hover:bg-gray-100 text-gray-500 border-0 bg-transparent cursor-pointer","aria-label":"Close filters",id:"close-filter",children:(0,r.jsx)(f.I,{name:"x",size:"sm",variant:"regular"})})]}),!l&&(0,r.jsx)("p",{className:"px-6 pb-4 text-sm text-gray-500",children:"You can filter your Library by Type, Date, or Labels"})]})}let I=a.forwardRef((e,t)=>{let{activeCount:n,iconOnly:l,triggerWidth:a,triggerHeight:o,triggerFontSize:i,...s}=e;return(0,r.jsxs)(y.$,{ref:t,variant:"filterTrigger",className:"relative flex items-center gap-1 font-medium rounded-[6px] cursor-pointer shadow-none transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:pointer-events-none ".concat(l?"justify-center px-1.5":"justify-center p-2.5"),size:l?"icon":"md",style:{width:a,height:o,fontSize:i},id:"filter-button",...s,children:[!l&&(0,r.jsx)("span",{className:"hidden sm:inline text-gray-11",style:{fontFamily:"IBM Plex Sans, sans-serif",fontWeight:500,fontSize:"14px",lineHeight:"100%",letterSpacing:"0px"},children:"Filters"}),n>0&&(0,r.jsx)("span",{className:"absolute -top-1.5 -right-1.5 inline-flex items-center justify-center min-w-[16px] h-4 px-1 text-[10px] leading-none font-semibold text-white bg-red-9 rounded-full ring-2 ring-white z-10 pointer-events-none",children:n}),(0,r.jsx)("span",{className:"flex h-4 w-4 flex-shrink-0 items-center justify-center text-gray-12",children:(0,r.jsx)(f.I,{name:"barsFilter",variant:"regular",width:16,height:16})})]})});function k(e){let{activeTypes:t,activeDates:n,activeLabels:i,coloredLabels:s,onApply:c,onReset:d,disabled:u,excludeTypes:p,typeOptions:h,isMobileWeb:m,iconOnly:g,triggerWidth:f,triggerHeight:x,triggerFontSize:b,hideHeaderText:C,portalContainer:y}=e,[k,E]=(0,a.useState)(!1),[N,S]=(0,a.useState)([]),[T,A]=(0,a.useState)([]),[R,M]=(0,a.useState)([]),[L,D]=(0,a.useState)(!1);(0,a.useEffect)(()=>{k&&(S([...t]),A([...n]),M([...i]))},[k]);let _=+(n.length>0),H=t.length+_+i.length,P=+(T.length>0),O=N.length+P+R.length,z=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(j,{localTotalSelected:O,onClose:()=>E(!1),hideText:C}
1),(0,r.jsx)(v,{coloredLabels:s,localTypes:N,localDates:T,localLabels:R,setLocalTypes:S,setLocalDates:A,setLocalLabels:M,excludeTypes:p,typeOptions:h,onDateInvalidChange:D}),(0,r.jsx)(w,{localTotalSelected:O,onReset:function(){S([]),A([]),M([]),d(),E(!1)},onApply:function(){c(N,T,R),E(!1)},disabled:L})]});return m?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{activeCount:H,disabled:u,onClick:()=>!u&&E(!0),iconOnly:g,triggerWidth:f,triggerHeight:x,triggerFontSize:b}),k&&(0,o.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-50 bg-black/40 pointer-events-auto",onClick:()=>E(!1),children:(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-white rounded-t-2xl flex flex-col max-h-[80vh]",onClick:e=>e.stopPropagation(),children:z})}),document.body)]}):(0,r.jsxs)(l.bL,{open:k,onOpenChange:u?void 0:E,children:[(0,r.jsx)(l.l9,{asChild:!0,children:(0,r.jsx)(I,{activeCount:H,disabled:u,iconOnly:g,triggerWidth:f,triggerHeight:x,triggerFontSize:b})}),(0,r.jsx)(l.ZL,{container:null!=y?y:void 0,children:(0,r.jsx)(l.UC,{align:"end",sideOffset:4,collisionPadding:12,className:"z-50 w-[420px] max-w-[calc(100vw-24px)] bg-white rounded-lg border border-gray-200 shadow-lg flex flex-col",children:z})})]})}I.displayName="FilterTrigger"},80033:()=>{},80839:()=>{},81761:(e,t,n)=>{"use strict";let r;n.d(t,{E_:()=>i,Oh:()=>o,Rc:()=>s,dc:()=>d,ek:()=>h});var l=n(11445);let a=l.z.lazy(()=>l.z.object({id:l.z.number(),name:l.z.string(),libraryId:l.z.number(),parentId:l.z.number().nullable().optional(),itemCount:l.z.number(),locked:l.z.boolean().optional(),externalId:l.z.string().nullable().optional(),failedImportCount:l.z.number().optional(),children:l.z.array(a).optional().default([])}));var o=function(e){return e.REFERENCES="references",e.PAPERPAL_DOCUMENTS="paperpal documents",e.UPLOADS="uploads",e}({});let i=l.z.object({success:l.z.boolean(),data:l.z.array(a).default([])}),s=l.z.object({success:l.z.boolean(),data:a}),c=l.z.object({name:l.z.string(),color:l.z.string(),id:l.z.number()});l.z.object({success:l.z.boolean(),data:l.z.array(c).default([])}),l.z.object({id:l.z.number(),parentItemId:l.z.number().nullable(),title:l.z.string(),contentType:l.z.string().optional(),filename:l.z.string().optional(),url:l.z.string().optional(),size:l.z.number().optional(),uploadId:l.z.string().optional(),userCitationId:l.z.number().optional(),dateAdded:l.z.string(),dateModified:l.z.string()}),l.z.custom();let d=l.z.object({success:l.z.boolean(),data:(r=l.z.custom(),l.z.object({content:l.z.array(r),page:l.z.number(),size:l.z.number(),totalElements:l.z.number(),totalPages:l.z.number(),last:l.z.boolean()}))}),u=l.z.object({isPrimeUser:l.z.boolean(),fileUploadCap:l.z.number(),dailyFileUploadCap:l.z.number(),monthlyFileUploadCap:l.z.number(),monthlyFileUploadBalance:l.z.number(),pageLimitPerFile:l.z.number(),fileSizeLimit:l.z.number(),aiWordsLimit:l.z.number(),aiWordsUsed:l.z.number(),aiWordsCap:l.z.string(),aiWordsProcessed:l.z.string(),isFirstTimeChatPdfUser:l.z.boolean()});l.z.object({maxItems:l.z.number().optional(),maxCollections:l.z.number().optional(),maxStorageMb:l.z.number().optional(),allowedItemTypes:l.z.array(l.z.string()).optional(),featureFlags:l.z.record(l.z.boolean()).optional()});let p=l.z.object({libraryId:l.z.number(),libraryName:l.z.string().optional(),chatConfig:u}),h=l.z.object({success:l.z.boolean(),data:p})},81993:(e,t,n)=>{"use strict";n.d(t,{Q:()=>r});let r=e=>{switch(e){case"Q1":return"Top 25%";case"Q2":return"Top 25–50%";case"Q3":return"Top 50–75%";case"Q4":return"Bottom 25%";default:return""}}},82006:(e,t,n)=>{"use strict";n.d(t,{KY:()=>c,T8:()=>l,n1:()=>o});var r=n(11445);let l=r.z.enum(["DOCUMENT_TOO_LONG","DOCUMENT_TOO_SHORT","UPLOAD_TOO_LARGE","LANGUAGE_NOT_SUPPORTED","NOT_ENOUGH_ENGLISH_SENTENCES_FOUND","PLAGIARISM_FILE_SIZE_NOT_SUPPORTED","PLAGIARISM_PROCESSING_ERROR","PLAGIARISM_UNSUPPORTED_FILE_FORMAT","PLAGIARISM_BAD_REQUEST","NOT_YOUR_DOCUMENT","PAYMENT_REQUIRED","PLAGIARISM_REMAINING_QUOTA_INSUFFICIENT","PLAGIARISM_TIME_OUT","PLAGIARISM_DOCUMENT_EXCEEDS_QUOTA","PLAGIARISM_DOCUMENT_TOO_SMALL","PLAGIARISM_MONTHLY_QUOTA_LAPSED","PLAGIARISM_EULA_NOT_ACCEPTED","FREE_PLAGIARISM_MONTHLY_QUOTA_LAPSED","FREE_PLAGIARISM_REMAINING_QUOTA_INSUFFICIENT","FREE_PLAGIARISM_DOCUMENT_EXCEEDS_QUOTA"]),a=r.z.enum(["AI_DETECTION_SUBMIT_FAILED","AI_DETECTION_PROCESSING_FAILED","AI_DETECTION_NO_TEXT_TO_PROCESS","AI_DETECTION_FREE_QUOTA_EXHAUSTED","AI_DETECTION_PAID_QUOTA_EXHAUSTED","DOCUMENT_EXCEEDS_WORD_COUNT_LIMIT","FREE_AI_DETECTION_DOCUMENT_EXCEEDS_QUOTA","PRIME_AI_DETECTION_DOCUMENT_EXCEEDS_QUOTA"]);r.z.enum(["PLAGIARISM_DOCUMENT_EXCEEDS_QUOTA","PLAGIARISM_MONTHLY_QUOTA_LAPSED","PLAGIARISM_REMAINING_QUOTA_INSUFFICIENT","FREE_PLAGIARISM_DOCUMENT_EXCEEDS_QUOTA","FREE_PLAGIARISM_MONTHLY_QUOTA_LAPSED","FREE_PLAGIARISM_REMAINING_QUOTA_INSUFFICIENT"]);let o=r.z.enum(["AI_DETECTION_PAID_QUOTA_EXHAUSTED","AI_DETECTION_FREE_QUOTA_EXHAUSTED","FREE_AI_DETECTION_DOCUMENT_EXCEEDS_QUOTA","PRIME_AI_DETECTION_DOCUMENT_EXCEEDS_QUOTA"]),i=r.z.object({errorCode:r.z.string(),errorReason:r.z.string(),errorDetails:r.z.object({errorMessage:r.z.string().optional(),tip:r.z.string().optional(),supportEmail:r.z.boolean().optional()}).optional()});r.z.object({response:r.z.object({status:r.z.number()})}).transform(e=>e.response.status);let s=i.extend({errorCode:l});function c(e){return s.safeParse(e).success}i.extend({errorCode:a})},82014:()=>{}
1,83264:(e,t,n)=>{"use strict";n.d(t,{HM:()=>b,eE:()=>v,lG:()=>p});var r=n(80263),l=n(10070),a=n(53239),o=n(86121),i=n(16679),s=n(87987),c=n(87387),d=n(67106),u=n(52743);let p=a.forwardRef((e,t)=>{let{open:n,setOpen:i,closeOnEscape:s,isMobileStickyBottom:c=!1,isExtensionAddToNotes:d=!1,portalContainer:u,...p}=e,[h,m]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{if(!d||!n)return;let e=document.body.style.overflow,t=document.body.style.position,r=document.body.style.top,l=window.scrollY;document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top="-".concat(l,"px"),document.body.style.width="100%";let a=e=>{e.target&&"scrollIntoView"in e.target&&(e.preventDefault(),e.stopImmediatePropagation())};return document.addEventListener("scroll",a,{capture:!0,passive:!1}),window.addEventListener("scroll",a,{capture:!0,passive:!1}),()=>{document.body.style.overflow=e,document.body.style.position=t,document.body.style.top=r,document.body.style.width="",document.removeEventListener("scroll",a,{capture:!0}),window.removeEventListener("scroll",a,{capture:!0}),window.scrollTo(0,l)}},[d,n]),(0,a.useEffect)(()=>{m(!0)},[]),(0,r.jsx)(l.Root,{open:e.open&&h,onOpenChange:null==s||s?e.setOpen:void 0,children:(0,r.jsxs)(l.AlertDialogPortal,{container:u,children:[(0,r.jsx)(g,{css:{zIndex:d?0x7ffffffe:1001},...d&&{onClick:e=>{d&&e.stopPropagation()}}}),(0,r.jsxs)(x,{isMobileStickyBottom:c,ref:t,...p,css:{zIndex:d?0x7ffffffe:1001},children:[(0,r.jsxs)(o.s,{children:[(0,r.jsx)(l.AlertDialogTitle,{}),(0,r.jsx)(l.AlertDialogDescription,{})]}),e.children]})]})})}),h=(0,i.i7)({"0%":{opacity:0},"100%":{opacity:1}}),m=(0,i.i7)({"0%":{opacity:0,transform:"translate(-50%, -48%) scale(.96)"},"100%":{opacity:1,transform:"translate(-50%, -50%) scale(1)"}}),g=(0,i.I4)(l.Overlay,{backgroundColor:i.w4.colors.overlayBlackAlpha9,position:"fixed",inset:0,zIndex:1001,pointerEvents:"auto",contain:"layout style paint","@media (prefers-reduced-motion: no-preference)":{animation:"".concat(h," 150ms cubic-bezier(0.16, 1, 0.3, 1)")}}),f=(0,i.I4)(s.J,{position:"absolute",top:20,right:20,border:"none",cursor:"pointer"}),x=(0,i.I4)(l.AlertDialogContent,{backgroundColor:"white",borderRadius:16,overflow:"auto",zIndex:1001,transform:"translate(-50%, -50%)",top:"50%",left:"50%",maxHeight:"90vh",maxWidth:"90vw",boxShadow:"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",position:"fixed",pointerEvents:"auto",scrollMargin:0,"@media (prefers-reduced-motion: no-preference)":{animation:"".concat(m," 150ms cubic-bezier(0.16, 1, 0.3, 1)")},"&:focus":{outline:"none",scrollMargin:0},"&:focus-visible":{outline:"none",scrollMargin:0},variants:{isMobileStickyBottom:{true:{"@sm":{transform:"none",maxWidth:"100%",width:"100%",top:"auto",bottom:0,left:0,borderRadius:"16px 16px 0 0",animation:"none"}},false:{}}}}),b=a.forwardRef((e,t)=>(0,r.jsx)(f,{ref:t,onClick:e.onClick,trackingName:"dialogClose","aria-label":"Close",css:{zIndex:999},children:(0,r.jsx)(c.w,{width:"14"})})),C=(0,i.I4)("div",{position:"absolute",top:8,right:16,border:"none",cursor:"pointer",color:i.w4.colors.gray8,opacity:.5,zIndex:999}),v=a.forwardRef((e,t)=>{var n;return(0,r.jsx)(C,{children:(0,r.jsx)(u.US,{ref:t,onClick:e.onClick,role:"button",tabIndex:0,"aria-label":e.ariaLabel||"Close dialog","data-id":e.dataId||"dialog-close-button","data-testid":e.dataTestId||"dialog-close-button",onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),e.onClick())},trackingName:e.trackingName||"dialogClose",trackingProperties:{sectionName:(null==(n=e.trackingProperties)?void 0:n.sectionName)||"dialog"},children:(0,r.jsx)(d.I,{name:"circleXmark",variant:"regular",width:20,height:20})})})})},83672:(e,t,n)=>{"use strict";n.d(t,{w:()=>L});var r=n(80263),l=n(53239),a=n(16679),o=n(70077),i=n(18696),s=n(67106),c=n(38767),d=n(68162),u=n(26827);let p=(0,a.I4)("div",{paddingInline:(0,o.D)(8),marginTop:(0,o.D)(12),position:"relative",fontFamily:a.w4.fonts.sansSerif,variants:{isInline:{true:{marginTop:0,"@sm":{flex:1,minWidth:0,paddingInline:0}}}}}),h=(0,a.I4)("button",{display:"flex",alignItems:"center",justifyContent:"center",gap:(0,o.D)(6),padding:"".concat((0,o.D)(6)," ").concat((0,o.D)(12)),border:"none",borderRadius:(0,o.D)(8),background:a.w4.colors.gray2,fontSize:(0,o.D)(14),fontWeight:500,color:a.w4.colors.blue11,cursor:"pointer",width:"100%",height:(0,o.D)(32),"&:hover":{backgroundColor:a.w4.colors.blue2},"&:disabled":{backgroundColor:a.w4.colors.gray3,color:a.w4.colors.gray9,opacity:.4},variants:{isInline:{true:{width:(0,o.D)(200),gap:(0,o.D)(16),padding:"".concat((0,o.D)(4)," ").concat((0,o.D)(8)),borderRadius:(0,o.D)(6),border:"".concat((0,o.D)(1)," solid ").concat(a.w4.colors.gray7),background:"transparent",lineHeight:(0,o.D)(24),"@sm":{width:"100%",justifyContent:"space-between"}}}}}),m=(0,a.I4)("span",{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"left",flex:1,minWidth:0,gap:(0,o.D)(6),display:"flex",alignItems:"center",justifyContent:"flex-start",fontFamily:"IBM Plex Sans",fontWeight:500,fontStyle:"Medium",fontSize:"14px",leadingTrim:"NONE",lineHeight:"24px",letterSpacing:"0px",color:a.w4.colors.gray12,"& svg":{color:"".concat(a.w4.colors.gray11," !important")},variants:{isInline:{true:{color:a.w4.colors.blue11}}}}),g=(0,a.I4)("div",{position:"absolute",top:"100%",left:(0,o.D)(0),right:(0,o.D)(0),zIndex:1e3,backgroundColor:"white",border:"1px solid ".concat(a.w4.colors.gray7),borderRadius:(0,o.D)(6),boxShadow:"0px 4px 12px rgba(0, 0, 0, 0.15)",display:"flex",flexDirection:"column",maxHeight:(0,o.D)(316),marginTop:(0,o.D)(4),variants:{isInline:{true:{right:"auto",minWidth:(0,o.D)(260),width:"max-content",maxWidth:(0,o.D)(300),"@sm":{right:(0,o.D)(0),width:"auto",minWidth:0,maxWidth:"none"}}}}}),f=(0,a.I4)("div",{margin:"".concat((0,o.D)(0)," ").concat((0,o.D)(10)),padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(0)),position:"relative",borderBottom:"1px solid ".concat(a.w4.colors.gray5),flexShrink:0}),x=(0,a.I4)("div",{position:"absolute",left:(0,o.D)(10),top:"50%",transform:"translateY(-50%)",color:a.w4.colors.gray9,pointerEvents:"none",fontSize:(0,o.D)(12)}),b=(0,a.I4)("input",{width:"100%",height:(0,o.D)(44),border:"1px solid ".concat(a.w4.colors.gray7),borderRadius:(0,o.D)(6),padding:"".concat((0,o.D)(6)," ").concat((0,o.D)(8)),paddingLeft:(0,o.D)(28),fontFamily:"inherit",fontSize:(0,o.D)(14),outline:"none",color:a.w4.colors.gray11,boxSizing:"border-box","&::placeholder":{color:a.w4.colors.gray9},"&:focus":{borderColor:a.w4.colors.blue9},"@sm":{fontSize:(0,o.D)(16)},variants:{isInline:{true:{height:(0,o.D)(32),"@sm":{height:(0,o.D)(36)}}}}}),C=(0,a.I4)("div",{flex:1,overflowY:"auto",maxHeight:(0,o.D)(200),WebkitOverflowScrolling:"touch"}),v="1px dotted ".concat(a.w4.colors.gray7),y={top:"-".concat((0,o.D)(14)),borderLeft:v},w={"&::before, &::after":{content:'""',position:"absolute",left:"$$railX"},"&::after":{top:"50%",width:"calc($$indentStep - ".concat((0,o.D)(8),")"),borderTop:v}},j=(0,a.I4)("div",{$$indentStep:(0,o.D)(16),$$railX:"calc(".concat((0,o.D)(16)," + (var(--indent-depth, 0) - 1) * $$indentStep)"),position:"relative",display:"flex",alignItems:"center",gap:(0,o.D)(8),padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(12)),paddingLeft:"calc(".concat((0,o.D)(8)," + var(--indent-depth, 0) * $$indentStep)"),cursor:"pointer",height:(0,o.D)(40),fontSize:(0,o.D)(14),fontWeight:500,color:a.w4.colors.gray12,transition:"background-color 0.15s","&:hover":{backgroundColor:a.w4.colors.blue3},"@sm":{$$indentStep:(0,o.D)(8)},variants:{active:{true:{backgroundColor:a.w4.colors.blue2,color:a.w4.colors.blue11}},rail:{full:{...w,"&::before":{...y,bottom:0}},elbow:{...w,"&::before":{...y,height:(0,o.D)(34)}}}}}),I=(0,a.I4)("div",{display:"flex",alignItems:"center",gap:(0,o.D)(8),flex:1,overflow:"hidden",cursor:"pointer"}),k=(0,a.I4)("span",{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1}),E=(0,a.I4)("span",{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:(0,o.D)(16),color:a.w4.colors.gray9}),N=(0,a.I4)("button",{background:"none",border:"none",padding:0,cursor:"pointer",display:"flex",alignItems:"center",color:a.w4.colors.gray9,flexShrink:0,"&:hover":{color:a.w4.colors.gray12}}),S=(0,a.I4)("span",{width:(0,o.D)(12),flexShrink:0}),T=(0,a.I4)("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:(0,o.D)(16)}),A=(0,a.I4)("div",{padding:(0,o.D)(16),textAlign:"center",fontSize:(0,o.D)(13),color:a.w4.colors.gray9}),R=(0,a.I4)("div",{borderTop:"1px solid ".concat(a.w4.colors.gray5),flexShrink:0}),M=(0,a.I4)(i.$,{display:"flex",alignItems:"center",justifyContent:"center",gap:(0,o.D)(6),border:"none",padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(10)),background:"".concat(a.w4.colors.gray3," !important"),fontSize:(0,o.D)(14),fontWeight:500,borderRadius:(0,o.D)(0),color:a.w4.colors.blue11,cursor:"pointer",width:"100%",transition:"background-color 0.15s",height:(0,o.D)(40),"&:hover":{backgroundColor:"".concat(a.w4.colors.blue3," !important"),borderRadius:(0,o.D)(0)}}),L=e=>{let{collections:t,isCollectionsLoading:n,selectedCollection:o,onSelect:i,onCreateCollection:v,selectedCollectionCount:y,isInline:w=!1}=e,[L,D]=(0,l.useState)(!1),{search:_,setSearch:H,isSearching:P,collapsedIds:O,toggleExpand:z,rows:B}=(0,u.S)(t),F=(0,l.useRef)(null);(0,l.useEffect)(()=>{let e=e=>{F.current&&!F.current.contains(e.target)&&(D(!1),H(""))};return L&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[L,H]);let V=(0,l.useCallback)((e,t)=>{t.stopPropagation(),z(e)},[z]),U=(0,l.useCallback)(e=>{i(e),D(!1),H("")},[i,H]),W=(0,l.useCallback)(()=>{v&&(v(!0),D(!1),H(""))},[v,H]);return(0,r.jsxs)(p,{ref:F,isInline:w,children:[(0,r.jsxs)(h,{isInline:w,onClick:()=>D(e=>!e),disabled:n,children:[(0,r.jsxs)(m,{isInline:w,children:[null==o?void 0:o.name,void 0!==y&&y>0&&" (".concat(y,")")]}),(0,r.jsx)(s.I,{name:L?"chevronUp":"chevronDown",variant:"regular",width:w?14:12,height:w?14:12})]}),L&&(0,r.jsx)(g,{isInline:w,children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(f,{children:[(0,r.jsx)(x,{children:(0,r.jsx)(s.I,{name:"search",variant:"regular"})}
1),(0,r.jsx)(b,{placeholder:"Search collections...",value:_,onChange:e=>H(e.target.value),autoFocus:!0,isInline:w})]}),(0,r.jsx)(C,{children:n?(0,r.jsx)(T,{children:(0,r.jsx)(c.y,{size:16,color:a.w4.colors.blue10})}):0===B.length?(0,r.jsx)(A,{children:"No collections found"}):B.map((e,t)=>{var n;let{collection:l,depth:a}=e,i=!!(null==(n=l.children)?void 0:n.length),c=!O.has(l.id),u=B.slice(t+1).find(e=>e.depth<=a),p=P||0===a?void 0:!u||u.depth<a?"elbow":"full";return(0,r.jsxs)(j,{active:(null==o?void 0:o.id)===l.id,rail:p,onClick:()=>U(l),style:{"--indent-depth":Math.min(a,4)},children:[(0,r.jsxs)(I,{children:[(0,r.jsx)(E,{children:(0,r.jsx)(d.c,{collection:l,folderWidth:16,folderHeight:12})}),(0,r.jsx)(k,{title:l.name,children:l.name})]}),i?(0,r.jsx)(N,{onClick:e=>V(l.id,e),children:(0,r.jsx)(s.I,{name:c?"chevronUp":"chevronDown",variant:"regular",width:12,height:12})}):(0,r.jsx)(S,{})]},l.id)})}),v&&(0,r.jsx)(R,{children:(0,r.jsxs)(M,{onClick:W,children:[(0,r.jsx)(s.I,{name:"Plus",variant:"regular",width:16,height:16}),"Create Collection"]})})]})})]})}},84275:()=>{},84413:()=>{},84577:(e,t,n)=>{"use strict";n.d(t,{_:()=>x});var r=n(80263),l=n(37786),a=n(77274),o=n(53239),i=n(6437),s=n(54541),c=n(67106),d=n(29404),u=n(70077),p=n(77503),h=n(16679),m=n(29525),g=n(31353),f=n(18696);let x=e=>{let{css:t,isPopupOpen:n,contextType:f,setIsPopupOpen:x,setContextType:w,disableViewRecent:j,uploadFileTooltip:I,isMobileWeb:k,handleViewRecentClick:E,isExtension:N=!1,isOverleaf:S=!1,isGoogleDocs:T=!1,disableCurrentDocument:A=!1,disableFileAttachementOption:R=!1,disableUpload:M=!1,webSearchEnabled:L,onWebSearchToggle:D,tipInfo:_="Attachment",accept:H=l.kT,onSignupClick:P}=e,[O,z]=(0,o.useState)(null);return(0,o.useLayoutEffect)(()=>{if(!N)return;let e=(0,a.M)();e&&z(e)},[N]),(0,r.jsx)(b,{css:{...t},children:(0,r.jsxs)(i.A.Root,{open:n,onOpenChange:x,...N&&{modal:!1},children:[(0,r.jsx)(i.A.Anchor,{children:k?(0,r.jsx)(s.vu,{css:{width:27,height:27,justifyContent:"center",padding:0},onClick:()=>x(!0),"data-test-id":"s3-file-attachment-plus",children:(0,r.jsx)(c.I,{name:"Plus",variant:"regular"})}):(0,r.jsx)(d.h,{tipInfo:_,side:"left",children:(0,r.jsx)(s.vu,{css:{width:27,height:27,justifyContent:"center",padding:0},onClick:()=>x(!0),"data-test-id":"s3-file-attachment-plus",children:(0,r.jsx)(c.I,{name:"Plus",variant:"regular"})})})}),(0,r.jsx)(i.A.Popup,{align:"start",style:{border:"none",borderRadius:(0,u.D)(6),minWidth:200,zIndex:0x7fffffff,boxShadow:"16px 8px 32px 16px #00000005, 4px 4px 16px 0px #00000014"},container:O||void 0,onOpenAutoFocus:e=>e.preventDefault(),children:(0,r.jsxs)(C,{children:[R&&(0,r.jsx)(p.ck,{children:(0,r.jsx)(y,{variant:"link",size:"small",onClick:()=>{x(!1),null==P||P()},dataId:"s3-file-attachment-signup",trackingName:"file-attachment-signup",children:"Sign up to use"})}),!R&&void 0!==D&&(0,r.jsx)(p.ck,{children:(0,r.jsxs)(p.Wj,{onClick:()=>{D(),x(!1)},style:{borderBottom:"1px solid ".concat(h.w4.colors.gray4)},"data-test-id":"web-search-toggle-button",children:[(0,r.jsx)(p.HM,{children:(0,r.jsx)(c.I,{name:"globe",variant:"regular"})}),(0,r.jsx)(p.u6,{children:"Web Search"}),L&&(0,r.jsx)(c.I,{name:"check",variant:"regular"})]})}),(0,r.jsx)(p.ck,{children:(0,r.jsx)(d.h,{side:"left",delayDuration:500,supportMobileTap:!k,tipInfo:(0,r.jsx)(m.P,{size:"tiny",css:{fontWeight:500,color:h.w4.colors.white,width:200},children:I}),children:(0,r.jsxs)(p.Wj,{style:{position:"relative",overflow:"hidden"},onClick:e=>{e.stopPropagation()},"data-test-id":"s3-upload-trigger",disabled:R||M,children:[(0,r.jsx)(p.HM,{children:(0,r.jsx)(c.I,{name:"paperclip",variant:"regular"})}),(0,r.jsx)(p.u6,{children:"Upload"}),!R&&!M&&(0,r.jsx)(v,{children:(0,r.jsx)(g.E,{accept:H,multiple:!0})})]})})}),(0,r.jsx)(p.ck,{children:(0,r.jsxs)(p.Wj,{disabled:j||R,onClick:E,"data-test-id":"view-library-button",children:[(0,r.jsx)(p.HM,{children:(0,r.jsx)(c.I,{name:"buildingColumns",variant:"regular"})}),(0,r.jsx)(p.u6,{children:"Add from Library"})]})}),w&&!A&&(0,r.jsx)(p.ck,{children:(0,r.jsxs)(p.Wj,{disabled:"Current Document"===f||N&&!S&&!T,onClick:()=>{x(!1),w()},"data-test-id":"switch-to-current-document-context-button",children:[(0,r.jsx)(p.HM,{children:(0,r.jsx)(c.I,{name:"squareList",variant:"regular"})}),(0,r.jsx)(p.u6,{children:"Current Document"})]})})]})})]})})},b=(0,h.I4)("div",{position:"absolute",left:8,bottom:8,zIndex:1}),C=(0,h.I4)(p.B8,{fontSize:(0,u.D)(14),borderRadius:6,overflow:"hidden",boxShadow:"none",">li":{fontWeight:500,"button, >label":{gap:6},"button > div":{fontSize:(0,u.D)(12),lineHeight:"normal",color:h.w4.colors.gray12,minWidth:"auto"},"button:disabled > div":{color:h.w4.colors.gray8},"> label:hover":{backgroundColor:h.w4.colors.gray3},"> label  > div":{fontSize:(0,u.D)(14),color:h.w4.colors.gray12}}}),v=(0,h.I4)("div",{width:"100%",height:"100%",position:"absolute",left:0,top:0,div:{width:"100%",height:"100%"},button:{width:"100%",height:"100%",background:"transparent",border:"none",padding:0,opacity:0,cursor:"pointer"}}),y=(0,h.I4)(f.$,{fontSize:(0,u.D)(12),fontWeight:400,color:h.w4.colors.gray9,textDecoration:"underline"})}
1,84699:(e,t,n)=>{"use strict";n.d(t,{T0:()=>hz});var r=n(80263),l=n(68102),a=n(73095),o=n(98805),i=n.n(o);let s=l.YY.create({name:a.A.CITATION_REFERENCE_PANEL,addOptions:()=>({ydoc:null}),addStorage(){let{ydoc:e}=this.options,t=null==e?void 0:e.getMap("citationStyle");return{citations:[],citationStyle:null==t?void 0:t.get("style"),editor:{},eventEmitter:new(i())}},addCommands(){return{setCitationReferences:e=>()=>{if(this.storage.citations=e,e.length>0){var t,n;this.storage.eventEmitter.emit("open",{citations:e}),null==(t=(n=this.options).onRequestOpen)||t.call(n,{citations:e})}else this.storage.eventEmitter.emit("close");return!0},setDocumentCitationStyle:e=>()=>(this.storage.citationStyle=e,this.storage.eventEmitter.emit("citationStyleUpdated",e),!0),closeCitationPanel:()=>()=>(this.storage.eventEmitter.emit("close"),!0)}}});var c=n(58212),d=n(46685),u=n(25960);let p=e=>!!e&&((null==e?void 0:e.planMachineName)==="paperpal-prime-write-disabled"||(null==e?void 0:e.planMachineName)==="editage-plus-write-disabled");var h=n(53239);let m=(0,h.createContext)({aiToken:void 0,sessionId:"",documentId:"",isPrime:!1,isPrimeWriteDisabled:!1,genAiBalance:{totalBalance:0,usedBalance:0},isFreeTrialPlan:!1});m.Consumer;let g=()=>{let e=(0,h.useContext)(m);if(!e)throw Error("useAi must be used within an AiProvider");return e};function f(e){let{children:t,aiToken:n,documentId:l,sessionId:a}=e,{data:o}=(0,u.l)(0,"tip-tap-editor-v3",!1),i=(0,h.useMemo)(()=>(null==o?void 0:o.isPrime)||!1,[o]),s=(0,h.useMemo)(()=>(null==o?void 0:o.planMachineName)==="paperpal-free-trial-7-days",[o]),c=(0,h.useMemo)(()=>(null==o?void 0:o.genAIBalance)?o.genAIBalance:{totalBalance:0,usedBalance:0},[o]),d=p(o),g=(0,h.useMemo)(()=>({isPrime:i,aiToken:n,sessionId:a,documentId:l,isPrimeWriteDisabled:d,genAiBalance:c,isFreeTrialPlan:s}),[i,n,a,l,d,c,s]);return(0,r.jsx)(m.Provider,{value:g,children:t})}var x=n(78681),b=n(10413);function C(){let e=(0,h.useCallback)(e=>{let{message:t,position:n="bottom-center"}=e;b.Ay.success(t,{duration:2e3,position:n,className:"bg-green-600/50 text-white"})},[]),t=(0,h.useCallback)(e=>{let{message:t,duration:n=4e3}=e;(0,b.Ay)(t,{duration:n,position:"bottom-center",style:{width:"800px",maxWidth:"90vw",padding:"5px",borderRadius:"8px",fontWeight:500,border:"1px solid rgb(183, 205, 248)",backgroundColor:"rgb(245, 248, 255)",color:"rgb(0, 84, 241)"}})},[]);return{successToast:e,errorToast:(0,h.useCallback)(e=>{let{message:t,position:n="bottom-center"}=e;b.Ay.error(t,{duration:4e3,position:n})},[]),infoToast:t}}var v=n(1198);let y=e=>{let[t,n]=(0,h.useState)(e||""),[r,l]=(0,h.useState)(!1),[a,o]=(0,h.useState)(null),i=function(e,t){let[n,r]=(0,h.useState)(e);return(0,h.useEffect)(()=>{let t=setTimeout(()=>{r(e)},500);return()=>{clearTimeout(t)}},[e,500]),n}(t,500),s=(0,h.useCallback)(e=>{n(e),l(!0),a&&o(null)},[a]);return{searchTerm:t,setSearchTerm:n,debouncedTerm:i,selectedCitationStyle:a,setSelectedCitationStyle:o,handleChange:s,hasUserTyped:r}};var w=n(62628);function j(e,t,n,r,l){let a=e;return l||(a=e.split("\n\n").filter(Boolean).map(e=>"<p>".concat(e.trim().replace(/\n/g,"<br/>"),"</p>")).join("")),'<div data-insertion-type="ai-generated" data-feature-name="'.concat(t,'" data-req-id="').concat(n,'" data-source="').concat(null!=r?r:"SIDE_BAR",'">').concat(a,"</div>")}var I=n(16679),k=n(81614),E=n(13211),N=n(7604);let S=e=>{let{color:t="#5D6A81",...n}=e;return(0,r.jsx)("svg",{width:n.width||"16",height:n.height||"16",viewBox:"0 0 640 640",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M480 272C480 317.9 465.1 360.3 440 394.7L566.6 521.4C579.1 533.9 579.1 554.2 566.6 566.7C554.1 579.2 533.8 579.2 521.3 566.7L394.7 440C360.3 465.1 317.9 480 272 480C157.1 480 64 386.9 64 272C64 157.1 157.1 64 272 64C386.9 64 480 157.1 480 272zM272 416C351.5 416 416 351.5 416 272C416 192.5 351.5 128 272 128C192.5 128 128 192.5 128 272C128 351.5 192.5 416 272 416z",fill:t})})},T=e=>{let{isLoading:t,onSubmit:n,placeholder:l,onChange:a,value:o,showLoading:i,disabled:s,allowSearchClick:d,isPromptModal:u=!1}=e,{register:p,getValues:h}=(0,N.mN)({});return(0,r.jsx)("form",{style:{width:u?"60%":"100%"},onSubmit:e=>e.preventDefault(),children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{style:{paddingTop:8,paddingBottom:8,paddingRight:30,textOverflow:"ellipsis"},onKeyDown:e=>{let t=h("title");t&&"Enter"===e.key&&n&&(e.preventDefault(),n(t||""))},placeholder:l,...p("title",{required:{value:!0,message:"This is a required field."},onChange:e=>{null==a||a(e.target.value)}}),value:o,disabled:s,autoComplete:"off",className:"w-full border border-solid border-gray-8 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-2 focus:border-transparent ${ px-3 py-2"}),(0,r.jsx)("div",{className:"absolute right-2.5 top-2 cursor-pointer ".concat(d?"":"pointer-events-none cursor-default"),onClick:e=>{e.preventDefault(),null==n||n(h("title"))},children:t&&i?(0,r.jsx)("div",{style:{marginTop:5},children:(0,r.jsx)(c.y,{size:16})}):(0,r.jsx)(S,{})})]})})};var A=n(78773),R=n(11445),M=n(70178),L=n(1321);let D=R.z.object({sourceDocId:R.z.string(),inlineCitation:R.z.string(),fullCitation:R.z.object({text:R.z.string(),num:R.z.string().optional()})});R.z.object({styleKey:R.z.string(),styleName:R.z.string(),citations:R.z.array(D),documentId:R.z.string(),isThisDefaultStyle:R.z.boolean(),styleId:R.z.number()});let _=R.z.object({id:R.z.number(),name:R.z.string(),key:R.z.string(),type:R.z.string().optional()});R.z.object({papers:R.z.object({content:R.z.array(M.qP),totalPages:R.z.number(),number:R.z.number()}),styleId:R.z.number().optional(),cslJsonMap:L.$s.optional()});var H=function(e){return e.CITE="CITE",e.COPY_REFERENCE="COPY_REFERENCE",e.COPY_CITE="COPY_CITE",e.INSERT="INSERT",e.INSERT_INLINE="INSERT_INLINE",e}({}),P=n(64014);let O=()=>{let{webApiClient:e}=(0,P.p)(),t=async t=>{let{key:n,id:r,name:l,documentId:a}=t,o=await e.post("/api/v2/citation/document/".concat(a,"/style"),{key:n,id:r,name:l});return _.parse(o)},n=(0,A.useMutation)({mutationKey:["apply-citation-style"],mutationFn:t,onError:e=>{console.error("Error in apply citation style",e)}});return{applySelectedCitationStyle:(0,h.useCallback)(async(e,t,r,l)=>await n.mutateAsync({name:e,key:t,id:r,documentId:l}),[n]),isLoading:n.isLoading,data:n.data}};var z=n(80415);let B=function(e,t,n){let r=!(arguments.length>3)||void 0===arguments[3]||arguments[3],{showToast:l}=(0,z._)(),{applySelectedCitationStyle:a,isLoading:o}=O(),i=(0,A.useQueryClient)(),s=(0,h.useCallback)(t=>{i.setQueryData(["document-citation-style",e],e=>e?{...e,name:t.name,key:t.key,id:t.id}:e)},[e,i]);return{saveSelectedCitationStyle:(0,h.useCallback)(async o=>{try{let i=o||n;if(i){t.afterCitationStyleChange({documentCitationStyle:{name:i.name,key:i.key}});let n=await a(i.name,i.key,i.id,e);
1n&&(s(n),r&&l({title:"Citation style applied",color:"success"}))}}catch(e){console.error("Error in apply citation style",e),l({title:"Something went wrong",color:"danger"})}},[r,n,a,e,t,s]),isApplying:o}},F=e=>{let{color:t="#7D8AA1",...n}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"29",viewBox:"0 0 18 19",fill:"none",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11.25 1.4375H8.208C6.8295 1.4375 5.7375 1.4375 4.88325 1.55225C4.00425 1.67075 3.2925 1.91975 2.73075 2.48075C2.16975 3.0425 1.92075 3.75425 1.80225 4.63325C1.6875 5.48825 1.6875 6.5795 1.6875 7.958V12.5C1.68752 13.1701 1.9267 13.8181 2.362 14.3275C2.7973 14.8369 3.40014 15.1742 4.062 15.2787C4.16475 15.8518 4.3635 16.3408 4.761 16.739C5.2125 17.1905 5.781 17.384 6.456 17.4755C7.10625 17.5625 7.9335 17.5625 8.95875 17.5625H11.2913C12.3165 17.5625 13.1438 17.5625 13.794 17.4755C14.469 17.384 15.0375 17.1905 15.489 16.739C15.9405 16.2875 16.134 15.719 16.2255 15.044C16.3125 14.3938 16.3125 13.5665 16.3125 12.5413V8.70875C16.3125 7.6835 16.3125 6.85625 16.2255 6.206C16.134 5.531 15.9405 4.9625 15.489 4.511C15.0908 4.1135 14.6018 3.91475 14.0287 3.812C13.9242 3.15014 13.5869 2.5473 13.0775 2.112C12.5681 1.6767 11.9201 1.43752 11.25 1.4375ZM12.8475 3.70325C12.7335 3.37025 12.5181 3.08124 12.2317 2.87669C11.9452 2.67214 11.602 2.56229 11.25 2.5625H8.25C6.81975 2.5625 5.80425 2.564 5.0325 2.6675C4.27875 2.76875 3.84375 2.95925 3.5265 3.2765C3.20925 3.59375 3.01875 4.02875 2.9175 4.78325C2.814 5.55425 2.8125 6.56975 2.8125 8V12.5C2.81229 12.852 2.92214 13.1952 3.12669 13.4817C3.33124 13.7681 3.62025 13.9835 3.95325 14.0975C3.9375 13.64 3.9375 13.1225 3.9375 12.5413V8.70875C3.9375 7.6835 3.9375 6.85625 4.02525 6.206C4.11525 5.531 4.31025 4.9625 4.761 4.511C5.2125 4.0595 5.781 3.866 6.456 3.77525C7.10625 3.6875 7.9335 3.6875 8.95875 3.6875H11.2913C11.8725 3.6875 12.39 3.6875 12.8475 3.70325ZM5.556 5.3075C5.76375 5.09975 6.05475 4.96475 6.606 4.8905C7.1715 4.81475 7.923 4.81325 8.99925 4.81325H11.2492C12.3255 4.81325 13.0763 4.81475 13.6432 4.8905C14.1938 4.96475 14.4847 5.1005 14.6925 5.3075C14.9003 5.51525 15.0352 5.80625 15.1095 6.3575C15.1853 6.923 15.1868 7.6745 15.1868 8.75075V12.5007C15.1868 13.577 15.1853 14.3278 15.1095 14.8948C15.0352 15.4453 14.8995 15.7362 14.6925 15.944C14.4847 16.1517 14.1938 16.2868 13.6425 16.361C13.0763 16.4368 12.3255 16.4382 11.2492 16.4382H8.99925C7.923 16.4382 7.1715 16.4368 6.60525 16.361C6.05475 16.2868 5.76375 16.151 5.556 15.944C5.34825 15.7362 5.21325 15.4452 5.139 14.894C5.06325 14.3277 5.06175 13.577 5.06175 12.5007V8.75075C5.06175 7.6745 5.06325 6.923 5.139 6.35675C5.21325 5.80625 5.349 5.51525 5.556 5.3075Z",fill:t,strokeWidth:"0.5"})})},V=e=>(0,r.jsxs)("svg",{...e,width:"20",height:"19",viewBox:"0 0 20 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{opacity:"0.2",d:"M18.3749 4.69308L8.93819 0.740427C8.04062 0.364468 7.00821 0.787321 6.63225 1.6849L2.6796 11.1216C2.30364 12.0191 2.7265 13.0515 3.62407 13.4275L13.0607 17.3802C13.9583 17.7561 14.9907 17.3333 15.3667 16.4357L19.3193 6.99902C19.6953 6.10144 19.2724 5.06904 18.3749 4.69308Z",fill:"#ECB441"}),(0,r.jsx)("path",{opacity:"0.4",d:"M16.3 2.99615L6.39334 0.440193C5.45106 0.197081 4.49011 0.763866 4.247 1.70614L1.69104 11.6128C1.44793 12.555 2.01471 13.516 2.95699 13.7591L12.8636 16.3151C13.8059 16.5582 14.7668 15.9914 15.01 15.0491L17.5659 5.14249C17.809 4.20021 17.2422 3.23926 16.3 2.99615Z",fill:"#ECB441"}),(0,r.jsx)("path",{d:"M12.536 1.50513H1.76201C0.78888 1.50513 0 2.29401 0 3.26714V14.0411C0 15.0142 0.78888 15.8031 1.76201 15.8031H12.536C13.5091 15.8031 14.298 15.0142 14.298 14.0411V3.26714C14.298 2.29401 13.5091 1.50513 12.536 1.50
1513Z",fill:"#F1C468"}),(0,r.jsx)("path",{d:"M11.0202 7.16522L8.53872 6.82189L7.42944 4.681C7.39914 4.62237 7.34927 4.57493 7.28769 4.54607C7.13329 4.47352 6.94564 4.534 6.86842 4.681L5.7591 6.82189L3.2776 7.16522C3.20918 7.17451 3.14663 7.20522 3.09874 7.25178C3.04084 7.30843 3.00894 7.38463 3.01004 7.46366C3.01114 7.54269 3.04515 7.61806 3.1046 7.67325L4.90003 9.33963L4.47582 11.6927C4.46591 11.7474 4.47226 11.8037 4.49419 11.8552C4.51618 11.9067 4.55282 11.9512 4.60005 11.9839C4.64722 12.0165 4.70312 12.0359 4.76131 12.0399C4.81955 12.0438 4.87774 12.0322 4.92932 12.0062L7.14893 10.8953L9.36849 12.0062C9.42911 12.0369 9.49946 12.0472 9.5669 12.036C9.73698 12.0081 9.85133 11.8546 9.82199 11.6927L9.39783 9.33963L11.1932 7.67325C11.2421 7.62766 11.2744 7.5681 11.2841 7.50295C11.3105 7.34014 11.1913 7.1894 11.0202 7.16522Z",fill:"#956A11"})]}),U=e=>{let{color:t="#5D6A81",...n}=e;return(0,r.jsx)("svg",{width:n.width||"16",height:n.height||"16",viewBox:"0 0 512 512",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M464 32H336c-26.5 0-48 21.5-48 48v128c0 26.5 21.5 48 48 48h80v64c0 35.3-28.7 64-64 64h-8c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h8c88.4 0 160-71.6 160-160V80c0-26.5-21.5-48-48-48zm-288 0H48C21.5 32 0 53.5 0 80v128c0 26.5 21.5 48 48 48h80v64c0 35.3-28.7 64-64 64h-8c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h8c88.4 0 160-71.6 160-160V80c0-26.5-21.5-48-48-48z",fill:t})})},W="APA 7th edition",G=e=>{let{editor:t}=e,{openPayload:n}=function(e){let[t,n]=(0,h.useState)(null);return(0,h.useEffect)(()=>{if(!e)return;let t=e.storage[a.A.CITATION_REFERENCE_PANEL];if(!(null==t?void 0:t.eventEmitter))return;let r=e=>{e&&n(e)},l=()=>{n(null)};return t.eventEmitter.on("open",r),t.eventEmitter.on("close",l),()=>{var e,n;null==(e=t.eventEmitter)||e.off("open",r),null==(n=t.eventEmitter)||n.off("close",l)}},[e]),{openPayload:t,openPanel:(0,h.useCallback)(t=>{null==e||e.commands.setCitationReferences(t)},[e]),closePanel:(0,h.useCallback)(()=>null==e?void 0:e.commands.closeCitationPanel(),[e])}}(t),{documentController:l}=(0,x.R1)(),{documentId:o,isPrime:i}=g();return n&&t&&l?(0,r.jsx)("div",{className:"paperpal-editor-content relative border-gray-4 border border-t-1 border-solid ",id:"citations-panel-wrapper",children:(0,r.jsx)(Z,{citations:n.citations,editor:t,documentController:l,documentId:o,isPrime:i})}):null},Z=e=>{var t,n,l,o;let{citations:i,editor:s,documentController:u,documentId:p,isPrime:m}=e,[g,f]=(0,h.useState)(null!=(n=null==(t=s.storage[a.A.CITATION_REFERENCE_PANEL])?void 0:t.citationStyle)?n:void 0),x=(0,h.useRef)(null),b=(0,h.useRef)(null),[I,k]=(0,h.useState)(!1),{searchTerm:N,debouncedTerm:S,selectedCitationStyle:A,setSelectedCitationStyle:R,handleChange:M,hasUserTyped:L}=y(""),{citationStyleData:D,isLoading:_,hasNextSetOfStyle:H,isFetchingNextCitationStyle:P,fetchNextCitationStyle:O}=(0,v.G)(S,!1),{saveSelectedCitationStyle:z}=B(p,u,A),{successToast:G,errorToast:Z}=C(),$=(0,h.useCallback)(e=>{let{scrollTop:t,clientHeight:n,scrollHeight:r}=e.currentTarget;t+n>=r-20&&!N&&H&&!P&&O()},[O,H,P,N]);(0,h.useEffect)(()=>{let e=s.storage[a.A.CITATION_REFERENCE_PANEL],t=e=>{e&&f(e)};return(null==e?void 0:e.eventEmitter)&&e.eventEmitter.on("citationStyleUpdated",t),()=>{(null==e?void 0:e.eventEmitter)&&e.eventEmitter.off("citationStyleUpdated",t)}},[s]),(0,h.useEffect)(()=>{let e=e=>{b.current&&!b.current.contains(e.target)&&k(!1)};return I&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[I]);let K=async e=>{f(e),k(!1),z(e)},Y=(0,h.useCallback)(()=>{k(!0),M("")},[M]);return(0,r.jsxs)("div",{className:"citation-panel flex-1 pt-12 md:px-12 px-4 pb-[20vh]",children:[(0,r.jsxs)("div",{className:"w-full flex justify-between flex-wrap mb-[30px] font-ibm",children:[(0,r.jsxs)("div",{className:"inline-flex items-center",children:[(0,r.jsx)("span",{className:"font-bold text-xl font-ibm text-gray-11",children:"References"}),m?(0,r.jsx)(d.$n,{tooltip:"Copy references",className:"border-0 cursor-pointer bg-transparent !p-0 ml-[20px] !shadow-none",onClick:()=>{try{let e=i.map(e=>({html:"".concat(e),text:"".concat((0,w.v)(e))})),t=e.map(e=>e.html).join("<br>"),n=e.map(e=>e.text).join("\n"),r=j(t,"Research"),l=new Blob([r],{type:"text/html"}),a=new Blob([n],{type:"text/plain"}),o=[new ClipboardItem({"text/html":l,"text/plain":a})];navigator.clipboard.write(o).then(()=>{G({message:"Copied to clipboard"})})}catch(e){console.error("TipTap Error: CitationReferencePanel copying citations ",JSON.stringify(e)),Z({message:"Unable to copy"})}},children:(0,r.jsx)(F,{})}):(0,r.jsxs)(q,{href:"/plans",id:"upgrade-to-copy-references",children:["Upgrade to unlock"," ",(0,r.jsx)(V,{style:{border:"none",strokeWidth:0,marginTop:2,padding:"0px !important"}})]})]}),(0,r.jsx)("div",{className:"relative w-[400px] min-w-[250px]",ref:b,children:I?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T,{onChange:e=>{A&&R(null),M(e)},placeholder:"Search style",isLoading:_,showLoading:!A,validationError:"",showSearchButton:!1,value:N,ctaSearchLabel:"Search"}),!A&&L&&(0,r.jsxs)("ul",{className:" list-none p-0 m-0 absolute w-full z-[1001] border border-gray-8 border-t-0 rounded-b-lg rounded-t-none pt-[10px] max-h-[200px] overflow-auto bg-white shadow-[0_4px_12px_rgba(0,0,0,0.12)] ",ref:x,onScroll:$,children:[D.length?(0,r.jsx)(E.h,{viewportRef:x,items:D,children:e=>(0,r.jsx)("li",{className:"text-left w-full flex items-center gap-2 py-2 px-4 hover:bg-gray-2 cursor-pointer",onClick:()=>K(e),children:(0,r.jsx)("label",{className:"cursor-pointer text-sm  font-normal text-gray-11",children:e.name})},e.id)}):(0,r.jsx)("p",{className:"flex items-center font-bold px-4 my-[10px] text-xs leading-4 text-red-11",children:"No results found"}),H&&(0,r.jsxs)("p",{className:"flex items-center font-bold px-4 my-[10px] text-gray-8 text-xs leading-4",children:[P&&(0,r.jsx)(c.y,{size:15})," ","\xa0","Search from 10,000+ styles..."]})]})]}
1):(0,r.jsxs)(d.$n,{tooltip:"Choose citation style",className:" flex w-full items-center gap-2 text-sm font-normal text-blue-12  border  border-solid border-gray-8 border-[1px] rounded-md bg-blue-2 cursor-pointer px-[10px] py-[8px]  ","data-test-id":"citation-style-".concat(null!=(l=null==g?void 0:g.name)?l:W),"aria-readonly":!0,onClick:Y,children:[(0,r.jsx)(U,{width:12,height:12}),null!=(o=null==g?void 0:g.name)?o:W]})})]}),(0,r.jsx)("div",{className:"grid gap-[6px] break-all","data-insertion-type":"ai-generated","data-feature-name":"Research","data-source":"INLINE",children:i.map((e,t)=>(0,r.jsx)("div",{className:"font-ibm ".concat(m?"select-text":"pointer-events-none blur-[3px] select-none"),dangerouslySetInnerHTML:{__html:e}},t))})]})},q=(0,I.I4)(k.u,{display:"inline-flex",alignItems:"center",fontWeight:500,fontSize:"15px",margin:"5px 0px 5px 20px",color:I.w4.colors.blue9,textDecoration:"underline",background:"transparent",border:"none",boxShadow:"none",padding:0,flexShrink:1,"&:hover":{textDecoration:"none",boxShadow:"none"}});var $=n(30131),K=n(12029);let Y=new $.hs("commentIndicator"),X=l.YY.create({name:"commentIndicator",addProseMirrorPlugins(){return[new $.k_({key:Y,state:{init:()=>({lastUpdate:0}),apply:(e,t)=>(null==e?void 0:e.getMeta("commentStorageUpdate"))?{...t,lastUpdate:Date.now()}:t},props:{decorations:e=>{let{doc:t}=e,n=[],r=new Map;for(let[e,i]of(t.descendants((e,n)=>{let l=e.marks.find(e=>e.attrs["data-thread-id"]),a=null==l?void 0:l.attrs["data-thread-id"];if(a&&!r.has(a)){let e=t.resolve(n),l=!1;for(let t=e.depth;t>0;t--)if("tableCell"===e.node(t).type.name||"tableHeader"===e.node(t).type.name){l=!0;break}r.set(a,{pos:n,isInsideTable:l})}}),r.entries())){var l,a,o;let{pos:t,isInsideTable:r}=i,s=null==(a=this.editor.storage.comments)||null==(l=a.threads)?void 0:l.find(t=>t.id===e),c=(null==s||null==(o=s.comments)?void 0:o.length)||0,d=null==s?void 0:s.resolvedAt,u=d?ee:c?Q:J;n.push(K.NZ.widget(t,()=>{let t=document.createElement("span");return t.className=r?"comment-indicator comment-indicator-table":"comment-indicator",t.dataset.threadId=e,t.innerHTML='\n            <div id="'.concat(d?"resolved":"unresolved",'" class="count-container">\n              ').concat(u,"\n              ").concat(c&&!d?'<span class="comment-count">'.concat(c>9?"+9":c>1?"+".concat(c):c,"</span>"):"","\n            </div>"),t.addEventListener("mousedown",t=>{var n,r;t.preventDefault(),t.stopImmediatePropagation(),null==(n=(r=this.options).handleRedirectToCommentThread)||n.call(r,e),this.editor.commands.selectThread({id:e})}),t},{side:-1,key:"comment-".concat(e,"-").concat(c)}))}return K.zF.create(t,n)}}})]},addCommands:()=>({updateCommentIndicators:()=>e=>{let{tr:t,dispatch:n}=e;return n&&(t.setMeta("commentStorageUpdate",!0),n(t)),!0}})}),J='\n  <svg\n    class="comment-icon"\n    width="16"\n    height="16"\n    viewBox="0 0 16 16"\n    fill="none"\n    xmlns="http://www.w3.org/2000/svg"\n  >\n    <path\n      opacity="0.4"\n      d="M0 2.99988V9.99988C0 11.6561 1.34375 12.9999 3 12.9999H4V15.2499C4 15.6655 4.33437 15.9999 4.75 15.9999C4.9125 15.9999 5.06875 15.9468 5.2 15.8499L8.8 13.1499C8.93125 13.053 9.0875 12.9999 9.25 12.9999H13C14.6562 12.9999 16 11.6561 16 9.99988V2.99988C16 1.34363 14.6562 -0.00012207 13 -0.00012207H3C1.34375 -0.00012207 0 1.34363 0 2.99988ZM5 6.49988C5 6.76509 4.89464 7.01945 4.70711 7.20698C4.51957 7.39452 4.26522 7.49988 4 7.49988C3.73478 7.49988 3.48043 7.39452 3.29289 7.20698C3.10536 7.01945 3 6.76509 3 6.49988C3 6.23466 3.10536 5.98031 3.29289 5.79277C3.48043 5.60524 3.73478 5.49988 4 5.49988C4.26522 5.49988 4.51957 5.60524 4.70711 5.79277C4.89464 5.98031 5 6.23466 5 6.49988ZM9 6.49988C9 6.76509 8.89464 7.01945 8.70711 7.20698C8.51957 7.39452 8.26522 7.49988 8 7.49988C7.73478 7.49988 7.48043 7.39452 7.29289 7.20698C7.10536 7.01945 7 6.76509 7 6.49988C7 6.23466 7.10536 5.98031 7.29289 5.79277C7.48043 5.60524 7.73478 5.49988 8 5.49988C8.26522 5.49988 8.51957 5.60524 8.70711 5.79277C8.89464 5.98031 9 6.23466 9 6.49988ZM13 6.49988C13 6.76509 12.8946 7.01945 12.7071 7.20698C12.5196 7.39452 12.2652 7.49988 12 7.49988C11.7348 7.49988 11.4804 7.39452 11.2929 7.20698C11.1054 7.01945 11 6.76509 11 6.49988C11 6.23466 11.1054 5.98031 11.2929 5.79277C11.4804 5.60524 11.7348 5.49988 12 5.49988C12.2652 5.49988 12.5196 5.60524 12.7071 5.79277C12.8946 5.98031 13 6.23466 13 6.49988Z"\n      fill="currentColor"\n    />\n  </svg>
1\n',Q=' <svg class="comment-icon" width="16" height="16" viewBox="0 0 16 16" \n       xmlns="http://www.w3.org/2000/svg">\n    <path \n          d="M0 2.99988V9.99988C0 11.6561 1.34375 12.9999 3 12.9999H4V15.2499C4 15.6655 4.33437 15.9999 4.75 15.9999C4.9125 15.9999 5.06875 15.9468 5.2 15.8499L8.8 13.1499C8.93125 13.053 9.0875 12.9999 9.25 12.9999H13C14.6562 12.9999 16 11.6561 16 9.99988V2.99988C16 1.34363 14.6562 -0.00012207 13 -0.00012207H3C1.34375 -0.00012207 0 1.34363 0 2.99988Z" \n          opacity="0.4" fill="currentColor"/>\n  </svg>',ee='<svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path opacity="1" d="M0.875 3.04688V8.40625C0.875 9.67432 1.90381 10.7031 3.17188 10.7031H3.9375V12.4258C3.9375 12.744 4.19351 13 4.51172 13C4.63613 13 4.75576 12.9593 4.85625 12.8852L7.6125 10.818C7.71299 10.7438 7.83262 10.7031 7.95703 10.7031H10.8281C12.0962 10.7031 13.125 9.67432 13.125 8.40625V3.04688C13.125 1.77881 12.0962 0.75 10.8281 0.75H3.17188C1.90381 0.75 0.875 1.77881 0.875 3.04688ZM5.00938 5.87969C4.81797 5.62607 4.87061 5.26719 5.12422 5.07578C5.37783 4.88438 5.73672 4.93701 5.92812 5.19063L6.57412 6.05195L8.04316 3.70005C8.21064 3.43208 8.56475 3.34834 8.83511 3.51821C9.10547 3.68809 9.18682 4.03979 9.01694 4.31016L7.10288 7.37266C7.00239 7.53296 6.83013 7.63345 6.64111 7.64302C6.4521 7.65259 6.27026 7.56645 6.15781 7.41333L5.00938 5.88208V5.87969Z" fill="#BCC7DC"/>\n</svg>\n';var et=n(32854),en=n(17228);function er(e,t,n,r){let l=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return t.content.descendants((t,a)=>{let o=t.nodeSize;if(t.isInline&&!t.marks.some(e=>{var t,n;return["ai-generated","copied"].includes(null!=(n=null==(t=e.attrs)?void 0:t["data-insertion-type"])?n:"")})){var i;let s=r.create({"data-insertion-type":"copied","data-copy-source":l?"paperpal_editor":null!=(i=t.attrs["data-copy-source"])?i:"unknown"});e.addMark(n+a,n+a+o,s)}return!0}),e}let el=e=>e.split(/\s+/).filter(e=>""!==e).length,ea=(e,t,n)=>{try{let r=e.doc.content.size,l=Math.min(Math.max(t,0),r),a=Math.min(Math.max(n,0),r),o=Math.min(l,a),i=Math.max(l,a),s=e.doc.resolve(o),c=e.doc.resolve(i);return e.setSelection($.U3.between(s,c))}catch(t){return e}};function eo(e){var t,n,r,l;if(!(e instanceof HTMLElement)||"P"!==e.tagName)return null;let a=null!=(n=e.getAttribute("style"))?n:"",o=null!=(r=e.className)?r:"",i=null!=(l=null==(t=e.textContent)?void 0:t.trim())?l:"";return a.includes("mso-list")||/MsoList/i.test(o)?/MsoListNumber/i.test(o)||/^\d+[.)]\s/.test(i)?"ordered":"bullet":/^[•·◦▸▪▫●○■□]\s/.test(i)?"bullet":/^\d+[.)]\s/.test(i)?"ordered":null}let ei=l.YY.create({name:"customPasteHandler",addProseMirrorPlugins(){let{documentId:e,insertCitationsToDocument:t,insertCitationsToLibrary:n,setPastedTextLength:r,updateInlineCitations:l}=this.options;return[new $.k_({key:new $.hs("customPasteHandler"),props:{transformPastedHTML:e=>(function(e){try{let t=new DOMParser().parseFromString(e,"text/html"),n=t.body;return Array.from(n.querySelectorAll("p")).forEach(e=>{let n=function(e){var t,n;let r=(null!=(t=e.className)?t:"").match(/MsoHeading(\d+)/i);if(!r)return null;let l=parseInt(null!=(n=r[1])?n:"",10);return l>=1&&l<=6?l:null}(e);if(n){let r=t.createElement("h".concat(n));r.innerHTML=e.innerHTML,e.replaceWith(r)}}),!function(e,t){let n=0;for(;n<e.children.length;){let r=e.children[n];if(!r){n++;continue}let l=eo(r);if(!l){n++;continue}let a=[],o=n;for(;o<e.children.length;){let t=e.children[o];if(t&&eo(t)!==l)break;a.push(t),o++}let i=t.createElement("bullet"===l?"ul":"ol");for(let n of(e.insertBefore(i,r),a))i.appendChild(function(e,t){let n=t.createElement("li"),r=e.cloneNode(!0);r.querySelectorAll("[style]").forEach(e=>{var t;(null!=(t=e.getAttribute("style"))?t:"").includes("mso-list:Ignore")&&e.remove()});let l=t.createTreeWalker(r,NodeFilter.SHOW_TEXT).nextNode();if(l){var a;l.textContent=(null!=(a=l.textContent)?a:"").replace(/^\s*[•·◦▸▪▫●○■□]\s+/,"")}return n.innerHTML=r.innerHTML,n}(n,t)),n.remove();n++}}
1(n,t),n.querySelectorAll("p").forEach(e=>{var t,n,r,l;let a=1===e.children.length&&(null==(t=e.children[0])?void 0:t.tagName)==="BR"&&!(null==(n=e.textContent)?void 0:n.trim());(null==(l=e.textContent)||null==(r=l.replace(/\u00a0/g,""))?void 0:r.trim())&&!a||e.remove()}),n.innerHTML}catch(t){return console.error("TipTap Error: Error transforming pasted HTML, falling back to original"),e}})(e),handlePaste:(o,i,s)=>{var c,d,u,p;let h=i.clipboardData,m=null==h?void 0:h.getData("text/html"),g=null==h?void 0:h.getData("text/plain"),f=null==h?void 0:h.getData("application/x-custom-attributes"),{state:x}=o,{tr:b,selection:C}=x,{from:v}=C;if(!g)return;let y=el(g||""),w=y>0&&y<=500;null==r||r(y);let j=e=>{w&&ea(e,v,e.selection.to),this.editor.view.dispatch(e)};if(!m&&!f&&(null==g?void 0:g.trim())){let e=o.state.schema.marks[et.G2];if(e){let{from:t}=o.state.selection,n=o.state.tr;return n.replaceSelection(s),er(n,s,t,e,!1),j(n),!0}return!1}let I=new DOMParser().parseFromString(null!=m?m:"","text/html"),k={};if(f)k=JSON.parse(null!=f?f:"");else{let e=I.querySelector('[data-insertion-type="ai-generated"]');e&&(k={reqId:null!=(d=e.getAttribute("data-req-id"))?d:void 0,featureName:null!=(u=e.getAttribute("data-feature-name"))?u:void 0,"data-insertion-type":"ai-generated"})}let E=null!=(p=null==(c=this.editor.storage[a.A.PAPERPAL_CITATION])?void 0:c.citationStyle)?p:"apa",N=(e,t)=>{if(k){let r="true"===k["data-is-copied-from-editor"],l="ai-generated"===k["data-insertion-type"]||"ai-generated"===k.insertionType;if(r)return b;let a=this.editor.schema.marks[et.Vi],o=this.editor.schema.marks[et.G2];if(a&&l){let n={"data-insertion-type":"ai-generated","data-req-id":k.reqId,"data-feature-name":k.featureName};b.addMark(e,t,a.create(n))}if(o&&!l){var n;let r={"data-insertion-type":"copied","data-copy-source":null!=(n=k["data-copy-source"])?n:"unknown"};try{b.addMark(e,t,o.create(r))}catch(e){console.error("Failed to apply mark:",JSON.stringify(e))}}}return b},S=(()=>{let e=I.querySelectorAll("#paperpal-research-cite-citation");return 0===e.length?null:{uniqueSourceDocIds:Array.from(new Set(Array.from(e).flatMap(e=>{var t,n;
1return null!=(n=null==(t=e.getAttribute("data-id-paperpal"))?void 0:t.split(";"))?n:[]}))),uniquePaperArticleResponses:Array.from(new Set(Array.from(e).map(e=>e.getAttribute("data-article-response")).filter(Boolean))).map(e=>e?JSON.parse((0,en.hb)(e)):null).filter(Boolean).flatMap(e=>Array.isArray(e)?e:[e])}})();if(S){let{uniqueSourceDocIds:r,uniquePaperArticleResponses:a}=S;r.length>0&&t(null!=e?e:"",r),a.length>0&&n(a),b.replaceSelection(s);let o=N(v,v+s.size);return l({editor:this.editor,transaction:o,citationStyle:E}).then(e=>{j(null!=e?e:o)}),!0}let T=I.querySelector("#paperpal-chat-pdf-citation, #paperpal-library-citation"),A=null==T?void 0:T.getAttribute("data-id-paperpal");if(A&&T){b.replaceSelection(s);let e=N(v,v+s.size);return l({editor:this.editor,transaction:e,citationStyle:E}).then(t=>{j(null!=t?t:e)}),!0}let R=Array.from(new Set(Array.from(I.querySelectorAll('[data-type="'.concat(a.A.PAPERPAL_CITATION,'"]'))).flatMap(e=>{var t,n;return null!=(n=null==(t=e.getAttribute("data-id-paperpal"))?void 0:t.split(";"))?n:[]})));if(R.length>0){t(null!=e?e:"",R),b.replaceSelection(s);let n=N(v,v+s.size);return l({editor:this.editor,transaction:n,citationStyle:E}).then(e=>{j(null!=e?e:n)}),!0}let M=()=>{var n,r,l;A&&t(null!=e?e:"",A),null==(l=I.getElementById("citation-reference"))||l.remove(),this.editor.commands.insertContent(I.body.innerHTML);let{to:a}=this.editor.state.selection;this.editor.chain().setTextSelection({from:v,to:a}).setAiInsertMark({"data-insertion-type":"ai-generated","data-req-id":null!=(n=k.reqId)?n:"","data-feature-name":null!=(r=k.featureName)?r:""}).run()};if(A&&"apa"!==E){b.replaceSelection(s);let e=N(v,v+s.size);return l({editor:this.editor,transaction:e,citationStyle:E}).then(t=>{j(null!=t?t:e)}).catch(()=>{M()}),!0}if(A&&"apa"===E)return M(),!0;b.replaceSelection(s);let L=N(v,v+s.size),D=this.editor.schema.marks[et.G2];return m&&(null===f||"true"===k["data-is-copied-from-editor"])&&D&&(L=er(L,s,v,D,"true"===k["data-is-copied-from-editor"])),j(L),!0}}})]}});var es=n(30420);new $.hs("decorateLanguageSuggestions");let ec=new $.hs("decorateLanguageSuggestionPlugin"),ed=l.YY.create({name:"decorateLanguageSuggestions",addOptions:()=>({decorationClass:"search-result",disableRegex:!0}),addStorage:()=>({suggestions:[]}),addCommands:()=>({setDecoration:e=>t=>{let{editor:n}=t;return n.storage.decorateLanguageSuggestions.suggestions=e,!1}}),addProseMirrorPlugins(){let{handleRedirect:e}=this.options,t=this.editor;return[new $.k_({key:ec,state:{init:()=>K.zF.empty,apply(e,n,r,l){let{suggestions:o}=t.storage.decorateLanguageSuggestions;var i=l,s=t.view,c=o;let{doc:d}=i,u=[];return c?(d.descendants((e,t)=>{var n,r,l;if(!e.isText&&!e.textContent)return;let o={text:"",citations:[]};for(let t of null!=(n=e.children)?n:[])t.isText?o.text+=null!=(l=t.text)?l:"":t.type.name===a.A.PAPERPAL_CITATION&&(null==(r=t.attrs)?void 0:r.label)&&(o.text+=(0,en.hb)(t.attrs.label),o.citations.find(e=>e.attrs.label===t.attrs.label)||o.citations.push(t.toJSON()));let i=o.citations.map(e=>(0,en.hb)(e.attrs.label)),s=i.reduce((e,t)=>e.split(t).join(""),o.text);c.filter(e=>e.text&&o.text.includes(e.text)).map(e=>{var t;let n=o.citations.filter(t=>{var n;let r=(0,en.hb)(t.attrs.label);return(null==(n=e.text)?void 0:n.includes(r))&&""!==r}).map(e=>({text:(0,en.hb)(e.attrs.label),html:""})),r=(0,es.B)(null!=(t=e.text)?t:"",e.languageSuggestions,n);return{...e,newUpdatedText:r.updatedSentence,languageSuggestions:r.updatedSuggestions}}).forEach(e=>{if(!(null==e?void 0:e.newUpdatedText)||!o||!(null==e?void 0:e.text))return;let n=e.newUpdatedText,r=o.text.indexOf(e.text),l=o.text.substring(0,r),a=i.reduce((e,t)=>{let n=l.split(t).length-1;return e+(n>0?n:0)},0),c=s.indexOf(n);for(;-1!==c;){var d;null==(d=e.languageSuggestions)||d.forEach(e=>{let n=t+c+e.start+1+a,r=t+c+e.end+1+a;u.push(K.NZ.inline(n,r,{class:"suggestion-highlighted",nodeName:"paperpal-".concat(e.id),attributes:"paperpal-".concat(e.id)}))}),c=s.indexOf(n,c+n.length)}})}),K.zF.create(d,u)):K.zF.empty}},props:{decorations(e){return this.getState(e)},handleDOMEvents:{click(t,n){var r;return null!=n&&null!=(r=n.target)&&!!r.closest(".suggestion-highlighted")&&(e&&e("language"),!0)}}}})]}});var eu=n(6359);let ep=l.CU.create({name:eu.YT,inclusive:!1,addOptions:()=>({HTMLAttributes:{},onClick:null}),addAttributes:()=>({ppref:{default:null,parseHTML:e=>e.getAttribute("data-ppref"),renderHTML:e=>e.ppref?{"data-ppref":e.ppref}:{}}}),parseHTML:()=>[{tag:"span[data-inline-citation]"}],renderHTML(e){let{HTMLAttributes:t}=e;return["span",(0,l.KV)(this.options.HTMLAttributes,t,{"data-inline-citation":"",class:"inline-citation",contenteditable:"false"}),0]},addCommands(){var e=this;return{setInlineCitation:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let{commands:r}=n;return r.setMark(e.name,t)}},toggleInlineCitation:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let{commands:r}=n;return r.toggleMark(e.name,t)}},unsetInlineCitation:()=>e=>{let{commands:t}=e;return t.unsetMark(this.name)}}},addProseMirrorPlugins:()=>[new $.k_({key:new $.hs("inlineCitationClick"),props:{}})]});var eh=n(844);let em=l.CU.create({name:eu.Gw,inclusive:!1,addOptions:()=>({HTMLAttributes:{},onClick:null}),addAttributes:()=>({label:{default:"",parseHTML:e=>e.getAttribute("data-label")||"",renderHTML:e=>e.label?{"data-label":e.label}:{}}}),parseHTML:()=>[{tag:"span[data-inline-failed-citation]"}],renderHTML(e){let{HTMLAttributes:t}=e;return["span",(0,l.KV)(this.options.HTMLAttributes,t,{"data-inline-failed-citation":"",class:"inline-failed-citation"}),0]},addCommands(){var e=this;return{setFailedInlineCitation:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let{commands:r}=n;return r.setMark(e.name,t)}},toggleFailedInlineCitation:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let{commands:r}=n;return r.toggleMark(e.name,t)}},unsetFailedInlineCitation:()=>e=>{let{commands:t}=e;return t.unsetMark(this.name)}}},addProseMirrorPlugins(){let{onClick:e}=this.options;return[new $.k_({key:new $.hs("failedInlineCitationClick"),props:{handleClick:(t,n,r)=>{let l=r.target;if(!(l instanceof HTMLElement))return!1;let a=l.closest("[data-inline-failed-citation]");if(!a)return!1;"function"==typeof e&&e(r);let{state:o,dispatch:i}=t,s=o.schema.marks[this.name];if(!s)return!1;let c=null,d=null;return o.doc.descendants((e,n)=>{if(null!==c)return!1;if(e.isText&&s.isInSet(e.marks)){let r=t.nodeDOM(n),l=r instanceof HTMLElement?r:null==r?void 0:r.parentElement;if(l&&(l===a||a.contains(l)||l.contains(a)))return c=n,d=n+e.nodeSize,!1}}),null!==c&&null!==d&&(i(o.tr.setSelection($.U3.create(o.doc,c,d))),(0,eh.ku)(this.editor),requestAnimationFrame(()=>{this.editor.commands.showCiteMenu()}),!1)}}})]}});var eg=n(64451),ef=n(79002);function ex(e){let{editor:t,node:n,updateAttributes:l,getPos:a}=e,o=n.content.size>0;return(0,r.jsx)(eb,{src:n.attrs.src,alt:n.attrs.alt||"",editor:t,align:n.attrs["data-align"],initialWidth:n.attrs.width,showCaption:n.attrs.showCaption,hasContent:o,nodeSize:n.nodeSize,onImageResize:e=>l({width:e}),onUpdateAttributes:l,getPos:a})}n(5675);let eb=e=>{let{src:t,alt:n="",editor:l,minWidth:a=96,maxWidth:o=800,align:i="left",initialWidth:s,showCaption:c=!1,hasContent:d=!1,nodeSize:u,onImageResize:p,onUpdateAttributes:m,getPos:g}=e,[f,x]=(0,h.useState)(),[b,C]=(0,h.useState)(s),[v,y]=(0,h.useState)(!1),w=(0,h.useRef)(!1),j=(0,h.useRef)(null),I=(0,h.useRef)(null),k=(0,h.useRef)(null),E=(0,h.useRef)(null);(0,h.useEffect)(()=>
1{if(!l||!c)return;let e=()=>{let e=g();if(!(0,eg.u1)(e)||!u)return;let{from:t,to:n}=l.state.selection,r=e+u;(n<e||t>r)&&!d&&m&&m({showCaption:!1})};return l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,c,d,g,u,m]);let N=(0,h.useCallback)(e=>{if(!l||!g||f)return;e.preventDefault(),e.stopPropagation();let t=g();(0,eg.u1)(t)&&l.chain().focus().setNodeSelection(t).run()},[l,g,f]),S=(0,h.useCallback)(e=>{var t,n,r,s;if(!f||!l)return;let c="touches"in e?null!=(s=null==(t=e.touches[0])?void 0:t.clientX)?s:0:e.clientX,d="left"===f.handleUsed,u="center"===i?2:1,p=d?(f.initialClientX-c)*u:(c-f.initialClientX)*u,h=Math.min(Math.max(f.initialWidth+p,a),(null==(r=l.view.dom)||null==(n=r.firstElementChild)?void 0:n.clientWidth)||o);C(h),j.current&&(j.current.style.width="".concat(h,"px"))},[l,i,o,a,f]),T=(0,h.useCallback)(e=>{var t,n,r,a,o;if(!l)return;let i="touches"in e?document.elementFromPoint(null!=(a=null==(t=e.changedTouches[0])?void 0:t.clientX)?a:0,null!=(o=null==(n=e.changedTouches[0])?void 0:n.clientY)?o:0):e.target;if(i&&(null==(r=j.current)?void 0:r.contains(i))&&l.isEditable||!v||y(!1),!f)return;let s=l.state.selection instanceof $.nh&&"image"===l.state.selection.node.type.name;x(void 0),null==p||p(b);let c=g();(0,eg.u1)(c)&&s&&l.chain().focus().setNodeSelection(c).run(),w.current=!1},[l,g,p,f,v,b]),A=(0,h.useCallback)((e,t)=>{var n,r;x({handleUsed:e,initialWidth:null!=(r=null==(n=j.current)?void 0:n.clientWidth)?r:a,initialClientX:t}),w.current=!0},[a]);(0,h.useEffect)(()=>(window.addEventListener("mousemove",S),window.addEventListener("mouseup",T),window.addEventListener("touchmove",S,{passive:!1}),window.addEventListener("touchend",T),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",T),window.removeEventListener("touchmove",S),window.removeEventListener("touchend",T)}),[S,T]);let R=c||d;return(0,r.jsx)(ef.VR,{onMouseEnter:()=>{(null==l?void 0:l.isEditable)&&y(!0)},onMouseLeave:e=>{e.relatedTarget!==I.current&&e.relatedTarget!==k.current&&!f&&(null==l?void 0:l.isEditable)&&y(!1)},onTouchStart:()=>{(null==l?void 0:l.isEditable)&&y(!0)},"data-align":i,"data-width":b,className:"tiptap-image",children:(0,r.jsxs)("div",{ref:j,className:"tiptap-image-container",style:{width:b?"".concat(b,"px"):"fit-content"},children:[(0,r.jsxs)("div",{className:"tiptap-image-content",children:[(0,r.jsx)("img",{ref:E,src:t,alt:null!=n?n:"img",className:"tiptap-image-img",contentEditable:!1,draggable:!1,onClick:N,loading:"lazy",style:{cursor:(null==l?void 0:l.isEditable)?"pointer":"default"}}),v&&(null==l?void 0:l.isEditable)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:I,className:"tiptap-image-handle tiptap-image-handle-left",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),A("left",e.clientX)},onTouchStart:e=>{e.preventDefault();let t=e.touches[0];t&&A("left",t.clientX)}}),(0,r.jsx)("div",{ref:k,className:"tiptap-image-handle tiptap-image-handle-right",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),A("right",e.clientX)},onTouchStart:e=>{e.preventDefault();let t=e.touches[0];t&&A("right",t.clientX)}})]})]}),(null==l?void 0:l.isEditable)&&R&&(0,r.jsx)(ef.$p,{as:"div",className:"tiptap-image-caption","data-placeholder":"Add a caption..."})]})})};var eC=n(47944);let ev=e=>({src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:e.getAttribute("width"),height:e.getAttribute("height")}),ey=eC._V.extend({content:"inline*",addAttributes(){var e;return{...null==(e=this.parent)?void 0:e.call(this),"data-align":{default:null},showCaption:{default:!1,parseHTML:e=>"FIGURE"===e.tagName||"true"===e.getAttribute("data-show-caption"),renderHTML:e=>e.showCaption?{"data-show-caption":"true"}:{}}}},parseHTML:()=>[{tag:"figure",getAttrs:e=>{let t=e.querySelector("img");return!!t&&{...ev(t),"data-align":e.getAttribute("data-align"),showCaption:!0}},contentElement:"figcaption"},{tag:"img[src]",getAttrs:e=>!e.closest("figure")&&{...ev(e),"data-align":e.getAttribute("data-align"),showCaption:!1}}],renderHTML(e){let{node:t}=e,{src:n,alt:r,title:l,width:a,height:o,showCaption:i}=t.attrs,s=t.attrs["data-align"],c=function(e){let t={src:e.src||""};return e.alt&&(t.alt=e.alt),e.title&&(t.title=e.title),e.width&&(t.width=e.width),e.height&&(t.height=e.height),t}({src:n,alt:r,title:l,width:a,height:o}),d=t.content.size>0;if(i||d){let e={"data-url":n||""};return i&&(e["data-show-caption"]="true"),s&&(e["data-align"]=s),["figure",e,["img",c],["figcaption",{},0]]}return s&&(c["data-align"]=s),["img",c]},addKeyboardShortcuts(){return{"Mod-a":e=>{let{editor:t}=e,{state:n,view:r}=t,{selection:l}=n,{$from:a}=l,o=null,i=null;for(let e=a.depth;e>=0;e--){let t=a.node(e);if(t.type===this.type){i=t,o=0===e?0:a.before(e);break}}if(!i||null===o||0===i.content.size||0===i.textContent.length)return!1;let s=o+1,c=o+i.nodeSize-1,d=n.tr.setSelection($.U3.create(n.doc,s,c));return r.dispatch(d),!0}}},addNodeView:()=>(0,ef.gu)(ex,{stopEvent:e=>{let{event:t}=e;return!/dragstart|dragover|dragend|drop/.test(t.type)&&!/mousedown|drag|drop/.test(t.type)}})});var ew=n(25432);let ej=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})})});ej.displayName="CloseIcon",n(57379);let eI=()=>{let{webApiClient:e}=(0,P.p)(),t=async t=>{let{documentId:n,file:r}=t,l=new FormData;l.append("file",r);try{return(await e.post("/api/v1/tiptap/images?documentId=".concat(n),l)).url}catch(e){throw console.error("Failed to upload image:",e),Error("Failed to upload image")}},{mutateAsync:n,isLoading:r,isError:l,error:a}=(0,A.useMutation)({mutationFn:t});return{upload:n,isLoading:r,isError:l,error:a}},ek=()=>(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.435
178 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),eE=()=>(0,r.jsx)("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),eN=()=>(0,r.jsx)("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),eS=e=>{let{onFile:t,children:n}=e,[l,a]=(0,h.useState)(!1),[o,i]=(0,h.useState)(!1);return(0,r.jsx)("div",{className:"tiptap-image-upload-drag-area mt-[20px]  ".concat(o?"drag-active":""," ").concat(l?"drag-over":""),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),i(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||(i(!1),a(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),a(!0)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),i(!1),a(!1);let n=Array.from(e.dataTransfer.files);n.length>0&&t(n)},children:(0,r.jsx)("div",{className:"bg-gray-2 py-2 px-1",children:n})})},eT=e=>{let{fileItem:t,onRemove:n}=e;return(0,r.jsxs)("div",{className:"tiptap-image-upload-preview",children:["uploading"===t.status&&(0,r.jsx)("div",{className:"tiptap-image-upload-progress",style:{width:"".concat(t.progress,"%")}}),"error"===t.status?(0,r.jsxs)("div",{className:"tiptap-image-upload-preview-content bg-red-4",children:[(0,r.jsxs)("div",{className:"tiptap-image-upload-file-info",children:[(0,r.jsx)("div",{className:"text-red-11",children:(0,r.jsx)(ew.ZE,{className:"w-4 h-4 "})}),(0,r.jsxs)("div",{className:"tiptap-image-upload-details",children:[(0,r.jsx)("span",{className:"tiptap-image-upload-text !text-red-11",children:t.file.name}),(0,r.jsx)("span",{className:"tiptap-image-upload-subtext !text-red-11",children:"Upload Failed. Please try again with a different file or contact support if the issue persists."})]})]}),(0,r.jsx)("div",{className:"tiptap-image-upload-actions",children:(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",onClick:e=>{e.stopPropagation(),n()},children:(0,r.jsx)(ej,{className:"tiptap-button-icon"})})})]}):(0,r.jsxs)("div",{className:"tiptap-image-upload-preview-content",children:[(0,r.jsxs)("div",{className:"tiptap-image-upload-file-info",children:[(0,r.jsx)("div",{className:"tiptap-image-upload-file-icon",children:(0,r.jsx)(ek,{})}),(0,r.jsxs)("div",{className:"tiptap-image-upload-details",children:[(0,r.jsx)("span",{className:"tiptap-image-upload-text",children:t.file.name}),(0,r.jsx)("span",{className:"tiptap-image-upload-subtext",children:(e=>{if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return"".concat(parseFloat((e/Math.pow(1024,t)).toFixed(2))," ").concat(["Bytes","KB","MB","GB"][t])})(t.file.size)})]})]}),(0,r.jsxs)("div",{className:"tiptap-image-upload-actions",children:["uploading"===t.status&&(0,r.jsxs)("span",{className:"tiptap-image-upload-progress-text",children:[t.progress,"%"]}),(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",onClick:e=>{e.stopPropagation(),n()},children:(0,r.jsx)(ej,{className:"tiptap-button-icon"})})]})]})]})},eA=()=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"tiptap-image-upload-dropzone",children:[(0,r.jsx)(eE,{}),(0,r.jsx)(eN,{}),(0,r.jsx)("div",{className:"tiptap-image-upload-icon-container",children:(0,r.jsx)(ek,{})})]}),(0,r.jsx)("div",{className:"tiptap-image-upload-content",children:(0,r.jsxs)("span",{className:"tiptap-image-upload-text",children:[(0,r.jsx)("em",{children:"Upload"})," or drag and drop"]})})]}),eR=e=>{let{accept:t,limit:n,maxSize:l}=e.node.attrs,a=(0,h.useRef)(null),o=e.extension,{fileItems:i,uploadFiles:s,removeFileItem:c,clearAllFiles:u}=function(e){let[t,n]=(0,h.useState)([]),{upload:r}=eI(),{documentId:l}=g(),a=async t=>{var a,o,i;if(t.size>e.maxSize){let t=Error("File size exceeds maximum allowed (".concat(e.maxSize/1024/1024,"MB)"));return null==(a=e.onError)||a.call(e,t),null}let s=new AbortController,c=crypto.randomUUID(),d={id:c,file:t,progress:0,status:"uploading",abortController:s};n(e=>[...e,d]);let u=setInterval(()=>{n(e=>e.map(e=>e.id===c&&e.progress<90?{...e,progress:Math.min(e.progress+5,90)}:e))},500);try{if(!e.upload)throw Error("Upload function is not defined");let a=await r({documentId:l,file:t});if(!a)throw Error("Upload failed: No URL returned");
1if(clearInterval(u),!s.signal.aborted)return n(e=>e.map(e=>e.id===c?{...e,status:"success",url:a,progress:100}:e)),null==(o=e.onSuccess)||o.call(e,a),a;return null}catch(t){return clearInterval(u),s.signal.aborted||(n(e=>e.map(e=>e.id===c?{...e,status:"error",progress:0}:e)),null==(i=e.onError)||i.call(e,t instanceof Error?t:Error("Upload failed"))),null}};return{fileItems:t,uploadFiles:async t=>{var n,r;if(!t||0===t.length)return null==(n=e.onError)||n.call(e,Error("No files to upload")),[];if(e.limit&&t.length>e.limit)return null==(r=e.onError)||r.call(e,Error("Maximum ".concat(e.limit," file").concat(1===e.limit?"":"s"," allowed"))),[];let l=t.map(e=>a(e));return(await Promise.all(l)).filter(e=>null!==e)},removeFileItem:e=>{n(t=>{let n=t.find(t=>t.id===e);return(null==n?void 0:n.abortController)&&n.abortController.abort(),(null==n?void 0:n.url)&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)})},clearAllFiles:()=>{t.forEach(e=>{e.abortController&&e.abortController.abort(),e.url&&URL.revokeObjectURL(e.url)}),n([])}}}({maxSize:l,limit:n,accept:t,upload:o.options.upload,onSuccess:o.options.onSuccess,onError:o.options.onError}),p=async t=>{let n=await s(t);if(n.length>0){let r=e.getPos();if((0,eg.u1)(r)){let l=n.map((e,n)=>{var r;let l=(null==(r=t[n])?void 0:r.name.replace(/\.[^/.]+$/,""))||"unknown";return{type:o.options.type,attrs:{...o.options,src:e,alt:l,title:l}}});e.editor.chain().focus().deleteRange({from:r,to:r+e.node.nodeSize}).insertContentAt(r,l).run(),(0,eg.A8)(e.editor)}}},m=i.length>0;return(0,r.jsxs)(ef.VR,{className:"tiptap-image-upload",tabIndex:0,onClick:()=>{a.current&&0===i.length&&(a.current.value="",a.current.click())},children:[!m&&(0,r.jsx)(eS,{onFile:p,children:(0,r.jsx)(eA,{maxSize:l,limit:n})}),m&&(0,r.jsxs)("div",{className:"tiptap-image-upload-previews",children:[i.length>1&&(0,r.jsxs)("div",{className:"tiptap-image-upload-header",children:[(0,r.jsxs)("span",{children:["Uploading ",i.length," files"]}),(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",onClick:e=>{e.stopPropagation(),u()},children:"Clear All"})]}),i.map(e=>(0,r.jsx)(eT,{fileItem:e,onRemove:()=>c(e.id)},e.id))]}),(0,r.jsx)("input",{ref:a,name:"file",accept:t,type:"file",multiple:n>1,onChange:e=>{let t=e.target.files;if(!t||0===t.length){var n,r;null==(n=(r=o.options).onError)||n.call(r,Error("No file selected"));return}p(Array.from(t))},onClick:e=>e.stopPropagation()})]})},eM=l.bP.create({name:"imageUpload",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions:()=>({type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}),addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML:()=>[{tag:'div[data-type="image-upload"]'}],renderHTML(e){let{HTMLAttributes:t}=e;return["div",(0,l.KV)({"data-type":"image-upload"},t)]},addNodeView:()=>(0,ef.gu)(eR),addCommands(){return{setImageUploadNode:e=>t=>{let{commands:n}=t;return n.insertContent({type:this.name,attrs:e})}}},addKeyboardShortcuts:()=>({Enter:e=>{let{editor:t}=e,{selection:n}=t.state,{nodeAfter:r}=n.$from;if(r&&"imageUpload"===r.type.name&&t.isActive("imageUpload")){let e=t.view.nodeDOM(n.$from.pos);if(e&&e instanceof HTMLElement){let t=e.firstChild;if(t&&t instanceof HTMLElement)return t.click(),!0}}return!1}})}),eL=["boxSizing","backgroundColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","color","font","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textTransform","textDecoration","textAlign","verticalAlign","whiteSpace","width","minWidth","maxWidth","height","minHeight","maxHeight","backgroundClip"],eD=e=>e.replace(/[A-Z]/g,e=>"-".concat(e.toLowerCase()));function e_(e){let t=e.cloneNode(!0),n=[{src:e,dst:t}];for(;n.length;){let{src:e,dst:t}=n.shift();e instanceof HTMLElement&&t instanceof HTMLElement&&function(e,t){let n=getComputedStyle(e);for(let e of eL){let r=String(e),l=n.getPropertyValue(eD(r));l&&(t.style[r]=l)}t.style.overflow="hidden",t.style.textOverflow="ellipsis",(""===n.whiteSpace||"normal"===n.whiteSpace)&&(t.style.whiteSpace="nowrap")}(e,t);let r=Array.from(e.children),l=Array.from(t.children),a=Math.min(r.length,l.length);for(let e=0;e<a;e++){let t=r[e],a=l[e];t&&a&&n.push({src:t,dst:a})}}return t}function eH(e,t){let n=getComputedStyle(e);t.style.borderCollapse=n.borderCollapse,t.style.borderSpacing=n.borderSpacing,t.style.tableLayout="fixed",t.className=e.className}function eP(e,t){let n=e.getBoundingClientRect();n.width>0&&(t.style.width="".concat(n.width,"px"),t.style.maxWidth="".concat(n.width,"px"))}var eO=n(72904),ez=n(75373);let eB={cells:[],mergedCells:[]};function eF(e){return e instanceof HTMLElement}function eV(e,t){var n,r;return null!=(r=null==e||null==(n=e.closest)?void 0:n.call(e,t))?r:null}function eU(e){let t=e;for(;t&&"TD"!==t.tagName&&"TH"!==t.tagName&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;t=eF(t.parentNode)?t.parentNode:null}if(t)return"TD"===t.tagName||"TH"===t.tagName?{type:"cell",domNode:t,tbodyNode:eV(t,"tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function eW(e,t,n){return Math.max(t,Math.min(e,n))}function eG(e,t,n){return e>=0&&e<n.height&&t>=0&&t<n.width}function eZ(e,t,n,r){if(!e)return eB;let{state:l}=e,a=e$(e,r);if(!a)return eB;let o=a.start,i=a.node,s=a.map,c=function(e,t,n,r){var l;if("number"==typeof r)return r;if(e.selection instanceof eO.rn){let t=(0,eO._t)(e);return"row"===n?t.top:t.left}let a=null!=(l=(0,eO.KW)(e.selection.$anchor))?l:(0,eO.t6)(e);if(!a)return null;let o=a.pos-t.start,i=t.map.findCell(o);return"row"===n?i.top:i.left}(l,a,t,n);if(null===c)return eB;let d="row"===t?s.height:s.width;if(c<0||c>=d)return eB;let u=[],p=[],h=new Set,m="row"===t?s.width:s.height;for(let e=0;e<m;e++){let n="row"===t?c:e,r="row"===t?e:c,l=n*s.width+r,a=s.map[l];if(void 0===a)continue;let d=o+a,m=i.nodeAt(a);if(!m)continue;let g={row:n,column:r,pos:d,node:m,start:d+1,depth:m?m.content.size:0};(function(e){var t,n;if(!e)return!1;let r=null!=(t=e.attrs.colspan)?t:1,l=null!=(n=e.attrs.rowspan)?n:1;return r>1||l>1})(m)&&!h.has(d)&&(p.push(g),h.add(d)),u.push(g)}return{cells:u,mergedCells:p}}function eq(e,t,n){let r=e$(e,t);if(!r)return 0;let{doc:l}=e.state,a="row"===n?r.map.height:r.map.width,o=0;for(let e=a-1;e>=0;e--){let a=new Set,i=!0,s="row"===n?r.map.width:r.map.height;for(let o=0;o<s;
1o++){let s="row"===n?e:o,c="row"===n?o:e,d=r.map.positionAt(s,c,r.node);if(a.has(d))continue;a.add(d);let u=t+1+d,p=l.nodeAt(u);if(p&&!eX(p)){i=!1;break}}if(i)o++;else break}return o}function e$(e,t){if(!e)return null;let n=null;if("number"==typeof t){let r=e.state.doc.nodeAt(t);(null==r?void 0:r.type.name)==="table"&&(n={node:r,pos:t,start:t+1,depth:e.state.doc.resolve(t).depth})}if(!n)return null;let r=eO.J3.get(n.node);return r?{...n,map:r}:null}function eK(e,t){let{width:n,height:r,map:l}=e,a=t.top*n+t.left,o=a,i=(t.bottom-1)*n+t.left,s=a+(t.right-t.left-1);for(let e=t.top;e<t.bottom;e++){if(t.left>0&&l[o]===l[o-1]||t.right<n&&l[s]===l[s+1])return!0;o+=n,s+=n}for(let e=t.left;e<t.right;e++){if(t.top>0&&l[a]===l[a-n]||t.bottom<r&&l[i]===l[i+n])return!0;a++,i++}return!1}function eY(e,t){let n=e.view,r=n.state.selection,l=r.getBookmark(),a=new ez.X9,o=n.dispatch;n.dispatch=e=>{a.appendMapping(e.mapping),o(e)};try{t()}finally{n.dispatch=o}try{let e=l.map(a).resolve(n.state.doc);return n.dispatch(n.state.tr.setSelection(e)),!0}catch(l){let e=eW(a.map(r.from,-1),0,n.state.doc.content.size),t=$.LN.near(n.state.doc.resolve(e),-1);return n.dispatch(n.state.tr.setSelection(t)),!1}}function eX(e){if(0===e.childCount)return!0;let t=!0;return e.descendants(e=>{var n;return!(e.isText&&(null==(n=e.text)?void 0:n.trim()))&&(!e.isLeaf||!!e.isText)||(t=!1,!1)}),t}function eJ(e,t,n,r){if("number"==typeof t&&n)return{orientation:n,index:t};if(!e)return null;let{state:l}=e;if(!e$(e,r))return null;if(l.selection instanceof eO.rn){let e=(0,eO._t)(l),t=e.right-e.left,n=e.bottom-e.top;if(1===n&&t>=1)return{orientation:"row",index:e.top};if(1===t&&n>=1)return{orientation:"column",index:e.left}}return null}function eQ(e,t,n,r){let l={cells:[],mergedCells:[],index:void 0,orientation:void 0,tablePos:void 0};if(!e||"number"!=typeof t&&!(e.state.selection instanceof eO.rn))return l;let a=t,o=n;if("number"!=typeof a||!o||!["row","column"].includes(o)){let t=eJ(e);if(!t)return l;a=t.index,o=t.orientation}return{...eZ(e,o,a,r),index:a,orientation:o}}function e0(e,t,n){return eZ(e,"column",t,n)}function e1(e,t,n,r){try{let l=e$(e,r);if(!l)return;let{state:a}=e,{map:o}=l;if("row"===t){if(n>=0&&n<o.height){let t=o.width-1,r=l.start+o.positionAt(n,0,l.node),i=l.start+o.positionAt(n,t,l.node),s=a.doc.resolve(r),c=a.doc.resolve(i),d=eO.rn.create(a.doc,s.pos,c.pos),u=a.tr.setSelection(d);e.view.dispatch(u)}}else if("column"===t&&n>=0&&n<o.width){let t=o.height-1,r=l.start+o.positionAt(0,n,l.node),i=l.start+o.positionAt(t,n,l.node),s=a.doc.resolve(r),c=a.doc.resolve(i),d=eO.rn.create(a.doc,s.pos,c.pos),u=a.tr.setSelection(d);e.view.dispatch(u)}}catch(e){console.warn("Failed to update selection after move:",e)}}function e2(e,t){return!e&&!t||!!e&&!!t&&e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function e4(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{mode:"state"};if(!e)return;let l=e$(e,t);if(!l)return;let{state:a}=e,o=l.map,i=n.map(e=>({row:eW(e.row,0,o.height-1),col:eW(e.col,0,o.width-1)})).filter(e=>eG(e.row,e.col,o));if(0===i.length)return;let s=i.map(e=>e.row),c=Math.min(...s),d=Math.max(...s),u=i.map(e=>e.col),p=Math.min(...u),h=Math.max(...u),m=(e,n)=>{let r=o.map[e*o.width+n];return void 0===r?null:t+1+r},g=m(c,p);if(null===g)return;let f=m(d,h);if(null!==f){if(f===g){let e=!1;for(let t=d;t>=c&&!e;t--)for(let n=h;n>=p&&!e;n--){let r=m(t,n);null!==r&&r!==g&&(f=r,e=!0)}}try{let e=a.doc.resolve(g),t=a.doc.resolve(f),n=new eO.rn(e,t),l=a.tr.setSelection(n);var x,b=a,C=l,v=r;switch(null!=(x=v.mode)?x:"state"){case"dispatch":"function"==typeof v.dispatch&&v.dispatch(C);return;case"transaction":return C;default:return b.apply(C)}}catch(e){console.error("Failed to create cell selection:",e);return}}}function e5(e,t,n,r){let l=eO.J3.get(t),a="row"===r,o=a?l.height-1:0,i=a?0:l.width-1,s=o*l.width+i,c=l.map[s];if(!c&&0!==c)return console.warn("selectLastCell: cell position not found in map",{index:s,row:o,col:i,map:l}),!1;let d=l.map.indexOf(c);return function(e){let{editor:t,row:n,col:r,tablePos:l,dispatch:a}=e;if(!t)return!1;let{state:o,view:i}=t,s=e$(t,l);if(!s||!eG(n,r,s.map))return!1;let c=s.map.positionAt(n,r,s.node),d=s.start+c,u=o.doc.resolve(d),p=(0,eO.KW)(u),h=p?p.pos:d,m=eO.rn.create(o.doc,h),g=null!=a?a:null==i?void 0:i.dispatch;return!!g&&(g(o.tr.setSelection(m)),!0)}({editor:e,row:d>=0?Math.floor(d/l.width):0,col:d>=0?d%l.width:0,tablePos:n,dispatch:e.view.dispatch.bind(e.view)})}function e7(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t)return null;let a=e$(t,l);if(!a)return null;let{map:o}=a,{width:i,height:s}=o;return n<0||"row"===r&&n>=s||"column"===r&&n>=i?null:"row"===r?Array.from({length:o.width},(e,t)=>({row:n,col:t})):Array.from({length:o.height}
1,(e,t)=>({row:t,col:n}))}function e3(e,t,n){if(!t)return null;try{let r=n.view.posAtDOM(e,0),l=n.view.state.doc.resolve(r);for(let e=l.depth;e>0;e--){let n=l.node(e);if("tableCell"===n.type.name||"tableHeader"===n.type.name){let n=eO.J3.get(t),r=l.before(e),a=l.start(e-2),o=r-a,i=n.map.indexOf(o);return{rowIndex:Math.floor(i/n.width),colIndex:i%n.width}}}}catch(e){console.warn("Could not get cell position:",e)}return null}function e9(e){return!!e&&("table"===e.type.name||"table"===e.type.spec.tableRole)}let e6=new $.hs("tableHandlePlugin");class e8{hideHandles(){var e;(null==(e=this.state)?void 0:e.show)&&(this.state={...this.state,show:!1,showAddOrRemoveRowsButton:!1,showAddOrRemoveColumnsButton:!1,colIndex:void 0,rowIndex:void 0,referencePosCell:void 0},this.emitUpdate())}_handleMouseMoveNow(e){var t,n,r,l,a,o,i;let s,c=eU(e.target);if((null==c?void 0:c.type)==="cell"&&"down"===this.mouseState&&!(null==(t=this.state)?void 0:t.draggingState)){this.mouseState="selecting",this.hideHandles();return}if(!c||!this.editor.isEditable)return void this.hideHandles();let d=c.tbodyNode;if(!d)return;let u=d.getBoundingClientRect(),p=this.editor.view.posAtCoords({left:e.clientX,top:e.clientY});if(!p)return;let h=this.editor.view.state.doc.resolve(p.pos);for(let e=h.depth;e>=0;e--){let t=h.node(e);if(e9(t)){s={node:t,pos:0===e?0:h.before(e)};break}}if(!s||"table"!==s.node.type.name)return;this.tableElement=this.editor.view.nodeDOM(s.pos),this.tablePos=s.pos,this.tableId=s.node.attrs.id;let m=eV(c.domNode,".tableWrapper"),g=null==m?void 0:m.querySelector(".table-controls");if("wrapper"===c.type){let t=e.clientY>=u.bottom-1&&e.clientY<u.bottom+20,a=e.clientX>=u.right-1&&e.clientX<u.right+20,o=e.clientX>u.right||e.clientY>u.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:t,showAddOrRemoveColumnsButton:a,referencePosTable:u,block:s.node,blockPos:s.pos,widgetContainer:g,colIndex:o||null==(n=this.state)?void 0:n.colIndex,rowIndex:o||null==(r=this.state)?void 0:r.rowIndex,referencePosCell:o||null==(l=this.state)?void 0:l.referencePosCell}}else{let e=e3(c.domNode,s.node,this.editor);if(!e)return;let{rowIndex:t,colIndex:n}=e,r=c.domNode.getBoundingClientRect(),l=s.node.content.childCount-1,d=(null!=(i=null==(a=s.node.content.firstChild)?void 0:a.content.childCount)?i:0)-1;if((null==(o=this.state)?void 0:o.show)&&this.tableId===s.node.attrs.id&&this.state.rowIndex===t&&this.state.colIndex===n)return;this.state={show:!0,showAddOrRemoveColumnsButton:n===d,showAddOrRemoveRowsButton:t===l,referencePosTable:u,block:s.node,blockPos:s.pos,draggingState:void 0,referencePosCell:r,colIndex:n,rowIndex:t,widgetContainer:g}}return this.emitUpdate(),!1}update(e){var t,n,r;let l=e6.getState(e.state);if(void 0!==l&&l!==this.menuFrozen&&(this.menuFrozen=l),!(null==(t=this.state)?void 0:t.show))return;if(!(null==(n=this.tableElement)?void 0:n.isConnected))return void this.hideHandles();let a=function(e,t){try{let n=t.view.posAtDOM(e,0),r=t.view.state.doc.resolve(n);for(let e=r.depth;e>=0;e--){let t=r.node(e);if(e9(t))return{node:t,pos:0===e?0:r.before(e)}}}catch(e){console.warn("Could not get table from DOM:",e)}return null}(this.tableElement,this.editor);if(!a)return void this.hideHandles();let o=this.state.block!==a.node||this.state.blockPos!==a.pos;if(!a.node||"table"!==a.node.type.name||!(null==(r=this.tableElement)?void 0:r.isConnected))return void this.hideHandles();let{height:i,width:s}=eO.J3.get(a.node),c=this.state.rowIndex,d=this.state.colIndex;void 0!==c&&c>=i&&(c=i?i-1:void 0),void 0!==d&&d>=s&&(d=s?s-1:void 0);let u=this.tableElement.querySelector("tbody");if(!u)throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");let p=this.state.referencePosCell;if(void 0!==c&&void 0!==d){let e=u.children[c],t=null==e?void 0:e.children[d];t?p=t.getBoundingClientRect():(c=void 0,d=void 0,p=void 0)}let h=u.getBoundingClientRect(),m=c!==this.state.rowIndex||d!==this.state.colIndex,g=p!==this.state.referencePosCell||h!==this.state.referencePosTable;(o||m||g)&&(this.state={...this.state,block:a.node,blockPos:a.pos,rowIndex:c,colIndex:d,referencePosCell:p,referencePosTable:h},this.emitUpdate())}destroy(){this.editorView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.editorView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.editorView.root.removeEventListener("dragover",this.dragOverHandler),this.editorView.root.removeEventListener("drop",this.dropHandler)}constructor(e,t,n){this.state=void 0,this.menuFrozen=!1,this.mouseState="up",this.viewMousedownHandler=e=>{this.mouseState="down";let{state:t,view:n}=this.editor;if(!(t.selection instanceof eO.rn)||this.editor.isFocused)return;let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return;let l=t.doc.resolve(r.pos),{nodes:a}=t.schema,o=-1,i=!1;for(let e=l.depth;e>=0;e--){let t=l.node(e);if(i||t.type!==a.tableCell&&t.type!==a.tableHeader||(i=!0),-1===o&&t.type===a.paragraph&&(o=e),i&&-1!==o)break}if(!i||-1===o)return;let s=l.start(o),c=l.end(o),d=$.U3.create(t.doc,s,c);t.selection.eq(d)||(n.dispatch(t.tr.setSelection(d)),n.focus())},this.mouseUpHandler=e=>{this.mouseState="up",this.mouseMoveHandler(e)},this.mouseMoveHandler=e=>{if(this.menuFrozen||"selecting"===this.mouseState)return;let t=e.target;eF(t)&&this.editorView.dom.contains(t)&&this._handleMouseMoveNow(e)},this.dragOverHandler=e=>{var t;if((null==(t=this.state)?void 0:t.draggingState)===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect="move",this.editorView.root.querySelectorAll(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline").forEach(e
1=>{e.style.visibility="hidden"});let{left:n,right:r,top:l,bottom:a}=this.state.referencePosTable,o={left:eW(e.clientX,n+1,r-1),top:eW(e.clientY,l+1,a-1)},i=this.editorView.root.elementsFromPoint(o.left,o.top).filter(e=>"TD"===e.tagName||"TH"===e.tagName);if(0===i.length)return;let s=i[0];if(!eF(s))return;let c=e3(s,this.state.block,this.editor);if(!c)return;let{rowIndex:d,colIndex:u}=c,p="row"===this.state.draggingState.draggedCellOrientation?this.state.rowIndex:this.state.colIndex,h="row"===this.state.draggingState.draggedCellOrientation?d:u,m="row"===this.state.draggingState.draggedCellOrientation?o.top:o.left,g=this.state.rowIndex!==d||this.state.colIndex!==u,f=this.state.draggingState.mousePos!==m;(g||f)&&(this.state={...this.state,rowIndex:d,colIndex:u,referencePosCell:s.getBoundingClientRect(),draggingState:{...this.state.draggingState,mousePos:m}},this.emitUpdate()),h!==p&&this.editor.view.dispatch(this.editor.state.tr.setMeta(e6,!0))},this.dropHandler=()=>{this.mouseState="up";let e=this.state;if(!(null==e?void 0:e.draggingState))return!1;let{draggingState:t,rowIndex:n,colIndex:r,blockPos:l}=e;if(!(0,eg.u1)(l))return!1;if("row"===t.draggedCellOrientation&&void 0===n||"col"===t.draggedCellOrientation&&void 0===r)throw Error("Attempted to drop table row or column, but no table block was hovered prior.");let a="row"===t.draggedCellOrientation,o=e7({editor:this.editor,index:t.originalIndex,orientation:a?"row":"column",tablePos:l});return!!o&&!!e4(this.editor,l,o,{mode:"state"})&&(this.state={...e,draggingState:void 0},this.emitUpdate(),this.editor.view.dispatch(this.editor.state.tr.setMeta(e6,null)),!0)},this.editor=e,this.editorView=t,this.emitUpdate=()=>this.state&&n(this.state),this.editorView.dom.addEventListener("mousemove",this.mouseMoveHandler),this.editorView.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),this.editorView.root.addEventListener("dragover",this.dragOverHandler),this.editorView.root.addEventListener("drop",this.dropHandler)}}let te=null,tt=(e,t)=>{if(!(null==te?void 0:te.state))throw Error("Attempted to drag table ".concat(e,", but no table block was hovered prior."));let{state:n,editor:r}=te,l="col"===e?n.colIndex:n.rowIndex;if(void 0===l)throw Error("Attempted to drag table ".concat(e,", but no table block was hovered prior."));let{blockPos:a,referencePosCell:o}=n,i="col"===e?t.clientX:t.clientY;if(r.state.selection instanceof eO.rn){let e=$.U3.near(r.state.doc.resolve(a),1);r.view.dispatch(r.state.tr.setSelection(e))}let s=function(e,t,n,r){let l=e.view.dom.getBoundingClientRect(),a=Math.max(0,l.width),o=document.createElement("div");Object.assign(o.style,{position:"fixed",top:"-10000px",left:"-10000px",pointerEvents:"none",zIndex:"2147483647",maxWidth:"".concat(a,"px"),borderRadius:"12px",background:"transparent",filter:"drop-shadow(0 8px 24px rgba(0,0,0,0.18)) drop-shadow(0 2px 8px rgba(0,0,0,0.10))",overflow:"hidden"});let i=e.view.nodeDOM(r);if(!i)return document.body.appendChild(o),o;let s=Math.min(i.getBoundingClientRect().width,l.width);o.style.width="".concat(s,"px");let c="row"===t?function(e,t){var n,r,l;let a=null!=(l=null==(n=e.tBodies)?void 0:n[0])?l:e.querySelector("tbody");if(!a)return null;let o=null==(r=a.rows)?void 0:r[t];if(!o)return null;let i=document.createElement("table"),s=document.createElement("tbody"),c=e_(o);eH(e,i);for(let e=0;e<o.cells.length;e++){let t=o.cells[e],n=c.cells[e];n&&eP(t,n)}return s.appendChild(c),i.appendChild(s),i}(i,n):function(e,t){var n,r,l;let a=null!=(r=null==(n=e.tBodies)?void 0:n[0])?r:e.querySelector("tbody");if(!a)return null;let o=document.createElement("table"),i=document.createElement("tbody");eH(e,o);let s=0;for(let e=0;e<a.rows.length;e++){let n=a.rows[e];if(!n)continue;let r=null==(l=n.cells)?void 0:l[t];if(!r)continue;let o=document.createElement("tr"),c=e_(r),d=r.getBoundingClientRect();!s&&d.width>0&&(s=d.width),eP(r,c),o.appendChild(c),i.appendChild(o)}return s>0&&(o.style.width="".concat(s,"px"),o.style.maxWidth="".concat(s,"px")),o.appendChild(i),o}(i,n);if(c){let e=document.createElement("div");Object.assign(e.style,{background:"var(--drag-image-bg, transparent)",overflow:"hidden"}),e.appendChild(c),o.appendChild(e)}o.isConnected||document.body.appendChild(o);let d=o.getBoundingClientRect();if(d.width>a&&d.width>0){let e=a/d.width;o.style.transformOrigin="top left",o.style.transform="scale(".concat(e,")")}return o}(r,e,l,a);if(t.dataTransfer){let n=t.currentTarget.getBoundingClientRect(),r="col"===e?{x:n.width/2,y:0}:{x:0,y:n.height/2};t.dataTransfer.effectAllowed="col"===e?"move":"copyMove",t.dataTransfer.setDragImage(s,r.x,r.y)}let c=()=>{var e;return null==(e=s.parentNode)?void 0:e.removeChild(s)};document.addEventListener("drop",c,{once:!0}),document.addEventListener("dragend",c,{once:!0});let d=o?("col"===e?o.left:o.top)-i:0;te.state={...n,draggingState:{draggedCellOrientation:e,originalIndex:l,mousePos:i,initialOffset:d}},te.emitUpdate(),r.view.dispatch(r.state.tr.setMeta(e6,!0))},tn=e=>tt("col",{...e,clientY:0}),tr=e=>tt("row",{...e,clientX:0}),tl=()=>{if(!te||void 0===te.state)return;te.state={...te.state,draggingState:void 0},te.emitUpdate();let e=te.editor;e.view.dispatch(e.state.tr.setMeta(e6,null))},ta=l.YY.create({name:"tableHandleExtension",addCommands:()=>({freezeHandles:()=>e=>{let{tr:t,dispatch:n}=e;return n&&t.setMeta(e6,!0),!0},unfreezeHandles:()=>e=>{let{tr:t,dispatch:n}=e;return n&&t.setMeta(e6,!1),!0}}),addProseMirrorPlugins(){var e;let{editor:t}=this;return[(e=e=>{this.editor.emit("tableHandleState",e)},new $.k_({key:e6,state:{init:()=>!1,apply:(e,t)=>{let n=e.getMeta(e6);return void 0!==n?n:t}},view:n=>te=new e8(t,n,e),props:{decorations:e=>{if(!te)return null;if(void 0===te||void 0===te.state||void 0===te.state.draggingState||void 0===te.tablePos)return;
1let n="row"===te.state.draggingState.draggedCellOrientation?te.state.rowIndex:te.state.colIndex;if(void 0===n)return;let r=[],{draggingState:l}=te.state,{originalIndex:a}=l;return("row"===te.state.draggingState.draggedCellOrientation?eZ(t,"row",a,te.state.blockPos).cells.forEach(e=>{e.node&&r.push(K.NZ.node(e.pos,e.pos+e.node.nodeSize,{class:"table-cell-dragging-source"}))}):e0(t,a,te.state.blockPos).cells.forEach(e=>{e.node&&r.push(K.NZ.node(e.pos,e.pos+e.node.nodeSize,{class:"table-cell-dragging-source"}))}),n!==a&&t)?("row"===te.state.draggingState.draggedCellOrientation?eZ(t,"row",n,te.state.blockPos).cells.forEach(e=>{let t=e.node;if(!t)return;let l=e.pos+(n>a?t.nodeSize-2:2);r.push(K.NZ.widget(l,()=>{let e=document.createElement("div");return e.className="tiptap-table-dropcursor",e.style.left="0",e.style.right="0",n>a?e.style.bottom="-1px":e.style.top="-1px",e.style.height="3px",e}))}):e0(t,n,te.state.blockPos).cells.forEach(e=>{let t=e.node;if(!t)return;let l=e.pos+(n>a?t.nodeSize-2:2);r.push(K.NZ.widget(l,()=>{let e=document.createElement("div");return e.className="tiptap-table-dropcursor",e.style.top="0",e.style.bottom="0",n>a?e.style.right="-1px":e.style.left="-1px",e.style.width="3px",e}))}),K.zF.create(e.doc,r)):K.zF.create(e.doc,r)}}}))]}});var to=n(32762);let ti=n(87437).XI.extend({parseHTML(){var e,t;return[...null!=(t=null==(e=this.parent)?void 0:e.call(this))?t:[],{tag:"thead",skip:!0},{tag:"tbody",skip:!0},{tag:"tfoot",skip:!0}]},addProseMirrorPlugins(){let e=this.options.resizable&&this.editor.isEditable,t=this.options.cellMinWidth<120?120:this.options.cellMinWidth;return[...e?[(0,eO.AL)({handleWidth:this.options.handleWidth,cellMinWidth:35,defaultCellMinWidth:t,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],(0,eO.LF)({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){return e=>{let{node:t,HTMLAttributes:n}=e;class r extends eO.Qg{createBlockContainer(){let e=document.createElement("div");return e.setAttribute("data-content-type","table"),this.applyContainerAttributes(e),e}createInnerTableContainer(){let e=document.createElement("div");return e.className="table-container",e}createWidgetsContainer(){let e=document.createElement("div");return e.className="table-controls",e.style.position="relative",e}createOverlayContainer(){let e=document.createElement("div");return e.className="table-selection-overlay-container",e}applyContainerAttributes(e){Object.entries(this.containerAttributes).forEach(t=>{let[n,r]=t;"class"!==n&&e.setAttribute(n,r)})}setupDOMStructure(){let e=this.dom,t=e.firstChild;this.innerTableContainer.appendChild(t),e.appendChild(this.innerTableContainer),e.appendChild(this.widgetsContainer),e.appendChild(this.overlayContainer),this.blockContainer.appendChild(e),this.dom=this.blockContainer}ignoreMutation(e){return!e.target.closest(".table-container")||super.ignoreMutation(e)}constructor(e,t,n){super(e,t),this.containerAttributes=null!=n?n:{},this.blockContainer=this.createBlockContainer(),this.innerTableContainer=this.createInnerTableContainer(),this.widgetsContainer=this.createWidgetsContainer(),this.overlayContainer=this.createOverlayContainer(),this.setupDOMStructure()}}return new r(t,this.options.cellMinWidth<120?120:this.options.cellMinWidth,n)}}}),ts=to.nA.extend({addKeyboardShortcuts(){var e;return{...null==(e=this.parent)?void 0:e.call(this),"Mod-a":()=>{let{state:e,view:t}=this.editor,{selection:n,doc:r}=e,l=n.$anchor,a=(0,eO.KW)(l);if(!a)return!1;let o=r.nodeAt(a.pos);if(!o||!o.textContent)return!1;let i=a.pos+1,s=a.pos+o.nodeSize-1;if(i>=s)return!0;let c=r.resolve(i),d=r.resolve(s),u=$.U3.between(c,d,1);return!!(!u||e.selection.eq(u))||(t.dispatch(e.tr.setSelection(u)),!0)}}}}),tc=l.YY.create({name:"tableKit",addExtensions(){let e=[];return!1!==this.options.table&&e.push(ti.configure(this.options.table)),!1!==this.options.tableCell&&e.push(ts.configure(this.options.tableCell)),!1!==this.options.tableHeader&&e.push(to.A0.configure(this.options.tableHeader)),!1!==this.options.tableRow&&e.push(to.Hj.configure(this.options.tableRow)),e}});var td=n(82402),tu=n(68980);
1let tp=["image/png","image/jpeg","image/gif","image/webp"],th=()=>{let{documentId:e}=g(),{errorToast:t}=C(),{upload:n}=eI(),{trackCommonEvent:r}=(0,tu._)(),l=(e,t,n)=>{r({type:e?"file-upload":"file-upload-failed",message:t,Success:e,feature:"IMAGE",...n&&{uploadMethod:n}})},a=(e,n)=>!e.type||!!tp.includes(e.type)||(t({message:"File type unsupported"}),l(!1,"Image file type unsupported: type:".concat(e.type,", size:").concat(e.size),n),!1),o=(e,n)=>!(e.size>5242880)||(t({message:"File size exceeded"}),l(!1,"Image file size exceeded: type:".concat(e.type,", size:").concat(e.size),n),!1),i=(e,t)=>a(e,t)&&o(e,t),s=e=>{let{editor:t,pos:n,uploadId:r,url:l}=e;t.chain().insertContentAt(n,{type:"image",attrs:{src:l||"",alt:r}}).blur().run()},c=e=>{let{editor:t,uploadId:n,url:r}=e,{view:l}=t,{tr:a}=l.state;a.doc.descendants((e,t)=>{if("image"===e.type.name&&e.attrs.alt===n)return a.setNodeMarkup(t,void 0,{...e.attrs,src:r,alt:void 0}),!1}),a.docChanged&&l.dispatch(a)},d=e=>{let{editor:t,uploadId:n}=e,{view:r}=t,{tr:l}=r.state;l.doc.descendants((e,t)=>{if("image"===e.type.name&&e.attrs.alt===n)return l.delete(t,t+e.nodeSize),!1}),l.docChanged&&r.dispatch(l)},u=async(r,a,o,i)=>{let u="upload-".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),p=new FileReader;p.readAsDataURL(a),p.onload=()=>{s({editor:r,pos:o,uploadId:u,url:p.result})};try{let t=await n({file:a,documentId:e});c({editor:r,uploadId:u,url:t}),l(!0,"Image uploaded: type:".concat(a.type,", size:").concat(a.size),i)}catch(e){console.error("Error in image processing:",JSON.stringify(e)),t({message:"Failed to upload image. Please try again."}),l(!1,"Failed to upload image during processing",i),d({editor:r,uploadId:u})}},p=async(e,t,n,r)=>{for(let l of t)i(l,r)&&await u(e,l,n,r)},h=e=>{if(!e)return!0;let n=/<img[^>]+>/i.test(e),r=e.trim(),a=/^<meta[^>]*>?\s*<img[^>]+>$/i.test(r);return!!n&&!!a||(n&&!a&&t({message:"Your pasted content contains images that might be lost. Please add images manually."}),console.error("Pasted HTML content with images:",e),l(!1,"Image upload failed: paste html content"),!1)};return td.Ay.configure({allowedMimeTypes:tp,onDrop:async(e,t,n)=>{await p(e,t,n,"drag-drop")},onPaste:async(e,t,n)=>{if(!h(n))return!1;await p(e,t,e.state.selection.anchor,"paste")}})};var tm=n(46515),tg=n(51322),tf=n(1704),tx=n(83262),tb=n(7150),tC=n(23961),tv=n(76861),ty=n(98158),tw=n(88010),tj=n(73166),tI=n(12858),tk=n(66626),tE=n(96079),tN=n(43810),tS=n(76897),tT=n(43359);let tA=()=>{let{webApiClient:e}=(0,P.p)();return async function(t){let n=t.sourceDocIds.join("&sourceDocIds=");return await e.put("/api/v1/citation/document/".concat(t.documentId,"/source-docs?sourceDocIds=").concat(n))}},tR=()=>{let e=tA(),t=(0,A.useMutation)({mutationFn:e,retry:!1});return{insertCitationsToDocument:(0,h.useCallback)(async(e,n)=>{await t.mutateAsync({documentId:e,sourceDocIds:n})},[t])}};var tM=n(9722);let tL=l.CU.create({name:"aiDetection",addOptions:()=>({HTMLAttributes:{}}),addAttributes:()=>({"data-sentence-id":{default:null,parseHTML:e=>e.getAttribute("data-sentence-id"),renderHTML:e=>null===e["data-sentence-id"]?{}:{"data-sentence-id":e["data-sentence-id"]}},"data-ai-score":{default:null,parseHTML:e=>{var t;return null!=(t=e.getAttribute("data-ai-score"))?t:e.getAttribute("score")},renderHTML:e=>{let t=null!==e["data-ai-score"]?e["data-ai-score"]:e.score;return null===t?{}:{"data-ai-score":t}}},"data-ai-label":{default:null,parseHTML:e=>{var t;return null!=(t=e.getAttribute("data-ai-label"))?t:e.getAttribute("label")},renderHTML:e=>{let t=null!==e["data-ai-label"]?e["data-ai-label"]:e.label;return null===t?{}:{"data-ai-label":t}}},"data-text-label":{default:null,parseHTML:e=>e.getAttribute("data-text-label"),renderHTML:e=>{let t=null!==e["data-text-label"]?e["data-text-label"]:"";return null===t?{}:{"data-text-label":t}}}}),parseHTML:()=>[{tag:"span[data-ai-detection]",getAttrs:e=>({"data-sentence-id":e.getAttribute("data-sentence-id"),"data-ai-score":e.getAttribute("data-ai-score"),"data-ai-label":e.getAttribute("data-ai-label"),"data-text-label":e.getAttribute("data-text-label")})}],renderHTML(e){let{HTMLAttributes:t}=e,n=t["data-ai-label"],r=(0,tM.XC)(n),a=n||"",o=t["data-text-label"]||"";return["span",(0,l.KV)(t,{"data-ai-detection":"","data-tooltip-label":"unprocessed-text"!==o?r:"",class:"unprocessed-text"===o?"ai-detection-".concat(o).trim():"ai-detection ".concat(a).trim()}),0]},addCommands(){return{setAIDetected:e=>t=>{let{commands:n}=t;return n.setMark(this.name,e)},unsetAIDetected:()=>e=>{let{commands:t}=e;return t.unsetMark(this.name)}}},addProseMirrorPlugins:()=>[new $.k_({key:new $.hs("ai-detected-tracker"),props:{handleTextInput(e,t){let{state:n,dispatch:r}=e,{selection:l}=n,a=n.schema.marks.aiDetection;if(!a||!l.empty||0===t)return!1;let o=n.doc.resolve(t),i=o.nodeBefore,s=o.nodeAfter,c=null==i?void 0:i.marks.some(e=>e.type===a),d=null==s?void 0:s.marks.some(e=>e.type===a);if(c&&d){let e=n.tr;e.removeStoredMark(a),r(e)}return!1}}}),new $.k_({key:new $.hs("ai-detection-tooltip"),view(){let e=null,t=t=>{var n;let l=t.target;(null==l||null==(n=l.classList)?void 0:n.contains("ai-detection"))&&(e=l,r(l))},n=t=>{t.target===e&&(e=null)},r=e=>{let t=e.getBoundingClientRect(),n=Math.round(t.top),r=Math.round(t.left+t.width/2);e.style.setProperty("--tooltip-top","".concat(n,"px")),e.style.setProperty("--tooltip-left","".concat(r,"px"))};return document.addEventListener("mouseenter",t,!0),document.addEventListener("mouseleave",n,!0),{destroy(){document.removeEventListener("mouseenter",t,!0),document.removeEventListener("mouseleave",n,!0)}}}})]}),tD=l.CU.create({name:et.Vi,inclusive:!1,addOptions:()=>({}),addAttributes:()=>({"data-insertion-type":{default:null},"data-req-id":{default:null},"data-feature-name":{default:null},"data-source":{default:"SIDE_BAR"}}),parseHTML:()=>[{tag:"span[data-ai-insert]",getAttrs:e=>({"data-insertion-type":e.getAttribute("data-insertion-type"),"data-req-id":e.getAttribute("data-req-id"),"data-feature-name":e.getAttribute("data-feature-name"),"data-source":e.getAttribute("data-source")})}],renderHTML(e){let{HTMLAttributes:t}=e;return["span",(0,l.KV)(t,{"data-ai-insert":"true",class:"ai-insert"}),0]},addCommands(){var e=this;return{setAiInsertMark:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let{commands:r}=n;return r.setMark(e.name,t)}}}},addProseMirrorPlugins:()=>[new $.k_({key:new $.hs("ai-insert-tracker"),props:{handleTextInput(e,t){let{state:n,dispatch:r}=e,{selection:l}=n,a=n.schema.marks.aiInsert;if(!a||!l.empty||0===t)return!1;let o=n.doc.resolve(t),i=o.nodeBefore,s=o.nodeAfter,c=null==i?void 0:i.marks.some(e=>e.type===a),d=null==s?void 0:s.marks.some(e=>e.type===a);if(c&&d){let e=n.tr;e.removeStoredMark(a),r(e)}return!1}}})]}),t_=n(34669).A.extend({content:"(paragraph | heading) block*"});var tH=n(76629),tP=n(4698);function tO(e){var t;return(null==e||null==(t=e.type)?void 0:t.name)===a.A.PAPERPAL_CITATION}
1function tz(e){return{id:e.getAttribute("data-id-paperpal"),label:e.getAttribute("data-label"),citations:e.getAttribute("data-citations")}}async function tB(e,t){for(let n=0;n<3;n++){let n=await t();if(!n||!n.docChanged)return;if(n.before.eq(e.state.doc))return void e.view.dispatch(n)}}let tF=new $.hs(a.A.PAPERPAL_CITATION),tV=l.bP.create({name:a.A.PAPERPAL_CITATION,priority:110,addStorage(){var e;let t=null==(e=this.options.ydoc)?void 0:e.getMap("citationStyle"),n=null==t?void 0:t.get("style");return{citationStyle:n?n.key:"apa",loadingMessage:void 0,eventEmitter:new(i())}},addOptions:()=>({HTMLAttributes:{},renderText:e=>{let{node:t}=e;try{let{label:e,id:n}=t.attrs,r=(0,en.hb)(e);return r?(0,w.v)(r):"".concat(n)}catch(e){return console.error("TipTap Error: renderText Failed for inline citation:",e),""}},deleteTriggerWithBackspace:!1,renderHTML(e){let{options:t,node:n}=e,{label:r,id:o}=n.attrs,i=(0,en.hb)(r);return["span",(0,l.KV)({"data-type":a.A.PAPERPAL_CITATION,class:a.A.PAPERPAL_CITATION,translate:"no"},this.HTMLAttributes,t.HTMLAttributes),null!=i?i:"".concat(o)]}}),group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes:()=>({id:{default:null,parseHTML:e=>
1e.getAttribute("data-id-paperpal"),renderHTML:e=>e.id?{"data-id-paperpal":e.id}:{}},label:{default:null,parseHTML:e=>{var t,n,r;return null!=(r=e.getAttribute("data-label"))?r:(0,en.bK)(null!=(n=null==(t=e.textContent)?void 0:t.trim())?n:"")},renderHTML:e=>e.label?{"data-label":e.label}:{}},citations:{default:null,parseHTML:e=>e.getAttribute("data-citations"),renderHTML:e=>e.citations?{"data-citations":e.citations}:{}}}),parseHTML:()=>[{tag:'span[data-type="'.concat(a.A.PAPERPAL_CITATION,'"][data-id-paperpal]'),getAttrs:tz},{tag:"span.".concat(a.A.PAPERPAL_CITATION,"[data-id-paperpal]"),getAttrs:tz}],renderHTML(e){let{HTMLAttributes:t,node:n}=e,{label:r,id:o}=n.attrs,i=function(e){let t=document.createElement("template");return t.innerHTML=e.trim(),Array.from(t.content.childNodes).map(function e(t){if(3===t.nodeType){var n;return null!=(n=t.textContent)?n:""}if(1===t.nodeType){let n=t.tagName.toLowerCase(),r={};for(let e of t.attributes)r[e.name]=e.value;return[n,r,...Array.from(t.childNodes).map(e)]}return console.error("Functional error: Unhandled node type",t.nodeType,t),""})}((0,en.hb)(r)||"".concat(o));return["span",(0,l.KV)({"data-type":this.name,class:a.A.PAPERPAL_CITATION,translate:"no"},this.options.HTMLAttributes,t),...i]},renderText(e){let{node:t}=e;return this.options.renderText({options:this.options,node:t})},addKeyboardShortcuts(){let{updateInlineCitations:e}=this.options;return{Backspace:t=>{let{editor:n}=t;try{let t,r,{state:l}=n,{tr:a,selection:o}=l,{from:i,to:s,empty:c}=o;if(c){let e=l.doc.resolve(i);if(t=0===e.parentOffset?i-2:i-1,r=i,!(t>=0))return!1;a.delete(t,r)}else a.deleteSelection(),t=a.mapping.map(i),r=a.mapping.map(s);let d=a.doc.resolve(t),u=d.nodeBefore,p=d.nodeAfter,h=this.storage.citationStyle;if(u&&p&&tO(u)&&tO(p)&&e)return!function(e,t,n,r){let l=e=>JSON.parse((0,en.hb)(e.citations||"[]")),a=l(e.attrs),o=function(e,t){let n=new Map;return[...e,...t].forEach(e=>n.set(e.id,e)),[...n.values()]}(a,l(t.attrs)),i=Array.from(new Set([...e.attrs.id.split(";"),...t.attrs.id.split(";")])).join(";"),s=e.type.create({...e.attrs,id:i,citations:(0,en.bK)(JSON.stringify(o))});n.replaceWith(r.pos-e.nodeSize,r.pos+t.nodeSize,s)}(u,p,a,d),n.view.dispatch(a),tB(n,()=>e({editor:n,ignoreHistory:!0,citationStyle:h,skipMergeCitation:!0})),!0}catch(e){console.error("Tip Tap Error Citation Backspace",JSON.stringify(e))}return!1}}},addCommands(){return{insertCitationCiteProc:e=>t=>{let{editor:n}=t,{citations:r,label:l,id:a}=e,{updateInlineCitations:o,insertCitationsToDocument:i,documentId:s}=this.options,{state:c,view:d}=n,{selection:{from:u},tr:p}=c,h=c.schema.nodes[this.name];if(!h)return console.error('Node type "'.concat(this.name,'" not found in schema.')),!1;let m=h.create({id:a,label:l,citations:r?(0,en.bK)(JSON.stringify(r)):void 0});p.insert(u,m);let g=u+m.nodeSize,f=n.schema.marks[et.Vi];f&&p.addMark(u,g,f.create({"data-insertion-type":"ai-generated","data-req-id":"","data-feature-name":"Research"})),p.setSelection($.U3.create(p.doc,g));let x=!!(null==r?void 0:r.filter(e=>e.source_origin));return x&&(this.storage.loadingMessage="Inserting citation",this.storage.eventEmitter.emit("loading-message-update")),d.dispatch(p),o?tB(n,()=>o({editor:n,ignoreHistory:!0,citationStyle:this.storage.citationStyle,cslResponse:x?r:void 0})).finally(()=>{this.storage.loadingMessage=void 0,this.storage.eventEmitter.emit("loading-message-update")}):(this.storage.loadingMessage=void 0,this.storage.eventEmitter.emit("loading-message-update")),i&&s&&i(s,[e.id]),!1},updateCitationStyle:e=>t=>{var n;let{editor:r}=t,{ydoc:l,updateInlineCitations:a}=this.options;return this.storage.citationStyle=e.key,"function"==typeof r.commands.setDocumentCitationStyle&&r.commands.setDocumentCitationStyle(e),a&&tB(this.editor,()=>a({editor:this.editor,ignoreHistory:!0,citationStyle:e.key})),null==l||null==(n=l.getMap("citationStyle"))||n.set("style",e),!0},insertReserchResponse:e=>t=>{let{editor:n}=t,{updateInlineCitations:r}=this.options,{size:l}=n.view.state.doc.content,{state:a}=n,{tr:o,schema:i}=a,s=e.replace(/^\n/,"").replace(/\n$/,"").replace(/\n/g,"<br />"),c=document.createElement("div");c.innerHTML=s;let d=tH.S4.fromSchema(i).parse(c).content;o.insert(l,d);let u=l+d.size,p=n.schema.marks[et.Vi];p&&o.addMark(l,u,p.create({"data-insertion-type":"ai-generated","data-feature-name":"Research"}));let h=n.schema.marks.highlight;return h&&o.addMark(l,u,h.create({color:"#f0fdf4"})),o.setSelection($.U3.create(o.doc,l,u)),o.scrollIntoView(),r&&r({editor:n,transaction:o,ignoreHistory:!0,citationStyle:this.storage.citationStyle}).then(e=>{n.view.dispatch(null!=e?e:o),setTimeout(()=>{let e=n.state.tr.removeMark(l,u,h).setMeta("addToHistory",!1);n.view.dispatch(e)},2e3)}),!0},updateCitationInDocumentCiteProc:(e,t)=>n=>{let{editor:r}=n;try{this.storage.loadingMessage=t?"Updating citations":"Refreshing citations",this.storage.eventEmitter.emit("loading-message-update");let{updateInlineCitations:n}=this.options;n&&tB(r,()=>n({editor:r,ignoreHistory:!0,citationStyle:this.storage.citationStyle,cslResponse:e}))}catch(e){}finally{setTimeout(()=>{var e;this.storage.loadingMessage=void 0,null==(e=this.storage)||e.eventEmitter.emit("loading-message-update")},1500)}return!1}}},addNodeView:()=>e=>{let{node:t,getPos:n,editor:r}=e,{label:l,id:o}=t.attrs,i=document.createElement("span");i.setAttribute("data-citation",o),i.className=a.A.PAPERPAL_CITATION,i.setAttribute("contenteditable","false");let s=document.createElement("span");return s.innerHTML=(0,en.hb)(l),i.appendChild(s),i.addEventListener("click",()=>{if(n&&n()){let e=null==n?void 0:n();"number"==typeof e&&r.commands.setNodeSelection(e)}}),{dom:i}},addProseMirrorPlugins(){let{updateInlineCitations:e}=this.options,t=(0,tP.A)(()=>{e&&tB(this.editor,()=>e({editor:this.editor,ignoreHistory:!0,citationStyle:this.storage.citationStyle}))},300);return[new $.k_({key:tF,state:{init(e,t){let{doc:n}=t,r=[];return n.descendants(e=>{e.type.name===a.A.PAPERPAL_CITATION&&r.push(e.attrs)}),r},apply(e,t,n,r){let l=[];return r.doc.descendants(e=>{e.type.name===a.A.PAPERPAL_CITATION&&l.push(e.attrs)}),l}},appendTransaction:(e,n,r)=>{let l=tF.getState(n)||[],a=tF.getState(r)||[];return(l.length!==a.length||l.some((e,t)=>{var n;return e.id!==(null==(n=a[t])?void 0:n.id)}))&&t(),null}})]}}),tU=l.YY.create({name:"listNormalization",addKeyboardShortcuts(){let e=["bulletList","orderedList","taskList"];return{Backspace:t=>{let{editor:n}=t,{state:r,view:l}=n,{selection:a}=r,{$from:o,empty:i}=a;if(!i||0!==o.parentOffset)return!1;let s=o.parent;if("paragraph"!==s.type.name||s.content.size>0)return!1;let c=o.depth-1;if(c<0)return!1;let d=o.node(c),u=o.index(c);if(0===u||u>=d.childCount-1)return!1;let p=d.child(u-1),h=d.child(u+1),m=e.includes(p.type.name),g=e.includes(h.type.name);if(!m||!g||p.type.name!==h.type.name)return!1;let f=o.before(c+1),x=o.after(c+1),b=r.doc.resolve(f-1),C=$.U3.findFrom(b,-1,!0);if(!C)return!1;let v=C.from,y=r.tr;y.delete(f,x),(0,ez.n9)(y.doc,f)&&y.join(f);let w=y.mapping.map(v);return y.setSelection($.U3.create(y.doc,w)),l.dispatch(y),!0}}}});function tW(e,t,n){if(0===e.length)return null;for(let a of e){var r,l;if((null!=(l=null==(r=a.node.attrs)?void 0:r[t])?l:null)!==n)return n}return null}let tG=l.YY.create({name:"nodeAlignment",addOptions:()=>({types:["paragraph","heading","blockquote","tableCell","tableHeader"],useStyle:!0,textAlignValues:["left","center","right","justify"],verticalAlignValues:["top","middle","bottom"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{nodeTextAlign:{default:null,parseHTML:e=>{var t;let n=null==(t=e.style)?void 0:t.textAlign;if(n&&this.options.textAlignValues.includes(n))return n;let r=e.getAttribute("data-node-text-align");return r&&this.options.textAlignValues.includes(r)?r:null},renderHTML:e=>{let t=e.nodeTextAlign;return t&&this.options.textAlignValues.includes(t)?this.options.useStyle?{style:"text-align: ".concat(t)}:{"data-node-text-align":t}:{}}},nodeVerticalAlign:{default:null,parseHTML:e=>{var t;let n=null==(t=e.style)?void 0:t.verticalAlign;if(n&&this.options.verticalAlignValues.includes(n))return n;let r=e.getAttribute("data-node-vertical-align");return r&&this.options.verticalAlignValues.includes(r)?r:null},renderHTML:e=>{let t=e.nodeVerticalAlign;return t&&this.options.verticalAlignValues.includes(t)?this.options.useStyle?{style:"vertical-align: ".concat(t)}:{"data-node-vertical-align":t}:{}}}}}]},addCommands(){let e=(e,t)=>
1n=>r=>{let{state:l,tr:a}=r,o=(0,eg.cy)(l.selection,this.options.types);if(0===o.length)return!1;let i=t(o,n);return(0,eg.w6)(a,o,e,i)};return{setNodeTextAlign:e("nodeTextAlign",(e,t)=>t&&this.options.textAlignValues.includes(t)?t:null),unsetNodeTextAlign:e("nodeTextAlign",()=>null),toggleNodeTextAlign:e("nodeTextAlign",(e,t)=>t&&this.options.textAlignValues.includes(t)?tW(e,"nodeTextAlign",t):null),setNodeVAlign:e("nodeVerticalAlign",(e,t)=>t&&this.options.verticalAlignValues.includes(t)?t:null),unsetNodeVAlign:e("nodeVerticalAlign",()=>null),toggleNodeVAlign:e("nodeVerticalAlign",(e,t)=>t&&this.options.verticalAlignValues.includes(t)?tW(e,"nodeVerticalAlign",t):null),setNodeAlignment:(e,t)=>n=>{let{state:r,tr:l}=n,a=(0,eg.cy)(r.selection,this.options.types);if(0===a.length)return!1;let o=!1;for(let{node:n,pos:r}of a){let a={...n.attrs};e&&this.options.textAlignValues.includes(e)&&(a.nodeTextAlign=e,o=!0),t&&this.options.verticalAlignValues.includes(t)&&(a.nodeVerticalAlign=t,o=!0),o&&l.setNodeMarkup(r,void 0,a)}return o},unsetNodeAlignment:()=>e=>{let{state:t,tr:n}=e,r=(0,eg.cy)(t.selection,this.options.types);if(0===r.length)return!1;let l=!1;for(let{node:e,pos:t}of r){var a,o,i,s;let r=null!=(i=null==(a=e.attrs)?void 0:a.nodeTextAlign)?i:null,c=null!=(s=null==(o=e.attrs)?void 0:o.nodeVerticalAlign)?s:null;if(r||c){let r={...e.attrs,nodeTextAlign:null,nodeVerticalAlign:null};n.setNodeMarkup(t,void 0,r),l=!0}}return l}}}}),tZ=l.YY.create({name:"nodeBackground",addOptions:()=>({types:["paragraph","heading","blockquote","taskList","bulletList","orderedList","tableCell","tableHeader"],useStyle:!0}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{var t;let n=null==(t=e.style)?void 0:t.backgroundColor;return n||e.getAttribute("data-background-color")||null},renderHTML:e=>{let t=e.backgroundColor;return t?this.options.useStyle?{style:"background-color: ".concat(t)}:{"data-background-color":t}:{}}}}}]},addCommands(){let e=e=>t=>n=>{let{state:r,tr:l}=n,a=(0,eg.cy)(r.selection,this.options.types);if(0===a.length)return!1;let o=e(a,t);return(0,eg.w6)(l,a,"backgroundColor",o)};return{setNodeBackgroundColor:e((e,t)=>t||null),unsetNodeBackgroundColor:e(()=>null),toggleNodeBackgroundColor:e((e,t)=>(function(e,t){if(0===e.length)return null;for(let l of e){var n,r;if((null!=(r=null==(n=l.node.attrs)?void 0:n.backgroundColor)?r:null)!==t)return t}return null})(e,t||""))}}}),tq=l.bP.create({name:"figcaption",content:"inline*",group:"block",defining:!0,addAttributes:()=>({style:{default:null,parseHTML:e=>e.getAttribute("style"),renderHTML:e=>e.style?{style:e.style}:{}}}),parseHTML:()=>[{tag:"figcaption"}],renderHTML(e){let{HTMLAttributes:t}=e;return["figcaption",(0,l.KV)(t),0]}}),t$=l.bP.create({name:"figure",group:"block",content:"image figcaption?",defining:!0,addAttributes:()=>({align:{default:null,parseHTML:e=>e.getAttribute("align")||e.getAttribute("data-align"),renderHTML:e=>e.align?{align:e.align}:{}},style:{default:null,parseHTML:e=>e.getAttribute("style"),renderHTML:e=>e.style?{style:e.style}:{}}}),parseHTML:()=>[{tag:"figure",priority:51}],renderHTML(e){let{HTMLAttributes:t}=e;return["figure",(0,l.KV)(t),0]},addProseMirrorPlugins(){let e=new $.hs("transformFigure");return[new $.k_({key:e,appendTransaction:(e,t,n)=>{if(!e.some(e=>e.docChanged))return null;let{tr:r}=n,{schema:l}=n,a=!1,o=[];return n.doc.descendants((e,t)=>{"figure"===e.type.name&&o.push({pos:t,node:e})}),o.reverse().forEach(e=>{let{pos:t,node:n}=e,o=null,i=null;if(n.forEach(e=>{"image"===e.type.name?o=e:"figcaption"===e.type.name&&(i=e.content)}),o&&l.nodes.image)try{let e={...o.attrs,"data-align":n.attrs.align||o.attrs["data-align"]||null,showCaption:!0},s=l.nodes.image.create(e,i);r.replaceRangeWith(t,t+n.nodeSize,s),a=!0}catch(e){console.error("Error transforming figure to image:",e)}}),a?r:null}})]}});var tK=n(4230);let tY={rewrite:tK.ih,trim:tK.kz,tone:tK.Oe};function tX(e){for(let[t,n]of Object.entries(tY))if(n.includes(e))return{groupName:t,features:n};return null}let tJ=()=>({isCiteMenuOpen:!1,aiGenerationIsSelection:!1,aiGenerationIsLoading:!1,aiGenerationActive:!1,aiGenerationHasMessage:!1,commentInputVisible:!1,lockDragHandle:!1,isDragging:!1,aiGenerationError:"",selectedCount:0,isCitationPresent:!1,activeGroup:null,activeFeature:"",results:{},resultRequestIds:{},activeResultIndexByFeature:{},citationSelection:null,processHtmlContent:"",requestId:void 0,isPrompt:!1,selectedText:"",processedFinalText:"",manualCitationPositions:[],activeManualCitationIndex:0}),tQ=l.YY.create({name:"uiState",addStorage:()=>tJ(),addCommands(){let e=e=>t=>()=>(this.storage[e]=t,!0),t=(e,t)=>()=>()=>(this.storage[e]=t,!0);return{aiGenerationSetIsSelection:e("aiGenerationIsSelection"),aiGenerationSetIsLoading:e("aiGenerationIsLoading"),aiGenerationHasMessage:e("aiGenerationHasMessage"),aiGenerationSetError:e=>()=>(this.storage.aiGenerationError=e,!0),aiGenerationShow:t("aiGenerationActive",!0),aiGenerationHide:t("aiGenerationActive",!1),uiStateSetActiveFeature:(e,t)=>
1()=>{let n=this.storage;if(n.activeFeature=e,!e)return!0;if(t){var r;let t=tX(e);n.activeGroup=null==t?void 0:t.groupName,0===Object.keys(n.results).length&&(null==t||t.features.forEach(e=>{var t,r,l,a;null!=(t=n.results)[e]||(t[e]=[]),null!=(r=n.activeResultIndexByFeature)[e]||(r[e]=0)}));let l=null!=(r=n.results[e])?r:[];n.activeResultIndexByFeature[e]=0===l.length?0:l.length}return!0},uiStateUpdateResult:(e,t)=>()=>{var n,r;let l=this.storage,a=l.results,o=null!=(n=a[e])?n:[],i=null!=(r=l.activeResultIndexByFeature[e])?r:o.length,s=[...o];return s[i]=t,l.results={...a,[e]:s},l.activeResultIndexByFeature={...l.activeResultIndexByFeature,[e]:i},!0},uiStateUpdateResultRequestIds:e=>()=>{var t,n;let r=this.storage,l=r.requestId,a=r.resultRequestIds,o=null!=(t=a[e])?t:[];if(!l)return!1;let i=null!=(n=r.activeResultIndexByFeature[e])?n:o.length;if(o[i]===l||o.includes(l))return!1;let s=[...o];return s[i]=l,r.resultRequestIds={...a,[e]:s},!0},uiStateSetActiveResultIndexByFeature:e=>()=>{var t;let n=this.storage,r=n.activeFeature;if(!r)return!1;let l=null!=(t=n.results[r])?t:[];return!(e<0)&&!(e>=l.length)&&(n.activeResultIndexByFeature={...n.activeResultIndexByFeature,[r]:e},!0)},uiStateResetRequestId:()=>()=>(this.storage.requestId=void 0,!0),commentInputShow:t("commentInputVisible",!0),commentInputHide:t("commentInputVisible",!1),setLockDragHandle:e("lockDragHandle"),setIsDragging:e("isDragging"),setIsPrompt:e("isPrompt"),showCiteMenu:t("isCiteMenuOpen",!0),hideCiteMenu:t("isCiteMenuOpen",!1),resetUiState:()=>()=>(Object.assign(this.storage,tJ()),!0),setManualCitationPositions:e=>()=>(this.storage.manualCitationPositions=e,this.storage.activeManualCitationIndex=0,!0),updateActiveManualCitationIndex:e=>()=>{var t;let n=null!=(t=this.storage.manualCitationPositions)?t:[];return e>=0&&e<n.length&&(this.storage.activeManualCitationIndex=e,!0)},nextManualCitation:()=>()=>{var e,t;let n=null!=(e=this.storage.manualCitationPositions)?e:[],r=(null!=(t=this.storage.activeManualCitationIndex)?t:0)+1;return r<n.length&&(this.storage.activeManualCitationIndex=r,!0)},prevManualCitation:()=>()=>{var e;let t=(null!=(e=this.storage.activeManualCitationIndex)?e:0)-1;return t>=0&&(this.storage.activeManualCitationIndex=t,!0)}}},addKeyboardShortcuts(){return{"mod-j":e=>{let{editor:t}=e,{selection:n}=t.state;return n.empty?this.editor.chain().focus().selectParentNode().aiGenerationShow().run():this.editor.chain().blur().aiGenerationShow().run(),!0}}},onCreate(){this.storage=tJ()}}),t0=l.CU.create({name:et.G2,inclusive:!1,addAttributes:()=>({"data-insertion-type":{default:null},"data-copy-source":{default:"unknown"}}),parseHTML:()=>[{tag:"span[data-copy-source]",getAttrs:e=>({"data-insertion-type":e.getAttribute("data-insertion-type"),"data-copy-source":e.getAttribute("data-copy-source")})}],renderHTML(e){let{HTMLAttributes:t}=e;return["span",(0,l.KV)(t,{class:"unknown-copy-source"}),0]},addProseMirrorPlugins:()=>[new $.k_({props:{handleTextInput(e,t){let{state:n,dispatch:r}=e,{selection:l}=n,a=n.schema.marks[et.G2];if(!a||!l.empty||0===t)return!1;let o=n.doc.resolve(t),i=o.nodeBefore,s=o.nodeAfter,c=null==i?void 0:i.marks.some(e=>e.type===a),d=null==s?void 0:s.marks.some(e=>e.type===a);if(c&&d){let e=n.tr;e.removeStoredMark(a),r(e)}return!1}}})]}),t1=function(){let{updateInlineCitations:e,ydoc:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=th(),{documentId:r}=g(),{insertCitationsToDocument:l}=tR();return{formattingExtensions:(0,h.useMemo)(()=>[tT.W.configure({undoRedo:!1,horizontalRule:!1,dropcursor:{width:2},link:{openOnClick:!1},listItem:!1}),t_,tS.oz.configure({markedOptions:{gfm:!0}}),tx.A,tj.A.configure({types:["heading","paragraph"]}),tv.A,tg.Ay.configure({emojis:tg.bH.filter(e=>!e.name.includes("regional")),forceFallbackImages:!0}),tc.configure({table:{resizable:!0,cellMinWidth:120}}),tZ,tG,tI.ds.configure({backgroundColor:{types:["textStyle"]},color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]},lineHeight:{types:["textStyle"]}}),ep,em,tC.Ay,tN.n4,tw.A,ty.A,tb._0,tb.L2.configure({nested:!0}),tf.f4.configure({multicolor:!0}),tN.LN.configure({className:"selection"}),tq,t$,ey,ta,tU,eM.configure({accept:"image/*",maxSize:eg.w3,limit:3,upload:eg.f5,onError:e=>console.error("Upload failed:",e)}),tE.Ay.configure({types:["table","paragraph","bulletList","orderedList","taskList","heading","blockquote","codeBlock"],filterTransaction:e=>!(0,tm.f)(e)}),tk.Ay,n,tQ,tV.configure({documentId:r||"",updateInlineCitations:e,insertCitationsToDocument:l,ydoc:t,HTMLAttributes:{class:a.A.PAPERPAL_CITATION,translate:"no"}}),tD,tL,t0],[n,r,l,e,t])}};var t2=n(5245);let t4=e=>{let{editor:t}=e,n=t.storage[a.A.PAPERPAL_CITATION],[l,o]=(0,h.useState)(!!n.loadingMessage),i=(0,h.useRef)("");return((0,h.useEffect)(()=>{var e;let t=()=>{var e;o(!!n.loadingMessage),i.current=null!=(e=n.loadingMessage)?e:""};return null==(e=n.eventEmitter)||e.on("loading-message-update",t),()=>{var e;null==(e=n.eventEmitter)||e.off("loading-message-update",t)}},[n]),l)?(0,r.jsx)(t2.bL,{open:l,onOpenChange:o,children:(0,r.jsxs)(t2.ZL,{children:[(0,r.jsx)(t2.hJ,{className:"fixed inset-0 bg-black/30"}),(0,r.jsx)(t2.UC,{className:"fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:(0,r.jsxs)("div",{className:"relative bg-white px-6 py-3 rounded-xl shadow-xl flex items-center gap-3 pointer-events-auto",children:[(0,r.jsx)("div",{className:"animate-spin",children:(0,r.jsx)(ew.x3,{})}),(0,r.jsx)("span",{className:"font-medium text-blue-600",children:i.current})]})})]})}):null};var t5=n(31042),t7=n(72984);function t3(e,t){let n={},r=t.names||{},l=t.types||{};
1return Object.entries(e).forEach(e=>{let[t,r]=e;if(!t7.JL.includes(t)){if("type"===t){let e=Object.keys(l).find(e=>l[e].includes(r));n[t]=e||r;return}n[t]=r}}),Object.entries(e).filter(e=>{let[t]=e;return t7.JL.includes(t)}).forEach(e=>{let[t,l]=e,a=r[t]?r[t]:"author";if(!a)return;n[a]||(n[a]=[]);let o=l.map(e=>({family:e.family||"",given:e.given||""}));n[a].push(...o)}),n}function t9(e,t){var n,r,l,a;let o=new DOMParser().parseFromString("<body>".concat(e,"</body>"),"text/html"),i=o.querySelector(".csl-left-margin");void 0!==t&&i&&(i.innerHTML=i.innerHTML.replace(/\d+/,t));let s=null!=(a=null==i||null==(n=i.innerHTML)?void 0:n.trim())?a:"",c=null==(l=o.querySelector(".csl-right-inline"))||null==(r=l.innerHTML)?void 0:r.trim();if(void 0!==c)return"".concat(s," ").concat(c).trim();let d=o.querySelector(".csl-entry");return d?d.innerHTML.trim():o.body.innerHTML.trim()}function t6(){let{getCiteprocEngine:e,updateCitationNumberMap:t,exportBiblographyRef:n,citationSchema:r}=(0,t5.h)(),l=e=>e?JSON.parse((0,en.hb)(e)):[],o=(0,h.useCallback)(async i=>{let{editor:s,transaction:c,ignoreHistory:d,citationStyle:u="apa",skipMergeCitation:p,isRegenerate:h=!1,cslResponse:m}=i,{state:g}=s,f=c||g.tr,x=r.csl.names,b=new Set,C=!1,v=[],y=new Map,w=new Map,j=[],I=null;if(f.doc.descendants((e,t)=>{if(e.type.name===a.A.PAPERPAL_CITATION){var n,r;let o=null!=(n=e.attrs.id)?n:"";if(!o)return;let i=o.split(";").map(e=>e.trim()).filter(Boolean),s=i.slice().sort().join(","),c=e.attrs.citations?l(e.attrs.citations):[],d=c.map(e=>(null==m?void 0:m.find(t=>t.id===e.id))||e),u={...e.attrs,citations:(0,en.bK)(JSON.stringify(d))},g=h?function(e){let t=e=>{var t,n;return"string"==typeof e&&null!=(n=null==(t=e.split(/[-–—]/)[0])?void 0:t.trim())?n:""},n=e=>(null==e?void 0:e.replace(/[\u200B-\u200D\uFEFF\u00A0]/g,"").trim())||"";return e.map(e=>{let r={...e};return"string"==typeof r.page&&(r.page=t(r.page)),["title","container-title"].forEach(e=>{r[e]&&(r[e]=n(r[e]))}),!r.issued||"object"==typeof r.issued&&Array.isArray(r.issued["date-parts"])&&Array.isArray(r.issued["date-parts"][0])||delete r.issued,Object.entries(r).forEach(e=>{let[t,n]=e;(null==n||""===n)&&"string"==typeof t&&delete r[t]}),r})}(d):d;if(i.forEach(e=>{if(!y.has(e)){let t=g.find(t=>t.id===e);t&&(t["short-container-title"]&&!t["container-title-short"]&&(t["container-title-short"]=t["short-container-title"].reduce((e,t)=>e.length<=t.length?e:t)),Object.assign(t,t3(t,x)),y.set(e,t),j.push(e))}}),p)v.push({citationIDs:i,attrs:u,pos:t,key:s});else{let n=!1;if(I&&t===I.pos+I.node.nodeSize&&I.node.type.name===a.A.PAPERPAL_CITATION){let r=Array.from(new Set([...(I.node.attrs.id||"").split(";").map(e=>e.trim()).filter(Boolean),...i])),a=(I.node.attrs.citations?l(I.node.attrs.citations):[]).map(e=>(null==m?void 0:m.find(t=>t.id===e.id))||e),o=new Map;[...a,...c].forEach(e=>o.set(e.id,e));let s=Array.from(o.values());I={node:e.type.create({...e.attrs,id:r.join(";"),citations:(0,en.bK)(JSON.stringify(s))}),pos:t},n=!0}if(n||(I={node:e,pos:t}),n&&v.length>0){let e=v[v.length-1];e&&(e.citationIDs=(null!=(r=null==I?void 0:I.node.attrs.id)?r:"").split(";").map(e=>e.trim()).filter(Boolean),e.attrs={...null==I?void 0:I.node.attrs},b.add(t))}else v.push({citationIDs:i,attrs:u,pos:t,key:s})}}}),console.log("citationClusters",v),0===v.length)return s.commands.setCitationReferences&&s.commands.setCitationReferences([]),n.current=null,null;if(!e)return console.error("No citeproc engine available."),null;let{engine:k}=await e({style:u,bibData:y,excludeCacheEngine:h||!!m});k.updateItems(j);for(let e=0;e<v.length;e++){var E,N;let t=v[e],n=e+1;if(!t){console.error("Cluster is undefined.");continue}let r=k.appendCitationCluster({citationItems:t.citationIDs.map(e=>({id:e})),properties:{noteIndex:n}}),l=null!=(N=null==r||null==(E=r[0])?void 0:E[1])?N:"";k.registry.reflist.forEach(e=>{e.id&&e.seq&&w.set(e.id,String(e.seq))});let a=(0,en.bK)(l);(a!==t.attrs.label||m)&&(f.setNodeMarkup(t.pos,void 0,{...t.attrs,label:a}),C=!0)}b.size>0&&(Array.from(b).sort((e,t)=>t-e).forEach(e=>{f.delete(e,e+1)}),C=!0),t&&t(w),d&&f.setMeta("addToHistory",!1);try{let[e,t]=k.makeBibliography(),r=t.map(e=>t9(e));return s.commands.setCitationReferences&&s.commands.setCitationReferences(r),n&&Array.isArray(e.entry_ids)&&(n.current={citations:e.entry_ids.map((e,n)=>{let[r]=e,l=t[n];return{sourceDocId:r,reference:(0,en.bK)(l?t9(l):"")}})}),C?f:null}catch(e){if(console.error("TipTap Error GC generateCitationRender UpdateInlineCitation 1: ".concat(u," "),JSON.stringify(y)),!h)return o({editor:s,transaction:f,ignoreHistory:d,citationStyle:u,skipMergeCitation:p,isRegenerate:!0,cslResponse:m}),C?f:null;return console.error("TipTap Error GC generateCitationRender UpdateInlineCitation 2: ".concat(u," "),"".concat(JSON.stringify(y))),null}},[e,t,n,r]);return{updateInlineCitations:o}}var t8=n(44020),ne=n(90802);let nt=(e,t)=>
1{if(!t||!e)return!1;let n=e.view.dom.parentElement,r=e.view.dom;return!!n&&(n===t||r===t||n.contains(t))};var nn=n(28553);function nr(e,t,n,r,l){let{dismissOptions:a,...o}=r||{},{refs:i,context:s,floatingStyles:c}=(0,ne.we)({open:e,whileElementsMounted:(e,t,n)=>(0,nn.ll)(e,t,n,l),...o}),{isMounted:d,styles:u}=(0,ne.DL)(s),p=(0,ne.s9)(s,a),{getReferenceProps:m,getFloatingProps:g}=(0,ne.bv)([p]);return(0,h.useEffect)(()=>null===t?void i.setReference(null):t instanceof HTMLElement?void i.setReference(t):void i.setReference({getBoundingClientRect:()=>("function"==typeof t?t():t)||new DOMRect}),[t,i]),(0,h.useMemo)(()=>({isMounted:d,ref:i.setFloating,style:{...u,...c,zIndex:n},getFloatingProps:g,getReferenceProps:m}),[c,d,i.setFloating,u,n,g,m])}function nl(e){let{editor:t}=(0,ef.aA)(),n=(0,h.useMemo)(()=>e||t,[e,t]);return(0,ef.er)({editor:n,selector:e=>e.editor?{editor:e.editor,editorState:e.editor.state,canCommand:e.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}})||{editor:null}}let na={paragraph:"Text",heading:"Heading",blockquote:"Blockquote",listItem:"List Item",codeBlock:"Code Block",table:"Table"},no=e=>{if(!e)return"Node";let{selection:t}=e.state;if(t instanceof $.nh){let e=t.node.type.name;return na[e]||e.toLowerCase()}if(t instanceof eO.rn)return"Table";let{$anchor:n}=t,r=n.parent.type.name;return na[r]||r.toLowerCase()};function ni(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),l=n.top<r.top,a=n.bottom>r.bottom;return l&&a?"both":l?"top":a?"bottom":"none"}let ns=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:["imageUpload","horizontalRule"];if(!e)return!1;t||(t=e.state.selection);let{state:r}=e,{doc:o}=r,{empty:i,from:s,to:c}=t,d=!o.textBetween(s,c).trim().length&&(0,l.eE)(t),u=t.$from.parent.type.spec.code||(0,l.BQ)(t)&&t.node.type.spec.code,p=(0,l.BQ)(t)&&n.includes(t.node.type.name),h=t instanceof eO.rn,m="@"===o.textBetween(s,c," "),g=e.isActive(eu.Gw)||e.isActive(eu.YT)||e.isActive(a.A.PAPERPAL_CITATION);return!i&&!d&&!u&&!p&&!h&&!m&&!g&&!(()=>{if(c-s>200)return!1;let e=!1;return o.nodesBetween(s,c,t=>{["imageUpload","horizontalRule"].includes(t.type.name)&&(e=!0)}),e})()},nc=e=>{if(!e)return!1;let{state:t}=e,{selection:n}=t;return(0,l.eE)(n)&&!n.empty&&!n.$from.parent.type.spec.code&&!(0,l.BQ)(n)},nd=e=>{let{state:t}=e.view,{selection:n}=t,{ranges:r}=n,a=Math.min(...r.map(e=>e.$from.pos)),o=Math.max(...r.map(e=>e.$to.pos));if((0,l.BQ)(n)){let t=e.view.nodeDOM(a);if(t)return t.getBoundingClientRect()}return(0,l.MG)(e.view,a,o)},nu=(0,h.forwardRef)((e,t)=>{let{editor:n,shouldShow:l,floatingOptions:a,zIndex:o=48,onOpenChange:i,referenceElement:s,getBoundingClientRect:c=nd,closeOnEscape:d=!0,children:u,style:p,resetTextSelectionOnClose:m=!0,...g}=e,[f,x]=(0,h.useState)(void 0!==l&&l),b=(0,h.useRef)(null),C=(0,h.useRef)(!1),v=(0,h.useRef)(!1),y=(0,h.useRef)(null),w=(0,h.useRef)(c),{editor:j}=nl(n);(0,h.useEffect)(()=>{y.current=j,w.current=c},[j,c]);let I=(0,h.useCallback)(e=>{null==i||i(e),x(e)},[i]),{isMounted:k,ref:E,style:N,getFloatingProps:S}=nr(f,(0,h.useMemo)(()=>s||(()=>y.current?w.current(y.current):null),[s]),o,{placement:"top",middleware:[(0,t8.BN)(),(0,t8.UU)(),(0,t8.cY)(4)],onOpenChange:e=>{if(!e&&j&&m){let e=j.state.tr.setSelection($.LN.near(j.state.doc.resolve(0)));j.view.dispatch(e)}I(e)},dismissOptions:{enabled:!0,escapeKey:!0,outsidePress(e){let t=e.target;return!!t&&!nt(j,t)}},...a}),T=(0,h.useCallback)(()=>{if(!j)return;let e=c(j);if(e&&void 0!==l&&!v.current)return void I(l);let t=ns(j);e&&!v.current&&(t||C.current)?I(!0):C.current||t&&!v.current&&j.isEditable||I(!1)},[j,c,I,l]);(0,h.useEffect)(()=>{if(!j||!d)return;let e=e=>"Escape"===e.key&&!!f&&(I(!1),!0),t=j.view.dom;return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}},[j,f,d,I]),(0,h.useEffect)(()=>{if(!j)return;let e=e=>{if(C.current){C.current=!1;return}let t=e.relatedTarget;if(!t)return;let n=nt(j,t),r=b.current,l=r&&(r===t||r.contains(t));n||l||!f||I(!1)},t=j.view.dom;return t.addEventListener("blur",e),()=>{t.removeEventListener("blur",e)}},[j,I,f]),(0,h.useEffect)(()=>
1{if(!j)return;let e=()=>{f&&I(!1)},t=j.view.dom;return t.addEventListener("dragstart",e),t.addEventListener("dragover",e),()=>{t.removeEventListener("dragstart",e),t.removeEventListener("dragover",e)}},[j,f,I]),(0,h.useEffect)(()=>{if(!j)return;let e=e=>{if(0!==e.button||(v.current=!0,1!==e.detail))return;let{state:t,view:n}=j,r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r||!(0,eg.u1)(r.pos))return;let l=t.doc.resolve(r.pos).nodeBefore;if(!l||l.isBlock)return;let a=t.tr.setSelection($.LN.near(t.doc.resolve(r.pos)));n.dispatch(a)},t=()=>{v.current&&(v.current=!1,T())},n=j.view.dom,r=j.view.root;return n.addEventListener("mousedown",e),r.addEventListener("mouseup",t),()=>{n.removeEventListener("mousedown",e),r.removeEventListener("mouseup",t)}},[j,T]),(0,h.useEffect)(()=>{if(j)return j.on("selectionUpdate",T),()=>{j.off("selectionUpdate",T)}},[j,T]),(0,h.useEffect)(()=>{j&&T()},[j,T]);let A=(0,h.useMemo)(()=>p&&Object.keys(p).length>0?p:N,[p,N]),R=(0,ne.SV)([E,t,b]);return j&&k&&f?(0,r.jsx)("div",{ref:R,style:{...A},...g,...S(),children:u}):null});nu.displayName="FloatingElement";var np=n(24323);n(3015);let nh=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:(0,eg.cn)("tiptap-card",n),...l})});nh.displayName="Card",(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:(0,eg.cn)("tiptap-card-header",n),...l})}).displayName="CardHeader";let nm=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:(0,eg.cn)("tiptap-card-body",n),...l})});nm.displayName="CardBody";let ng=(0,h.forwardRef)((e,t)=>{let{className:n,orientation:l="vertical",...a}=e;return(0,r.jsx)("div",{ref:t,"data-orientation":l,className:(0,eg.cn)("tiptap-card-item-group",n),...a})});ng.displayName="CardItemGroup";let nf=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:(0,eg.cn)("tiptap-card-group-label",n),...l})});nf.displayName="CardGroupLabel",(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:(0,eg.cn)("tiptap-card-footer",n),...l})}).displayName="CardFooter";var nx=n(93903),nb=n(58759),nC=n(37158),nv=n(90981);let ny=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]})});ny.displayName="ExternalLinkIcon";let nw=(0,h.memo)(e=>{let{color:t="#5D6A81",...n}=e;return(0,r.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 80 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M6.025 8.35C6.0125 8.25 6 8.1375 6 8.0375V8.0125C6 6.9125 6.9 6.0125 8 6.0125C8.1125 6.0125 8.2375 6.025 8.35 6.0375C9.2875 6.2 10 7.025 10 8.0125C10 9.1125 9.1 10.0125 8 10.0125C7.0125 10.0125 6.1875 9.3 6.025 8.3625V8.35ZM0 8C0 11.3625 2.0625 14.2375 5 15.4125V28.575C2.0625 29.7625 0 32.6375 0 35.9875C0 40.4 3.5875 43.9875 8 43.9875C11.3625 43.9875 14.2375 41.925 15.4125 38.9875H40.575C41.7625 41.925 44.6375 43.9875 47.9875 43.9875C52.4 43.9875 55.9875 40.4 55.9875 35.9875C55.9875 32.625 53.925 29.75 50.9875 28.575V15.4125C53.925 14.225 55.9875 11.35 55.9875 8C55.9875 3.5875 52.4 0 47.9875 0C44.625 0 41.75 2.0625 40.575 5H15.4125C14.2375 2.0625 11.3625 0 8 0C3.5875 0 0 3.5875 0 8ZM46 8C46 7.46957 46.2107 6.96086 46.5858 6.58579C46.9609 6.21071 47.4696 6 48 6C48.5304 6 49.0391 6.21071 49.4142 6.58579C49.7893 6.96086 50 7.46957 50 8C50 8.53043 49.7893 9.03914 49.4142 9.41421C49.0391 9.78929 48.5304 10 48 10C47.4696 10 46.9609 9.78929 46.5858 9.41421C46.2107 9.03914 46 8.53043 46 8ZM40.5875 11C41.4 13 43 14.6125 45 15.4125V28.575C43 29.3875 41.3875 30.9875 40.5875 32.9875H15.425C14.6125 30.9875 13.0125 29.375 11.0125 28.575V15.4125C13.0125 14.6 14.625 13 15.425 11H40.5875ZM48 34C48.5304 34 49.0391 34.2107 49.4142 34.5858C49.7893 34.9609 50 35.4696 50 36C50 36.5304 49.7893 37.0391 49.4142 37.4142C49.0391 37.7893 48.5304 38 48 38C47.4696 38 46.9609 37.7893 46.5858 37.4142C46.2107 37.0391 46 36.5304 46 36C46 35.4696 46.2107 34.9609 46.5858 34.5858C46.9609 34.2107 47.4696 34 48 34ZM10 36C10 3
16.9875 9.2875 37.8125 8.35 37.975C8.25 37.9875 8.1375 38 8.0375 38H8.0125C6.9125 38 6.0125 37.1 6.0125 36C6.0125 35.8875 6.025 35.7625 6.0375 35.65C6.2 34.7125 7.025 34 8.0125 34C9.1125 34 10.0125 34.9 10.0125 36H10ZM64.5875 31C65.4 33 67 34.6125 69 35.4125V48.575C67 49.3875 65.3875 50.9875 64.5875 52.9875H39.425C38.6125 50.9875 37.0125 49.375 35.0125 48.575V45.9875H29.0125V48.575C26.075 49.7625 24.0125 52.6375 24.0125 55.9875C24.0125 60.4 27.6 63.9875 32.0125 63.9875C35.375 63.9875 38.25 61.925 39.425 58.9875H64.5875C65.775 61.925 68.65 63.9875 72 63.9875C76.4125 63.9875 80 60.4 80 55.9875C80 52.625 77.9375 49.75 75 48.575V35.4125C77.9375 34.225 80 31.35 80 28C80 23.5875 76.4125 20 72 20C68.6375 20 65.7625 22.0625 64.5875 25H58V26.2C59.3375 27.5625 60.3875 29.1875 61.075 31H64.575H64.5875ZM72 30C71.4696 30 70.9609 29.7893 70.5858 29.4142C70.2107 29.0391 70 28.5304 70 28C70 27.4696 70.2107 26.9609 70.5858 26.5858C70.9609 26.2107 71.4696 26 72 26C72.5304 26 73.0391 26.2107 73.4142 26.5858C73.7893 26.9609 74 27.4696 74 28C74 28.5304 73.7893 29.0391 73.4142 29.4142C73.0391 29.7893 72.5304 30 72 30ZM33.975 56.3375C33.9389 56.6042 33.8494 56.8608 33.7117 57.092C33.5741 57.3232 33.3912 57.5243 33.1741 57.6832C32.9569 57.8421 32.7099 57.9556 32.4479 58.0168C32.1858 58.0779 31.9142 58.0856 31.6491 58.0393C31.384 57.9931 31.131 57.8938 30.9052 57.7474C30.6794 57.601 30.4855 57.4106 30.335 57.1875C30.1845 56.9644 30.0806 56.7133 30.0295 56.4491C29.9784 56.1849 29.9811 55.9131 30.0375 55.65C30.0736 55.3833 30.1631 55.1267 30.3008 54.8955C30.4384 54.6642 30.6213 54.4632 30.8384 54.3043C31.0556 54.1454 31.3026 54.0319 31.5646 53.9707C31.8266 53.9095 32.0983 53.9019 32.3634 53.9482C32.6285 53.9944 32.8815 54.0937 33.1073 54.2401C33.3331 54.3865 33.527 54.5769 33.6775 54.8C33.828 55.0231 33.9319 55.2742 33.983 55.5384C34.0341 55.8026 34.0314 56.0744 33.975 56.3375ZM71.6625 57.9625C70.725 57.8 70.0125 56.975 70.0125 55.9875C70.0125 54.8875 70.9125 53.9875 72.0125 53.9875C73 53.9875 73.825 54.7 73.9875 55.6375V55.65C74 55.7625 74.0125 55.875 74.0125 55.9875C74.0125 57.0875 73.1125 57.9875 72.0125 57.9875C71.9 57.9875 71.775 57.975 71.6625 57.9625Z",fill:t})})});nw.displayName="ObjectUngroupIcon";let nj=e=>{var t,n,l,a,o,i,s,c,u,p,m,g;let{handleCitationClick:f,citationDetails:x,citationSchema:b}=e,[C,v]=(0,h.useState)(0),[y,w]=(0,h.useState)(250),j=x.length,I=null!=(u=null==b||null==(n=b.locales)||null==(t=n["en-GB"])?void 0:t.itemTypes)?u:{},k=null!=(p=null==b||null==(l=b.csl)?void 0:l.types)?p:{},E=(0,h.useCallback)(()=>{w(250),v(e=>e>0?e-1:j-1)},[j]),N=(0,h.useCallback)(()=>{w(250),v(e=>e<j-1?e+1:0)},[j]),S=(0,h.useCallback)(e=>{let t=(0,nx.Y)(e);return null==t?void 0:t.map(e=>[e.given,e.family].filter(Boolean).join(" ")).join(", ")},[]),T=e=>{var t,n;let r=null==e?void 0:e.type;if(!r)return null;let l=null==(t=k[r])?void 0:t[0];return l?I[l]:null!=(n=I[r])?n:r},A=null!=(m=null==x||null==(a=x[C])?void 0:a.abstract)?m:"",R=A.length>250,M=(0,h.useMemo)(()=>250===y&&R?A.slice(0,250):A,[A,y,R]),L=(0,h.useCallback)(()=>{w(e=>250===e?A.length:250)},[A.length]);if((0,h.useEffect)(()=>{v(0),w(250)},[x]),0===x.length)return(0,r.jsx)("div",{className:"rounded-md shadow-[0px_5px_28px_-12px_rgba(0,78,223,0.41)] w-full max-w-full sm:max-w-md md:max-w-lg  min-h-[300px] bg-[#051E57]",children:(0,r.jsx)("div",{className:"flex flex-col items-start gap-[6px] p-[14px]",children:(0,r.jsx)("p",{className:"w-full font-light text-[12px] leading-normal font-inherit text-white",children:"Error fetching citation details"})})});if(0===x.length)return(0,r.jsx)("div",{className:"rounded-md shadow-lg w-full min-h-[300px] bg-[#051E57] flex items-center justify-center p-4",children:(0,r.jsx)("p",{className:"text-white text-sm font-light",children:"Error fetching citation details"})});let D=x[C],_=(null==D?void 0:D.type)==="webpage";return(0,r.jsx)(nh,{className:"rounded-md shadow-[0px_5px_28px_-12px_rgba(0,78,223,0.41)] w-full max-w-[500px]  bg-white border border-[#E4EAF7]",children:D&&(0,r.jsx)("div",{className:"px-4",children:(0,r.jsxs)(h.Fragment,{children:[(0,r.jsx)("div",{className:"flex flex-col mt-1",style:{userSelect:"text",pointerEvents:"auto"},children:_?(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[D.type&&(0,r.jsx)(d.$n,{tooltip:"Document type",className:"!inline-block !rounded !bg-gray-4 !text-gray-11 !font-medium !uppercase !inline-flex !items-center !text-[10px] !leading-4 !py-0.5 !px-1 !min-w-[10
1px] !h-auto !cursor-default w-fit",children:T(D)}),(D.source_origin||D.URL)&&(0,r.jsxs)("button",{onClick:()=>D.URL&&window.open(D.URL,"_blank"),className:"flex items-center gap-2 text-xs font-medium text-gray-11 hover:text-blue-11 cursor-pointer group transition-colors w-fit border-0 bg-transparent p-0",style:{pointerEvents:"auto"},children:[D.URL&&(0,r.jsx)("img",{src:"https://www.google.com/s2/favicons?domain=".concat((0,nb.BF)(D.URL),"&sz=32"),alt:"favicon",className:"w-4 h-4 rounded-sm flex-shrink-0",onError:e=>{e.currentTarget.style.display="none"}}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[D.source_origin||D.URL,(0,r.jsx)(ny,{className:"w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})]}),(0,r.jsx)("div",{className:"text-blue-12 font-medium text-[14px] leading-snug",children:D.title}),D.issued&&(0,r.jsxs)("div",{className:"flex items-center gap-1 text-gray-10 text-[12px]",children:[(0,r.jsx)(ew._v,{className:"w-3 h-3"}),(0,nC.eN)((null==(i=D.issued["date-parts"])||null==(o=i[0])?void 0:o.join("-"))||"")]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center flex-wrap gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 ".concat(1===j?"pt-1":""),children:[D.source_origin&&(0,r.jsxs)(d.$n,{tooltip:"Source Origin",className:"!rounded !bg-green-4 !text-green-11 !font-medium !uppercase !inline-flex !items-center !text-[10px] !leading-4 !py-0.5 !px-1 !min-w-[10px] !h-auto !cursor-default",children:[(0,r.jsx)(ew.vg,{className:"w-3 h-3"}),(0,r.jsxs)("span",{className:"text-green-10",children:[" ",(0,nv.l)(D.source_origin).sourceField]})]}),D.retracted&&(0,r.jsx)(d.$n,{tooltip:"This paper is retracted",className:"!inline-block !rounded !bg-red-4 !text-red-11 !font-medium !uppercase !inline-flex !items-center !text-[10px] !leading-4 !py-0.5 !px-1 !min-w-[10px] !h-auto !cursor-default",children:"RETRACTED"}),D.type&&(0,r.jsx)(d.$n,{tooltip:"Document type",className:"!inline-block !rounded !bg-gray-4 !text-gray-11 !font-medium !uppercase !inline-flex !items-center !text-[10px] !leading-4 !py-0.5 !px-1 !min-w-[10px] !h-auto !cursor-default",children:T(D)})]}),j>1&&(0,r.jsxs)("div",{className:"flex justify-between items-center flex-wrap gap-2",children:[(0,r.jsxs)(d.$n,{className:"!all-[unset] !px-2 !py-1 !inline-flex !gap-1 !rounded-md !bg-white !text-gray-11 !text-xs !font-medium !cursor-pointer hover:!bg-gray-3","data-test-id":"split-citation",onClick:()=>f("split-citation",x),children:[(0,r.jsx)(nw,{className:"w-3"})," Split citation block"]}),(0,r.jsxs)("div",{className:"flex items-center gap-0.5text-gray-600 text-xs",children:[(0,r.jsx)("button",{className:"border-0 bg-transparent text-gray-11 cursor-pointer disabled:text-gray-6 disabled:cursor-default",onClick:E,children:(0,r.jsx)(ew.ls,{className:"w-3 h-3"})}),(0,r.jsxs)("span",{children:[C+1," of ",j]}),(0,r.jsx)("button",{className:"border-0 bg-transparent text-gray-11 cursor-pointer disabled:text-gray-6 disabled:cursor-default",onClick:N,children:(0,r.jsx)(ew.yf,{className:"w-3 h-3"})})]})]})]}),(0,r.jsx)("div",{className:"text-blue-12 font-medium text-[16px] leading-tight",children:D.title}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1 text-gray-10 text-[12px]",children:[(0,r.jsxs)("div",{className:"flex items-center flex-wrap gap-1 text-gray-11 text-xs leading-4",children:[(0,r.jsx)("div",{className:"py-[3px] px-1",children:(0,r.jsx)(ew.vg,{className:"w-3 h-3"})}),(e=>{let t=(0,nx.Y)(e);if(!t.length)return(0,r.jsx)("span",{className:"italic",children:"Author data not available"});let n=t.slice(0,2),l=t.length-n.length;return(0,r.jsxs)(r.Fragment,{children:[n.map((e,t)=>(0,r.jsxs)("span",{children:[e.given," ",e.family,t<n.length-1?", ":""]},t)),l>0&&(0,r.jsx)(d.$n,{className:"p-0 !bg-transparent cursor-default min-w-0 !hover:bg-trasparent",tooltip:(0,r.jsx)("div",{className:"max-w-[300px]",children:S(e)}),children:(0,r.jsxs)("strong",{children:[" +",l]})})]})})(D)]}),D.issued&&(0,r.jsxs)("div",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)("div",{className:"py-[3px] px-1",children:(0,r.jsx)(ew._v,{className:"w-3 h-3"})}),(0,nC.eN)((null==(c=D.issued["date-parts"])||null==(s=c[0])?void 0:s.join("-"))||"")]}),D["container-title"]&&(0,r.jsxs)("div",{className:"inline-flex items-center gap-[5px]",children:[(0,r.jsx)("div",{className:"px-[6px]",children:(0,r.jsx)("span",{className:"block h-1 w-1 rounded-full bg-gray-9"})}),D["container-title"]]})]}),!!M&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-blue-12 text-sm font-semibold my-1",children:"Abstract"}),(0,r.jsxs)("p",{className:"text-gray-700 text-xs  leading-relaxed overflow-y-auto max-h-[200px]",children:[M,R&&(0,r.jsx)(d.$n,{className:"!contents !border-0 rounded  !text-blue-9 text-sm font-medium leading-3  !px-1 !py-1.5 !shadow-none cursor-pointer !hover:bg-blue-4 !hover:text-blue-10 !margin-0 !bg-transparent",onClick:L,"data-test-id":y>250?"read-less":"read-more",children:y>250?"read less":"...read more"})]})]})]})}
1),(0,r.jsx)(nI,{citationId:null!=(g=D.id)?g:"",citationDetails:x,handleCitationClick:f})]},D.id)})})},nI=(0,h.memo)(e=>{let{citationId:t,citationDetails:n,handleCitationClick:l}=e;return(0,r.jsx)("div",{className:"flex flex-wrap justify-between w-full gap-2 py-2",children:(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsxs)(d.$n,{tooltip:"Edit citation details",className:" all-[unset] px-2 py-1 inline-flex gap-1 rounded-md !bg-white !text-gray-11 text-sm font-medium cursor-pointer hover:!bg-gray-3","data-test-id":"edit-citation",onClick:()=>l("edit-citation",n,t),trackingProperties:{CTALabel:"Edit Citation",sectionName:"feed-cite-popup"},children:[(0,r.jsx)(ew.r9,{className:"w-4 h-4 mr-1"})," Edit"]}),(0,r.jsxs)(d.$n,{className:" all-[unset] px-2 py-1 inline-flex gap-1 rounded-md !bg-white !text-gray-11 text-sm font-medium cursor-pointer hover:!bg-gray-3","data-test-id":"copy-citation",onClick:()=>l("copy",n,t),children:[(0,r.jsx)(ew.bz,{className:"w-4 h-4 mr-1"})," Copy"]}),(0,r.jsxs)(d.$n,{className:" all-[unset] px-2 py-1 inline-flex gap-1 !bg-transparent rounded-md bg-white !text-red-10 text-sm font-medium !cursor-pointer hover:!bg-red-4","data-test-id":"delete-citation",onClick:()=>l("delete",n,t),color:"danger",children:[(0,r.jsx)(ew.WM,{className:"w-4 h-4 mr-1"})," Remove"]})]})})}),nk=e=>{var t,n;let{editor:l}=e,{infoToast:o,successToast:i,errorToast:s}=C(),{documentId:c}=g(),{generateCitationRender:d,citationSchema:u,setEditCitationCslObject:p,setCitationEditorOverlay:m}=(0,t5.h)(),{updateInlineCitations:f}=t6(),[x,b]=(0,h.useState)(null),v=l.extensionStorage[a.A.PAPERPAL_CITATION],[y,I]=(0,h.useState)([]),k=(0,h.useRef)(""),E=(0,h.useCallback)(async(e,t)=>{try{var n,r;let{state:o,view:s}=l,{tr:c,selection:u}=o,{$from:p}=u,h=null!=(n=p.nodeAfter)?n:p.nodeBefore;if(!h||h.type.name!==a.A.PAPERPAL_CITATION)return void console.warn("Selection is not on a citation node");let m=p.pos,g=(null!=(r=t.map(e=>e.id))?r:[]).filter(t=>t!==e);if(0===g.length){let e=h.nodeSize;s.dispatch(c.delete(m,m+e)),l.chain().blur().run()}else{let n=t.filter(t=>t.id!==e),r=await d({citations:n,style:v.citationStyle,isBiblographyRequired:!1}),a=h.type.create({...h.attrs,id:g.join(";"),label:(0,en.bK)(r.inlineCitation),citations:(0,en.bK)(JSON.stringify(n))},h.content,h.marks),o=c.replaceWith(m,m+h.nodeSize,a);o=o.setSelection($.nh.create(o.doc,m));let i=await f({editor:l,transaction:o,citationStyle:v.citationStyle});s.dispatch(null!=i?i:o)}i({message:"Citation removed successfully."})}catch(e){console.error("TipTap Error GC : deleteInlineCitation deleting inline citation ",JSON.stringify(e))}},[l,d,i,f,v]),N=(0,h.useCallback)(async(e,t)=>{try{let n=t.find(t=>t.id===e);if(n){let e=l.extensionStorage[a.A.PAPERPAL_CITATION],{inlineCitation:t}=await d({citations:[n],style:e.citationStyle,isBiblographyRequired:!1});if(t){let e=(0,en.bK)(JSON.stringify([n])),r=(0,w.v)(t),l='<span data-type="'.concat(a.A.PAPERPAL_CITATION,'" translate="no"  class="').concat(a.A.PAPERPAL_CITATION,'" data-id-p
1aperpal="').concat(n.id,'" data-label="').concat((0,en.bK)(t),'"  data-citations="').concat(e,'">').concat(r,"</span>"),o=(0,w.v)(l),s=j(l,"Research");(0,np.x)(s,o),i({message:"Copied to clipboard"}),b(null)}}}catch(e){s({message:"unable to copy"}),console.error("TipTap Error GC: copying inline citation ",JSON.stringify(e))}},[l,i,s,d]),S=(0,h.useCallback)(async e=>{try{if(0===e.length)return void o({message:"No citations to split"});let t=l.extensionStorage[a.A.PAPERPAL_CITATION],{state:n}=l,{tr:r,selection:i}=n,{from:s,to:c}=i;r.delete(s,c);let u=s;for(let n of e){let{inlineCitation:e}=await d({citations:[n],style:t.citationStyle,isBiblographyRequired:!1});if(e){let t=l.schema.nodes[a.A.PAPERPAL_CITATION];if(!t)continue;let o=t.create({id:n.id,label:(0,en.bK)(e),citations:(0,en.bK)(JSON.stringify([n]))});r.insert(u,o),u+=o.nodeSize,r.insertText(" ",u),u+=1}}let p=await f({editor:l,transaction:r,citationStyle:t.citationStyle});l.view.dispatch(null!=p?p:r)}catch(e){console.error("TipTap Error GC : splitting inline citations ",JSON.stringify(e)),s({message:"Unable to split citations"})}},[l,s,o,d,f]),T=(0,h.useCallback)(async(e,t,n)=>{switch(e){case"delete":n&&await E(n,t);break;case"copy":n&&await N(n,t);break;case"split-citation":await S(t);break;case"edit-citation":if(n){let e=t.find(e=>e.id===n);e&&(null==p||p(null!=e?e:null),m({mode:"csl-edit"}))}}null==b||b(null)},[S,E,N,p,m]);(0,h.useEffect)(()=>{var e;if(!l.isActive(a.A.PAPERPAL_CITATION))return;let t=l.getAttributes(a.A.PAPERPAL_CITATION),n=null==t?void 0:t.id,r=null!=(e=null==t?void 0:t.citations)?e:"";(n!==x||r!==k.current)&&(b(n),I(r?JSON.parse((0,en.hb)(r)):[]),k.current=r),setTimeout(()=>{let e=document.querySelector(".inline-citation-details-dialog");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},50)},[l.state]);let A=(0,h.useCallback)(()=>l.isActive(a.A.PAPERPAL_CITATION),[l]);return(0,r.jsx)(nu,{shouldShow:A(),className:"inline-citation-details-dialog z-[52]",floatingOptions:{placement:"bottom-start",middleware:[(0,t8.cY)(8),(0,t8.BN)({padding:12,boundary:null!=(t=l.view.dom.parentElement)?t:"clippingAncestors"}),(0,t8.Ej)({boundary:null!=(n=l.view.dom.parentElement)?n:"clippingAncestors",apply(e){let{availableWidth:t,elements:n}=e;n.floating&&(n.floating.style.maxWidth="".concat(t,"px"))}})]},children:c&&x&&(0,r.jsx)(nj,{handleCitationClick:T,citationDetails:y,citationSchema:u})})},nE=l.YY.create({name:"providerExtension",addOptions:()=>({provider:null}),addStorage:()=>({provider:null}),onCreate(){this.storage.provider=this.options.provider}});var nN=n(96088);let nS="get-document-details";function nT(e){let{webApiClient:t}=(0,P.p)(),n=(0,h.useCallback)(async e=>t.get("/api/v1/draft/".concat(e)).then(nN.Lz.parse),[t]);return(0,A.useQuery)({queryKey:[nS,e],queryFn:()=>n(e),enabled:!!e,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:!1,refetchOnMount:"always"})}var nA=n(95124);let nR=(e,t,n,r)=>{let[l,a]=(0,h.useState)(null),o=(0,h.useRef)(null),i=(0,h.useRef)(!1),s=(0,h.useRef)(r),{successToast:c}=C();(0,h.useEffect)(()=>{s.current=r},[r]);let d=()=>{o.current&&(clearInterval(o.current),o.current=null)};(0,h.useEffect)(()=>{if(!e){i.current=!1,d(),a(null);return}if(!i.current){if(i.current=!0,n&&!t){s.current(),a(null),c({message:"Citations converted successfully!"});return}t&&a(10)}},[e,n,t]);let u=null!==l;return(0,h.useEffect)(()=>u?(o.current=setInterval(()=>{a(e=>null===e?null:e<=1?(d(),s.current(),null):e-1)},1e3),d):void d(),[u]),{resetCountdown:l}},nM=()=>{let{webApiClient:e}=(0,P.p)(),t=(0,h.useCallback)(t=>{if(0===t.length)return Promise.reject({success:!1});let n=t.map(e=>(0,en.X8)(e));return e.post("/api/v1/citation/user/add/csl",n)},[e]);return(0,A.useMutation)({mutationFn:e=>t(e),onError:e=>{console.error("Error inserting non-Paperpal citations to library:",e)}})};var nL=n(46593);let nD=()=>{let e=nM(),[t,n]=(0,h.useState)(!1),[r,l]=(0,h.useState)(!1),[a,o]=(0,h.useState)(!1),i=(0,h.useCallback)(e=>{if(!e)return{hasInlineCitation:!1,hasFailedCitation:!1};if((0,nL.rz)(e).length<=0){var t,n;return{hasInlineCitation:!1,hasFailedCitation:(null!=(n=null==(t=(0,eh.ku)(e))?void 0:t.positions.length)?n:0)>0}}return{hasInlineCitation:!0,hasFailedCitation:!1}},[]),s=(0,h.useCallback)(()=>{l(!0),o(!1),n(!1)},[]),c=(0,h.useCallback)(()=>{n(!0)},[]),d=(0,h.useCallback)(()=>{n(!1)},[]),u=(0,h.useCallback)(()=>{o(!0),n(!1)},[]);return{isConversionModalOpen:t,conversionStarted:r,conversionComplete:a,startConversion:s,openConversionModal:c,closeConversionModal:d,handleConversionComplete:u,reset:(0,h.useCallback)(()=>{n(!1),l(!1),o(!1)},[]),hasInlineCitations:i,insertCitationsToLibrary:(0,h.useCallback)(async(t,n)=>{if(null==t?void 0:t.citations){let r=[];t.citations.forEach((e,t)=>{var l,a;if("completed"===e.status&&(null==(l=n[t])?void 0:l.sources)){let e=null==(a=n[t])?void 0:a.sources;r.push(...e)}}),r.length>0&&await e.mutateAsync(r)}},[e])}},n_=(0,h.lazy)(()=>n.e(8927).then(n.bind(n,28927)).then(e=>({default:e.ConversionProgressModal}))),nH=e=>{var t,n,l;let{editor:a,documentId:o}=e,{errorToast:i}=C(),{reset:s,isConversionModalOpen:d,conversionStarted:u,conversionComplete:p,handleConversionComplete:m,openConversionModal:g,closeConversionModal:f,hasInlineCitations:x,insertCitationsToLibrary:b,startConversion:v}=nD(),{data:y}=nT(o),w=(0,h.useRef)(null),j=(null==y?void 0:y.documentTag)==="UPLOAD_DOCUMENT"&&(null==(t=w.current)?void 0:t.hasInlineCitation),{data:I,isLoading:k,isFetching:E,isError:N}=(0,nA.d)(o,j),S=null!=(n=null==I?void 0:I.uniqueSourceCount)?n:0,T=(0,h.useCallback)(()=>{s(),w.current=null},[s]);return((0,h.useEffect)(()=>{!j||!I||k||E||N||v()},[j,k,E,N,I]),(0,h.useEffect)(()=>{N&&i({message:"Failed to fetch citation mapping data. Please try again later."})},[N]),(0,h.useEffect)(()=>{a&&(w.current||(a.commands.setManualCitationPositions([]),w.current=x(a)))},[a]),j&&k)?(0,r.jsxs)("button",{disabled:!0,title:"citation conversion ",className:"cursor-pointer border-2 border-blue-9 bg-white text-gray-12 font-medium py-2 px-5 rounded-full shadow-md transition-colors flex items-center gap-2 whitespace-nowrap hover:shadow-lg animate-slide-up",children:[(0,r.jsx)(c.y,{size:16,color:{value:"#0062FF"}}),"Importing reference"]}):!k&&!N&&(j&&w.current||u)?(0,r.jsx)(nP,{documentId:o,reset:T,isConversionModalOpen:d,conversionStarted:u,conversionComplete:p,openConversionModal:g,closeConversionModal:f,handleConversionComplete:m,data:null!=(l=null==I?void 0:I.citations)?l:[],editor:a,uniqueSourceCount:S,insertCitationsToLibrary:b},o):null},nP=e=>{let{data:t,editor:n,uniqueSourceCount:l,isConversionModalOpen:a,conversionStarted:o,conversionComplete:i,documentId:s,openConversionModal:c,closeConversionModal:d,reset:u,handleConversionComplete:p,insertCitationsToLibrary:m}=e,[g,f]=(0,h.useState)({completed:0,total:0,failed:0,importedSourceCount:0,displaySourceTotal:0}),x=(o||i)&&!a,b=(0,h.useCallback)(()=>{u(),f({completed:0,total:0,failed:0,importedSourceCount:0,displaySourceTotal:0})},[u]),C=(0,h.useCallback)((e,t,n,r,l)=>{f({completed:e,total:t,failed:n,importedSourceCount:r,displaySourceTotal:l})},[]);return(0,h.useEffect)(()=>{i&&g.failed>0&&c()},[i,g.failed,c]),(0,r.jsxs)(r.Fragment,{children:[x&&(0,r.jsx)("div",{className:"fixed bottom-10 left-1/2 -translate-x-1/2 z-50",children:(0,r.jsx)(nO,{uniqueSourceCount:l,conversionComplete:i,conversionProgress:g,onClick:c,handleReset:b})}),(0,r.jsx)(h.Suspense,{fallback:null,children:(0,r.jsx)(n_,{isOpen:a,documentId:s,shouldStart:o,editor:n,citationListResp:t,uniqueSourceCount:l,onClose:d,onReset:b,onComplete:p,insertCitationsToLibrary:m,onProgressChange:C,autoStart:!0})})]})},nO=(0,h.memo)(e=>{let{conversionComplete:t,conversionProgress:n,onClick:l,uniqueSourceCount:a,handleReset:o}=e,i=!t,s=t&&n.failed>0,d=t&&0===n.failed;nR(t,s,d,o);let u=s?"border-red-9":"border-blue-9",p=s?"text-red-9":"text-blue-9";return(0,r.jsxs)("button",{onClick:l,title:"View citation conversion progress",className:"cursor-pointer border-2 ".concat(u," bg-white text-gray-12 font-medium py-2 px-5 rounded-full shadow-md transition-colors flex items-center gap-2 whitespace-nowrap hover:shadow-lg animate-slide-up"),
1children:[i&&(0,r.jsx)(c.y,{size:16,color:{value:s?"#DC2626":"#0062FF"}}),d&&(0,r.jsx)(ew.iQ,{className:"w-4 h-4 flex-shrink-0 ".concat(p)}),s&&(0,r.jsx)(ew.ZE,{className:"w-4 h-4 flex-shrink-0 ".concat(p)}),i&&(0,r.jsxs)("span",{className:"text-sm",children:["Importing reference",n.total>0&&(0,r.jsxs)("span",{className:"ml-1 tabular-nums font-semibold",children:[n.importedSourceCount,"/",n.displaySourceTotal||a]})]}),d&&(0,r.jsx)("span",{className:"text-sm",children:"References imported"}),s&&(0,r.jsx)("span",{className:"text-sm",children:"".concat(n.importedSourceCount,"/").concat(n.displaySourceTotal||a," imported")})]})},(e,t)=>e.conversionComplete===t.conversionComplete&&e.conversionProgress.completed===t.conversionProgress.completed&&e.conversionProgress.total===t.conversionProgress.total&&e.conversionProgress.failed===t.conversionProgress.failed&&e.conversionProgress.importedSourceCount===t.conversionProgress.importedSourceCount&&e.conversionProgress.displaySourceTotal===t.conversionProgress.displaySourceTotal&&e.onClick===t.onClick&&e.uniqueSourceCount===t.uniqueSourceCount&&e.handleReset===t.handleReset);n(80839),n(73171),n(86407),n(13837),n(46349),n(21367),n(76487),n(48276),n(73010);let nz=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M8 14C9.10457 14 10 14.8954 10 16C10 17.1046 9.10457 18 8 18C6.89543 18 6 17.1046 6 16C6 14.8954 6.89543 14 8 14ZM16 14C17.1046 14 18 14.8954 18 16C18 17.1046 17.1046 18 16 18C14.8954 18 14 17.1046 14 16C14 14.8954 14.8954 14 16 14ZM8 6C9.10457 6 10 6.89543 10 8C10 9.10457 9.10457 10 8 10C6.89543 10 6 9.10457 6 8C6 6.89543 6.89543 6 8 6ZM16 6C17.1046 6 18 6.89543 18 8C18 9.10457 17.1046 10 16 10C14.8954 10 14 9.10457 14 8C14 6.89543 14.8954 6 16 6Z",fill:"currentColor"})})});nz.displayName="Grip4Icon";let nB=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M3 16C3.55228 16 4 16.4477 4 17V19L4.00488 19.0986C4.02757 19.3276 4.12883 19.5429 4.29297 19.707C4.48051 19.8946 4.73478 20 5 20H7C7.55228 20 8 20.4477 8 21C8 21.5523 7.55228 22 7 22H5C4.20435 22 3.44151 21.6837 2.87891 21.1211C2.3163 20.5585 2 19.7957 2 19V17C2 16.4477 2.44772 16 3 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M21 16C21.5523 16 22 16.4477 22 17V19C22 19.7957 21.6837 20.5585 21.1211 21.1211C20.5585 21.6837 19.7957 22 19 22H17C16.4477 22 16 21.5523 16 21C16 20.4477 16.4477 20 17 20H19C19.2652 20 19.5195 19.8946 19.707 19.707C19.8946 19.5195 20 19.2652 20 19V17C20 16.4477 20.4477 16 21 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M7 16C7.55228 16 8 16.4477 8 17C8 17.5523 7.55228 18 7 18C6.44772 18 6 17.5523 6 17C6 16.4477 6.44772 16 7 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M12 16C12.5523 16 13 16.4477 13 17C13 17.5523 12.5523 18 12 18C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M17 16C17.5523 16 18 16.4477 18 17C18 17.5523 17.5523 18 17 18C16.4477 18 16 17.5523 16 17C16 16.4477 16.4477 16 17 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M7 11C7.55228 11 8 11.4477 8 12C8 12.5523 7.55228 13 7 13C6.44772 13 6 12.5523 6 12C6 11.4477 6.44772 11 7 11Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13C11.4477 13 11 12.5523 11 12C11 11.4477 11.4477 11 12 11Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M17 11C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13C16.4477 13 16 12.5523 16 12C16 11.4477 16.4477 11 17 11Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M7 2C7.55228 2 8 2.44772 8 3C8 3.55228 7.55228 4 7 4H5C4.73478 4 4.4805 4.10543 4.29297 4.29297C4.10543 4.4805 4 4.73478 4 5V7C4 7.55228 3.55228 8 3 8C2.44772 8 2 7.55228 2 7V5C2 4.20435 2.3163 3.44152 2.87891 2.87891C3.44152 2.3163 4.20435 2 5 2H7Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M7 6C7.55228 6 8 6.44772 8 7C8 7.55228 7.55228 8 7 8C6.44772 8 6 7.55228 6 7C6 6.44772 6.44772 6 7 6Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M12 6C12.5523 6 13 6.44772 13 7C13 7.55228 12.5523 8 12 8C11.4477 8 11 7.55228 11 7C11 6.44772 11.4477 6 12 6Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M17 6C17.5523 6 18 6.44772 18 7C18 7.55228 17.5523 8 17 8C16.4477 8 16 7.55228 16 7C16 6.44772 16.4477 6 17 6Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M19 2C19.7957 2 20.5585 2.3163 21.1211 2.87891C21.6837 3.44151 22 4.20435 22 5V7C22 7.55228 21.5523 8 21 8C20.4477 8 20 7.55228 20 7V5C20 4.73478 19.8946 4.48051 19.707 4.29297C19.5429 4.12883 19.3276 4.02757 19.0986 4.00488L19 4H17C16.4477 4 16 3.55228 16 3C16 2.44772 16.4477 2 17 2H19Z",fill:"currentColor"})]})});nB.displayName="AlignmentIcon";let nF=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.29289 5.29289C8.68342 4.90237 9.31658 4.90237 9.70711 5.29289L15.7071 11.2929C16.0976 11.6834 16.0976 12.3166 15.7071 12.7071L9.70711 18.7071C9.31658 19.0976 8.68342 19.0976 8.29289 18.7071C7.90237 18.3166 7.90237 17.6834 8.29289 17.2929L13.5858 12L8.29289 6.70711C7.90237 6.31658 7.90237 5.68342 8.29289 5.29289Z",fill:"currentColor"})})});nF.displayName="ChevronRightIcon";let nV=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M11 11.5858L9.70711 10.2929C9.31658 9.90237 8.68342 9.90237 8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071L11.2929 14.7071C11.6834 15.0976 12.3166 15.0976 12.7071 14.7071L15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929C15.3166 9.90237 14.6834 9.90237 14.2929 10.2929L13 11.5858V4C13 3.44771 12.5523 3 12 3C11.4477 3 11 3.44771 11 4V11.5858Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]})});nV.displayName="AlignBottomIcon";let nU=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]})});nU.displayName="AlignCenterIcon";let nW=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]})});nW.displayName="AlignJustifyIcon";let nG=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]})});nG.displayName="AlignLeftIcon";let nZ=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M3 12H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M12 22V16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M12 2L12 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M15 19L12 16L9 19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M9 5L12 8L15 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})});nZ.displayName="AlignMiddleIcon";let nq=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]})});nq.displayName="AlignRightIcon";let n$=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M2 4C2 3.44772 2.44772 3 3 3H21C21.5523 3 22 3.44772 22 4C22 4.55228 21.5523 5 21 5H3C2.44772 5 2 4.55228 2 4Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M13 10.4142L14.2929 11.7071C14.6834 12.0976 15.3166 12.0976 15.7071 11.7071C16.0976 11.3166 16.0976 10.6834 15.7071 10.2929L12.7071 7.29289C12.3166 6.90237 11.6834 6.90237 11.2929 7.29289L8.29289 10.2929C7.90237 10.6834 7.90237 11.3166 8.29289 11.7071C8.68342 12.0976 9.31658 12.0976 9.70711 11.7071L11 10.4142L11 20C11 20.5523 11.4477 21 12 21C12.5523 21 13 20.5523 13 20L13 10.4142Z",fill:"currentColor"})]})});n$.displayName="AlignTopIcon";let nK=["table"],nY={text:{left:"Align left",center:"Align center",right:"Align right",justify:"Justify"},vertical:{top:"Align top",middle:"Align middle",bottom:"Align bottom"}},nX={text:{left:nG,center:nU,right:nq,justify:nW},vertical:{top:n$,middle:nZ,bottom:nV}};function nJ(e){if(!e||!e.isEditable||!(0,eg.xU)(e,nK))return!1;try{return e.isActive("tableCell")||e.isActive("tableHeader")}catch(e){return!1}}function nQ(e){let{editor:t,index:n,orientation:r}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,nK))return!1;try{if(!e$(t))return!1;let e=eQ(t,n,r);if(0===e.cells.length)return!1;return!0}catch(e){return!1}}function n0(e){let{editor:t,alignmentType:n,alignment:r,index:l,orientation:a,hideWhenUnavailable:o=!1,onAligned:i}=e,{editor:s}=nl(t),c=function(e){let{editor:t,hideWhenUnavailable:n,index:r,orientation:l}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,nK)&&(!n||("number"==typeof r&&l?nQ({editor:t,index:r,orientation:l}):nJ(t)))}({editor:s,hideWhenUnavailable:o,index:l,orientation:a}),d=()=>{if("number"==typeof l&&a){if(!s)return null;try{let e=eQ(s,l,a);if(0===e.cells.length)return null;let t=e.cells[0];if(!(null==t?void 0:t.node))return null;let r=t.node.attrs||{};if("text"===n)return r.nodeTextAlign||"left";return r.nodeVerticalAlign||"top"}catch(e){return null}}return function(e,t){if(!nJ(e)||!e)return null;try{let{selection:n}=e.state,r=n.$anchor,l=null;for(let e=r.depth;e>=0;e--){let t=r.node(e);if("tableCell"===t.type.name||"tableHeader"===t.type.name){l=t;break}}if(!l)return null;let a=l.attrs||{};if("text"===t)return a.nodeTextAlign||"left";return a.nodeVerticalAlign||"top"}catch(e){return null}}(s,n)},u=d()===r,p=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,alignmentType:n,alignment:r,index:l,orientation:a}=e;if(!t)return!1;try{if("number"==typeof l&&a)return function(e){let{editor:t,alignmentType:n,alignment:r,index:l,orientation:a}=e;if(!nQ({editor:t,index:l,orientation:a})||!t)return!1;try{let{state:e,view:o}=t,i=e.tr,s=eQ(t,l,a);if(0===s.cells.length)return!1;let c=new Map;if(s.cells.forEach(e=>{e.node&&void 0!==e.pos&&c.set(e.pos,e)}),0===c.size)return!1;let d=Array.from(c.values()).sort((e,t)=>t.pos-e.pos),u="text"===n?"nodeTextAlign":"nodeVerticalAlign";if(d.forEach(e=>{if(e.node&&void 0!==e.pos){let t=e.node.type.create({...e.node.attrs,[u]:r},e.node.content,e.node.marks),n=e.pos+e.node.nodeSize;i.replaceWith(e.pos,n,t)}}),i.docChanged)return o.dispatch(i),!0;return!1}catch(e){return console.error("Error aligning table ".concat(a,":"),e),!1}}({editor:t,alignmentType:n,alignment:r,index:l,orientation:a});if(!nJ(t)||!t)return!1;try{if("text"===n)return t.commands.setCellAttribute("nodeTextAlign",r);return t.commands.setCellAttribute("nodeVerticalAlign",r)}
1catch(e){return console.error("Error setting table cell alignment:",e),!1}}catch(e){return console.error("Error aligning table cell:",e),!1}}({editor:s,alignmentType:n,alignment:r,index:l,orientation:a});return e&&(null==i||i(r)),e},[s,n,r,l,a,i]);return{isVisible:c,canAlignCell:()=>"number"==typeof l&&a?nQ({editor:s,index:l,orientation:a}):nJ(s),handleAlign:p,label:(0,h.useMemo)(()=>"text"===n?nY.text[r]:nY.vertical[r],[n,r]),Icon:(0,h.useMemo)(()=>"text"===n?nX.text[r]:nX.vertical[r],[n,r]),isActive:u,currentAlignment:d}}var n1=n(84660),n2=n(12690),n4=n(34865),n5=n(34201),n7=n(17648);function n3(e){let{...t}=e;return(0,r.jsx)(n1.v,{includesBaseElement:!1,resetValueOnHide:!0,...t})}n(26205);let n9=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(n2.e,{ref:t,className:(0,eg.cn)("tiptap-combobox-list",n),...l})});n9.displayName="ComboboxList";let n6=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(n4.N,{ref:t,className:(0,eg.cn)("tiptap-combobox-popover",n),...l})});n6.displayName="ComboboxPopover";let n8=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(n5.G,{ref:t,autoSelect:!0,...l,className:(0,eg.cn)("tiptap-combobox",n)})});n8.displayName="Combobox";let re=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(n7.x,{ref:t,className:(0,eg.cn)("tiptap-combobox-item",n),...l})});re.displayName="ComboboxItem";var rt=n(46947),rn=n(5685),rr=n(93066),rl=n(43299),ra=n(32192),ro=n(64573),ri=n(54183),rs=n(95064),rc=n(53296);n(32549);let rd=(0,h.forwardRef)((e,t)=>{let{as:n="div",...r}=e,l={...r};return"label"===n&&(l.onMouseDown=e=>{var t;e.target.closest("button, input, select, textarea")||(null==(t=r.onMouseDown)||t.call(r,e),!e.defaultPrevented&&e.detail>1&&e.preventDefault())}),(0,h.createElement)(n,{...l,ref:t,className:(0,eg.cn)("tiptap-label",r.className)})});rd.displayName="Label";let ru=(0,h.createContext)(!1),rp=(0,h.createContext)({isRootMenu:!1,open:!1}),rh=()=>(0,h.useContext)(ru),rm=()=>(0,h.useContext)(rp);var rg=n(8912),rf=n(32617),rx=n(76176);function rb(){var e;let t=rg.Ay(),n=null!=(e=rf.O$(t,"value"))?e:"";if(!t)throw Error("useComboboxValueState must be used within ComboboxProvider");return[n,t.setValue]}function rC(){let e=rx.c(),t=(0,h.useCallback)(t=>{e.setAnchorElement(t),e.show(),e.setAutoFocusOnShow(!0)},[e]);return(0,h.useMemo)(()=>({store:e,show:t}),[e,t])}n(80033);let rv=(e,t)=>{"function"==typeof e?e(t):e&&"object"==typeof e&&"current"in e&&(e.current=t)},ry=(e,t)=>{let n=(0,h.useRef)(null);return(0,h.useCallback)(r=>{e&&"current"in e&&(e.current=r),n.current&&rv(n.current,null),n.current=t,t&&rv(t,r)},[e,t])},rw=h.useLayoutEffect;function rj(e){let{children:t,trigger:n,value:l,onOpenChange:a,onValueChange:o,onValuesChange:i,...s}=e,c=!rt.KZ(),[d,u]=(0,h.useState)(!1),p=!!i||c,m=(0,h.useCallback)(e=>{void 0===s.open&&u(e),null==a||a(e)},[s.open,a]),g=(0,h.useMemo)(()=>{var e;return{isRootMenu:c,open:null!=(e=s.open)?e:d}},[c,s.open,d]),f=(0,r.jsxs)(rn.B,{open:d,setOpen:m,setValues:i,showTimeout:100,...s,children:[n,(0,r.jsx)(rp.Provider,{value:g,children:(0,r.jsx)(ru.Provider,{value:p,children:t})})]});return p?(0,r.jsx)(n3,{value:l,setValue:o,children:f}):f}function rI(e){let{children:t,className:n,ref:l,onClickOutside:a,...o}=e,i=(0,h.useRef)(null),{open:s}=rm(),c=function(){let e=rx.c();return rf.O$(e,e=>{var t;return(null==(t=e.currentPlacement)?void 0:t.split("-")[0])||"bottom"})}();return!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"mousedown",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(e,t,n,r){let l=(0,h.useRef)(t);rw(()=>{l.current=t},[t]),(0,h.useEffect)(()=>{var t;let a=null!=(t=null==n?void 0:n.current)?t:window;if(!(a&&a.addEventListener))return;let o=e=>{l.current(e)};return a.addEventListener(e,o,r),()=>{a.removeEventListener(e,o,r)}},[e,n,r])}(n,n=>{let r=n.target;r&&r.isConnected&&(Array.isArray(e)?e.filter(e=>!!e.current).every(e=>e.current&&!e.current.contains(r)):e.current&&!e.current.contains(r))&&(n.stopPropagation(),n.preventDefault(),n.stopImmediatePropagation(),t(n))},void 0,r)}(i,a||(()=>{})),(0,r.jsx)(rr.W,{ref:ry(i,l),className:(0,eg.cn)("tiptap-menu-content",n),"data-side":c,"data-state":s?"open":"closed",gutter:4,flip:!0,unmountOnHide:!0,...o,children:t})}let rk=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(rl.I,{ref:t,...l,className:(0,eg.cn)("tiptap-menu-button",n)})});rk.displayName="MenuButton";
1let rE=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(ra.D,{ref:t,...l,className:(0,eg.cn)("tiptap-menu-button-arrow",n)})});rE.displayName="MenuButtonArrow";let rN=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(ro.r,{ref:t,...l,className:(0,eg.cn)("tiptap-menu-group",n)})});rN.displayName="MenuGroup";let rS=(0,h.forwardRef)((e,t)=>(0,r.jsx)(rd,{ref:t,...e}));rS.displayName="MenuGroupLabel",(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(ri.p,{ref:t,...l,className:(0,eg.cn)("tiptap-menu-item-check",n)})}).displayName="MenuItemCheck";let rT=(0,h.forwardRef)((e,t)=>{let{className:n,...l}=e;return(0,r.jsx)(rs.s,{ref:t,...l,className:(0,eg.cn)("tiptap-menu-item-radio",n)})});rT.displayName="MenuItemRadio";let rA=function(e){let{name:t,value:n,preventClose:l,className:a,...o}=e,i=rt.KZ(),s=rh(),c=(0,h.useCallback)(e=>!e.currentTarget.hasAttribute("aria-expanded")&&!l&&(null==i||i.hideAll(),!1),[i,l]),d={blurOnHoverEnd:!1,focusOnHover:!0,className:(0,eg.cn)("tiptap-menu-item",a),...o};return s?(0,r.jsx)(re,{...d,hideOnClick:c}):t&&n?(0,r.jsx)(rT,{...d,hideOnClick:!0,name:t,value:n}):(0,r.jsx)(rc.D,{...d})};n(20937);let rR=(0,h.forwardRef)((e,t)=>{let{decorative:n,orientation:l="vertical",className:a,...o}=e;return(0,r.jsx)("div",{className:(0,eg.cn)("tiptap-separator",a),"data-orientation":l,...n?{role:"none"}:{"aria-orientation":"vertical"===l?l:void 0,role:"separator"},...o,ref:t})});rR.displayName="Separator";let rM=e=>{let{index:t,orientation:n}=e,l={left:n0({alignmentType:"text",alignment:"left",index:t,orientation:n}),center:n0({alignmentType:"text",alignment:"center",index:t,orientation:n}),right:n0({alignmentType:"text",alignment:"right",index:t,orientation:n})},a={top:n0({alignmentType:"vertical",alignment:"top",index:t,orientation:n}),middle:n0({alignmentType:"vertical",alignment:"middle",index:t,orientation:n}),bottom:n0({alignmentType:"vertical",alignment:"bottom",index:t,orientation:n})};return l.left.canAlignCell()?(0,r.jsx)(rj,{placement:"right",trigger:(0,r.jsx)(rk,{render:(0,r.jsx)(rA,{render:(0,r.jsxs)(d.$n,{"data-style":"ghost",children:[(0,r.jsx)(nB,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:"Alignment"}),(0,r.jsx)(rE,{render:(0,r.jsx)(nF,{})})]})})}),children:(0,r.jsx)(rI,{children:(0,r.jsx)(n9,{children:(0,r.jsxs)(rN,{children:[Object.values(l).map((e,t)=>(0,r.jsx)(rL,{icon:e.Icon,label:e.label,disabled:!e.canAlignCell,isActive:e.isActive,onClick:e.handleAlign},"text-".concat(t))),(0,r.jsx)(rR,{orientation:"horizontal"}),Object.values(a).map((e,t)=>(0,r.jsx)(rL,{icon:e.Icon,label:e.label,disabled:!e.canAlignCell,isActive:e.isActive,onClick:e.handleAlign},"vertical-".concat(t)))]})})})}):null},rL=e=>{let{icon:t,label:n,onClick:l,disabled:a=!1,isActive:o=!1,shortcutBadge:i}=e;return(0,r.jsxs)(rA,{render:(0,r.jsx)(d.$n,{"data-style":"ghost","data-active-state":o?"on":"off"}),onClick:l,disabled:a,children:[(0,r.jsx)(t,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:n}),i]})};rL.displayName="ActionItem";let rD=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H5ZM2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM15.7071 8.29289C16.0976 8.68342 16.0976 9.31658 15.7071 9.70711L13.4142 12L15.7071 14.2929C16.0976 14.6834 16.0976 15.3166 15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071L12 13.4142L9.70711 15.7071C9.31658 16.0976 8.68342 16.0976 8.29289 15.7071C7.90237 15.3166 7.90237 14.6834 8.29289 14.2929L10.5858 12L8.29289 9.70711C7.90237 9.31658 7.90237 8.68342 8.29289 8.29289C8.68342 7.90237 9.31658 7.90237 9.70711 8.29289L12 10.5858L14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289Z",fill:"currentColor"})})});rD.displayName="SquareXIcon";let r_=["table"],rH={row:"Clear row contents",column:"Clear column contents"},rP={backgroundColor:null,nodeVerticalAlign:null,nodeTextAlign:null};function rO(e){try{return function(e,t){if(!(0,eO.aH)(e))return!1;let n=(0,eO.t6)(e),r="string"==typeof rP?{[rP]:void 0}:rP;if(t){let l=e.tr;e.selection instanceof eO.rn?e.selection.forEachCell((e,t)=>{Object.entries(r).some(t=>{let[n,r]=t;return e.attrs[n]!==r})&&l.setNodeMarkup(t,null,{...e.attrs,...r})}):Object.entries(r).some(e=>{let[t,r]=e;return n.nodeAfter.attrs[t]!==r})&&l.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,...r}),t(l)}return!0}(e.state,e.view.dispatch)}catch(e){return console.error("Error resetting cell attributes:",e),!1}}function rz(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,r_))return!1;try{if(!e$(t,l))return!1;let e=eJ(t,n,r,l);if(e){let n=eQ(t,e.index,e.orientation,l);if(0===n.cells.length)return!1;return n.cells.some(e=>e.node&&!eX(e.node))}{let{selection:e}=t.state;if(e instanceof eO.rn){let t=!1;return e.forEachCell(e=>{eX(e)||(t=!0)}),t}let{$anchor:n}=e,r=(0,eO.KW)(n);if(!r)return!1;let l=t.state.doc.nodeAt(r.pos);return!!l&&!eX(l)}}catch(e){return!1}}function rB(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{editor:t,index:n,orientation:r,tablePos:l,hideWhenUnavailable:a=!1,resetAttrs:o=!1,onCleared:i}=e,{editor:s}=nl(t),c=eJ(s,n,r,l),d=function(e){let{editor:t,index:n,orientation:r,tablePos:l,hideWhenUnavailable:a}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,r_)||!e$(t,l))return!1;let o=eJ(t,n,r,l),{selection:i}
1=t.state,s=i instanceof eO.rn||(0,eO.KW)(i.$anchor);return(!!o||!!s)&&(!a||rz({editor:t,index:n,orientation:r,tablePos:l}))}({editor:s,index:n,orientation:r,tablePos:l,hideWhenUnavailable:a}),u=rz({editor:s,index:n,orientation:r,tablePos:l}),p=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,tablePos:l,resetAttrs:a=!1}=e;if(!rz({editor:t,index:n,orientation:r,tablePos:l})||!t)return!1;try{let e=eJ(t,n,r,l);if(e)return function(e){let{editor:t,index:n,orientation:r,tablePos:l,resetAttrs:a=!1}=e;try{let{state:e,view:o}=t,i=e.tr,s=eQ(t,n,r,l);if(0===s.cells.length)return!1;if([...s.cells].reverse().forEach(e=>{if(e.node&&!eX(e.node)){let t=e.pos+1,n=e.pos+e.node.nodeSize-1;t<n&&i.delete(t,n),a&&i.setNodeMarkup(e.pos,null,{...e.node.attrs,...rP})}}),i.docChanged)return o.dispatch(i),!0;return!1}catch(e){return console.error("Error clearing ".concat(r," content:"),e),!1}}({editor:t,index:e.index,orientation:e.orientation,resetAttrs:a,tablePos:l});return function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{let{selection:n}=e.state;if(n instanceof eO.rn)return t&&rO(e),(0,eO.MT)(e.state,e.view.dispatch),!0;let{$anchor:r}=n,l=(0,eO.KW)(r);if(!l)return!1;let a=e.state.doc.nodeAt(l.pos);if(!a)return!1;let o=l.pos+1,i=l.pos+a.nodeSize-1;if(o>=i)return!1;return t&&rO(e),e.view.dispatch(e.state.tr.delete(o,i)),!0}catch(e){return console.error("Error clearing selected cells:",e),!1}}(t,a)}catch(e){return console.error("Error clearing table content:",e),!1}}({editor:s,index:n,orientation:r,tablePos:l,resetAttrs:o});return e&&(null==i||i()),e},[s,n,r,l,o,i]);return{isVisible:d,canClearRowColumnContent:u,handleClear:p,label:(0,h.useMemo)(()=>c?rH[c.orientation]:"Clear contents",[c]),Icon:rD}}let rF=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M10 16C10.5177 16 10.9438 16.3933 10.9951 16.8975L11 17V19C11 20.6569 9.65685 22 8 22H4C2.34315 22 1 20.6569 1 19V17C1 16.4477 1.44772 16 2 16C2.55228 16 3 16.4477 3 17V19C3 19.5523 3.44772 20 4 20H8C8.55228 20 9 19.5523 9 19V17L9.00488 16.8975C9.05621 16.3933 9.48232 16 10 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M22 16C22.5177 16 22.9438 16.3933 22.9951 16.8975L23 17V19C23 20.6569 21.6569 22 20 22H16C14.3431 22 13 20.6569 13 19V17C13 16.4477 13.4477 16 14 16C14.5523 16 15 16.4477 15 17V19C15 19.5523 15.4477 20 16 20H20C20.5523 20 21 19.5523 21 19V17L21.0049 16.8975C21.0562 16.3933 21.4823 16 22 16Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M5.29297 8.29297C5.68349 7.90244 6.31651 7.90244 6.70703 8.29297L9.70703 11.293L9.77539 11.3691C10.0957 11.7619 10.0731 12.3409 9.70703 12.707L6.70703 15.707C6.31651 16.0975 5.68349 16.0975 5.29297 15.707C4.90245 15.3165 4.90245 14.6835 5.29297 14.293L6.58594 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6.58594L5.29297 9.70703C4.90245 9.31651 4.90245 8.68349 5.29297 8.29297Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M17.293 8.29297C17.6835 7.90245 18.3165 7.90246 18.707 8.29297C19.0976 8.68349 19.0976 9.31651 18.707 9.70703L17.4141 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H17.4141L18.707 14.293C19.0976 14.6835 19.0976 15.3165 18.707 15.707C18.3165 16.0976 17.6835 16.0976 17.293 15.707L14.293 12.707L14.2246 12.6309C13.9043 12.2381 13.9269 11.6591 14.293 11.293L17.293 8.29297Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M8 2C9.65685 2 11 3.34315 11 5V7C11 7.55228 10.5523 8 10 8C9.44771 8 9 7.55228 9 7V5C9 4.44772 8.55228 4 8 4H4C3.44772 4 3 4.44772 3 5V7C3 7.55228 2.55228 8 2 8C1.44772 8 1 7.55228 1 7V5C1 3.34315 2.34315 2 4 2H8Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M20 2C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5C13 3.34315 14.3431 2 16 2H20Z",fill:"currentColor"})]})});rF.displayName="TableCellMergeIcon";let rV=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M4 2C2.34315 2 1 3.34315 1 5V7C1 7.55228 1.44772 8 2 8C2.55228 8 3 7.55228 3 7V5C3 4.44772 3.44772 4 4 4H8C8.55228 4 9 4.44772 9 5V7C9 7.55228 9.44772 8 10 8C10.5523 8 11 7.55228 11 7V5C11 3.34315 9.65685 2 8 2H4Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M20 22C21.6569 22 23 20.6569 23 19V17C23 16.4477 22.5523 16 22 16C21.4477 16 21 16.4477 21 17V19C21 19.5523 20.5523 20 20 20H16C15.4477 20 15 19.5523 15 19V17C15 16.4477 14.5523 16 14 16C13.4477 16 13 16.4477 13 17V19C13 20.6569 14.3431 22 16 22H20Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M13 5C13 3.34315 14.3431 2 16 2H20C21.6569 2 23 3.34315 23 5V7C23 7.55228 22.5523 8 22 8C21.4477 8 21 7.55228 21 7V5C21 4.44772 20.5523 4 20 4H16C15.4477 4 15 4.44772 15 5V7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7V5Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M8 22C9.65685 22 11 20.6569 11 19V17C11 16.4477 10.5523 16 10 16C9.44772 16 9 16.4477 9 17V19C9 19.5523 8.55229 20 8 20H4C3.44772 20 3 19.5523 3 19L3 17C3 16.4477 2.55229 16 2 16C1.44772 16 1 16.4477 1 17V19C1 20.6569 2.34315 22 4 22H8Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M18.7071 15.7071L21.7061 12.7081C21.8877 12.527 22 12.2766 22 12L22 11.997C21.9992 11.7421 21.9016 11.4874 21.7071 11.2929L18.7071 8.29289C18.3166 7.90237 17.6834 7.90237 17.2929 8.29289C16.9024 8.68342 16.9024 9.31658 17.2929 9.70711L18.5858 11H15C14.4477 11 14 11.4477 14 12C14 12.5523 14.4477 13 15 13H18.5858L17.2929 14.2929C16.9024 14.6834 16.9024 15.3166 17.2929 15.7071C17.6834 16.0976 18.3166 16.0976 18.7071 15.7071Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M2.07588 11.6172C2.02699 11.7351 2 11.8644 2 12C2 12.2728 2.10925 12.5201 2.2864 12.7005C2.28879 12.703 2.2912 12.7054 2.29362 12.7078L5.29289 15.7071C5.68342 16.0976 6.31658 16.0976 6.70711 15.7071C7.09763 15.3166 7.09763 14.6834 6.70711 14.2929L5.41421 13L9 13C9.55228 13 10 12.5523 10 12C10 11.4477 9.55229 11 9 11L5.41421 11L6.70711 9.70711C7.09763 9.31658 7.09763 8.68342 6.70711 8.29289C6.31658 7.90237 5.68342 7.90237 5.29289 8.29289L2.29366 11.2921C2.29122 11.2946 2.2888 11.297 2.2864 11.2995C2.19374 11.3938 2.12357 11.502 2.07588 11.6172Z",fill:"currentColor"})]})});rV.displayName="TableCellSplitIcon";let rU=["table"],rW={merge:"Merge cells",split:"Split cell"},rG={merge:rF,split:rV};function rZ(e){if(!e||!e.isEditable||!(0,eg.xU)(e,rU))return!1;try{return(0,eO.w7)(e.state,void 0)}catch(e){return!1}}function rq(e){if(!e||!e.isEditable||!(0,eg.xU)(e,rU))return!1;try{return(0,eO.L0)(e.state,void 0)}catch(e){return!1}}function r$(e){let{editor:t,action:n,hideWhenUnavailable:r=!1,onExecuted:l}=e,{editor:a}=nl(t),o=function(e){let{editor:t,action:n,hideWhenUnavailable:r}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,rU)&&(!r||("merge"===n?rZ(t):rq(t)))}({editor:a,action:n,hideWhenUnavailable:r}),i="merge"===n?rZ(a):rq(a),s=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,action:n}=e;if(!t)return!1;try{return"merge"===n?function(e){if(!rZ(e)||!e)return!1;try{let{state:t,view:n}=e;return(0,eO.w7)(t,n.dispatch.bind(n))}catch(e){return console.error("Error merging table cells:",e),!1}}(t):function(e){if(!rq(e)||!e)return!1;try{let{state:t,view:n}=e;return(0,eO.L0)(t,n.dispatch.bind(n))}catch(e){return console.error("Error splitting table cell:",e),!1}}(t)}catch(e){return console.error("Error ".concat(n,"ing table cell:"),e),!1}}({editor:a,action:n});return e&&(null==l||l(n)),e},[a,n,l]);return{isVisible:o,canExecute:i,handleExecute:s,label:rW[n],Icon:rG[n]}}let rK=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 1.29289C5.31658 0.902369 4.68342 0.902369 4.29289 1.29289C3.90237 1.68342 3.90237 2.31658 4.29289 2.70711L7.08575 5.49997L1.69282 10.8929L1.68582 10.9C1.13614 11.4608 0.828247 12.2147 0.828247 13C0.828247 13.7853 1.1361 14.5392 1.68578 15.1L6.89285 20.3071C8.08338 21.4976 9.91654 21.4976 11.1071 20.3071L19.7071 11.7071C20.0976 11.3166 20.0976 10.6834 19.7071 10.2929L11.7071 2.29289C11.3165 1.90237 10.6834 1.90237 10.2929 2.29289L8.49997 4.08576L5.70711 1.29289ZM17.5857 11L16.5857 12H3.41418L8.49998 6.91419L9.29289 7.70711C9.68342 8.09763 10.3166 8.09763 10.7071 7.70711C11.0976 7.31658 11.0976 6.68342 10.7071 6.29289L9.91419 5.49998L11 4.41421L17.5857 11ZM14.5857 14H3.41418L8.30707 18.8929C8.71654 19.3024 9.28338 19.3024 9.69285 18.8929L14.5857 14Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.9829 15.8157C20.8942 15.3427 20.4812 15 20 15C19.5188 15 19.1058 15.3427 19.0171 15.8157C18.9233 16.3161 18.6226 16.706 18.1385 17.3337L18.0955 17.3895C17.6418 17.9781 17 18.8237 17 20C17 20.7957 17.3161 21.5587 17.8787 22.1213C18.4413 22.6839 19.2043 23 20 23C20.7957 23 21.5587 22.6839 22.1213 22.1213C22.6839 21.5587 23 20.7957 23 20C23 18.8237 22.3582 17.9781 21.9045 17.3895L21.8615 17.3337C21.3774 16.706 21.0767 16.3161 20.9829 15.8157ZM19 20C19 19.5763 19.2082 19.2219 19.6795 18.6105C19.714 18.5658 19.7503 18.5192 19.7881 18.4709C19.855 18.3851 19.9265 18.2935 20 18.1963C20.0735 18.2935 20.1449 18.385 20.2119 18.4708C20.2496 18.5192 20.286 18.5658 20.3205 18.6105C20.7918 19.2219 21 19.5763 21 20C21 20.2652 20.8946 20.5196 20.7071 20.7071C20.5196 20.8946 20.2652 21 20 21C19.7348 21 19.4804 20.8946 19.2929 20.7071C19.1054 20.5196 19 20.2652 19 20Z",fill:"currentColor"})]})});rK.displayName="MoreVerticalIcon";let rY=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.8944 5.55279C12.725 5.214 12.3787 5 12 5C11.6212 5 11.2749 5.214 11.1055 5.55279L5.10555 17.5528C4.85856 18.0468 5.05878 18.6474 5.55276 18.8944C6.04674 19.1414 6.64741 18.9412 6.8944 18.4472L8.64957 14.9369C8.75862 14.9777 8.87671 15 9 15H15C15.1233 15 15.2413 14.9777 15.3504 14.9369L17.1055 18.4472C17.3525 18.9412 17.9532 19.1414 18.4472 18.8944C18.9412 18.6474 19.1414 18.0468 18.8944 17.5528L12.8944 5.55279ZM14.3819 13L12 8.23607L9.61801 13H14.3819Z",fill:"currentColor"})})});function rX(e){let{orientation:t="horizontal",size:n,style:l={},...a}=e,o={...l,..."horizontal"===t&&!n&&{flex:1},...n&&{width:"vertical"===t?"1px":n,height:"horizontal"===t?"1px":n}};return(0,r.jsx)("div",{...a,style:o})}rY.displayName="TextColorSmallIcon";let rJ=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})})});function rQ(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"max",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:768,[n,r]=(0,h.useState)(void 0);return(0,h.useEffect)(()=>{let n=window.matchMedia("min"===e?"(min-width: ".concat(t,"px)"):"(max-width: ".concat(t-1,"px)")),l=e=>r(e.matches);return r(n.matches),n.addEventListener("change",l),()=>n.removeEventListener("change",l)},[e,t]),!!n}rJ.displayName="HighlighterIcon";var r0=n(34556);let r1="mod+shift+h",r2=[{label:"Default background",value:"#ffffff",border:"#ffffff00"},{label:"Gray background",value:"#f8f8f7",border:"#54483126"},{label:"Brown background",value:"#f4eeee",border:"#d2a28d59"},{label:"Orange background",value:"#fbecdd",border:"#e07c3945"},{label:"Yellow background",value:"#fef9c3",border:"#fbe60463"},{label:"Green background",value:"#dcfce7",border:"#c7fad845"},{label:"Blue background",value:"#e0f2fe",border:"#ceeafd45"},{label:"Purple background",value:"#f3e8ff",border:"#e4ccff45"},{label:"Pink background",value:"#fcf1f6",border:"#e188b345"},{label:"Red background",value:"#ffe4e6",border:"#ffccd066"}];function r4(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"mark";if(!e||!e.isEditable)return!1;if("mark"===t)return!(!(0,eg.qi)("highlight",e)||(0,eg.ee)(e,["image"]))&&e.can().setMark("highlight");if(!(0,eg.xU)(e,["nodeBackground"]))return!1;try{return e.can().toggleNodeBackgroundColor("test")}catch(e){return!1}}function r5(e){let{editor:t,label:n,highlightColor:r,hideWhenUnavailable:l=!1,mode:a="mark",onApplied:o}=e,{editor:i}=nl(t),s=rQ(),[c,d]=(0,h.useState)(!0),u=r4(i,a),p=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"mark";if(!e||!e.isEditable)return!1;if("mark"===n)return t?e.isActive("highlight",{color:t}):e.isActive("highlight");if(!t)return!1;try{let{state:n}=e,{selection:l}=n,a=l.$anchor;for(let e=a.depth;e>=0;e--){var r;let n=a.node(e);if(n&&(null==(r=n.attrs)?void 0:r.backgroundColor)===t)return!0}return!1}catch(e){return!1}}(i,r,a);(0,h.useEffect)(()=>{if(!i)return;let e=()=>{d(function(e){let{editor:t,hideWhenUnavailable:n,mode:r}=e;if(!t||!t.isEditable)return!1;if("mark"===r){if(!(0,eg.qi)("highlight",t))return!1}
1else if(!(0,eg.xU)(t,["nodeBackground"]))return!1;return!n||!!t.isActive("code")||r4(t,r)}({editor:i,hideWhenUnavailable:l,mode:a}))};return e(),i.on("selectionUpdate",e),()=>{i.off("selectionUpdate",e)}},[i,l,a]);let m=(0,h.useCallback)(()=>{if(!i||!u||!r||!n)return!1;if("mark"===a){if(i.state.storedMarks){let e=i.schema.marks.highlight;e&&i.view.dispatch(i.state.tr.removeStoredMark(e))}return setTimeout(()=>{let e=i.chain().focus().toggleMark("highlight",{color:r}).run();return e&&(null==o||o({color:r,label:n,mode:a})),e},0),!0}{let e=i.chain().focus().toggleNodeBackgroundColor(r).run();return e&&(null==o||o({color:r,label:n,mode:a})),e}},[u,r,i,n,o,a]),g=(0,h.useCallback)(()=>{let e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"mark";return!!e&&!!e.isEditable&&!!r4(e,t)&&("mark"===t?e.chain().focus().unsetMark("highlight").run():e.chain().focus().unsetNodeBackgroundColor().run())}(i,a);return e&&(null==o||o({color:"",label:"Remove highlight",mode:a})),e},[i,o,a]);return(0,r0.vC)(r1,e=>{e.preventDefault(),m()},{enabled:c&&u,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:c,isActive:p,handleColorHighlight:m,handleRemoveHighlight:g,canColorHighlight:u,label:n||"Highlight",shortcutKeys:r1,Icon:rJ,mode:a}}let r7="mod+shift+t",r3=[{label:"Default text",value:"#0e0e11",border:"#ffffff00"},{label:"Gray text",value:"#787673",border:"#54473126"},{label:"Brown text",value:"#7c5243",border:"#b8948259"},{label:"Orange text",value:"#c45e08",border:"#c4824845"},{label:"Yellow text",value:"#b8892e",border:"#dcb95063"},{label:"Green text",value:"#3e7c52",border:"#82c49845"},{label:"Blue text",value:"#317fa0",border:"#5aa8c845"},{label:"Purple text",value:"#8a6aab",border:"#a894d245"},{label:"Pink text",value:"#b84e7e",border:"#dc94b845"},{label:"Red text",value:"#c45252",border:"#f0a8a066"}];function r9(e){if(!e||!e.isEditable||!(0,eg.qi)("textStyle",e)||(0,eg.ee)(e,["image"]))return!1;try{return e.can().setMark("textStyle",{color:"currentColor"})}catch(e){return!1}}function r6(e){let{editor:t,label:n,textColor:r,hideWhenUnavailable:l=!1,onApplied:a}=e,{editor:o}=nl(t),i=rQ(),[s,c]=(0,h.useState)(!0),d=r9(o),u=!!o&&!!o.isEditable&&o.isActive("textStyle",{color:r});(0,h.useEffect)(()=>{if(!o)return;let e=()=>{c(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.qi)("textStyle",t)&&(!n||!!t.isActive("code")||r9(t))}({editor:o,hideWhenUnavailable:l}))};return e(),o.on("selectionUpdate",e),()=>{o.off("selectionUpdate",e)}},[o,l]);let p=(0,h.useCallback)(()=>{if(!o||!d)return!1;if(o.state.storedMarks){let e=o.schema.marks.textStyle;e&&o.view.dispatch(o.state.tr.removeStoredMark(e))}setTimeout(()=>{(0,eg.So)(o);let e=o.chain().focus().toggleMark("textStyle",{color:r}).run();return e&&(null==a||a({color:r,label:n})),e},0)},[o,d,r,a,n]);return(0,r0.vC)(r7,e=>{e.preventDefault(),p()},{enabled:s&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:s,isActive:u,handleColorText:p,canColorText:d,label:n||"Color text to ".concat(r),shortcutKeys:r7,Icon:rY}}var r8=n(17916);function le(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,r*t+t))}function lt(e){if(!e)return{hasContent:!1,content:"",allContentAbove:""};let{state:t}=e,{$from:n}=t.selection,r="",l="";for(let e=n.index(0)-1;e>=0;e--){let n=t.doc.child(e).textContent.trim();n&&(l||(l=n),r=r?"".concat(n,"\n").concat(r):n)}return{hasContent:r.length>0,content:l,allContentAbove:r}}function ln(e,t){if(!e)return null;let{state:n}=e,{from:r,to:l,empty:a,$from:o}=n.selection;if(a){var i;let e=o.marks().find(e=>e.type.name===t);return null!=(i=null==e?void 0:e.attrs)?i:null}let s=new Set,c=null;return n.doc.nodesBetween(r,l,e=>{if(e.isText)for(let n of e.marks)n.type.name!==t||s.has(n.type.name)||(s.add(n.type.name),c=n.attrs)}),c}function lr(e){let{editor:t,node:n,nodePos:r}=e;if((0,eg.u1)(r))return r;if(n){let e=(0,eg.po)({editor:t,node:n});if(e)return e.pos}let{selection:l}=t.state;if(!l.empty)return null;let a=l.$anchor;return a.node(1)?a.before(1):null}function ll(e){let{state:t,view:n}=e,{selection:r}=t;if(r instanceof $.nh)return n.nodeDOM(r.from);if(r instanceof $.U3){let e=r.$anchor;if(e.depth>=1){let t=n.nodeDOM(e.before(1));if(t instanceof HTMLElement)return t}}if(r instanceof $.i5){let e=n.dom.firstElementChild;if(e instanceof HTMLElement)return e}return null}function la(e){if(!e)return!1;let{state:t}=e,{selection:n,doc:r}=t;return!n.empty&&r.textBetween(n.from,n.to,"\n","\0").trim().length>0}function lo(e,t){var n;return null!=(n=t.find(t=>t.value===e))?n:{value:e,label:e}}function li(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,[t,n]=(0,h.useState)([]),[r,l]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{try{let t=localStorage.getItem("tiptapRecentlyUsedColors");if(t){let r=JSON.parse(t);n(r.slice(0,e))}}catch(e){console.error("Failed to load stored colors:",e)}finally{l(!0)}},[e]),{recentColors:t,addRecentColor:(0,h.useCallback)(t=>{let{type:r,label:l,value:a}=t;n(t=>{let n=t.filter(e=>e.type!==r||e.value!==a),o=[{type:r,label:l,value:a},...n].slice(0,e);try{localStorage.setItem("tiptapRecentlyUsedColors",JSON.stringify(o))}catch(e){console.error("Failed to store colors:",e)}return o}
1)},[e]),isInitialized:r}}let ls=e=>{let{color:t}=e,{addRecentColor:n}=li(),{isActive:l,handleColorText:a,label:o}=r6({label:t.label,textColor:t.value,onApplied:e=>{let{color:t,label:r}=e;return n({type:"text",label:r,value:t})}});return(0,r.jsxs)(rA,{render:(0,r.jsx)(d.$n,{"data-style":"ghost","data-active-state":l?"on":"off"}),onClick:a,children:[(0,r.jsx)("span",{className:"tiptap-button-color-text",style:{color:t.value},children:(0,r.jsx)(rY,{className:"tiptap-button-icon",style:{color:t.value,flexGrow:1}})}),(0,r.jsx)("span",{className:"tiptap-button-text",children:o})]})},lc=e=>{let{color:t}=e,{addRecentColor:n}=li(),{isActive:l,handleColorHighlight:a,label:o}=r5({label:t.label,highlightColor:t.value,mode:"node",onApplied:e=>{let{color:t,label:r}=e;return n({type:"highlight",label:r,value:t})}});return(0,r.jsxs)(rA,{render:(0,r.jsx)(d.$n,{"data-style":"ghost","data-active-state":l?"on":"off"}),onClick:a,children:[(0,r.jsx)("span",{className:"tiptap-button-highlight",style:{"--highlight-color":t.value}}),(0,r.jsx)("span",{className:"tiptap-button-text",children:o})]})},ld=e=>{let{colorObj:t}=e,n="text"===t.type?r3:r2,l=lo(t.value,n),a="text"===t.type?ls:lc;return(0,r.jsx)(a,{color:l})},lu=e=>{let{editor:t,trigger:n,label:l="Color",placement:a="right"}=e,[o,i]=(0,h.useState)(!1),{editor:s}=nl(t),{recentColors:c,isInitialized:u}=li(),p=!!(null==s?void 0:s.can().setMark("textStyle"))||!!(null==s?void 0:s.can().setMark("highlight"))||!!(null==s?void 0:s.can().toggleNodeBackgroundColor("yellow"));if(!s||!p)return null;let m=(0,r.jsx)(rA,{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),render:(0,r.jsx)(rk,{render:(0,r.jsxs)(d.$n,{"data-style":"ghost",children:[(0,r.jsx)(rK,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),(0,r.jsx)(rX,{}),(0,r.jsx)(nF,{className:"tiptap-button-icon"})]})})});return(0,r.jsx)(rj,{open:o,placement:a,trigger:n||m,onOpenChange:i,children:(0,r.jsx)(rI,{onMouseLeave:()=>i(!1),className:"max-h-[200px] overflow-auto",children:(0,r.jsxs)(n9,{children:[u&&c.length>0&&(0,r.jsxs)(rN,{children:[(0,r.jsx)(rS,{children:"Recent colors"}),c.map(e=>(0,r.jsx)(ld,{colorObj:e},e.value)),(0,r.jsx)(rR,{orientation:"horizontal"})]}),(0,r.jsxs)(rN,{children:[(0,r.jsx)(rS,{children:"Text color"}),r3.map(e=>(0,r.jsx)(ls,{color:e},e.value))]}),(0,r.jsx)(rR,{orientation:"horizontal"}
1),(0,r.jsxs)(rN,{children:[(0,r.jsx)(rS,{children:"Background color"}),r2.map(e=>(0,r.jsx)(lc,{color:e},e.value))]})]})})})};n(88904);let lp=e=>{let{action:t}=e,{icon:n,label:l,onClick:a,isActive:o=!1,shortcutBadge:i}=t;return(0,r.jsxs)(rA,{render:(0,r.jsx)(d.$n,{"data-style":"ghost","data-active-state":o?"on":"off"}),onClick:a,children:[(0,r.jsx)(n,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i]})},lh=e=>{let{onClose:t}=e,{mergeAction:n,splitAction:l,clearAction:a}=function(){let e=r$({action:"merge"}),t=r$({action:"split"}),n=rB({resetAttrs:!0}),r={icon:e.Icon,label:e.label,onClick:e.handleExecute,isAvailable:e.canExecute};return{mergeAction:r,splitAction:{icon:t.Icon,label:t.label,onClick:t.handleExecute,isAvailable:t.canExecute},clearAction:{icon:n.Icon,label:n.label,onClick:n.handleClear,isAvailable:n.canClearRowColumnContent}}}(),o=n.isAvailable||l.isAvailable;return(0,r.jsxs)(rI,{autoFocusOnShow:!0,modal:!0,onClose:t,children:[(0,r.jsx)(n8,{style:eg.X6}),(0,r.jsxs)(n9,{style:{minWidth:"15rem"},children:[o&&(0,r.jsxs)(rN,{children:[n.isAvailable&&(0,r.jsx)(lp,{action:n}),l.isAvailable&&(0,r.jsx)(lp,{action:l}),(0,r.jsx)(rR,{orientation:"horizontal"})]}),(0,r.jsxs)(rN,{children:[(0,r.jsx)(lu,{}),(0,r.jsx)(rM,{}),a.isAvailable&&(0,r.jsx)(lp,{action:a})]})]})]})},lm=(0,h.forwardRef)((e,t)=>{let{editor:n,onOpenChange:l,className:a,...o}=e,{editor:i}=nl(n),{isMenuOpen:s,handleMenuToggle:c,closeMenu:d}=function(e){let{editor:t}=e,[n,r]=(0,h.useState)(!1),l=(0,h.useCallback)(()=>{r(!1),null==t||t.commands.unfreezeHandles()},[t]);return{isMenuOpen:n,handleMenuToggle:(0,h.useCallback)(e=>{r(e),t&&(e?t.commands.freezeHandles():t.commands.unfreezeHandles())},[t]),closeMenu:l}}({editor:i});return(0,h.useEffect)(()=>{null==l||l(s)},[s,l]),(0,r.jsx)(rj,{open:s,onOpenChange:c,placement:"bottom-start",trigger:(0,r.jsx)(rk,{ref:t,className:(0,eg.cn)("expandable-menu-button",s&&"menu-opened",a),"aria-label":"Table cells option","aria-haspopup":"menu","aria-expanded":s,...o,children:(0,r.jsx)(nz,{className:"tiptap-button-icon"})}),children:(0,r.jsx)(lh,{onClose:d})})});lm.displayName="TableCellHandleMenu";let lg=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M13.5 8C13.5 7.17157 12.8284 6.5 12 6.5C11.1716 6.5 10.5 7.17157 10.5 8V10.5H8C7.17157 10.5 6.5 11.1716 6.5 12C6.5 12.8284 7.17157 13.5 8 13.5H10.5V16C10.5 16.8284 11.1716 17.5 12 17.5C12.8284 17.5 13.5 16.8284 13.5 16V13.5H16C16.8284 13.5 17.5 12.8284 17.5 12C17.5 11.1716 16.8284 10.5 16 10.5H13.5V8Z",fill:"currentColor"})})});function lf(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{editor:t,initialState:n=null,watchFields:r,onStateChange:l}=e,{editor:a}=nl(t),[o,i]=(0,h.useState)(n),s=(0,h.useRef)(n),c=(0,h.useCallback)(e=>{(!r||!s.current||r.some(t=>s.current[t]!==e[t]))&&(i(e),s.current=e,null==l||l(e))},[r,l]);return(0,h.useEffect)(()=>{if(!a){i(null),s.current=null,null==l||l(null);return}return a.on("tableHandleState",c),()=>{a.off("tableHandleState",c)}},[a,l,c]),o}lg.displayName="PlusSmallIcon";let lx={row:{placement:"bottom",sizeProperty:"width"},column:{placement:"right",sizeProperty:"height"}};function lb(e,t,n){let r=lx[e],{refs:l,update:a,context:o,floatingStyles:i}=(0,ne.we)({open:t,placement:r.placement,middleware:[(0,t8.cY)(4),(0,t8.Ej)({apply(e){let{rects:t,elements:n}=e,l=n.floating;if(!l)return;let a="".concat(t.reference[r.sizeProperty],"px");l.style[r.sizeProperty]=a}})]}),{isMounted:s,styles:c}=(0,ne.DL)(o),d=(0,h.useCallback)(e=>({getBoundingClientRect:()=>e}),[]);return(0,h.useEffect)(()=>{n&&(l.setReference(d(n)),a())},[n,l,a,d]),(0,h.useMemo)(()=>({isMounted:s,ref:l.setFloating,style:{display:"flex",...c,...i}}),[i,s,l.setFloating,c])}n(18740);let lC=e=>{let{editor:t,onMouseDown:n,onMouseUp:l,orientation:a,children:o}=e,{editor:i}=nl(t),s=lf({editor:i}),c="row"===a,d=(0,h.useRef)(!1),[u,p]=(0,h.useState)(null),m=(0,h.useCallback)(e=>{if(!s)return;let t=eO.J3.get(s.block);d.current=!1,p({startPos:c?e.clientY:e.clientX,originalHeight:t.height,originalWidth:t.width}),n(),e.preventDefault()},[s,c,n]),g=(0,h.useCallback)(()=>{!d.current&&i&&s&&eY(i,()=>{e5(i,s.block,s.blockPos,a),c?i.commands.addRowAfter():i.commands.addColumnAfter()})},[i,c,a,s]);return((0,h.useEffect)(()=>
1{if(!u||!i||!s)return;let e=e=>{d.current=!0;let t=(c?e.clientY:e.clientX)-u.startPos,n=c?40:120,r=eO.J3.get(s.block),l=c?r.height:r.width,o=Math.max(1,(c?u.originalHeight:u.originalWidth)+function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.3,n=Math.floor(e),r=Math.ceil(e);return e<n+t?n:e>r-t?r:Math.round(e)}(t/n,.3))-l;0!==o&&(o>0?eY(i,()=>{e5(i,s.block,s.blockPos,a);for(let e=0;e<o;e++)c?i.commands.addRowAfter():i.commands.addColumnAfter()}):eY(i,()=>{let e=Math.min(Math.abs(o),c?eq(i,s.blockPos,"row"):eq(i,s.blockPos,"column"),l-1);e5(i,s.block,s.blockPos,a);for(let t=0;t<e;t++)c?i.commands.deleteRow():i.commands.deleteColumn()}))},t=()=>{p(null),l()};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[u,i,c,a,l,s]),null==i?void 0:i.isEditable)?(0,r.jsx)("button",{className:(0,eg.cn)("tiptap-table-extend-row-column-button",c?"tiptap-table-row-end-add-remove":"tiptap-table-column-end-add-remove",u&&"editing"),onClick:g,onMouseDown:m,type:"button","aria-label":c?"Add or remove rows":"Add or remove columns",children:null!=o?o:(0,r.jsx)(lg,{className:"tiptap-button-icon"})}):null},lv=e=>{var t,n,l;let{editor:a,onMouseDown:o,onMouseUp:i}=e,{editor:s}=nl(a),c=lf({editor:s}),{columnButton:d,rowButton:u}=function(e,t,n){let r=lb("row",t,n),l=lb("column",e,n);return(0,h.useMemo)(()=>({rowButton:r,columnButton:l}),[r,l])}(null!=(t=null==c?void 0:c.showAddOrRemoveColumnsButton)&&t,null!=(n=null==c?void 0:c.showAddOrRemoveRowsButton)&&n,null!=(l=null==c?void 0:c.referencePosTable)?l:null),p=(0,h.useCallback)(()=>{s&&(s.commands.freezeHandles(),null==o||o())},[s,o]),m=(0,h.useCallback)(()=>{s&&(s.commands.unfreezeHandles(),null==i||i())},[s,i]);return c?(0,r.jsxs)(ne.XF,{root:c.widgetContainer,children:[(0,r.jsx)("div",{ref:u.ref,style:u.style,children:(0,r.jsx)(lC,{editor:s,orientation:"row",block:c.block,onMouseDown:p,onMouseUp:m})}),(0,r.jsx)("div",{ref:d.ref,style:d.style,children:(0,r.jsx)(lC,{editor:s,orientation:"column",block:c.block,onMouseDown:p,onMouseUp:m})})]}):null},ly=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 5C10 3.89543 10.8954 3 12 3C13.1046 3 14 3.89543 14 5C14 6.10457 13.1046 7 12 7C10.8954 7 10 6.10457 10 5Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 19C10 17.8954 10.8954 17 12 17C13.1046 17 14 17.8954 14 19C14 20.1046 13.1046 21 12 21C10.8954 21 10 20.1046 10 19Z",fill:"currentColor"})]})});ly.displayName="MoreVerticalIcon";let lw=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H15C13.3431 22 12 20.6569 12 19V5C12 3.34315 13.3431 2 15 2H19ZM14 19C14 19.5523 14.4477 20 15 20H19C19.5523 20 20 19.5523 20 19V13H14V19ZM15 4C14.4477 4 14 4.44772 14 5V11H20V5C20 4.44772 19.5523 4 19 4H15Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M6 8C6.55228 8 7 8.44772 7 9V11H9C9.55228 11 10 11.4477 10 12C10 12.5523 9.55228 13 9 13H7V15C7 15.5523 6.55228 16 6 16C5.44772 16 5 15.5523 5 15V13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H5V9C5 8.44772 5.44772 8 6 8Z",fill:"currentColor"})]})});lw.displayName="AddColLeftIcon";let lj=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 2C10.6569 2 12 3.34315 12 5V19C12 20.6569 
110.6569 22 9 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H9ZM4 19C4 19.5523 4.44772 20 5 20H9C9.55228 20 10 19.5523 10 19V13H4V19ZM5 4C4.44772 4 4 4.44772 4 5V11H10V5C10 4.44772 9.55228 4 9 4H5Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M18 8C18.5523 8 19 8.44772 19 9V11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H19V15C19 15.5523 18.5523 16 18 16C17.4477 16 17 15.5523 17 15V13H15C14.4477 13 14 12.5523 14 12C14 11.4477 14.4477 11 15 11H17V9C17 8.44772 17.4477 8 18 8Z",fill:"currentColor"})]})});lj.displayName="AddColRightIcon";let lI=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M12 14C12.5523 14 13 14.4477 13 15V17H15C15.5523 17 16 17.4477 16 18C16 18.5523 15.5523 19 15 19H13V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V19H9C8.44772 19 8 18.5523 8 18C8 17.4477 8.44772 17 9 17H11V15C11 14.4477 11.4477 14 12 14Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 2C20.6569 2 22 3.34315 22 5V9C22 10.6569 20.6569 12 19 12H5C3.34315 12 2 10.6569 2 9V5C2 3.34315 3.34315 2 5 2H19ZM5 4C4.44772 4 4 4.44772 4 5V9C4 9.55228 4.44772 10 5 10H11V4H5ZM13 10H19C19.5523 10 20 9.55228 20 9V5C20 4.44772 19.5523 4 19 4H13V10Z",fill:"currentColor"})]})});lI.displayName="AddRowBottomIcon";let lk=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 12C20.6569 12 22 13.3431 22 15V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V15C2 13.3431 3.34315 12 5 12H19ZM5 14C4.44772 14 4 14.4477 4 15V19C4 19.5523 4.44772 20 5 20H11V14H5ZM13 20H19C19.5523 20 20 19.5523 20 19V15C20 14.4477 19.5523 14 19 14H13V20Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V5H15C15.5523 5 16 5.44772 16 6C16 6.55228 15.5523 7 15 7H13V9C13 9.55228 12.5523 10 12 10C11.4477 10 11 9.55228 11 9V7H9C8.44772 7 8 6.55228 8 6C8 5.44772 8.44772 5 9 5H11V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"})]})});lk.displayName="AddRowTopIcon";let lE=["table"],lN={row:{above:"Insert row above",below:"Insert row below"},column:{left:"Insert column left",right:"Insert column right"}};function lS(e){let{editor:t,index:n,orientation:r,tablePos:l,side:a}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,lE))return!1;let o=e$(t,l);if(!o)return!1;let i=eJ(t,n,r);if(!i)return!1;let{map:s,node:c}=o,d=i.index,u=i.orientation;return!("number"!=typeof d||d<0||"column"===u&&d>=s.width||"row"===u&&d>=s.height||"left"===a&&"column"===u&&function(e,t,n){try{return(0,eO.Ui)(e,t,n)}catch(e){return!1}}(s,c,d)||"above"===a&&"row"===u&&function(e,t,n){try{return(0,eO.KL)(e,t,n)}catch(e){return!1}}(s,c,d))}function lT(e){let{editor:t,index:n,orientation:r,side:l,tablePos:a,hideWhenUnavailable:o=!1,onAdded:i}=e,{editor:s}=nl(t),c=eJ(s,n,r),d=function(e){let{editor:t,index:n,orientation:r,tablePos:l,side:a,hideWhenUnavailable:o}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,lE)&&(o?lS({editor:t,index:n,orientation:r,tablePos:l,side:a}):!!eJ(t,n,r))}({editor:s,index:n,orientation:r,tablePos:a,side:l,hideWhenUnavailable:o}),u=lS({editor:s,index:n,orientation:r,tablePos:a,side:l}),p=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,side:l,tablePos:a}=e;if(!lS({editor:t,index:n,orientation:r,tablePos:a,side:l})||!t)return!1;let o=eJ(t,n,r);if(!o)return!1;let{orientation:i,index:s}=o,c=e=>t.view.dispatch(e),d="row"===i?"above"===l?eO.JD:eO.gC:"left"===l?eO.RC:eO.GU;try{let e=!1;if(t.state.selection instanceof eO.rn)e=d(t.state,c);else{let n=e$(t,a);if(!n)return!1;let r=e4(t,n.pos,["row"===i?{row:s,col:0}:{row:0,col:s}],{mode:"state"});if(!r)return!1;e=d(r,c)}if(e){let e="row"===i?"above"===l?s:s+1:"left"===l?s:s+1;e1(t,i,e,a)}return e}catch(e){return console.error("Error adding row/column:",e),!1}}({editor:s,index:n,orientation:r,tablePos:a,side:l});return e&&(null==i||i()),e},[s,n,r,a,l,i]);return{isVisible:d,canAddRowColumn:u,handleAdd:p,label:(null==c?void 0:c.orientation)==="row"?lN.row[l]:lN.column[l],Icon:(null==c?void 0:c.orientation)==="row"?"above"===l?lk:lI:"left"===l?lw:lj}}let lA=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})})});lA.displayName="TrashIcon";let lR=["table"],lM={row:"Delete row",column:"Delete column"};function lL(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,lR))return!1;try{if(!e$(t,l)||!eJ(t,n,r))return!1;return!0}catch(e){return!1}}let lD=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:n.width||"24",height:n.height||"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 9C9.44772 9 9 9.44772 9 10V20C9 20.5523 9.44772 21 10 21H20C20.5523 21 21 20.5523 21 20V10C21 9.44772 20.5523 9 20 9H10ZM7 10C7 8.34315 8.34315 7 10 7H20C21.6569 7 23 8.34315 23 10V20C23 21.6569 21.6569 23 20 23H10C8.34315 23 7 21.6569 7 20V10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C3.45228 3 3 3.45228 3 4V14C3 14.5477 3.45228 15 4 15C4.55228 15 5 15.4477 5 16C5 16.5523 4.55228 17 4 17C2.34772 17 1 15.6523 1 14V4C1 2.34772 2.34772 1 4 1H14C15.6523 1 17 2.34772 17 4C17 4.55228 16.5523 5 16 5C15.4477 5 15 4.55228 15 4C15 3.45228 14.5477 3 14 3H4Z",fill:"currentColor"})]})});lD.displayName="CopyIcon";let l_=["tableHandleExtension"],lH={row:"Duplicate row",column:"Duplicate column"};function lP(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,l_))return!1;try{if(!e$(t,l))return!1;let e=eQ(t,n,r,l);if(e.mergedCells.length>0)return!1;return e.cells.length>0}catch(e){return!1}}let lO=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 19V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19ZM8 20V16H20V19C20 19.5523 19.5523 20 19 20H8ZM8 
114L20 14V10L8 10V14ZM20 8L8 8V4H19C19.5523 4 20 4.44772 20 5V8Z",fill:"currentColor"})})});lO.displayName="TableHeaderColumnIcon";let lz=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5V7V19C2 20.6569 3.34315 22 5 22H19C20.6569 22 22 20.6569 22 19V7V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5ZM20 19V8H16V20H19C19.5523 20 20 19.5523 20 19ZM14 20L14 8H10L10 20H14ZM8 20L8 8H4V19C4 19.5523 4.44772 20 5 20H8Z",fill:"currentColor"})})});lz.displayName="TableHeaderRowIcon";let lB=["table"],lF={row:"Header row",column:"Header column"},lV={row:lz,column:lO};function lU(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,lB))return!1;let a=eJ(t,n,r,l);return!!a&&0===a.index}let lW=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M12.707 19.707C12.3165 20.0976 11.6835 20.0976 11.293 19.707L4.29297 12.707C3.90245 12.3165 3.90245 11.6835 4.29297 11.293C4.68349 10.9024 5.31651 10.9024 5.70703 11.293L11 16.5859L11 5C11 4.44771 11.4477 4 12 4C12.5523 4 13 4.44771 13 5L13 16.5859L18.293 11.293C18.6835 10.9024 19.3165 10.9024 19.707 11.293C20.0976 11.6835 20.0976 12.3165 19.707 12.707L12.707 19.707Z",fill:"currentColor"})})});
1lW.displayName="ArrowDownIcon";let lG=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})})});lG.displayName="ArrowLeftIcon";let lZ=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289C10.9024 4.68342 10.9024 5.31658 11.2929 5.70711L16.5858 11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H16.5858L11.2929 18.2929C10.9024 18.6834 10.9024 19.3166 11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071L19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})})});lZ.displayName="ArrowRightIcon";let lq=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071C4.68342 13.0976 5.31658 13.0976 5.70711 12.7071L11 7.41421V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V7.41421L18.2929 12.7071C18.6834 13.0976 19.3166 13.0976 19.7071 12.7071C20.0976 12.3166 20.0976 11.6834 19.7071 11.2929L12.7071 4.29289Z",fill:"currentColor"})})});lq.displayName="ArrowUpIcon";let l$=["tableHandleExtension"],lK={row:{up:"Move row up",down:"Move row down",left:"Move row left",right:"Move row right"},column:{up:"Move column up",down:"Move column down",left:"Move column left",right:"Move column right"}},lY={up:lq,down:lW,left:lG,right:lZ};function lX(e,t){return"row"===e?"up"===t||"down"===t:"column"===e&&("left"===t||"right"===t)}function lJ(e){let{editor:t,index:n,orientation:r,direction:l,tablePos:a}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,l$))return!1;try{let e=e$(t,a);if(!e)return!1;let o=eJ(t,n,r);if(!o)return!1;let{orientation:i,index:s}=o;if(!lX(i,l)||"row"===i&&function(e,t,n){try{return(0,eO.KL)(e,t,n)}catch(e){return!1}}(e.map,e.node,s)||"column"===i&&function(e,t,n){try{return(0,eO.Ui)(e,t,n)}catch(e){return!1}}(e.map,e.node,s))return!1;let{width:c,height:d}=e.map,u="row"===i?"up"===l?s-1:s+1:"left"===l?s-1:s+1,p="row"===i?d:c;if(u<0||u>=p)return!1;let h=e7({editor:t,index:s,orientation:i,tablePos:a}),m=e7({editor:t,index:u,orientation:i,tablePos:a});if(!h||!m)return!1;let g=e4(t,e.pos,h,{mode:"state"});if(!g)return!1;let f=(0,eO._t)(g),x=e4(t,e.pos,m,{mode:"state"});if(!x)return!1;let b=(0,eO._t)(x);if(eK(e.map,f)&&eK(e.map,b))return!1;return"row"===i?"up"===l?s>0:s<d-1:"left"===l?s>0:s<c-1}catch(e){return!1}}function lQ(e){let{editor:t,index:n,orientation:r,tablePos:l,direction:a,hideWhenUnavailable:o=!1,onMoved:i}=e,{editor:s}=nl(t),c=eJ(s,n,r),d=function(e){let{editor:t,index:n,orientation:r,direction:l,hideWhenUnavailable:a,tablePos:o}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,l$))return!1;let i=eJ(t,n,r);return!!i&&!!lX(i.orientation,l)&&(!a||lJ({editor:t,index:n,orientation:r,direction:l,tablePos:o}))}({editor:s,index:n,orientation:r,direction:a,hideWhenUnavailable:o,tablePos:l}),u=lJ({editor:s,index:n,orientation:r,direction:a,tablePos:l}),p=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,direction:l,tablePos:a}=e;if(!lJ({editor:t,index:n,orientation:r,direction:l,tablePos:a})||!t)return!1;try{let e=e$(t,a);if(!e)return!1;let o=eJ(t,n,r);if(!o)return!1;let{orientation:i,index:s}=o;if(!lX(i,l))return!1;if(t.state.selection instanceof eO.rn)return console.warn("CellSelection move not implemented yet."),!0;{let n=e7({editor:t,index:s,orientation:i,tablePos:a});if(!n||!e4(t,e.pos,n,{mode:"state"}))return!1;return!0}}catch(e){return console.error("Error moving table row/column:",e),!1}}({editor:s,index:n,orientation:r,direction:a,tablePos:l});return e&&(null==i||i()),e},[s,n,r,a,l,i]);return{isVisible:d,canMoveRowColumn:u,handleMove:p,label:(0,h.useMemo)(()=>lK[(null==c?void 0:c.orientation)||"row"][a]||"Move ".concat(null==c?void 0:c.orientation," ").concat(a),[c,a]),Icon:(0,h.useMemo)(()=>lY[a],[a])}}let l0=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M20.1437 13.0107C20.4734 13.0585 20.7615 13.2687 20.9054 13.5762C21.0699 13.9275 21.0171 14.3426 20.7687 14.6406L17.1359 19H20.0002C20.5524 19 21.0002 19.4477 21.0002 20C21.0002 20.5523 20.5524 21 20.0002 21H15.0002C14.6122 21 14.2595 20.7752 14.0949 20.4238C13.9304 20.0725 13.9832 19.6574 14.2316 19.3594L17.8644 15H15.0002C14.4479 15 14.0002 14.5523 14.0002 14C14.0002 13.4477 14.4479 13 15.0002 13H20.0002L20.1437 13.0107Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 3C18.4284 3.00002 19.3184 3.36903 19.9748 4.02539C20.6311 4.68176 21.0002 5.57176 21.0002 6.5V10C21.0002 10.5523 20.5524 11 20.0002 11C19.4479 11 19.0002 10.5523 19.0002 10V9H16.0002V10C16.0002 10.5523 15.5524 11 15.0002 11C14.4479 11 14.0002 10.5523 14.0002 10V6.5C14.0002 5.57174 14.3692 4.68177 15.0256 4.02539C15.6819 3.36904 16.5719 3 17.5002 3ZM17.5002 5C17.1024 5 16.7209 5.15817 16.4396 5.43945C16.1583 5.72076 16.0002 6.10218 16.0002 6.5V7H19.0002V6.5C19.0002 6.10219 18.842 5.72075 18.5607 5.43945C18.2794 5.15817 17.898 5.00002 17.5002 5Z",fill:"currentColor"})]})});l0.displayName="ArrowDownAZIcon";let l1=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M7.00017 3C7.55242 3.00004 8.00017 3.44774 8.00017 4V17.5859L10.2931 15.293C10.6837 14.9025 11.3167 14.9025 11.7072 15.293C12.0976 15.6835 12.0976 16.3165 11.7072 16.707L7.7072 20.707C7.66067 20.7536 7.60881 20.7944 7.55388 20.8311C7.51475 20.8572 7.47445 20.8804 7.43279 20.9004C7.38729 20.9223 7.34018 20.9412 7.29118 20.9561C7.27445 20.9611 7.25734 20.9646 7.2404 20.9688C7.2248 20.9726 7.20941 20.9774 7.19353 20.9805C7.18643 20.9819 7.17916 20.9822 7.17204 20.9834C7.1161 20.9931 7.05889 21 7.00017 21L6.89763 20.9951C6.87615 20.9929 6.85521 20.9879 6.83415 20.9844C6.82375 20.9826 6.81326 20.9816 6.8029 20.9795C6.7914 20.9772 6.78008 20.9744 6.76872 20.9717C6.74815 20.9668 6.72749 20.9622 6.7072 20.9561C6.65855 20.9412 6.61176 20.9222 6.56658 20.9004C6.5247 20.8802 6.48381 20.8574 6.4445 20.8311C6.39008 20.7946 6.3393 20.7532 6.29314 20.707L2.29314 16.707C1.90261 16.3165 1.90261 15.6835 2.29314 15.293C2.68367 14.9025 3.3167 14.9025 3.7072 15.293L6.00017 17.5859V4C6.00017 3.44772 6.44788 3 7.00017 3Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.5002 13C18.4284 13 19.3184 13.369 19.9748 14.0254C20.6311 14.6818 21.0002 15.5718 21.0002 16.5V20C21.0002 20.5523 20.5524 21 20.0002 21C19.4479 21 19.0002 20.5523 19.0002 20V19H16.0002V20C16.0002 20.5523 15.5524 21 15.0002 21C14.4479 21 14.0002 20.5523 14.0002 20V16.5C14.0002 15.5717 14.3692 14.6818 15.0256 14.0254C15.6819 13.369 16.5719 13 17.5002 13ZM17.5002 15C17.1024 15 16.7209 15.1582 16.4396 15.4395C16.1583 15.7208 16.
10002 16.1022 16.0002 16.5V17H19.0002V16.5C19.0002 16.1022 18.842 15.7208 18.5607 15.4395C18.2794 15.1582 17.898 15 17.5002 15Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M20.1437 3.01074C20.4734 3.05854 20.7615 3.26875 20.9054 3.57617C21.0699 3.9275 21.0171 4.34259 20.7687 4.64062L17.1359 9H20.0002C20.5524 9.00004 21.0002 9.44774 21.0002 10C21.0002 10.5523 20.5524 11 20.0002 11H15.0002C14.6122 11 14.2595 10.7752 14.0949 10.4238C13.9304 10.0725 13.9832 9.65742 14.2316 9.35938L17.8644 5H15.0002C14.4479 5 14.0002 4.55228 14.0002 4C14.0002 3.44772 14.4479 3 15.0002 3H20.0002L20.1437 3.01074Z",fill:"currentColor"})]})});l1.displayName="ArrowDownZAIcon";let l2=["tableHandleExtension"],l4={row:{asc:"Sort row A-Z",desc:"Sort row Z-A"},column:{asc:"Sort column A-Z",desc:"Sort column Z-A"}},l5={asc:l0,desc:l1};function l7(e){var t;return!!e&&("tableHeader"===e.type.name||"table_header"===e.type.name||(null==(t=e.attrs)?void 0:t.header)===!0)}function l3(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t||!t.isEditable||!(0,eg.xU)(t,l2))return!1;try{let e=e$(t,l);if(!e)return!1;let a=eQ(t,n,r,l);if("row"===a.orientation){if(e.map.width<2)return!1}else if(e.map.height<2)return!1;if(a.mergedCells.length>0||!a.cells.some(e=>e.node&&!l7(e.node)&&!eX(e.node)))return!1;return!0}catch(e){return!1}}function l9(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{direction:"asc"},{editor:t,index:n,orientation:r,tablePos:l,direction:a,hideWhenUnavailable:o=!1,onSorted:i}=e,{editor:s}=nl(t),c=eJ(s,n,r),d=function(e){let{editor:t,index:n,orientation:r,hideWhenUnavailable:l,tablePos:a}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,l2)&&!!e$(t,a)&&!!eJ(t,n,r,a)&&(!l||l3({editor:t,index:n,orientation:r,tablePos:a}))}({editor:s,index:n,orientation:r,hideWhenUnavailable:o,tablePos:l}),u=l3({editor:s,index:n,orientation:r,tablePos:l}),p=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,direction:l,tablePos:a}=e;if(!l3({editor:t,index:n,orientation:r,tablePos:a})||!t)return!1;try{let{state:e,view:o}=t,i=e.tr,s=eQ(t,n,r,a);if(s.mergedCells.length>0)return console.warn("Cannot sort ".concat(r," ").concat(n,": contains merged cells")),!1;if(s.cells.length<2)return!1;
1let c=s.cells.map((e,t)=>{let n=l7(e.node),r=!e.node||eX(e.node);return{sortText:function(e){if(!e)return"";let t="";return e.descendants(e=>(e.isText&&(t+=e.text||""),!0)),t.trim().toLowerCase()}(e.node),originalNode:e.node,cellInfo:e,originalIndex:t,isHeader:n,isEmpty:r}}),d=c.filter(e=>!e.isHeader);if(d.length<2)return console.warn("No sortable data cells found (excluding headers)"),!1;d.sort((e,t)=>{if(e.isEmpty&&!t.isEmpty)return 1;if(!e.isEmpty&&t.isEmpty)return -1;if(e.isEmpty&&t.isEmpty)return 0;let n=e.sortText.localeCompare(t.sortText,void 0,{sensitivity:"base"});return"asc"===l?n:-n});let u=[],p=0;for(let e=0;e<c.length;e++){let t=c[e],n=s.cells[e];if(!n||!t)continue;let r=null;if(t.isHeader)r=t.originalNode;else{let e=d[p];r=(null==e?void 0:e.originalNode)||null,p++}if(r&&n.node){let e=n.node.type.create(r.attrs,r.content,r.marks);u.push(e)}else u.push(n.node)}let h=[...s.cells].reverse(),m=[...u].reverse();if(h.forEach((e,t)=>{let n=m[t];if(n&&e.node){let t=e.pos+e.node.nodeSize;i.replaceWith(e.pos,t,n)}}),i.docChanged)return o.dispatch(i),!0;return!1}catch(e){return console.error("Error sorting table ".concat(r,":"),e),!1}}({editor:s,index:n,orientation:r,direction:a,tablePos:l});return e&&(null==i||i()),e},[s,n,r,a,l,i]);return{isVisible:d,canSortRowColumn:u,handleSort:p,label:(0,h.useMemo)(()=>l4[(null==c?void 0:c.orientation)||"row"][a]||"Sort ".concat(null==c?void 0:c.orientation," ").concat(a),[c,a]),Icon:(0,h.useMemo)(()=>l5[a]||l0,[a])}}n(82014);let l6={row:"top-start",column:"bottom-start"},l8={row:"Row actions",column:"Column actions"},ae=(0,h.createContext)(null);function at(){let e=(0,h.useContext)(ae);if(!e)throw Error("useTableHandleContext must be used within TableHandleProvider");return e}function an(e,t){let{editor:n,orientation:r,index:l,tableNode:a,tablePos:o}=at(),[i,s]=(0,h.useState)(!1),[c,d]=(0,h.useState)(!1),u=(0,h.useMemo)(()=>l6[r],[r]),p=(0,h.useCallback)(()=>{if(n&&a&&(0,eg.u1)(o)&&(0,eg.u1)(l))try{let{width:e,height:t}=eO.J3.get(a),i="row"===r?{row:l,col:0}:{row:0,col:l},s="row"===r?{row:l,col:e-1}:{row:t-1,col:l};e4(n,o,[i,s],{mode:"dispatch",dispatch:n.view.dispatch.bind(n.view)})}catch(e){console.warn("Failed to select row/column:",e)}},[n,a,o,r,l]);return{isMenuOpen:i,isDragging:c,setIsDragging:d,menuPlacement:u,handleMenuToggle:(0,h.useCallback)(r=>{n&&(s(r),null==t||t(r),r?(n.commands.freezeHandles(),p(),null==e||e(!1)):(n.commands.unfreezeHandles(),null==e||e(!0)))},[n,t,e,p]),resetMenu:(0,h.useCallback)(()=>{n&&(s(!1),null==t||t(!1),n.commands.unfreezeHandles(),null==e||e(!0))},[n,t,e])}}let ar=e=>{let{icon:t,label:n,onClick:l,disabled:a=!1,isActive:o=!1,shortcutBadge:i}=e;return(0,r.jsxs)(rA,{render:(0,r.jsx)(d.$n,{"data-style":"ghost","data-active-state":o?"on":"off"}),onClick:l,disabled:a,children:[(0,r.jsx)(t,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:n}),i]})},al=()=>{let{index:e,orientation:t}=at(),{deleteAction:n,duplicateAction:l,clearContentAction:a,headerAction:o,addItems:i,moveItems:s,sortItems:c}=function(){let{editor:e,index:t,orientation:n,tablePos:r}=at(),l=function(e){let{editor:t,index:n,orientation:r,tablePos:l,hideWhenUnavailable:a=!1,onDeleted:o}=e,{editor:i}=nl(t),s=eJ(i,n,r),c=function(e){let{editor:t,index:n,orientation:r,hideWhenUnavailable:l,tablePos:a}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,lR)&&(!l||lL({editor:t,index:n,orientation:r,tablePos:a}))}({editor:i,index:n,orientation:r,hideWhenUnavailable:a}),d=lL({editor:i,index:n,orientation:r,tablePos:l});return{isVisible:c,canDeleteRowColumn:d,handleDelete:(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!lL({editor:t,index:n,orientation:r,tablePos:l})||!t)return!1;try{let e=eJ(t,n,r);if(!e)return!1;let{orientation:a,index:o}=e,i="row"===a,s=e=>t.view.dispatch(e),c=i?eO.aR:eO.gR;if(t.state.selection instanceof eO.rn)return c(t.state,s);let d=e$(t,l);if(!d)return!1;let u=e4(t,d.pos,[i?{row:o,col:0}:{row:0,col:o}],{mode:"state"});if(!u)return!1;return c(u,s)}catch(e){return console.error("Error deleting table row/column:",e),!1}}({editor:i,index:n,orientation:r,tablePos:l});return e&&(null==o||o()),e},[i,n,r,l,o]),label:(0,h.useMemo)(()=>lM[(null==s?void 0:s.orientation)||"row"],[s]),Icon:lA}}({editor:e,index:t,orientation:n,tablePos:r}),a=function(e){let{editor:t,index:n,orientation:r,tablePos:l,hideWhenUnavailable:a=!1,onDuplicated:o}=e,{editor:i}=nl(t),s=eJ(i,n,r),c=function(e){let{editor:t,index:n,orientation:r,hideWhenUnavailable:l}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,l_)&&(!l||lP({editor:t,index:n,orientation:r}))}({editor:i,index:n,orientation:r,hideWhenUnavailable:a}),d=lP({editor:i,index:n,tablePos:l,orientation:r}),u=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!lP({editor:t,index:n,orientation:r,tablePos:l})||!t||!e$(t,l))return!1;let a=eJ(t,n,r,l);if(!a)return!1;try{if("row"===a.orientation)return function(e){let{editor:t,index:n,tablePos:r}=e;try{let e=eQ(t,n,"row",r);if(0===e.cells.length)return!1;let l=!1;if(t.state.selection instanceof eO.rn)l=t.chain().focus().addRowAfter().run();else{if(!r)return!1;let e=e7({editor:t,index:n,orientation:"row",tablePos:r});if(!e)return!1;let a=e4(t,r,e,{mode:"state"});l=(0,eO.gC)(a,t.view.dispatch)}if(!l)return!1;let a=eQ(t,n+1,"row",r);if(0===a.cells.length)return!1;let{state:o,view:i}=t,s=o.tr,c=[...a.cells].reverse(),d=[...e.cells].reverse();if(c.forEach((e,t)=>{let n=d[t];if(e.node&&(null==n?void 0:n.node)){let t=e.node.type.create({...n.node.attrs},n.node.content,n.node.marks),r=e.pos+e.node.nodeSize;s.replaceWith(e.pos,r,t)}}),s.docChanged)return i.dispatch(s),e1(t,"row",n+1,r),!0;return!1}catch(e){return console.error("Error duplicating row:",e),!1}}({editor:t,index:a.index,tablePos:l});if("column"===a.orientation)return function(e){let{editor:t,index:n,tablePos:r}=e;try{let e=eQ(t,n,"column",r);
1if(0===e.cells.length)return!1;let l=!1;if(t.state.selection instanceof eO.rn)l=t.chain().focus().addColumnAfter().run();else{if(!r)return!1;let e=e7({editor:t,index:n,orientation:"column",tablePos:r});if(!e)return!1;let a=e4(t,r,e,{mode:"state"});l=(0,eO.GU)(a,t.view.dispatch)}if(!l)return!1;let a=eQ(t,n+1,"column",r);if(0===a.cells.length)return!1;let{state:o,view:i}=t,s=o.tr,c=[...a.cells].reverse(),d=[...e.cells].reverse();if(c.forEach((e,t)=>{let n=d[t];if(e.node&&(null==n?void 0:n.node)){let t=e.node.type.create({...n.node.attrs},n.node.content,n.node.marks),r=e.pos+e.node.nodeSize;s.replaceWith(e.pos,r,t)}}),s.docChanged)return i.dispatch(s),e1(t,"column",n+1,r),!0;return!1}catch(e){return console.error("Error duplicating column:",e),!1}}({editor:t,index:a.index,tablePos:l});return!1}catch(e){return console.error("Error duplicating row/column:",e),!1}}({editor:i,index:n,orientation:r,tablePos:l});return e&&(null==o||o()),e},[i,n,r,l,o]);return{isVisible:c,canDuplicateRowColumn:d,handleDuplicate:u,label:(0,h.useMemo)(()=>lH[(null==s?void 0:s.orientation)||"row"],[s]),Icon:lD}}({editor:e,index:t,orientation:n,tablePos:r}),o=l9({editor:e,tablePos:r,index:t,orientation:n,direction:"asc",hideWhenUnavailable:!0}),i=l9({editor:e,tablePos:r,index:t,orientation:n,direction:"desc",hideWhenUnavailable:!0}),s=rB({editor:e,index:t,orientation:n,tablePos:r,resetAttrs:!0,hideWhenUnavailable:!0}),c=function(e){let{editor:t,index:n,orientation:r,tablePos:l,hideWhenUnavailable:a=!1,onToggled:o}=e,{editor:i}=nl(t),s=eJ(i,n,r),c=function(e){let{editor:t,index:n,orientation:r,hideWhenUnavailable:l,tablePos:a}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,lB)&&(l?lU({editor:t,index:n,orientation:r,tablePos:a}):!!eJ(t,n,r))}({editor:i,index:n,orientation:r,hideWhenUnavailable:a,tablePos:l}),d=lU({editor:i,index:n,orientation:r,tablePos:l}),u=!1;if((null==i?void 0:i.state.selection)instanceof eO.rn)u=(null==i?void 0:i.isActive("tableHeader"))||!1;else{let e=eQ(i,n,null==s?void 0:s.orientation,l);if(e){var p,m;let t=+(e.cells.length>1);u=(null==(m=e.cells[t])||null==(p=m.node)?void 0:p.type.name)==="tableHeader"}}let g=(0,h.useCallback)(()=>{let e=function(e){let{editor:t,index:n,orientation:r,tablePos:l}=e;if(!t||!lU({editor:t,index:n,orientation:r,tablePos:l}))return!1;try{let e=eJ(t,n,r,l);if(!e)return!1;let a="row"===e.orientation;if(t.state.selection instanceof eO.rn)return a?t.commands.toggleHeaderRow():t.commands.toggleHeaderColumn();if(!(0,eg.u1)(l))return!1;let o=e7({editor:t,index:e.index,orientation:e.orientation,tablePos:l});if(!o)return!1;let i=e4(t,l,o,{mode:"state"});if(!i)return!1;let s=e=>t.view.dispatch(e);return a?(0,eO.iS)("row")(i,s):(0,eO.iS)("column")(i,s)}catch(e){return!1}}({editor:i,index:n,orientation:r,tablePos:l});return e&&(null==o||o()),e},[i,n,r,l,o]);return{isVisible:c,canToggleHeader:d,handleToggle:g,label:lF[(null==s?void 0:s.orientation)||"row"],Icon:lV[(null==s?void 0:s.orientation)||"row"],isActive:u}}({editor:e,index:t,orientation:n,tablePos:r,hideWhenUnavailable:!0}),d=lQ({editor:e,index:t,tablePos:r,orientation:"row",direction:"up",hideWhenUnavailable:!0}),u=lQ({editor:e,index:t,tablePos:r,orientation:"row",direction:"down",hideWhenUnavailable:!0}),p=lQ({editor:e,index:t,tablePos:r,orientation:"column",direction:"left",hideWhenUnavailable:!0}),m=lQ({editor:e,index:t,tablePos:r,orientation:"column",direction:"right",hideWhenUnavailable:!0}),g=lT({editor:e,index:t,tablePos:r,orientation:"row",side:"above",hideWhenUnavailable:!0}),f=lT({editor:e,index:t,tablePos:r,orientation:"row",side:"below",hideWhenUnavailable:!0}),x=lT({editor:e,index:t,tablePos:r,orientation:"column",side:"left",hideWhenUnavailable:!0}),b=lT({editor:e,index:t,tablePos:r,orientation:"column",side:"right",hideWhenUnavailable:!0}),C=(0,h.useMemo)(()=>({moveUp:d,moveDown:u,moveLeft:p,moveRight:m}),[d,u,p,m]),v=(0,h.useMemo)(()=>({addAbove:g,addBelow:f,addLeft:x,addRight:b}),[g,f,x,b]),y=(0,h.useMemo)(()=>({sortAsc:o,sortDesc:i}),[o,i]),w=(0,h.useCallback)(()=>{let e=[];return y.sortAsc.isVisible&&e.push({icon:y.sortAsc.Icon,label:y.sortAsc.label,disabled:!y.sortAsc.canSortRowColumn,onClick:y.sortAsc.handleSort}
1),y.sortDesc.isVisible&&e.push({icon:y.sortDesc.Icon,label:y.sortDesc.label,disabled:!y.sortDesc.canSortRowColumn,onClick:y.sortDesc.handleSort}),e},[y]),j=(0,h.useCallback)(()=>{let e=[];return"row"===n?(v.addAbove.isVisible&&e.push({icon:v.addAbove.Icon,label:v.addAbove.label,disabled:!v.addAbove.canAddRowColumn,onClick:v.addAbove.handleAdd}),v.addBelow.isVisible&&e.push({icon:v.addBelow.Icon,label:v.addBelow.label,disabled:!v.addBelow.canAddRowColumn,onClick:v.addBelow.handleAdd})):(v.addLeft.isVisible&&e.push({icon:v.addLeft.Icon,label:v.addLeft.label,disabled:!v.addLeft.canAddRowColumn,onClick:v.addLeft.handleAdd}),v.addRight.isVisible&&e.push({icon:v.addRight.Icon,label:v.addRight.label,disabled:!v.addRight.canAddRowColumn,onClick:v.addRight.handleAdd})),e},[n,v]),I=(0,h.useCallback)(()=>{let e=[];return"row"===n?(C.moveUp.isVisible&&e.push({icon:C.moveUp.Icon,label:C.moveUp.label,disabled:!C.moveUp.canMoveRowColumn,onClick:C.moveUp.handleMove}),C.moveDown.isVisible&&e.push({icon:C.moveDown.Icon,label:C.moveDown.label,disabled:!C.moveDown.canMoveRowColumn,onClick:C.moveDown.handleMove})):(C.moveLeft.isVisible&&e.push({icon:C.moveLeft.Icon,label:C.moveLeft.label,disabled:!C.moveLeft.canMoveRowColumn,onClick:C.moveLeft.handleMove}),C.moveRight.isVisible&&e.push({icon:C.moveRight.Icon,label:C.moveRight.label,disabled:!C.moveRight.canMoveRowColumn,onClick:C.moveRight.handleMove})),e},[n,C]);return{deleteAction:l,duplicateAction:a,clearContentAction:s,headerAction:c,addItems:j(),moveItems:I(),sortItems:w()}}(),d=n.isVisible||l.isVisible||a.isVisible,u=i.length>0,p=s.length>0,m=c.length>0,g=o.isVisible&&0===e;return d||u||p||m||g?(0,r.jsxs)(r.Fragment,{children:[g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rN,{children:(0,r.jsx)(ar,{icon:o.Icon,label:o.label,disabled:!o.canToggleHeader,isActive:o.isActive,onClick:o.handleToggle})}),(0,r.jsx)(rR,{orientation:"horizontal"})]}),u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rN,{children:i.map((e,t)=>(0,r.jsx)(ar,{...e},"add-".concat(t)))}),(0,r.jsx)(rR,{orientation:"horizontal"})]}),m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rN,{children:c.map((e,t)=>(0,r.jsx)(ar,{...e},"sort-".concat(t)))}),(0,r.jsx)(rR,{orientation:"horizontal"})]}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(rN,{children:[(0,r.jsx)(lu,{}),(0,r.jsx)(rM,{index:e,orientation:t}),a.isVisible&&(0,r.jsx)(ar,{icon:a.Icon,label:a.label,disabled:!a.canClearRowColumnContent,onClick:a.handleClear})]}),(0,r.jsx)(rR,{orientation:"horizontal"})]}),d&&(0,r.jsxs)(rN,{children:[l.isVisible&&(0,r.jsx)(ar,{icon:l.Icon,label:l.label,disabled:!l.canDuplicateRowColumn,onClick:l.handleDuplicate}),n.isVisible&&(0,r.jsx)(ar,{icon:n.Icon,label:n.label,disabled:!n.canDeleteRowColumn,onClick:n.handleDelete})]})]}):null},aa=()=>{let{resetMenu:e}=an();return(0,r.jsxs)(rI,{autoFocusOnShow:!0,autoFocusOnHide:!1,modal:!0,onClose:e,children:[(0,r.jsx)(n8,{style:eg.X6}),(0,r.jsx)(n9,{style:{minWidth:"15rem"},children:(0,r.jsx)(al,{})})]})},ao=e=>{let{editor:t,orientation:n,index:l,tableNode:a,tablePos:o,onToggleOtherHandle:i,onOpenChange:s,dragStart:c}=e,{editor:d}=nl(t),u=(0,h.useMemo)(()=>({editor:d,orientation:n,index:l,tableNode:a,tablePos:o}),[d,n,l,a,o]);return(0,r.jsx)(ae.Provider,{value:u,children:(0,r.jsx)(ai,{onToggleOtherHandle:i,onOpenChange:s,dragStart:c})})},ai=e=>{let{onToggleOtherHandle:t,onOpenChange:n,dragStart:l}=e,{orientation:a}=at(),{isMenuOpen:o,isDragging:i,setIsDragging:s,menuPlacement:c,handleMenuToggle:d}=an(t,n),u=l8[a],p=(0,h.useCallback)(e=>{s(!0),null==l||l(e)},[l,s]),m=(0,h.useCallback)(()=>{s(!1),tl()},[s]);return(0,r.jsx)(rj,{open:o,onOpenChange:d,placement:c,trigger:(0,r.jsx)(rk,{className:(0,eg.cn)("tiptap-table-handle-menu",o&&"menu-opened",i&&"is-dragging",a),draggable:!0,"aria-label":u,"aria-haspopup":"menu","aria-expanded":o,onDragStart:p,onDragEnd:m,children:(0,r.jsx)(ly,{className:"tiptap-button-icon"})}),children:(0,r.jsx)(aa,{})})};function as(e,t,n,r,l){let a=(0,h.useMemo)(()=>(function(e){switch(e){case"row":return"left";case"col":return"top";default:return"bottom-end"}})(e),[e]),o=(0,h.useMemo)(()=>(function(e){switch(e){case"row":case"col":return 4;default:return{mainAxis:1,crossAxis:-1}}})(e),[e]),{refs:i,update:s,context:c,floatingStyles:d}=(0,ne.we)({open:t,placement:a,middleware:[(0,t8.cY)(o),(0,t8.Ej)({apply(t){var l,a,o,i;let{rects:s,elements:c}=t;if(!c.floating)return;let d=null!=(a="col"===e&&null!=(l=null==n?void 0:n.width)?l:null==r?void 0:r.width)?a:s.reference.width,u=null!=(i="row"===e&&null!=(o=null==n?void 0:n.height)?o:null==r?void 0:r.height)?i:s.reference.height;c.floating.style.setProperty("--table-handle-ref-width","".concat(d,"px")),c.floating.style.setProperty("--table-handle-ref-height","".concat(u,"px"));let p="row"===e?u:d;c.floating.style.setProperty("--table-handle-available-size","".concat(p,"px"))}})]}),{isMounted:u,styles:p}=(0,ne.DL)(c);return(0,h.useEffect)(()=>{s()},[s,t,e,n,r,l]),(0,h.useEffect)(()=>{n&&r&&(l&&"cell"===e||i.setReference({getBoundingClientRect:()=>(function(e,t,n,r){var l,a;switch(e){case"row":if((null==r?void 0:r.draggedCellOrientation)==="row"){let e=eW(r.mousePos+(null!=(l=r.initialOffset)?l:0),n.y,n.bottom-t.height);return new DOMRect(n.x,e,n.width,t.height)}return new DOMRect(n.x,t.y,n.width,t.height);case"col":if((null==r?void 0:r.draggedCellOrientation)==="col")return new DOMRect(eW(r.mousePos+(null!=(a=r.initialOffset)?a:0),n.x,n.right-t.width),n.y,t.width,n.height);return new DOMRect(t.x,n.y,t.width,n.height);default:return new DOMRect(t.x,t.y,t.width,0)}})(e,n,r,l)}))},[i,e,n,r,l]),(0,h.useMemo)(()=>({isMounted:u,ref:i.setFloating,style:{display:"flex",...p,...d}}),[u,i.setFloating,p,d])}function ac(e){let{editor:t,rowButton:n,columnButton:l}=e,{editor:a}=nl(t),o=lf({editor:a}),[i,s]=(0,h.useState)(!0),[c,d]=(0,h.useState)(!0),[u,p]=(0,h.useState)(null),m=(0,h.useMemo)(()=>
1{if(null==o?void 0:o.draggingState)return{draggedCellOrientation:o.draggingState.draggedCellOrientation,mousePos:o.draggingState.mousePos,initialOffset:o.draggingState.initialOffset}},[null==o?void 0:o.draggingState]),{rowHandle:g,colHandle:f}=function(e,t,n,r){let l=as("row",e,t,n,r),a=as("col",e,t,n,r),o=as("cell",e,t,n,r);return(0,h.useMemo)(()=>({rowHandle:l,colHandle:a,cellHandle:o}),[l,a,o])}((null==o?void 0:o.show)||!1,(null==o?void 0:o.referencePosCell)||null,(null==o?void 0:o.referencePosTable)||null,m),x=(0,h.useCallback)(e=>{s(e)},[]),b=(0,h.useCallback)(e=>{d(e)},[]),C=(0,h.useCallback)((e,t)=>{p(t?e:null)},[]);if(!a||!o)return null;let v="number"==typeof o.rowIndex,y="number"==typeof o.colIndex,w=i&&g.isMounted&&v||"row"===u,j=c&&f.isMounted&&y||"column"===u,I=n||ao,k=l||ao;return(0,r.jsxs)(ne.XF,{root:o.widgetContainer,children:[w&&(0,r.jsx)("div",{ref:g.ref,style:g.style,children:(0,r.jsx)(I,{editor:a,orientation:"row",index:o.rowIndex,tablePos:o.blockPos,tableNode:o.block,onToggleOtherHandle:b,dragStart:tr,onOpenChange:e=>C("row",e)})}),j&&(0,r.jsx)("div",{ref:f.ref,style:f.style,children:(0,r.jsx)(k,{editor:a,orientation:"column",index:o.colIndex,tablePos:o.blockPos,tableNode:o.block,onToggleOtherHandle:x,dragStart:tn,onOpenChange:e=>C("column",e)})})]})}ac.displayName="TableHandle";let ad=(e,t,n,r)=>{var l;let a=null==(l=t.posAtCoords({left:n,top:r}))?void 0:l.pos;if(!a)return null;let o=e.doc.resolve(a);return(0,eO.KW)(o)},au=(e,t)=>{if(!(t instanceof eO.rn))return null;let n=[];if(t.forEachCell((t,r)=>{let l=e.nodeDOM(r);l&&n.push(l)}),0===n.length)return null;let r={left:1/0,top:1/0,right:-1/0,bottom:-1/0};return n.forEach(e=>{let t=e.getBoundingClientRect();r.left=Math.min(r.left,t.left),r.top=Math.min(r.top,t.top),r.right=Math.max(r.right,t.right),r.bottom=Math.max(r.bottom,t.bottom)}),new DOMRect(r.left,r.top,r.right-r.left,r.bottom-r.top)},ap=(e,t)=>{let n=e.nodeDOM(t);if(!n)return null;let r=n.getBoundingClientRect();return new DOMRect(r.left,r.top,r.width,r.height)},ah=e=>({getBoundingClientRect:()=>e}),am=(e,t,n)=>{let r={topLeft:null,topRight:null,bottomLeft:null,bottomRight:null},l=(e,t)=>5>Math.abs(e-t);return t.forEachCell((t,a)=>{let o=e.nodeDOM(a);if(!o)return;let i=o.getBoundingClientRect();l(i.left,n.left)&&l(i.top,n.top)&&(r.topLeft=a),l(i.right,n.right)&&l(i.top,n.top)&&(r.topRight=a),l(i.left,n.left)&&l(i.bottom,n.bottom)&&(r.bottomLeft=a),l(i.right,n.right)&&l(i.bottom,n.bottom)&&(r.bottomRight=a)}),r},ag=(e,t,n,r)=>{if(!r)return null;let l=am(e,t,n)[({tl:"bottomRight",tr:"bottomLeft",bl:"topRight",br:"topLeft"})[r]];return l?{pos:l}:null},af=()=>({position:"absolute",width:15,height:15,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",pointerEvents:"auto",zIndex:10}),ax=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{...af(),...{tl:{top:-7.5,left:-7.5,cursor:n?"default":"nwse-resize"},tr:{top:-7.5,right:-7.5,cursor:n?"default":"nesw-resize"},bl:{bottom:-7.5,left:-7.5,cursor:n?"default":"nesw-resize"},br:{bottom:-7.5,right:-7.5,cursor:n?"default":"nwse-resize"}}[e],opacity:n?.3:t?1:.5,pointerEvents:n?"none":"auto"}},ab=e=>{let{editor:t,cellMenu:n,showResizeHandles:l=!0,onMenuOpenChange:a}=e,{editor:o}=nl(t),[i,s]=(0,h.useState)(!0),[c,d]=(0,h.useState)(null),[u,p]=(0,h.useState)(null),[m,g]=(0,h.useState)(null),[f,x]=(0,h.useState)(!1),b=(0,h.useRef)(null),C=(0,h.useRef)(null),v=(0,h.useRef)(null),{refs:y,floatingStyles:w,update:j}=(0,ne.we)({placement:"top-start"});(0,h.useEffect)(()=>{if(c){let e=ah(c);y.setPositionReference(e)}},[c,y]);let I=(0,h.useCallback)(()=>{if(!o)return;let{selection:e}=o.state;if(e instanceof eO.rn){let t=au(o.view,e);if(!t){s(!1),d(e=>e?null:e);return}d(e=>e2(e,t)?e:t),s(!0);return}let{$anchor:t}=e,n=(0,eO.KW)(t);if(n){let e=ap(o.view,n.pos);if(e){d(t=>e2(t,e)?t:e),s(!0);return}}s(!1),d(e=>e?null:e)},[o]);!function(e,t){let n=(0,h.useRef)(null),r=(0,h.useCallback)(()=>{null!==n.current&&(cancelAnimationFrame(n.current),n.current=null)},[]),l=(0,h.useCallback)(()=>
1{if(null!==n.current)return;let l=()=>{let a=eO.QQ.getState(e.state),o=!!(null==a?void 0:a.dragging);t(),o?n.current=requestAnimationFrame(l):(r(),t())};n.current=requestAnimationFrame(l)},[e,t,r]);(0,h.useEffect)(()=>{if(!e)return;let n=e=>{let{transaction:n}=e;t();let a=n.getMeta(eO.QQ);a&&(Object.prototype.hasOwnProperty.call(a,"setDragging")&&a.setDragging&&l(),Object.prototype.hasOwnProperty.call(a,"setDragging")&&null===a.setDragging&&(r(),t()),Object.prototype.hasOwnProperty.call(a,"setHandle")&&t())};return e.on("transaction",n),()=>{e.off("transaction",n),r()}},[e,l,r,t])}(o,I),(0,h.useEffect)(()=>{j&&c&&j()},[j,c]);let k=(0,h.useCallback)(e=>t=>{if(!o||!e||!c||f||!l)return;t.preventDefault(),t.stopPropagation();let{selection:n}=o.state,r=null;if(n instanceof eO.rn)r=n;else{let{$anchor:e}=n,t=(0,eO.KW)(e);if(t)try{r=eO.rn.create(o.state.doc,t.pos,t.pos)}catch(e){console.warn("Could not create single cell selection for resize:",e);return}}if(!r)return;let a=ag(o.view,r,c,e);if(!a)return;p(e),C.current=e,b.current=a.pos;let i=e=>{if(!o||null===b.current)return;let t=eU(e.target);if(!t||"cell"!==t.type)return;let n=ad(o.state,o.view,e.clientX,e.clientY);if(n)try{let e=eO.rn.create(o.state.doc,b.current,n.pos),t=o.state.tr.setSelection(e);o.view.dispatch(t)}catch(e){console.warn("Invalid cell selection during resize:",e)}},s=()=>{p(null),C.current=null,b.current=null,window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},[o,c,f,l]),E=(0,h.useCallback)(()=>{if(!o)return void g(null);let e=e$(o);if(!e)return void g(null);g(t=>{let n=o.view.nodeDOM(e.pos);return t===n?t:n})},[o]),N=(0,h.useCallback)(e=>{x(e),null==a||a(e)},[a]);return((0,h.useEffect)(()=>{if(!o)return;let e=()=>{I(),E()};return o.on("selectionUpdate",e),I(),E(),()=>{o.off("selectionUpdate",e)}},[o,I,E]),(0,h.useEffect)(()=>{let e=null==m?void 0:m.querySelector(".table-selection-overlay-container");v.current=null!=e?e:null},[m]),i&&c&&o)?(0,r.jsx)(ne.XF,{root:v.current,children:(0,r.jsx)("div",{ref:y.setFloating,style:{...w,pointerEvents:"none",zIndex:10},children:(0,r.jsxs)("div",{className:"tiptap-table-selection-overlay",children:[(0,r.jsx)("div",{style:{position:"absolute",width:c.width,height:c.height,zIndex:2,borderRadius:2,top:0,left:0}}),(0,r.jsxs)("div",{style:{position:"absolute",width:c.width,height:c.height,border:"2px solid var(--tt-brand-color-400)",borderRadius:2,zIndex:3,top:0,left:0},children:[n?(0,r.jsx)("span",{onMouseDown:e=>e.stopPropagation(),style:{pointerEvents:"auto"},children:(0,r.jsx)(n,{onOpenChange:N,editor:o,onResizeStart:k})}):null,l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:ax("tl",!u||"tl"===u,f),onMouseDown:k("tl")}),(0,r.jsx)("div",{style:ax("tr",!u||"tr"===u,f),onMouseDown:k("tr")}),(0,r.jsx)("div",{style:ax("bl",!u||"bl"===u,f),onMouseDown:k("bl")}),(0,r.jsx)("div",{style:ax("br",!u||"br"===u,f),onMouseDown:k("br")})]})]})]})})}):null};n(40576);var aC=n(83264),av=n(36129);let ay=(0,h.memo)(e=>{let{setOpenDialogBox:t,openDialogBox:n,handleOnAccept:l,handleOnReject:a,aiGenerationHasMessage:o}=e;return(0,r.jsx)(aC.lG,{open:n,setOpen:t,children:(0,r.jsxs)(nh,{className:"font-sans flex flex-col items-center gap-4 p-4  rounded-xl",children:[(0,r.jsx)("div",{children:(0,r.jsx)(av.j,{})}),(0,r.jsx)("div",{className:"font-sans text-center font-medium text-blue-12",children:(0,r.jsx)("p",{children:"Do you want to discard the current writing?"})}),(0,r.jsxs)("div",{className:"w-full flex flex-col gap-2",children:[o&&(0,r.jsx)(d.$n,{className:"w-full h-10 text-md font-medium cursor-pointer rounded-md",onClick:()=>{l(),t(!1)},"aria-label":"Keep",children:"Keep"}),(0,r.jsx)(d.$n,{className:"w-full h-10 text-md font-medium cursor-pointer rounded-md",onClick:()=>{t(!1),a()},title:"Discard","aria-label":"Discard",children:"Discard"}),(0,r.jsx)(d.$n,{className:"w-full h-10 text-md font-medium cursor-pointer rounded-md",onClick:()=>{t(!1)},"aria-label":"Cancel",children:"Cancel"})]})]})})}),aw=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM8 9C8 8.44772 8.44772 8 9 8H15C15.5523 8 16 8.44772 16 9V15C16 15.5523 15.5523 16 15 16H9C8.44772 16 8 15.5523 8 15V9Z",fill:"currentColor"})})});aw.displayName="StopCircle2Icon";let aj=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 5.29289C21.0976 5.68342 21.0976 6.31658 20.7071 6.70711L9.70711 17.7071C9.31658 18.0976 8.68342 18.0976 8.29289 17.7071L3.29289 12.7071C2.90237 12.3166 2.90237 11.6834 3.29289 11.2929C3.68342 10.9024 4.31658 10.9024 4.70711 11.2929L9 15.5858L19.2929 5.29289C19.6834 4.90237 20.3166 4.90237 20.7071 5.29289Z",fill:"currentColor"})})});aj.displayName="CheckIcon";let aI=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M11.9949 2.00001C9.22128 2.01079 6.55914 3.0932 4.56496 5.02103L4.55289 5.03289L4 5.58579V3C4 2.44771 3.55228 2 3 2C2.44771 2 2 2.44771 2 3V7.99931L2 8.003C2.0004 8.1375 2.02735 8.26575 2.07588 8.38278C2.12357 8.49805 2.19374 8.6062 2.2864 8.70055L2.29945 8.7136C2.3938 8.80626 2.50195 8.87643 2.61722 8.92412C2.73512 8.97301 2.86441 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41421L5.96097 6.45325C7.58334 4.8878 9.74744 4.00891 12.0021 4C13.7624 4.00045 15.4735 4.58152 16.8701 5.65317C18.2673 6.72525 19.2716 8.22838 19.7274 9.92945C19.8704 10.4629 20.4187 10.7795 20.9522 10.6366C21.4856 10.4936 21.8022 9.94528 21.6593 9.41181C21.0895 7.28548 19.8341 5.40656 18.0876 4.06647C16.3412 2.72637 14.2014 2 12 2L11.9962 2.00001L11.9949 2.00001Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M10.6366 20.9522C10.4936 21.4856 9.9453 21.8022 9.41183 21.6593C7.2855 21.0895 5.40658 19.8341 4.06649 18.0876C2.72639 16.3412 2.00002 14.2013 2.00002 12C2.00002 11.4477 2.44774 11 3.00002 11C3.55231 11 4.00002 11.4477 4.00002 12C4.00002 13.7611 4.58112 15.4729 5.65319 16.8701C6.72527 18.2672 8.2284 19.2716 9.92947 19.7274C10.4629 19.8703 10.7795 20.4187 10.6366 20.9522Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.9379 11.653C17.7926 11.2605 17.4184 11 17 11C16.5816 11 16.2074 11.2605 16.0621 11.653L14.9511 14.6556C14.9004 14.7925 14.7925 14.9004 14.6556 14.9511L11.653 16.0621C11.2605 16.2074 11 16.5816 11 17C11 17.4184 11.2605 17.7926 11.653 17.9379L14.6556 19.0489C14.7925 19.0996 14.9004 19.2075 14.9511 19.3444L16.0621 22.347C16.2074 22.7395 16.5816 23 17 23C17.4184 23 17.7926 22.7395 17.9379 22.347L19.0489 19.3444C19.0996 19.2075 19.2075 19.0996 19.3444 19.0489L22.347 17.9379C22.7395 17.7926 23 17.4184 23 17C23 16.5816 22.7395 16.2074 22.347 16.0621L19.3444 14.9511C19.2075 14.9004 19.0996 14.7925 19.0489 14.6556L17.9379 11.653ZM16.8268 15.3497L17 14.8815L17.1732 15.3497C17.4265 16.034 17.966 16.5735 18.6503 16.8268L19.1185 17L18.6503 17.1732C17.966 17.4265 17.4265 17.966 17.1732 18.6503L17 19.1185L16.8268 18.6503C16.5735 17.966 16.034 17.4265 15.3497 17.1732L14.8815 17L15.3497 16.8268C16.034 
116.5735 16.5735 16.034 16.8268 15.3497Z",fill:"currentColor"})]})});aI.displayName="RefreshAiIcon";let ak=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 640 640",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M566.6 214.6L470.6 310.6C461.4 319.8 447.7 322.5 435.7 317.5C423.7 312.5 416 300.9 416 288L416 224L96 224C78.3 224 64 209.7 64 192C64 174.3 78.3 160 96 160L416 160L416 96C416 83.1 423.8 71.4 435.8 66.4C447.8 61.4 461.5 64.2 470.7 73.3L566.7 169.3C579.2 181.8 579.2 202.1 566.7 214.6zM169.3 566.6L73.3 470.6C60.8 458.1 60.8 437.8 73.3 425.3L169.3 329.3C178.5 320.1 192.2 317.4 204.2 322.4C216.2 327.4 224 339.1 224 352L224 416L544 416C561.7 416 576 430.3 576 448C576 465.7 561.7 480 544 480L224 480L224 544C224 556.9 216.2 568.6 204.2 573.6C192.2 578.6 178.5 575.8 169.3 566.7z",fill:"currentColor"})})});ak.displayName="RightLeftIcon",n(94568);var aE=n(58590);function aN(e){let t=(0,ef.er)({editor:e,selector:e=>{let{editor:t}=e;if(!t)return{...tJ};let{processHtmlContent:n,citationSelection:r,isCitationPresentInSelection:l}=(0,aE.B)(t),{state:a}=t,{from:o,to:i}=a.selection,s=(0,r8.f)(a.doc,o,i),c=s.trim().split(/\s+/).filter(Boolean).length,d=t.storage.uiState;return d?{...tJ,...d,selectedText:s,isCitationPresent:l,citationSelection:r,processHtmlContent:n,selectedCount:c}:(console.warn("uiState not initialized"),{...tJ})}});return null!=t?t:{...tJ}}function aS(e){var t,n,l;let{feature:a,editor:o,options:i,onAccept:s,onReject:c,onCopy:u,onReplace:p}=e,{aiGenerationIsLoading:m}=aN(o),g=(null==o||null==(t=o.storage)?void 0:t.ai)||(null==o||null==(n=o.storage)?void 0:n.aiAdvanced),f=(0,h.useMemo)(()=>{if(!o)return!1;let{from:e,to:t}=o.state.selection;return o.state.doc.textBetween(e,t,"").trim().length>0},[o]),x=(0,h.useCallback)(e=>{if(o){if(null==g?void 0:g.generatedWith){var t;let n=function(e){switch(e){case tK.vI.MAKE_ACADEMIC:return"restructure";case tK.vI.TRIM:case tK.vI.TRIM_HIGH:case tK.vI.TRIM_MODERATE:case tK.vI.TRIM_LESS:return"shorten";case tK.vI.KEEP_WRITING_CONTINUE:default:return"rephrase"}}(e);g.generatedWith.action=n,(null==(t=g.generatedWith)?void 0:t.options)&&(g.generatedWith.options.tone=e)}o.chain().focus().aiRegenerate().run()}},[o,g]),b=(0,h.useCallback)(()=>{o&&c()},[o,c]),C=(0,h.useCallback)(()=>{o&&s()},[o,s]),v=(0,h.useCallback)(()=>{o&&p()},[o,p]),y=(0,h.useCallback)(()=>{o&&u()},[o,u]),w=(null==g||null==(l=g.generatedWith)?void 0:l.action)==="complete";return m?null:(0,r.jsx)("div",{className:"tiptap-ai-menu-actions mb-1 ml-2",children:(0,r.jsx)("div",{className:"tiptap-ai-menu-results",children:(0,r.jsxs)(d.e2,{className:"gap-2",orientation:"horizontal",children:[(0,r.jsx)(d.$n,{"data-style":"primary",className:"tiptap-button mr-2",onClick:C,id:w?"inline-insert":"inline-replace",children:w?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aj,{className:"tiptap-button-icon"}),"Insert"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ak,{className:"tiptap-button-icon"}),"Replace"]})}),w&&f&&(0,r.jsxs)(d.$n,{"data-style":"ghost",className:"tiptap-button mr-2",onClick:v,id:"inline-replace",children:[(0,r.jsx)(ak,{className:"tiptap-button-icon"}),"Replace"]}),"simplify"!==a&&(0,r.jsxs)(d.$n,{"data-style":"ghost",className:"tiptap-button mr-2",onClick:y,disabled:m,id:"inline-copy",children:[(0,r.jsx)(lD,{className:"tiptap-button-icon"}),"Copy"]}),!w&&i.stream&&(0,r.jsxs)(d.$n,{"data-style":"ghost",className:"tiptap-button",onClick:()=>x(a),disabled:m,id:"inline-retry",children:[(0,r.jsx)(aI,{className:"tiptap-button-icon"}),"Retry"]}),(0,r.jsxs)(d.$n,{"data-style":"ghost",className:"tiptap-button mr-2",onClick:b,id:"inline-discard",children:[(0,r.jsx)(ew.gz,{className:"tiptap-button-icon"}),"Discard"]})]})})})}function aT(){document.querySelectorAll('[data-fallback-anchor="true"]').forEach(e=>e.remove())}function aA(e){var t;let n=e.view.dom.querySelectorAll(".selection"),r=null!=(t=n[n.length-1])?t:null;return r?r.getBoundingClientRect():null}let aR=(0,n(44347).vt)(e=>({suggestionsReviewed:0,synonymsAccepted:0,translationsRequested:0,citationsClicked:0,shouldRequestFeedback:!1,actions:{incSuggestionsReviewed:()=>e(e=>({suggestionsReviewed:e.suggestionsReviewed+1})),incSynonymsAccepted:()=>e(e=>({synonymsAccepted:e.synonymsAccepted+1})),incTranslationsRequested:()=>e(e=>({translationsRequested:e.translationsRequested+1})),incCitationsClicked:()=>e(e=>({citationsClicked:e.citationsClicked+1})),setShouldRequestFeedback:t=>e(()=>({shouldRequestFeedback:t}))}})),aM=()=>aR(e=>e.actions);var aL=n(20586);async function aD(e){let t=await (0,aL.y)(e,{gfm:!0,breaks:!1});return t.replace(/<br\s*\/?>/gi,"").replace(/\n\n+/g,"\n").replace(/\n/g,"").trim()}var a_=n(86912),aH=n(15352);let aP=(0,h.createContext)({activeThread:null,setActiveThread:()=>{},threadBubbles:{},triggerConfetti:()=>{},addThreadBubble:()=>{},removeThreadBubble:()=>{},setPastedTextLength:()=>{},setIsWordFileDownloaded:()=>{},handleRedirectToLanguageTab:()=>{},handleRedirectToCommentThread:()=>{},editorType:et.zR.DraftEditor,isEditable:!0});aP.Consumer;let aO=e=>{let{children:t,isEditable:n=!0,...l}=e,[a,o]=(0,h.useState)(null),[i,s]=(0,h.useState)({}),c=(0,h.useRef)({}),d=(0,h.useCallback)((e,t)=>
1{(Array.isArray(e)?e:[e]).forEach(e=>{var n;let r=null!=(n=c.current[e])?n:[];r.includes(t)||(c.current[e]=[...r,t])}),s({...c.current})},[]),u=(0,h.useCallback)(e=>{if("string"==typeof e){delete c.current[e],s({...c.current});return}if("string"!=typeof e){Object.keys(c.current).forEach(t=>{let n=c.current[t];if(n&&n.includes(e)){let r=n.filter(t=>t!==e);0===r.length?delete c.current[t]:c.current[t]=r}}),s({...c.current});return}},[]);c.current=i;let{query:p,updateRoute:m}=(0,aH.G)(),g=(0,h.useCallback)(e=>{if(e)return p.tab?void 0:void m(e,void 0,!0)},[p,m]),f=(0,h.useCallback)(e=>{(e||"comments"===p.tab)&&(e||"comments"!==p.tab?m(void 0,{...p,tab:"comments",type:e},!0):m("comments",void 0,!0))},[p,m]),x=(0,h.useMemo)(()=>({activeThread:a,setActiveThread:o,threadBubbles:i,addThreadBubble:d,removeThreadBubble:u,handleRedirectToLanguageTab:g,handleRedirectToCommentThread:f,isEditable:n,...l}),[l,a,n,o,i,d,u,g,f]);return(0,r.jsx)(aP.Provider,{value:x,children:t})},az=()=>{let e=(0,h.useContext)(aP);if(!e)throw Error("useAppState must be used within an AppProvider");return e};var aB=n(32469),aF=n(70401),aV=n(26897);let aU=[tK.vI.PARAPHRASE,tK.vI.IMPROVE_FLUENCY],aW=e=>{let{isPrime:t,selectedTab:n}=e,{data:r}=(0,aV.w)(),l=(0,h.useCallback)(e=>!!e&&!t&&!!(null==r?void 0:r.AB_PAYWALL_REWRITE)&&!aU.includes(e),[t,null==r?void 0:r.AB_PAYWALL_REWRITE]);return{showRewriteModePaywall:(0,h.useMemo)(()=>l(n),[n,l]),getShowRewriteModePaywall:l}},aG=e=>{let{isPrime:t}=g(),{getShowRewriteModePaywall:n}=aW({isPrime:t}),{processHtmlContent:r,selectedCount:l}=aN(e),a=(0,h.useMemo)(()=>({stream:!0,insert:!1,format:"rich-text",regenerate:!1}),[]),o=(0,h.useCallback)(t=>{if(e){if(t&&n(t))return e.chain().focus().run();e.chain().focus().aiGenerationShow().run(),setTimeout(()=>{if(t===tK.vI.MAKE_ACADEMIC)return void e.commands.aiRestructure({...a,tone:t,text:r});e.commands.aiRephrase({...a,tone:t,text:r})},0)}},[e,n,a,r]),i=(0,h.useCallback)(t=>{e&&(e.chain().focus().aiGenerationShow().run(),setTimeout(()=>{e.commands.aiRephrase({...a,tone:t,text:r})},0))},[e,a,r]),s=(0,h.useCallback)(t=>{e&&(e.chain().focus().aiGenerationShow().run(),setTimeout(()=>{e.commands.aiShorten({...a,tone:t,text:r})},0))},[e,a,r]),c=(0,h.useCallback)(t=>{e&&(e.chain().focus().aiGenerationShow().run(),setTimeout(()=>{e.commands.aiTranslate(t,{...a,stream:!1,text:r})},0))},[e,a,r]);return{executeAICommand:o,executeWriteCommand:(0,h.useCallback)(t=>{let{command:n,isRegenerate:o,text:i,context:s,isContentNeeded:c}=t;if(!e)return;let d=null!=i?i:l>0?r:" ";c&&!d.trim()&&(d=function(e){if(!e)return"";let{state:t}=e,{to:n}=t.selection;return(0,r8.f)(t.doc,0,n)}(e)||" "),d=d.trim()?d:" ",e.chain().focus().aiGenerationShow().run(),requestAnimationFrame(()=>{e.commands.aiComplete({...a,tone:n,text:d,regenerate:!!o,context:s})})},[e,a,r,l]),adjustTone:i,trim:s,translate:c,synonyms:(0,h.useCallback)(async()=>{if(!e)return;(0,aF.K)(e);let{from:t,to:n}=e.state.selection,r=e.state.doc.textBetween(t,n,""),{currentSentence:l}=await (0,aB.m)(e,n-1),o=l?l.toLowerCase().indexOf(r.toLowerCase().trim()):-1;l&&o>-1&&(e.chain().focus().aiGenerationShow().run(),setTimeout(()=>{e.commands.aiSimplify({...a,tone:JSON.stringify({startIndex:o,endIndex:o+r.length}),text:l,insert:!1,stream:!1})},0))},[e,a])}},aZ=(0,h.createContext)(null),aq={isOpen:!1,tone:void 0,language:"en",shouldShowInput:!0,inputIsFocused:!1,fallbackAnchor:{element:null,rect:null}};function a$(){let e=(0,h.useContext)(aZ);if(!e)throw Error("useAiMenuState must be used within an AiMenuStateProvider");return e}let aK=(e,t)=>t?(0,a_.J)(t,e):e;function aY(e,t){let{items:n=[],...r}=e;if(!t.trim())return n;let l=t.toLowerCase().trim();return[r.label,...r.keywords||[]].filter(Boolean).join(" ").toLowerCase().includes(l)?n:n.filter(e=>!!e.filterItems||[e.label,...e.keywords||[]].filter(Boolean).join(" ").toLowerCase().includes(l))}var aX=n(98714);let aJ=()=>{let{webApiClient:e}=(0,P.p)();return async function(){return await e.get("/api/v4/translation/languages").then(aX.jB.parse)}};var aQ=n(37786);let a0=()=>{let{supportedLanguageList:e}=function(){let e=aJ();return{supportedLanguageList:(0,A.useQuery)({queryKey:["language-list"],queryFn:e,staleTime:36e5}).data}}(),t=(0,h.useMemo)(()=>
1{if(!e)return[];let{supportedLanguages:t,recentlyUsed:n}=e;return t.filter(e=>!n.includes(e))},[e]);return{recentlyUsedLanguage:(null==e?void 0:e.recentlyUsed)||[],supportedLanguages:t}},a1=[{label:tK.vI.PROFESSIONAL,value:tK.vI.PROFESSIONAL},{label:tK.vI.CONVERSATIONAL,value:tK.vI.CONVERSATIONAL},{label:tK.vI.POLITE,value:tK.vI.POLITE},{label:tK.vI.PERSUASIVE,value:tK.vI.PERSUASIVE},{label:tK.vI.CREATIVE,value:tK.vI.CREATIVE}],a2=[{label:tK.vI.TRIM_LESS,value:tK.vI.TRIM_LESS},{label:tK.vI.TRIM_MODERATE,value:tK.vI.TRIM_MODERATE},{label:tK.vI.TRIM_HIGH,value:tK.vI.TRIM_HIGH}],a4=[{label:aQ.GU.SUMMARIZE_TEXT,value:aQ.sO.SUMMARIZE_TEXT},{label:aQ.GU.CONNECTING_SENTENCE,value:aQ.sO.CONNECTING_SENTENCE},{label:aQ.GU.CONCLUDING_STATEMENT,value:aQ.sO.CONCLUDING_STATEMENT}];function a5(e,t){let n=(0,h.useRef)(null);return(0,h.useEffect)(()=>{if(!e||!n.current)return;let r=n.current.parentElement;for(;r;){let{overflow:e,overflowY:t}=window.getComputedStyle(r);if(/auto|scroll/.test(e+t))break;r=r.parentElement}if(!r)return;let l=()=>t(!1);return r.addEventListener("scroll",l,{passive:!0}),()=>r.removeEventListener("scroll",l)},[e,t]),n}var a7=n(4518);function a3(e){var t,n,l,a;let{aiActions:o,emptyFeatures:i,setPromptValue:s,state:c}=e;return{[tK.O5.PARAPHRASE]:{type:"executable",icon:(0,r.jsx)(ew.lA,{className:"tiptap-button-icon"}),label:tK.vI.PARAPHRASE,value:tK.O5.PARAPHRASE,onSelect:()=>{o.executeAICommand(tK.vI.PARAPHRASE)},check:e=>!!la(e)},[tK.O5.IMPROVE_FLUENCY]:{type:"executable",icon:(0,r.jsx)(ew.oX,{className:"tiptap-button-icon"}),label:tK.vI.IMPROVE_FLUENCY,value:tK.O5.IMPROVE_FLUENCY,onSelect:()=>{o.executeAICommand(tK.vI.IMPROVE_FLUENCY)},check:e=>!!la(e)},[tK.O5.ACADEMIC_TONE]:{type:"executable",icon:(0,r.jsx)(ew.aw,{className:"tiptap-button-icon"}),label:tK.vI.MAKE_ACADEMIC,value:tK.O5.ACADEMIC_TONE,onSelect:()=>{o.executeAICommand(tK.vI.MAKE_ACADEMIC)},check:e=>!!la(e)},[tK.O5.SIMPLIFY]:{type:"executable",icon:(0,r.jsx)(ew.Go,{className:"tiptap-button-icon"}),label:tK.vI.SIMPLIFY,value:tK.O5.SIMPLIFY,onSelect:()=>{o.executeAICommand(tK.vI.SIMPLIFY)},check:e=>!!la(e)},[tK.O5.TRIM]:{type:"nested",component:oe,filterItems:!0,icon:(0,r.jsx)(ew.tH,{className:"tiptap-button-icon"}),items:a2,label:tK.vI.TRIM,value:tK.O5.TRIM,check:e=>!!la(e)},[tK.O5.CHANGE_TONE]:{type:"nested",component:a8,filterItems:!0,icon:(0,r.jsx)(ew.nV,{className:"tiptap-button-icon"}),items:a1,label:tK.vI.CHANGE_TONE,value:tK.O5.CHANGE_TONE,check:e=>!!la(e)},[tK.O5.SYNONYMS]:{type:"executable",icon:(0,r.jsx)(ew.NC,{className:"tiptap-button-icon"}),label:tK.vI.SYNONYMS,value:tK.O5.SYNONYMS,onSelect:()=>{o.synonyms()},check:()=>!!c&&c.selectedCount>=1&&c.selectedCount<=3&&!c.isCitationPresent},goBack:{type:"executable",icon:(0,r.jsx)(lG,{className:"tiptap-button-icon"}),label:"Go back",value:"goBack",onSelect:e=>{let{editor:t}=e;if(t)return t.commands.resetUiState(),t.chain().focus().insertContent("/").run(),!0},check:e=>!la(e)},continueWriting:{type:"executable",icon:(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),label:aQ.Xc.KEEP_WRITING,value:"continueWriting",onSelect:()=>{o.executeWriteCommand({command:aQ.sO.KEEP_WRITING})},check:e=>{let{hasContent:t}=lt(e);return!!t||la(e)}},explainThis:{type:"executable",icon:(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),label:aQ.GU.EXPLAIN_THIS,value:"explainThis",onSelect:()=>{o.executeWriteCommand({command:aQ.sO.EXPLAIN_THIS})},check:e=>{let{hasContent:t}=lt(e);return!!t||la(e)}},expandOnThis:{type:"executable",icon:(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),label:aQ.GU.EXPAND_ON_THIS,value:"expandOnThis",onSelect:()=>{o.executeWriteCommand({command:aQ.sO.EXPAND_ON_THIS})},check:e=>{let{hasContent:t}=lt(e);return!!t||la(e)}},writeParagraph:{type:"executable",icon:(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),label:null!=(t=null==i?void 0:i.WRITE_PARAGRAPH)?t:"",value:"writeParagraph",onSelect:()=>{null==s||s(aQ.cR.WRITE_PARAGRAPH)},check:e=>!la(e)},extractTakeaways:{type:"executable",icon:(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),label:null!=(n=null==i?void 0:i.EXTRACT_KEY_TAKEAWAYS)?n:"",value:"extractTakeaways",onSelect:()=>{null==s||s(aQ.cR.EXTRACT_KEY_TAKEAWAYS)},check:e=>!la(e)},draftOutline:{type:"executable",icon:(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),label:null!=(l=null==i?void 0:i.DRAFT_OUTLINE)?l:"",value:"draftOutline",onSelect:()=>{null==s||s(aQ.cR.DRAFT_OUTLINE)},check:e=>!la(e)},moreIdeasSelection:{type:"nested",component:ot,filterItems:!0,icon:(0,r.jsx)(ew.nV,{className:"tiptap-button-icon"}),items:a4,label:"More Ideas",value:"moreIdeasSelection",check:e=>!!la(e)},moreIdeasEmpty:{type:"nested",component:ot,filterItems:!0,icon:(0,r.jsx)(ew.nV,{className:"tiptap-button-icon"}),items:(a=i)?[{label:a.DRAFT_LITERATURE_REVIEW,value:aQ.cR.DRAFT_LITERATURE_REVIEW,isPrompt:!0},{label:a.WRITE_CONCLUSION,value:aQ.cR.WRITE_CONCLUSION,isPrompt:!0},{label:a.WRITE_IDEA,value:aQ.cR.WRITE_IDEA,isPrompt:!0}]:[],label:"More Ideas",value:"moreIdeasEmpty",check:e=>!la(e)},translateTo:{type:"nested",component:a6,filterItems:!1,icon:(0,r.jsx)(ew.zL,{className:"tiptap-button-icon"}),label:"Languages",value:"translateTo",check:e=>!!la(e)}}}function a9(e){return"nested"===e.type}function a6(e){let{editor:t}=e,[n]=rb(),[l,a]=(0,h.useState)(!1),o=a5(l,a),i=aG(t),{supportedLanguages:s,recentlyUsedLanguage:c}=a0(),u=(0,h.useCallback)(e=>{i.translate(e)},[i]),p=(0,r.jsxs)(r.Fragment,{children:[c.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rS,{children:"Recently Used"}),c.map(e=>(0,r.jsx)(rA,{onClick:()=>e&&u(e),render:(0,r.jsx)(d.$n,{id:e,"data-style":"ghost",children:(0,r.jsx)("span",{className:"tiptap-button-text",children:e})})},e))]}),(0,r.jsxs)(r.Fragment,{children:[s.length>0&&(0,r.jsx)(rS,{className:"capitalize",children:tK.vI.TRANSLATE}),s.map(e=>(0,r.jsx)(rA,{onClick:()=>e&&u(e),render:(0,r.jsx)(d.$n,{id:e,"data-style":"ghost",children:(0,r.jsx)("span",{className:"tiptap-button-text",children:e})})},e))]})]});return n?p:(0,r.jsx)("div",{ref:o,children:(0,r.jsx)(rj,{placement:"right",open:l,onOpenChange:a,trigger:(0,r.jsx)(rk,{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),render:(0,r.jsx)(rA,{render:(0,r.jsxs)(d.$n,{id:"inline-".concat(tK.vI.TRANSLATE),"data-style":"ghost",children:[(0,r.jsx)(ew.zL,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text capitalize",children:tK.vI.TRANSLATE}),(0,r.jsx)(rE,{render:(0,r.jsx)(nF,{})})]})})}),children:(0,r.jsx)(rI,{onMouseLeave:()=>a(!1),children:(0,r.jsx)(n9,{children:(0,r.jsx)(rN,{className:"max-h-[300px] overflow-auto",children:p})})})})})}function a8(e){let{editor:t}=e,[n]=rb(),l=aG(t),[a,o]=(0,h.useState)(!1),i=a5(a,o),s=(0,h.useMemo)(()=>aY({items:a3({aiActions:l}).CHANGE_TONE.items},n),[l,n]),c=(0,h.useCallback)(e=>{l.adjustTone(e)},[l]),u=s.map(e=>(0,r.jsx)(rA,{onClick:()=>c(e.value||""),render:(0,r.jsx)(d.$n,{id:"inline-".concat(e.label),"data-style":"ghost",children:(0,r.jsx)("span",{className:"tiptap-button-text",children:e.label})})},e.value));return n?u:(0,r.jsx)("div",{ref:i,children:(0,r.jsx)(rj,{placement:"right",open:a,onOpenChange:o,trigger:(0,r.jsx)(rk,{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),render:(0,r.jsx)(rA,{render:(0,r.jsxs)(d.$n,{id:"inline-".concat(tK.vI.CHANGE_TONE),"data-style":"ghost",children:[(0,r.jsx)(ew.nV,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:tK.vI.CHANGE_TONE}),(0,r.jsx)(rE,{render:(0,r.jsx)(nF,{})})]})})}),children:(0,r.jsx)(rI,{onMouseLeave:()=>o(!1),children:(0,r.jsx)(n9,{children:(0,r.jsx)(rN,{children:u})})})})})}function oe(e){let{editor:t}=e,[n]=rb(),l=aG(t),[a,o]=(0,h.useState)(!1),i=a5(a,o),s=(0,h.useMemo)(()=>aY({items:a3({aiActions:l}).TRIM.items},n),[l,n]),c=(0,h.useCallback)(e=>{l.trim(e)},[l]),u=s.map(e=>(0,r.jsx)(rA,{onClick:()=>c(e.value||""),render:(0,r.jsx)(d.$n,{id:"inline-".concat(e.label),"data-style":"ghost",children:(0,r.jsx)("span",{className:"tiptap-button-text",children:e.label})})},e.value));return n?u:(0,r.jsx)("div",{ref:i,children:(0,r.jsx)(rj,{placement:"right",open:a,onOpenChange:o,trigger:(0,r.jsx)(rk,{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),render:(0,r.jsx)(rA,{render:(0,r.jsxs)(d.$n,{id:"inline-".concat(tK.vI.TRIM),"data-style":"ghost",children:[(0,r.jsx)(ew.tH,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:tK.vI.TRIM}),(0,r.jsx)(rE,{render:(0,r.jsx)(nF,{})})]})})}),children:(0,r.jsx)(rI,{onMouseLeave:()=>o(!1),children:(0,r.jsx)(n9,{children:(0,r.jsx)(rN,{children:u})})})})})}function ot(e){let{editor:t,emptyFeatures:n}=e,[l,a]=rb(),o=aG(t),i=!!la(t),[s,c]=(0,h.useState)(!1),u=a5(s,c),p=(0,h.useMemo)(()=>{let e=a3({aiActions:o,emptyFeatures:n});return aY({items:(i?e.moreIdeasSelection:e.moreIdeasEmpty).items},l)},[o,i,n,l]),m=(0,h.useCallback)(e=>{let{value:t,isPrompt:n}=e;if(!n)return void o.executeWriteCommand({command:null!=t?t:""});null==a||a(null!=t?t:"")},[o,a]),g=p.map(e=>(0,r.jsx)(rA,{onClick:()=>m(e),render:(0,r.jsx)(d.$n,{id:"inline-".concat(e.label),"data-style":"ghost",children:(0,r.jsx)("span",{className:"tiptap-button-text",children:e.label})})},e.value));return l?g:(0,r.jsx)("div",{ref:u,children:(0,r.jsx)(rj,{placement:"right",open:s,onOpenChange:c,trigger:(0,r.jsx)(rk,{onMouseEnter:()=>c(!0),onMouseLeave:()=>
1c(!1),render:(0,r.jsx)(rA,{render:(0,r.jsxs)(d.$n,{id:"inline-More Ideas","data-style":"ghost",children:[(0,r.jsx)(ew.xg,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:"More Ideas"}),(0,r.jsx)(rE,{render:(0,r.jsx)(nF,{})})]})})}),children:(0,r.jsx)(rI,{onMouseLeave:()=>c(!1),children:(0,r.jsx)(n9,{children:(0,r.jsx)(rN,{children:g})})})})})}function on(e){let{menuItem:t,availableActions:n,editor:l,emptyFeatures:a,setIsFileRequired:o}=e,{state:i}=a$();if(!t.value)return null;let s=n[t.value];if(!s)return null;if(a9(s)){let e=s.component;return(0,r.jsx)(e,{editor:l,emptyFeatures:a,setIsFileRequired:o},t.value)}if("executable"===s.type){let e={stream:!0,format:"rich-text",insert:!1,language:i.language};return i.tone&&(e.tone=i.tone),(0,r.jsx)(rA,{onClick:()=>s.onSelect({editor:l,options:e}),render:(0,r.jsxs)(d.$n,{id:"inline-".concat(s.label),"data-style":"ghost",children:[s.icon,(0,r.jsx)("span",{className:"tiptap-button-text",children:s.label})]})},t.value)}return null}function or(e){let{editor:t}=e,{editor:n}=nl(t),[l,a]=rb(),o=aG(n),{t:i}=(0,a7.B)("tip-tap-web-editor-v3"),s=(0,aQ.O)(i),c=aN(n),d=(0,h.useMemo)(()=>a3({aiActions:o,emptyFeatures:s,setPromptValue:a,state:c}),[o,s,a,c]),u=(0,h.useMemo)(()=>{let e={};return Object.entries(d).forEach(t=>{let[r,l]=t;l.check&&n?l.check(n)&&(e[r]=l):e[r]=l}),e},[d,n]),p=(0,h.useMemo)(()=>(function(e){let t=e=>({label:e.label,value:e.value,icon:e.icon,filterItems:"nested"===e.type?e.filterItems:void 0}),n=e=>e.filter(e=>!!e).map(t);return[{label:"Rewrite",items:n(Object.values([e[tK.O5.PARAPHRASE],e[tK.O5.IMPROVE_FLUENCY],e[tK.O5.ACADEMIC_TONE],e[tK.O5.SIMPLIFY],e[tK.O5.TRIM],e[tK.O5.CHANGE_TONE],e[tK.O5.SYNONYMS]]))},{label:"",items:n(Object.values([e.goBack]))},{label:"Write",items:n(Object.values([e.continueWriting,e.explainThis,e.expandOnThis,e.writeParagraph,e.extractTakeaways,e.draftOutline,e.moreIdeasSelection,e.moreIdeasEmpty]))},{label:"Translate",items:n(Object.values([e.translateTo]))}]})(u),[u]),m=(0,h.useMemo)(()=>(l.trim()?p.reduce((e,t)=>{let n=aY(t,l);return n.length>0&&e.push({...t,items:n}),e},[]):p)||p,[p,l]),g=(0,h.useCallback)(e=>{if(!e.value)return!1;let t=d[e.value];return!!t&&(!(a9(t)&&t.filterItems&&l.trim())||aY({items:t.items||[]},l).length>0)},[d,l]);if(!n)return null;let f=m.map(e=>{var t,n;return{...e,items:null!=(n=null==(t=e.items)?void 0:t.filter(g))?n:[]}}).filter(e=>e.items.length>0);return 0===f.length?null:f.map((e,t)=>(0,r.jsxs)(h.Fragment,{children:[(0,r.jsxs)(rN,{children:[(0,r.jsx)(rS,{children:e.label}),e.items.map(e=>(0,r.jsx)(on,{menuItem:e,availableActions:d,editor:n,emptyFeatures:s},e.value||t))]},t),t<f.length-1&&(0,r.jsx)(rR,{orientation:"horizontal"})]},t))}n(6101);var ol=n(57940),oa=n(32386);let oo=(0,h.createContext)(void 0),oi=e=>{let{children:t}=e,{authState:n}=(0,oa.Z)(),{data:l}=(0,ol.Yq)({authState:n});return(0,r.jsx)(oo.Provider,{value:{discountPackageData:l},children:t})},os=()=>{let e=(0,h.useContext)(oo);if(!e)throw Error("useDiscountBannerContext must be used within a DiscountBannerProvider");return e};var oc=n(40653);let od=[aQ.xW.Enum.CONTRAST_THIS,aQ.xW.Enum.MAKE_PROFESSIONAL,aQ.xW.Enum.MAKE_CONCISE,aQ.xW.Enum.EXPAND_FURTHUR,aQ.xW.Enum.EXPLAIN_THIS],ou=(0,h.memo)(e=>{let{handleFollowUpAction:t}=e,{t:n}=(0,a7.B)("tip-tap-web-editor-v3"),l=(0,aQ.un)(n),a=(0,aQ.eJ)(n);return(0,r.jsx)(r.Fragment,{children:od.map((e,n)=>(0,r.jsx)(d.$n,{"data-style":"ghost",onClick:()=>t(a[e]),children:l[e]},n))})});var op=n(50246),oh=n(92152),om=n(67106),og=n(40704);let of=e=>{var t;let{showProPricing:n}=e,{discountPackageData:l}=os(),{productName:a}=(0,og.Gz)(),o=n?l.proAnnualPackage:"paperpal-lifesciences-for-web"===a?l.monthlyPackage:l.annualPackage,i=null!=(t=null==o?void 0:o.effectivePricePerMonth)?t:"$11.5",s=null==o?void 0:o.discountedEffectivePricePerMonthDisplay,c=(0,r.jsxs)(r.Fragment,{children:["starting at just ",(0,r.jsxs)("span",{children:[i,"/month"]}),"."]}),d=(0,r.jsxs)(r.Fragment,{children:["starting at just"," ",(0,r.jsxs)("span",{children:[s," ",(0,r.jsxs)("span",{style:{textDecoration:"line-through"},children:[i," "]}),"/month"]})]});return(0,r.jsx)(r.Fragment,{children:s?d:c})},ox=e=>{let{showRewriteModePaywall:t=!1,aiGenerationError:n,selectedTab:l}=e,a=n===oc.a.REWRITE_WORD_COUNT_LIMIT_EXCEEDED,{trackCommonEvent:o}=(0,tu._)(),{isPrime:i}=g(),{discountPackageData:s}=os(),c=i&&!!(null==s?void 0:s.proAnnualPackage),d=(0,h.useRef)(void 0),u=(0,h.useMemo)(()=>{var e,t;return null!=(t=null==l||null==(e=l.toLowerCase())?void 0:e.replace(" ","-"))?t:""},[l]);(0,h.useEffect)(()=>
1{if(d.current!==l){if(void 0===d.current||d.current!==l){let e=a?"word-limit-paywall-".concat(u):t?"rewrite-mode-paywall-".concat(u):"daily-limit-paywall-".concat(u);o({type:"view-to-track-paperpal",elementName:e,sectionName:"paywall-card-popup"},{intent:a?"word-limit-paywall-upgrade-to-prime":t?"rewrite-mode-paywall-upgrade-to-prime":"daily-limit-paywall-upgrade-to-prime"})}d.current=l}},[l,o,t,a,u]);let p=(0,h.useCallback)(()=>a?(0,r.jsxs)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 border-gray-6 border bg-white p-4 rounded-lg w-3/4",children:[(0,r.jsxs)("p",{className:"text-sm font-semibold mb-1",children:["Free plan allows rewriting upto"," ",(0,r.jsxs)("span",{className:"text-blue-9",children:[oc.f," words"]})," ","."]}),(0,r.jsxs)("p",{className:"text-sm font-medium mb-3",children:[(0,r.jsx)("span",{className:"text-blue-9",children:"Unlock higher limits,"})," ",(0,r.jsx)(of,{})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[(0,r.jsx)("div",{className:"no-twp shrink-0",children:(0,r.jsx)(k.u,{onClick:()=>{window.open("/plans","_self","noopener,noreferrer")},leftIcon:(0,r.jsx)(oh.v,{stroke:"transparent",width:20}),size:"small",id:"word-limit-upgrade-button",trackingProperties:{intent:"upgrade-intent"},trackingName:"word-limit-paywall-".concat(u),ariaLabel:"Upgrade",css:{display:"block"},children:"Upgrade"})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 py-2 px-3 rounded-full text-xs",style:{backgroundColor:I.w4.colors.yellow2.value},children:[(0,r.jsx)("span",{className:"shrink-0",children:(0,r.jsx)(om.I,{name:"lightbulb",variant:"regular",height:14,width:14})}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"font-bold",children:"Tip"})," - Select up to ",oc.f," words to rewrite with free plan"]})]})]}),(0,r.jsx)("p",{className:"text-xs text-gray-10 mt-2 italic",children:"7 days money back guarantee!"})]}):t?(0,r.jsx)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 border-gray-6 border bg-white p-4 rounded-lg w-3/4",children:(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("p",{className:"text-sm font-semibold mb-1",children:["This premium mode is available only with"," ",(0,r.jsx)("span",{className:"font-semibold text-yellow-9",children:"Prime"})]}),(0,r.jsxs)("p",{className:"text-sm font-medium mb-3",children:[(0,r.jsx)("span",{className:"text-blue-9",children:"Upgrade to get higher limits "})," ",(0,r.jsx)(of,{})]}),(0,r.jsxs)("div",{className:"no-twp flex justify-between items-center gap-7 mt-2",children:[(0,r.jsx)("div",{className:"text-xs font-semibold",children:"Only available with Prime"}),(0,r.jsx)("div",{className:"text-xs",children:"7 days money back guarantee!"}),(0,r.jsx)(k.u,{onClick:()=>{window.open("/plans","_self","noopener,noreferrer")},leftIcon:(0,r.jsx)(oh.v,{stroke:"transparent",width:20}),size:"small",id:"rewrite-mode-upgrade-button",trackingProperties:{intent:"upgrade-intent"},trackingName:"rewrite-mode-paywall-".concat(u),ariaLabel:"Upgrade to View",children:"Upgrade"})]})]})}):(0,r.jsxs)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 border-gray-6 border bg-white p-4 rounded-lg w-3/4",children:[(0,r.jsx)("p",{className:"text-sm font-semibold mb-1",children:c?"Monthly limit reached.":"You have reached your daily free limit."}),(0,r.jsxs)("p",{className:"text-sm font-medium mb-3",children:[(0,r.jsx)("span",{className:"text-blue-9",children:c?"Get unlimited usage for your research and writing with Pro ":"Upgrade to get higher limits "})," ",(0,r.jsx)(of,{showProPricing:c})]}),(0,r.jsxs)("div",{className:"no-twp flex justify-between items-center gap-7 mt-2",children:[(0,r.jsx)("div",{className:"text-xs font-semibold",children:"No free uses left"}),(0,r.jsx)(k.u,{onClick:()=>{window.open("/plans","_self","noopener,noreferrer")},id:"daily-limit-upgrade-button",leftIcon:c?(0,r.jsx)("img",{src:"https://cdn.paperpal.com/assets/images/pro_icon.webp",alt:"pro",width:20,height:20}):(0,r.jsx)(oh.v,{stroke:"transparent",width:20}),size:"small",trackingProperties:{intent:"upgrade-intent"},trackingName:"daily-limit-paywall-".concat(u),ariaLabel:"Upgrade to View",children:"Upgrade"})]})]}),[a,t,u,c]);return(0,r.jsxs)("div",{className:"relative overflow-hidden",children:[(0,r.jsx)("p",{className:"blur-sm text-base font-normal text-gray-12 select-none",children:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Let me know if you'd like me to generate more placeholder text or use it for a specific purpose! Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Let me know if you'd like me to generate more placeholder text or use it for a specific purpose!"}),(0,r.jsx)("div",{className:"flex justify-center",children:p()})]})};function ob(e){var t,n;let{editor:l,showRewriteModePaywall:a,showPaymentError:o,aiGenerationError:i}=e,{activeFeature:s}=aN(l),c=(null==(t=l.storage)?void 0:t.ai)||(null==(n=l.storage)?void 0:n.aiAdvanced),u=null==c?void 0:c.state;return o||a?(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("div",{className:"ml-0 flex flex-row justify-between items-center font-semibold text-sm text-gray-11 font-bold capitalize mb-4",children:[(0,r.jsx)("div",{}),(0,r.jsx)(d.$n,{className:"!bg-transparent hover:bg-gray-6 !p-0.5 focus:bg-gray-6 active:bg-gray-6 text-black",onClick:()=>l.commands.resetUiState(),tooltip:"discard",children:(0,r.jsx)(ej,{})})]}),(0,r.jsx)(ox,{showRewriteModePaywall:a,aiGenerationError:i,selectedTab:s})]}):(0,r.jsx)("p",{className:"text-sm font-medium text-red-900 mb-1 pb-2",children:"string"==typeof u?u:(0,op.F)(u).errorReason})}let oC=e=>(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",...e,children:[(0,r.jsx)("path",{d:"M14.6704 3.69658L5.7543 1.39618C4.90624 1.17738 4.04137 1.68749 3.82257 2.53555L1.52217 11.4517C1.30337 12.2997 1.81348 13.1646 2.661
154 13.3834L11.5776 15.6838C12.4257 15.9026 13.2906 15.3925 13.5094 14.5444L15.8098 5.62831C16.0286 4.78025 15.5185 3.91538 14.6704 3.69658Z",fill:"url(#paint0_linear_800_7971)",fillOpacity:"0.4"}),(0,r.jsx)("path",{d:"M11.2826 2.35474H1.58584C0.710003 2.35474 0 3.06474 0 3.94057V13.6373C0 14.5131 0.710003 15.2231 1.58584 15.2231H11.2826C12.1584 15.2231 12.8684 14.5131 12.8684 13.6373V3.94057C12.8684 3.06474 12.1584 2.35474 11.2826 2.35474Z",fill:"url(#paint1_linear_800_7971)"}),(0,r.jsx)("path",{d:"M9.91831 7.44885L7.6849 7.13985L6.68654 5.21302C6.65926 5.16026 6.61438 5.11756 6.55896 5.09159C6.42 5.02629 6.2511 5.08073 6.18161 5.21302L5.1832 7.13985L2.94982 7.44885C2.88824 7.45722 2.83195 7.48485 2.78884 7.52676C2.73673 7.57774 2.70802 7.64633 2.70901 7.71746C2.71 7.78858 2.74061 7.85641 2.79412 7.90609L4.41003 9.40586L4.02824 11.5236C4.01932 11.5729 4.02503 11.6236 4.04477 11.6699C4.06455 11.7162 4.09754 11.7563 4.14004 11.7857C4.1825 11.8151 4.23281 11.8325 4.28518 11.8361C4.3376 11.8397 4.38997 11.8292 4.43639 11.8058L6.43407 10.806L8.43171 11.8058C8.48626 11.8335 8.54958 11.8427 8.61027 11.8326C8.76335 11.8075 8.86627 11.6693 8.83986 11.5236L8.45811 9.40586L10.074 7.90609C10.118 7.86506 10.147 7.81146 10.1558 7.75282C10.1796 7.60629 10.0723 7.47062 9.91831 7.44885Z",fill:"url(#paint2_linear_800_7971)"}),(0,r.jsxs)("defs",{children:[(0,r.jsxs)("linearGradient",{id:"paint0_linear_800_7971",x1:"14.934",y1:"5.1104",x2:"2.70327",y2:"13.3941",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.0480121",stopColor:"#ECB441"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#FFF1D6"})]}),(0,r.jsxs)("linearGradient",{id:"paint1_linear_800_7971",x1:"11.8525",y1:"3.7093",x2:"-5.07962",y2:"19.9641",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.0480121",stopColor:"#ECB441"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#FFF1D6"})]}),(0,r.jsxs)("linearGradient",{id:"paint2_linear_800_7971",x1:"2.70898",y1:"14.3766",x2:"15.4784",y2:"-1.85479",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#956A11"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#CC9014",stopOpacity:"0.08"})]})]})]});var ov=n(80764);let oy=e=>{var t;let n=(0,u.l)(0,"use-should-show-pro-nudge"),r=n.data,{data:l,isLoading:a}=(0,ol.Yq)({authState:e}),o=!n.isSuccess||a,i=(0,h.useMemo)(()=>{var e;let t=null==(e=n.data)?void 0:e.planMachineName;return!!t&&ov.Kx.includes(t)},[null==(t=n.data)?void 0:t.planMachineName]),s=(0,h.useMemo)(()=>n.isSuccess&&(null==r?void 0:r.subscriptionStatus)==="active"&&(null==r?void 0:r.isPrime)&&!r.isPro,[n,null==r?void 0:r.subscriptionStatus,null==r?void 0:r.isPrime,null==r?void 0:r.isPro]),c=!o&&i&&!!(null==l?void 0:l.isProPlanAvailable);return{shouldShowProNudge:c,shouldShowProUpgradeNudge:!o&&!!(null==l?void 0:l.isProPlanAvailable)&&s,isLoading:o,isProMonthlyActivePlan:(0,h.useMemo)(()=>n.isSuccess&&(null==r?void 0:r.subscriptionStatus)==="active"&&(null==r?void 0:r.planMachineName)==="paperpal-pro-monthly",[n,null==r?void 0:r.subscriptionStatus,null==r?void 0:r.planMachineName]),isActivePrimePlan:s}},ow=(e,t)=>{let n=oy(e),r=(0,h.useMemo)(()=>!!t&&t.totalBalance>0&&t.usedBalance/t.totalBalance>=.5,[t]),l=n.shouldShowProUpgradeNudge&&r;return{...n,hasReachedHalfBalanceUsage:r,showProUpgrade:l}};var oj=n(52370);function oI(e){var t,n;let{toolbarName:l}=e,{genAiBalance:a,isPrime:o,isFreeTrialPlan:i}=g(),{authState:s}=(0,oa.Z)(),{showProUpgrade:c}=ow(s,a),d=(null==a||null==(t=a.freeCreditsBalanceDtoList)?void 0:t.reduce((e,t)=>{if(t.freeCreditsName.includes("GENAI")&&t.featuresAndLimits){var n;return e+((null==(n=t.featuresAndLimits[0])?void 0:n.featureLimit)||0)}return e},0))||0,u=(null!=(n=null==a?void 0:a.totalBalance)?n:0)-d,{t:p}=(0,a7.B)("tip-tap-web-editor-v3"),{message:h}=(0,oj.p)(a,u,p,void 0,void 0,o,i?"paperpal-free-trial-7-days":void 0);return!a||a.isUnlimited||o&&!c?null:(0,r.jsx)("div",{className:"no-twp w-full",children:(0,r.jsxs)("div",{className:"bg-gray-4 flex items-center justify-between\n            px-[10px] py-2 mt-[5px]\n            border border-gray-4\n            ".concat("KeepWritingToolbar"===l?"rounded-b-[5px]":"rounded-b-[13px]","\n          "),children:[(0,r.jsx)("p",{className:"text-[10px] leading-tight",children:h}),(0,r.jsxs)(ok,{href:"/plans",target:"_blank","data-intent":"upgrade-intent","data-test-id":c?"upgrade-to-pro-cta-footer":"upgrade-cta-footer",id:"upgrade-cta-footer",children:[c?"UPGRADE TO PRO":"UPGRADE",c?(0,r.jsx)("img",{src:"https://cdn.paperpal.com/assets/images/pro_icon.webp",alt:"pro",width:20,height:20}):(0,r.jsx)(oC,{stroke:"transparent",width:20})]})]})})}let ok=(0,I.I4)(k.u,{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:500,paddingInline:"8px",paddingBlock:"4px",borderRadius:"4px",background:I.w4.colors.blue9,color:I.w4.colors.white,"&:hover":{opacity:.9}});var oE=n(87094),oN=n(29314),oS=n(96025);let oT=()=>{let{discountPackageData:e}=os(),t=(0,oE.m)(),n=(0,h.useMemo)(()=>!!(e&&Object.values(null==e?void 0:e.Packs).some(e=>e.offer))||!1,[e]),l=(0,h.useMemo)(()=>oN.N[null==e?void 0:e.country],[null==e?void 0:e.country]);return e&&n?(0,r.jsx)("div",{className:"w-full mx-auto",children:(0,r.jsx)(oS.lF,{packs:null==e?void 0:e.Packs,isDifferentialPricingEnabled:null==e?void 0:e.annualPackage.isDifferentialPricingEnabled,country:l,partnerId:e.partnerId,theme:"light",offerBannerText:t})}):null};var oA=n(16755),oR=n(86379);function oM(e){let{...t}=e,[n,l]=(0,h.useState)(!1);return rw(()=>l(!0),[]),n?(0,r.jsx)(oR.A,{...t}):null}function oL(e){let{editor:t,containerRef:n,query:r,items:l,onSelect:a,onClose:o,orientation:i="vertical",autoSelectFirstItem:s=!0}=e,[c,d]=(0,h.useState)(s?0:-1);return(0,h.useEffect)(()=>{let e=e=>{if(!l.length)return!1;let t=()=>d(e=>-1===e?0:(e+1)%l.length),n=()=>d(e=>-1===e?l.length-1:(e-1+l.length)%l.length);switch(e.key){case"ArrowUp":if("horizontal"===i)return!1;return e.preventDefault(),n(),!0;case"ArrowDown":if("horizontal"===i)return!1;return e.preventDefault(),t(),!0;case"ArrowLeft":if("vertical"===i)return!1;return e.preventDefault(),n(),!0;case"ArrowRight":if("vertical"===i)return!1;return e.preventDefault(),t(),!0;case"Tab":return e.preventDefault(),e.shiftKey?n():t(),!0;case"Home":return e.preventDefault(),d(0),!0;case"End":return e.preventDefault(),d(l.length-1),!0;case"Enter":if(e.isComposing)return!1;return e.preventDefault(),-1!==c&&l[c]&&(null==a||a(l[c])),!0;case"Escape":return e.preventDefault(),null==o||o(),!0;default:return!1}},r=null;if(t?r=t.view.dom:(null==n?void 0:n.current)&&(r=n.current),r)return r.addEventListener("keydown",e,!0),()=>{null==r||r.removeEventListener("keydown",e,!0)}},[t,n,l,c,a,o,i]),(0,h.useEffect)(()=>{r&&d(s?0:-1)},[r,s]),{selectedIndex:l.length?c:void 0,setSelectedIndex:d}}oM.displayName="TextareaAutosize",n(32585);let oD=e=>{let[t,n]=(0,h.useState)([]),r=(0,h.useCallback)(()=>e.current?Array.from(e.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[e]);(0,h.useEffect)(()=>{let t=e.current;if(!t)return;let l=()=>n(r());l();let a=new MutationObserver(l);return a.observe(t,{childList:!0,subtree:!0}),()=>a.disconnect()},[r,e]);let{selectedIndex:l}=oL({containerRef:e,items:t,orientation:"horizontal",onSelect:e=>e.click(),autoSelectFirstItem:!1});(0,h.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{let n=e.target;t.contains(n)&&n.setAttribute("data-focus-visible","true")},r=e=>{let n=e.target;t.contains(n)&&n.removeAttribute("data-focus-visible")};return t.addEventListener("focus",n,!0),t.addEventListener("blur",r,!0),()=>{t.removeEventListener("focus",n,!0),t.removeEventListener("blur",r,!0)}},[e]),(0,h.useEffect)(()=>
1{if(void 0!==l&&t[l]){var e;null==(e=t[l])||e.focus()}},[l,t])},o_=(0,h.forwardRef)((e,t)=>{let{children:n,className:l,variant:a="fixed",...o}=e,i=(0,h.useRef)(null),s=ry(i,t);return oD(i),(0,r.jsx)("div",{ref:s,role:"toolbar","aria-label":"toolbar","data-variant":a,className:(0,eg.cn)("tiptap-toolbar",l),...o,children:n})});o_.displayName="Toolbar";let oH=(0,h.forwardRef)((e,t)=>{let{children:n,className:l,...a}=e;return(0,r.jsx)("div",{ref:t,role:"group",className:(0,eg.cn)("tiptap-toolbar-group",l),...a,children:n})});oH.displayName="ToolbarGroup";let oP=(0,h.forwardRef)((e,t)=>{let{...n}=e;return(0,r.jsx)(rR,{ref:t,orientation:"vertical",decorative:!0,...n})});oP.displayName="ToolbarSeparator";var oO=n(9820);n(61712);var oz=n(91280),oB=n(84577),oF=n(92137);function oV(e){let{showPlaceholder:t,onInputSubmit:n,isEmpty:l=!1}=e,[a]=rb(),o=(0,h.useCallback)(()=>{n(a)},[n,a]);return(0,r.jsxs)(o_,{variant:"floating","data-plain":"true",className:"tiptap-ai-prompt-input-toolbar",style:{display:t?"none":"flex"},children:[(0,r.jsx)(rX,{}),(0,r.jsx)(oH,{children:(0,r.jsx)(d.$n,{onClick:o,disabled:l,"data-style":"primary",id:"tip-tap-input-submit","aria-label":"Submit prompt",className:"absolute bottom-3 right-3 !h-[27px] !w-[27px]",children:(0,r.jsx)(ew.$6,{className:"tiptap-button-icon"})})})]})}function oU(e){var t,n;let{onInputSubmit:l,onToneChange:a,onClose:o,onInputFocus:i,onInputBlur:s,onEmptyBlur:c,onPlaceholderClick:d,setIsPopupOpen:u,isPopupOpen:p,showPlaceholder:m=!1,placeholder:g="Tell Paperpal what to write...",setIsRecentFilesDialogOpen:f,isRecentFilesDialogOpen:x,aiGenerationHasMessage:b,...C}=e,[v,y]=rb(),w=(0,h.useRef)(null),{files:j,areFilesProcessing:I,removeFile:k,maxFiles:E,fileCitationInfo:N}=(0,oA.v)(),S=Object.values(j)||[],T=(0,h.useRef)(null),A=(0,h.useCallback)(()=>{u(!1),f(!0)},[u,f]),R=(0,h.useCallback)(()=>{let e=null==v?void 0:v.trim();e&&(l(e,N),y(""))},[l,v,N,y]),M=(0,h.useMemo)(()=>[aQ.cR.DRAFT_OUTLINE,aQ.cR.DRAFT_LITERATURE_REVIEW,aQ.cR.WRITE_CONCLUSION,aQ.cR.WRITE_IDEA,aQ.cR.EXTRACT_KEY_TAKEAWAYS].some(e=>e.trim()===(null==v?void 0:v.trim())),[v]),L=(0,h.useMemo)(()=>{var e,t;let n=(e=v,null==(t=Object.entries(aQ.cR).find(t=>{let[,n]=t;return n===e}))?void 0:t[0]);if(!n)return v;let r=aQ.T4[n];if(!(null==r?void 0:r.length))return v;let l=v;return r.forEach(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=RegExp("\\b".concat(t,"\\b"),"g");l=l.replace(n,"[".concat(e,"]"))}),l},[v]);(0,h.useEffect)(()=>{L&&L!==v&&y(L)},[L,v]);let D=(t=M?void 0:R,(0,h.useCallback)(e=>{!(0,oO.v_)("backspace",e)||(null==v?void 0:v.length)?(0,oO.v_)("enter",e)&&!e.shiftKey?(e.preventDefault(),null==t||t()):(0,oO.v_)("escape",e)&&(e.preventDefault(),null==o||o()):(e.preventDefault(),null==o||o())},[v,o,t])),_=(n=""===v.trim(),(0,h.useCallback)(e=>{!e.currentTarget.contains(e.relatedTarget)&&(n&&c?c():s&&s())},[n,s,c])),H=(0,h.useCallback)(e=>{T.current&&T.current.focus(),D(e)},[D]),P=(0,h.useCallback)(()=>{i&&i()},[i]),O=(0,h.useCallback)(e=>{_(e)},[_]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"tiptap-ai-prompt-input relative flex-col",...C,children:[!!S.length&&(0,r.jsx)("div",{ref:w,className:"py-4 mb-2 px-0 overflow-auto",children:(0,r.jsx)(oz.T,{filesList:S,onRemove:k,setIsPopupOpen:u})}),(0,r.jsx)(oM,{onChange:e=>y(e.target.value),value:v,onKeyDown:H,onFocus:P,onBlur:O,className:"tiptap-ai-prompt-input-content",placeholder:g,autoFocus:!0,id:"tip-tap-editor-textarea"}),!b&&(0,r.jsx)(oB._,{isPopupOpen:!!p,setIsPopupOpen:u,uploadFileTooltip:aQ.HR,handleViewRecentClick:A,disableViewRecent:S.length===E,css:{bottom:12,right:44,left:"auto"}}),(0,r.jsx)(oV,{showPlaceholder:m,onInputSubmit:R,isEmpty:!(null==v?void 0:v.trim())||I||M&&!S.length}),x&&(0,r.jsx)(oF.O,{open:x,setOpen:f,isMobileWeb:!1,featureName:tK.A9.Enum.WRITE})]}),M&&!S.length&&(0,r.jsx)("div",{className:"w-full text-red-900 text-xs bg-white p-1 px-2 rounded-md",children:"File Required"})]})}let oW=e=>{let{aiGenerationHasMessage:t,isPopupOpen:n,isRecentFilesDialogOpen:l,inputRef:a,onInputFocus:o,onInputBlur:i,onClose:s,onPlaceholderClick:c,onInputSubmit:d,onToneChange:u,setIsPopupOpen:p,setIsRecentFilesDialogOpen:h}=e;return(0,r.jsx)(oA.o,{...aQ.Qf,feature:tK.A9.enum.WRITE,children:(0,r.jsx)(oU,{ref:a,aiGenerationHasMessage:t,onInputFocus:o,onInputBlur:i,onClose:s,onPlaceholderClick:c,onInputSubmit:d,onToneChange:u,setIsPopupOpen:p,isPopupOpen:n,setIsRecentFilesDialogOpen:h,isRecentFilesDialogOpen:l})})};class oG extends h.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("MarkdownErrorBoundary error details:",{error:e,errorInfo:t,thisText:this.props.text,reqId:this.props["data-req-id"]})}render(){return this.state.hasError?this.props.fallback||(0,r.jsx)("div",{className:"markdown-error-fallback",children:(0,r.jsx)("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:this.props.text||"Error rendering content"})}):this.props.children}constructor(e){super(e),this.state={hasError:!1}}}var oZ=n(26189),oq=n(62590),o$=n(55270),oK=n(91548),oY=n(45518);function oX(e){let{editor:t,isError:n,showPaymentError:l,setShowTrackChange:a,showTrackChange:o}=e,{results:i,activeFeature:s,activeResultIndexByFeature:c,activeGroup:u,aiGenerationIsLoading:p,isPrompt:m}=aN(t),g=aG(t),f=(0,h.useMemo)(()=>Object.keys(null!=i?i:{}),[i]),x=(0,h.useMemo)(()=>!!u,[u]),b=(0,h.useMemo)(()=>{var e,t;return s&&null!=(t=null==i||null==(e=i[s])?void 0:e.length)?t:0},[i,s]),C=(0,h.useMemo)(()=>{var e;return s&&null!=(e=null==c?void 0:c[s])?e:0},[s,c]),v=(0,h.useCallback)(()=>{let e=C>0?C-1:b-1;t.commands.uiStateSetActiveResultIndexByFeature(e)},[C,t,b]),y=(0,h.useCallback)(()=>{let e=C<b-1?C+1:0;t.commands.uiStateSetActiveResultIndexByFeature(e)},[C,t,b]),w=(0,h.useCallback)(e=>{var n;
1if(t.commands.uiStateSetActiveFeature(e),(null==i||null==(n=i[e])||!n.length)&&!l)switch(u){case"trim":g.trim(e);break;case"tone":g.adjustTone(e);break;default:g.executeAICommand(e)}},[t,i,u,g,l]),j=u||(m?"Preview":s);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex w-full border-b border-gray-300 overflow-hidden flex-col",children:[(j||b>1)&&(0,r.jsxs)("div",{className:"flex w-full ".concat(x?"m-3":"mx-3 mt-3","  justify-between"),children:[(0,r.jsx)("div",{className:"flex items-center  font-semibold text-sm text-gray-600 mx-1",children:(0,r.jsx)("span",{className:"capitalize",children:j})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-5",children:[!n&&x&&(0,r.jsxs)("div",{className:"flex text-xs font-medium text-blue-12 items-center gap-2 ml-auto",children:["Show changes",(0,r.jsx)(oY.j,{checked:o,trackingProperties:{CTALabel:"Show track change",sectionName:"Inline editor"},onClick:()=>a(!o)})]}),b>1&&(0,r.jsxs)("div",{className:"flex items-center text-sm text-gray-600",children:[(0,r.jsx)(d.$n,{className:"border-0 !bg-transparent text-gray-11 cursor-pointer disabled:text-gray-6 disabled:cursor-default",onClick:v,"data-type":"small","data-size":"small",disabled:p,children:(0,r.jsx)(ew.gu,{className:"tiptap-button-icon"})}),(0,r.jsxs)("span",{children:[C+1," of ",b]}),(0,r.jsx)(d.$n,{className:"border-0 !bg-transparent text-gray-11 cursor-pointer disabled:text-gray-6 disabled:cursor-default",onClick:y,"data-type":"small","data-size":"small",disabled:p,children:(0,r.jsx)(ew.Vj,{className:"tiptap-button-icon"})})]})]})]}),(0,r.jsx)("div",{className:"flex w-full",children:x&&(0,r.jsx)("div",{className:"flex gap-1 ml-6 relative z-10 ",children:f.map(e=>{var t,n;let l=null!=(n=null==i||null==(t=i[e])?void 0:t.filter(e=>""!==e.trim()).length)?n:0,a=e===s;return(0,r.jsxs)(d.$n,{onClick:()=>w(e),disabled:p,className:"\n                      shrink-0 px-3 py-2 text-sm font-medium \n                      inline-flex\n                      !rounded-t-md !rounded-b-none\n                      focus:outline-none\n                      !border !border-solid\n                     \n                      ".concat(a?"!text-gray-600 !bg-white !border-gray-300 !border-b-transparent":"!text-blue-600 !bg-blue-50 !border-blue-50 !border-b-gray-300"," \n                       ").concat(p||a?"cursor-not-allowed !text-gray-300":"cursor-pointer hover:!text-gray-800 hover:!bg-blue-4","\n                    "),children:[e,l>0&&(0,r.jsx)("span",{className:"rounded-full bg-blue-200 px-2 text-xs hidden md:inline-flex",children:l})]},e)})})})]})})}let oJ=()=>(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{role:"status",className:"flex flex-col w-full items-start gap-[2px] animate-pulse",children:[(0,r.jsx)("div",{className:"w-full h-[20px] bg-gray-5"}),(0,r.jsx)("div",{className:"w-full h-[20px] bg-gray-5"}),(0,r.jsx)("div",{className:"w-full h-[20px] bg-gray-5"}),(0,r.jsx)("div",{className:"w-2/3 h-[20px] bg-gray-5"})]})}),oQ=e=>{let{editor:t,activeResult:n,showPaymentError:l,showRewriteModePaywall:a,aiGenerationError:o,activeFeature:i,isTabView:s,selectedText:c,finished:d=!0}=e,[u,p]=(0,h.useState)(!1),m=l||a,g=(0,h.useMemo)(()=>i===tK.vI.TRIM||i===tK.vI.TRIM_HIGH||i===tK.vI.TRIM_LESS||i===tK.vI.TRIM_MODERATE,[i]),f=(0,h.useMemo)(()=>s&&d&&c&&n&&u?(0,oZ.o)(c,n):null,[s,d,c,n,u]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(oX,{editor:t,isError:m&&!n,showTrackChange:u,showPaymentError:l,setShowTrackChange:p}),(0,r.jsxs)("div",{className:"w-[97%] overflow-auto  ".concat(s?"border-[1px] border-solid border-gray-7 dark:border-neutral-700 rounded-md mx-2 mb-2 p-4 -mt-px":"p-1 m-3"),children:[!n&&!m&&(0,r.jsx)("div",{className:"mb-2 -mx-4",children:g?(0,r.jsx)(oq.M,{showLottie:!1}):(0,r.jsx)(oJ,{})}),s&&d&&u&&f&&f.length>0?(0,r.jsx)(o$.N3,{css:{whiteSpace:"break-spaces"},children:f.map((e,t)=>(0,r.jsx)(o$.$C,{chunk:e},t))}):n?(0,r.jsx)(oG,{text:n,fallback:(0,r.jsx)("p",{dangerouslySetInnerHTML:{__html:n},className:"block text-base font-normal text-gray-12 notranslate","data-insertion-type":"ai-generated","data-feature-name":i?i.toString():"","data-req-id":"","data-source":"INLINE"}),children:(0,r.jsx)(h.Suspense,{fallback:(0,r.jsx)(oJ,{}),children:(0,r.jsx)("div",{"data-insertion-type":"ai-generated","data-feature-name":i?i.toString():"","data-req-id":"","data-source":"INLINE",children:(0,r.jsx)(oK.l5,{className:"notranslate",mode:d?"static":"streaming",parseIncompleteMarkdown:!d,children:n})})})}):(0,r.jsx)(r.Fragment,{children:m&&(0,r.jsx)("div",{className:"max-h-80 mx-2 overflow-auto rounded-md",children:(0,r.jsx)(ob,{editor:t,showRewriteModePaywall:a,showPaymentError:l,aiGenerationError:o})})})]})]})},o0=e=>{var t;let{results:n,selectedSynonyms:l,setSelectedSynonyms:a}=e,o=null==(t=n[tK.vI.SYNONYMS])?void 0:t[0];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"grid w-full px-5 py-3 font-medium text-gray-9",children:"Synonyms"}),(0,r.jsx)(o1,{currentResponse:o,selectedSynonyms:l,setSelectedSynonyms:a})]})},o1=e=>{let{currentResponse:t,selectedSynonyms:n,setSelectedSynonyms:l}=e;return(0,h.useEffect)(()=>{let e=null==t?void 0:t.split(et.Fp)[0];e&&l(e)},[t,l]),(0,r.jsx)("ul",{className:"grid text-sm w-full gap-2 grid-cols-1 mb-2",children:null==t?void 0:t.split(et.Fp).map(e=>(0,r.jsxs)("li",{className:"flex gap-3 items-center",children:[(0,r.jsx)("input",{type:"radio",className:"w-[16px] h-[16px]",id:e,checked:n===e,name:"synonymSelection",onChange:e=>{l(e.target.id)}}),(0,r.jsx)("div",{className:"flex gap-2","data-insertion-type":"ai-generated","data-feature-name":"Synonyms","data-source":"INLINE",children:(0,r.jsx)("label",{className:"block w-[200px] text-blue-11 font-medium",children:e})})]}))})};function o2(e){let{children:t}=e,{value:n,AiMenuStateContext:l}=function(){let[e,t]=(0,h.useState)(aq),n=(0,h.useCallback)(e=>{t(t=>({...t,...e}))},[]),r=(0,h.useCallback)((e,t)=>{let r=t||(null==e?void 0:e.getBoundingClientRect())||null;n({fallbackAnchor:{element:e,rect:r}})},[n]),l=(0,h.useCallback)(()=>{t(aq),aT()},[]);return{value:(0,h.useMemo)(()=>
1({state:e,updateState:n,setFallbackAnchor:r,reset:l}),[e,n,r,l]),AiMenuStateContext:aZ}}();return(0,r.jsx)(l.Provider,{value:n,children:t})}function o4(e){var t,n,l,a,o;let{editor:i}=e,{editor:s}=nl(i),[c,d]=(0,h.useState)(!1),[u,p]=(0,h.useState)(!1),[m,f]=(0,h.useState)(!1),{state:x,updateState:b,setFallbackAnchor:v,reset:y}=a$(),{show:w,store:I}=rC(),k=(null==s||null==(t=s.storage)?void 0:t.ai)||(null==s||null==(n=s.storage)?void 0:n.aiAdvanced),E=(0,h.useRef)(null),{aiGenerationActive:N,aiGenerationIsLoading:S,aiGenerationError:T,aiGenerationHasMessage:A,activeFeature:R,activeGroup:M,results:L,resultRequestIds:D,activeResultIndexByFeature:_,selectedText:H}=aN(s),P=(0,h.useRef)(null),[O,z]=(0,h.useState)(""),{isPrime:B}=g(),{executeWriteCommand:F}=aG(s),{activeResult:V,activeRequestId:U}=function(e){var t,n,r,l,a;let{results:o,activeFeature:i,activeResultIndexByFeature:s,resultRequestIds:c}=e,d=null!=(r=null==s?void 0:s[i])?r:0;return{activeResult:null!=(l=null==o||null==(t=o[i])?void 0:t[d])?l:"",activeRequestId:null!=(a=null==c||null==(n=c[i])?void 0:n[d])?a:""}}({results:L,activeFeature:R,activeResultIndexByFeature:_,resultRequestIds:D}),W=(null==k||null==(l=k.generatedWith)?void 0:l.action)==="complete",G=(0,h.useCallback)(()=>{s&&(y(),null==I||I.hideAll(),s.commands.resetUiState(),p(!1),E.current=null)},[s,y,I]),Z=(0,h.useCallback)((e,t)=>{if(s&&e.trim()){if(s.commands.setIsPrompt(!0),!x.fallbackAnchor.element||!x.fallbackAnchor.rect){let e=ll(s);if(e){let t=e.getBoundingClientRect();v(e,t)}}F({command:e,context:t,isContentNeeded:!0})}},[s,x.fallbackAnchor,v,F]),q=(0,h.useCallback)(e=>{I.setAnchorElement(e)},[I]),$=(0,h.useCallback)((e,t,n)=>{v(e,t),n&&(E.current=n)},[v]),{showRewriteModePaywall:K}=aW({isPrime:B,selectedTab:R}),Y=(0,h.useCallback)(()=>{s&&(S?s.commands.aiReject({type:"reset"}):s.commands.aiAccept(),G())},[S,G,s]),X=(0,h.useCallback)(()=>{if(T)return void G();(S||A)&&!c&&!m?p(!0):c||m||G()},[S,T,A,c,m,G]);!function(e){let{editor:t,aiGenerationActive:n,setAnchorElement:r,fallbackAnchor:l}=e,a=(0,h.useRef)(null);(0,h.useEffect)(()=>{if(!t||!n)return;let e=e=>{let{editor:t}=e,n=t.storage.ai||t.storage.aiAdvanced;if((null==n?void 0:n.state)==="loading"){let e=function(e){let t=function(e){let t=e.view,n=t.dom.querySelectorAll(".tiptap-ai-insertion");if(0===n.length)return null;let r=n[n.length-1];if(r&&t.dom)try{var l=t.dom;if(!r||!l)throw Error("Both element and editorRoot must be provided");if(r===l)return r;if(!l.contains(r))throw Error("Element is not inside the editor root");let e=r;for(;e.parentElement&&e.parentElement!==l;)e=e.parentElement;return e}catch(e){}return r||null}(e);if(t)return t;let n=ll(e);return n||null}(t);e&&e!==t.view.dom&&(a.current&&(a.current.remove(),a.current=null),r(e))}};return t.on("transaction",e),()=>{t.off("transaction",e),a.current&&(a.current.remove(),a.current=null)}},[t,n,r,l])}({editor:s,aiGenerationActive:N,setAnchorElement:q,fallbackAnchor:x.fallbackAnchor}),function(e){let{editor:t,aiGenerationActive:n,showMenuAtElement:r,setMenuVisible:l,onSelectionChange:a,prevent:o=!1}=e;(0,h.useEffect)(()=>{if(!t||!n||o)return;let e=e=>{var t;if(null==(t=e.state.selection)?void 0:t.empty)return;let o=ll(e),i=!!(o&&n);if(i&&o){let t=o.getBoundingClientRect(),n=aA(e);null==a||a(o,t,n?n.bottom-t.bottom:void 0),r(o)}l(i)};e(t);let i=t=>{let{editor:n}=t;e(n)};return t.on("transaction",i),()=>{t.off("transaction",i)}},[t,n,r,l,a,o])}({editor:s,aiGenerationActive:N,showMenuAtElement:w,setMenuVisible:e=>b({isOpen:e}),onSelectionChange:$,prevent:S}),(0,h.useEffect)(()=>{S&&b({shouldShowInput:!1})},[S,b]),(0,h.useEffect)(()=>{N&&x.fallbackAnchor.element&&I.setAnchorElement(x.fallbackAnchor.element)},[N,x.fallbackAnchor.element,I]),(0,h.useEffect)(()=>{!N&&x.isOpen&&G()},[N,x.isOpen,G]);let J=e=>(null==e||e.focus(),e&&!Q(e)&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),setTimeout(()=>I.setAutoFocusOnShow(!1),0),!1),Q=e=>{let t=e.getBoundingClientRect();return(window.innerHeight||document.documentElement.clientHeight)-t.bottom>=200},ee=(0,h.useMemo)(()=>{var e;return{...(null==s||null==(e=s.storage.ai.generatedWith)?void 0:e.options)||{},tone:R,format:"rich-text"}},[s,R]),et=(0,h.useMemo)(()=>{let e="PAYMENT_REQUIRED"===T||T===oc.a.REWRITE_WORD_COUNT_LIMIT_EXCEEDED,t=!!T&&!e,n=!!T&&!M,r=e||K,l=""===V&&(e||K);return{isPaymentRequired:e,showErrorView:t,showActions:!S&&!!R&&!n&&!l,showPaywallCard:r}},[T,S,R,M,V,K]),en={aiGenerationHasMessage:A,isPopupOpen:c,isRecentFilesDialogOpen:m,inputRef:P,onInputFocus:()=>b({inputIsFocused:!0}),onInputBlur:()=>b({inputIsFocused:!1}),onClose:Y,onPlaceholderClick:()=>b({shouldShowInput:!0}),onInputSubmit:Z,onToneChange:e=>b({tone:e}),setIsPopupOpen:d,setIsRecentFilesDialogOpen:f},{handleFollowUpAction:er,handleOnAccept:el,handleOnCopy:ea,handleOnReject:eo}=function(e){var t,n,r;let{editor:l,activeResult:a,closeAiMenu:o,selectedSynonyms:i,activeRequestId:s}=e,{incSynonymsAccepted:c}=aM(),{successToast:d,errorToast:u}=C(),{executeWriteCommand:p}=aG(l),{triggerConfetti:m}=az(),{activeFeature:g,citationSelection:f}=aN(l),x=(null==l||null==(t=l.storage)?void 0:t.ai)||(null==l||null==(n=l.storage)?void 0:n.aiAdvanced),b=(null==x||null==(r=x.generatedWith)?void 0:r.action)==="complete",v=(0,h.useCallback)(()=>{l&&(l.commands.aiReject(),o())},[o,l]),y=(0,h.useCallback)(async e=>{var t,n,r;
1let{isReplace:d,isMarkDown:u}=e;if(!l)return;let p=null!=(r=null==(t=l.storage)?void 0:t.ai)?r:null==(n=l.storage)?void 0:n.aiAdvanced,h=g===tK.vI.SYNONYMS?i:aK(a,f),x="";try{x=u?await aD(h):h}catch(e){console.error("AI Menu hook Error processing markdown text:".concat(g),e),x=h}null==m||m(),p.response=x,p.pastResponses=[x],g===tK.vI.SYNONYMS&&c();let{from:C,to:v}=l.state.selection;l.commands.aiAccept({append:b&&!d}),o();let{to:y}=l.state.selection,w=d||g!==tK.vI.KEEP_WRITING?C:v;l.chain().focus().setTextSelection({from:w,to:y}).setAiInsertMark({"data-insertion-type":"ai-generated","data-req-id":null!=s?s:"","data-feature-name":g,"data-source":"INLINE"}).setTextSelection(y).run()},[l,f,a,b,o,m,g,i,c,s]),w=(0,h.useCallback)(async()=>{try{if(!l)return;let e=aK(a,f);o();let t=await aD(e),n=j(t,null!=g?g:"",null!=s?s:"","INLINE"),r=new DOMParser().parseFromString(n,"text/html").body.innerText;(0,np.x)(n,r),d({message:"Copied to clipboard"})}catch(e){u({message:"Failed to copy"})}},[l,a,g,s,o,d,u,f]);return{handleOnReject:v,handleOnAccept:y,handleOnCopy:w,handleFollowUpAction:(0,h.useCallback)(e=>{p({command:e,text:a,isRegenerate:!0})},[p,a])}}({activeResult:V,editor:s,selectedSynonyms:O,closeAiMenu:G,activeRequestId:U}),ei=(0,h.useCallback)(()=>{el({isMarkDown:!M})},[M,el]),es=(0,h.useCallback)(()=>{el({isMarkDown:!M,isReplace:!0})},[M,el]);return s&&x.isOpen&&N?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rj,{open:x.isOpen,placement:"bottom-start",store:I,children:(0,r.jsxs)(rI,{onClickOutside:X,className:"tiptap-ai-menu flex flex-col",autoFocusOnShow:J,flip:!1,style:{width:(null==s||null==(o=s.view)?void 0:o.dom)?s.view.dom.getBoundingClientRect().width-48:740,top:null!=(a=E.current)?a:"auto"},children:[(0,r.jsxs)(nh,{children:[et.showErrorView&&(0,r.jsx)(o7,{editor:s,error:T}),S&&R===tK.vI.SYNONYMS&&(0,r.jsx)(o5,{editor:s,closeAiMenu:G}),!et.showErrorView&&(0,r.jsxs)(r.Fragment,{children:[R?(0,r.jsx)(r.Fragment,{children:R===tK.vI.SYNONYMS?(0,r.jsx)(r.Fragment,{children:S?null:et.showPaywallCard?(0,r.jsx)("div",{className:"max-h-80 mx-2 overflow-auto rounded-md",children:(0,r.jsx)(ob,{editor:s,showRewriteModePaywall:K,showPaymentError:et.isPaymentRequired,aiGenerationError:T})}):(0,r.jsx)(o0,{results:L,selectedSynonyms:O,setSelectedSynonyms:z})}):(0,r.jsx)(oQ,{editor:s,activeResult:V,activeFeature:R,showPaymentError:et.isPaymentRequired,showRewriteModePaywall:K,aiGenerationError:T,isTabView:!!M,selectedText:H,finished:et.showActions})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(oW,{...en}),(0,r.jsx)(n6,{flip:!1,unmountOnHide:!0,autoFocus:!1,onFocus:()=>b({inputIsFocused:!0}),autoFocusOnShow:J,autoFocusOnHide:J,getAnchorRect:()=>{var e;return(null==(e=document.querySelector(".tiptap-ai-menu"))?void 0:e.getBoundingClientRect())||null},children:(0,r.jsx)(n9,{style:{display:"block",minWidth:"300px"},children:(0,r.jsx)(or,{})})})]}),et.showActions&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(aS,{editor:s,feature:R,options:ee,onAccept:ei,onReplace:es,onReject:eo,onCopy:ea}),W?(0,r.jsx)(oW,{...en}):(0,r.jsx)(oI,{})]})]})]}),(et.isPaymentRequired||K)&&(0,r.jsx)(oT,{}),W&&et.showActions&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"ai-follow-up",children:[(0,r.jsx)(ou,{handleFollowUpAction:er}),(0,r.jsx)(oI,{})]})})]})}),u&&(0,r.jsx)(ay,{openDialogBox:u,handleOnAccept:ei,handleOnReject:eo,setOpenDialogBox:p,aiGenerationHasMessage:A})]}):null}function o5(e){let{editor:t,closeAiMenu:n}=e,l=(0,h.useCallback)(()=>{t&&(t.commands.aiReject(),n())},[t,n]);return(0,r.jsxs)("div",{className:"tiptap-ai-menu-progress",children:[(0,r.jsxs)("div",{className:"tiptap-spinner-alt",children:[(0,r.jsx)("span",{children:"Paperpal is writing..."}),(0,r.jsxs)("div",{className:"dots-container",children:[(0,r.jsx)("div",{className:"dot"}),(0,r.jsx)("div",{className:"dot"}),(0,r.jsx)("div",{className:"dot"})]})]}),(0,r.jsx)(d.e2,{children:(0,r.jsx)(d.$n,{"data-style":"ghost",title:"Stop",onClick:l,children:(0,r.jsx)(aw,{className:"tiptap-button-icon"})})})]})}function o7(e){let{editor:t,error:n}=e,{reset:l}=a$(),a=(0,h.useCallback)(()=>{t&&(t.chain().aiReject({type:"reset"}).run(),l(),t.commands.resetUiState())},[t,l]);return(0,r.jsxs)("div",{className:"tiptap-ai-menu-error",children:[(0,r.jsx)("div",{className:"tiptap-spinner-alt",children:(0,r.jsx)("span",{className:"text-red-9",children:n})}),(0,r.jsx)(d.e2,{children:(0,r.jsx)(d.$n,{"data-style":"ghost",title:"Close",onClick:a,children:(0,r.jsx)(ew.MR,{className:"tiptap-button-icon"})})})]})}function o3(e){let{editor:t}=e;return(0,r.jsx)(o2,{children:(0,r.jsx)(oi,{children:(0,r.jsx)(o4,{editor:t})})})}function o9(e,t,n){if(!(null==t?void 0:t.text)||!n)return e;let r=t.text,l=r.lastIndexOf(n);return -1===l?e:e-r.substring(l).length}var o6=n(78538);let o8=e=>{var t,n,l,a;let{editor:o,floatingOptions:i,selector:s="tiptap-suggestion-menu",children:c,maxHeight:d=384,pluginKey:u=o6.X3,openFromCTA:p=!1,setOpenFromCTA:m,...g}=e,{editor:f}=nl(o),{isCiteMenuOpen:x}=aN(f),[b,C]=(0,h.useState)(!1),[v,y]=(0,h.useState)(),[w,j]=(0,h.useState)(null),I=(0,h.useRef)(g);(0,h.useEffect)(()=>{I.current=g},[g]);let k=(0,h.useCallback)(()=>{C(!1),y(void 0)},[]),E=(0,h.useCallback)(()=>{setTimeout(()=>{let e=document.querySelector(".tiptap-suggestion-menu");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},50)},[]),N=(0,h.useCallback)(()=>
1{if(!f)return;let{state:e,view:t}=f,{from:n}=e.selection,r=t.domAtPos(n).node;r.nodeType===Node.TEXT_NODE&&(r=r.parentElement||r),j(r),setTimeout(()=>{C(!0),E(),null==m||m(!1),null==f||f.commands.hideCiteMenu()},0)},[f,m]);return((0,h.useEffect)(()=>{(p||x)&&(y(p?"suggestion":"search"),N())},[p,x,N]),(0,h.useEffect)(()=>{if(!b||!f)return;let e=e=>{let t=e.target;(null==t||!t.closest(".tiptap-card"))&&(null!=t&&t.closest("[data-tiptap-cite-portal]")||k())},t=f.view.dom;return t.addEventListener("keydown",e),document.addEventListener("mousedown",e),()=>{t.removeEventListener("keydown",e),document.removeEventListener("mousedown",e)}},[b,f]),(0,h.useEffect)(()=>{if(!f||f.isDestroyed)return;f.state.plugins.find(e=>e.spec.key===u)&&f.unregisterPlugin(u);let e=(0,o6.V0)({pluginKey:u instanceof $.hs?u:new $.hs(u),editor:f,allow(e){let t=f.state.doc.resolve(e.range.from);for(let e=t.depth;e>0;e--)if("image"===t.node(e).type.name)return!1;return!0},command(e){var t,n;let{editor:r,range:l,props:a}=e;if(!l)return;let{view:o,state:i}=r,{selection:s}=i;if(!r.extensionManager.extensions.some(e=>{var t,n;return"mention"===e.name&&(null==(n=e.options)||null==(t=n.suggestion)?void 0:t.char)===I.current.char})){let e=s.$from.pos,t=null==(n=s.$head)?void 0:n.nodeBefore,r=t?o9(e,t,I.current.char):s.$from.start(),l=i.tr.deleteRange(r,e);o.dispatch(l)}let c=o.state.selection.$to.nodeAfter,d=null==c||null==(t=c.text)?void 0:t.startsWith(" "),u={...l};d&&(u.to+=1),a.onSelect({editor:r,range:u,context:a.context})},render:()=>({onStart:e=>{let{from:t,to:n}=e.range;if("@"===e.editor.state.doc.textBetween(t,n,"")){y(void 0),C(!0),E();return}},onUpdate:e=>{var t;j(null!=(t=e.decorationNode)?t:null)},onKeyDown:e=>"Escape"===e.event.key&&(k(),!0),onExit:()=>{j(null)}}),...I.current});return f.registerPlugin(e),()=>{f.isDestroyed||f.unregisterPlugin(u)}},[f,u,k]),f)?(0,r.jsx)(nu,{"data-selector":s,className:"tiptap-suggestion-menu overflow-hidden",shouldShow:b,referenceElement:w,floatingOptions:{placement:"bottom",middleware:[(0,t8.cY)(8),(0,t8.BN)({padding:12,boundary:null!=(n=null!=(t=f.view.dom.closest("[data-editor-container]"))?t:f.view.dom.parentElement)?n:"clippingAncestors"}),(0,t8.Ej)({boundary:null!=(a=null!=(l=f.view.dom.closest("[data-editor-container]"))?l:f.view.dom.parentElement)?a:"clippingAncestors",apply(e){let{availableHeight:t,availableWidth:n,elements:r}=e;r.floating&&(r.floating.style.setProperty("--suggestion-menu-max-height","".concat(Math.min(d,t),"px")),r.floating.style.setProperty("--suggestion-menu-max-width","".concat(n,"px")))}})],onOpenChange(e){e||C(!1)},...i},children:c({editor:f,openFromCTA:v})}):null};var ie=n(17288),it=function(e){return e.PUBLISHING_DATE="PUBLISHING_DATE",e.CITATION_COUNT="CITATION_COUNT",e.RELEVANCE="RELEVANCE",e}({}),ir=function(e){return e.PUBLISHING_DATE="Publishing Date",e.CITATION_COUNT="Citation Count",e.RELEVANCE="Relevance",e}({}),il=function(e){return e.SUGGESTIONS="Suggestions",e.LIBRARY="Library",e.SEARCH_PAPERS="Search Papers",e}({});n(6985);let ia=h.forwardRef((e,t)=>{let{className:n,type:l,...a}=e;return(0,r.jsx)("input",{ref:t,type:l,className:(0,eg.cn)("tiptap-input",n),...a}
1)});function io(e){let{className:t,children:n,...l}=e;return(0,r.jsx)("div",{className:(0,eg.cn)("tiptap-input-group",t),...l,children:n})}ia.displayName="Input";var ii=n(59008);let is=e=>{let{setSearchTerm:t,searchTerm:n,activeTab:l}=e,a=(0,N.mN)({}),{setCitationEditorOverlay:o}=(0,t5.h)(),{register:i,handleSubmit:s,reset:c,control:u}=a,p=(0,N.FH)({control:u,name:"searchSuggestion"});(0,h.useEffect)(()=>{c({searchSuggestion:n})},[n,c]);let m=async()=>{s(async e=>{t(e.searchSuggestion)})()};(0,h.useEffect)(()=>{(null==p?void 0:p.length)===0&&t(p)},[p,t]);let g="absolute  min-h-[26px] !h-[26px]  !min-w-[26px] bottom-1 right-[4px] border-none font-medium mx-1 text-gray-6 bg-gray-2 font-sans px-0.5 py-0.5 rounded hover:!bg-gray-3 hover:!text-gray-7 ".concat((null==p?void 0:p.length)>0?"!bg-blue-9 !text-gray-1 hover:!bg-blue-10":""),f=l===il.LIBRARY?"Search your library":"Enter keywords, title, or a DOI";return(0,r.jsx)("div",{className:"flex",children:(0,r.jsxs)("form",{className:"relative mx-2 flex-1",onSubmit:e=>{e.preventDefault(),m()},children:[(0,r.jsx)(ia,{placeholder:f,id:"searchSuggestion","data-test-id":"searchSuggestion",className:"w-full !h-[35px] py-4 pl-8 pr-12 text-sm focus:ring-0 border border-solid border-gray-7 rounded-lg focus:outline-none focus:ring-1 focus:ring-blue-9",...i("searchSuggestion",{required:{value:!0,message:"This is a required field."}}),style:{paddingLeft:"25px"},autoComplete:"off"}),l===il.LIBRARY?(0,r.jsx)(d.$n,{type:"button",id:"add-citation",className:"absolute bottom-1 !min-h-[24px] !h-[24px] !min-w-[24px] right-[4px] !border-none !font-medium !mx-1 !text-gray-6 !bg-gray-2 !font-sans !px-0.5 !py-0.5 !rounded hover:!bg-gray-3 hover:!text-gray-7",onClick:()=>o({mode:"csl-add"}),"data-testid":"add-citation",children:(0,r.jsx)(ii.X,{width:18,height:18})}):(0,r.jsx)(d.$n,{id:"submit",className:g,onClick:m,"data-testid":"submit",children:(0,r.jsx)(om.I,{name:"arrowDownLeft",variant:"regular"})}),(0,r.jsx)("div",{className:"!absolute !flex !items-center !justify-center !top-[1px] !left-0 !text-gray-11 !h-8 !w-8",children:(0,r.jsx)(om.I,{name:"magnifyingGlass",variant:"regular",height:12,width:12})})]})})};var ic=n(50108),id=function(e){return e.GENAI="gen-ai",e.CHATPDF="chat-pdf",e.WRITE="text/generation/keep-writing",e.AI_DISCLOSURE="ai-disclosure",e.PRESENTATION="presentation",e.LIBRARY="library",e}({});async function iu(e,t,n,r){let l=r?"/api/v2/".concat(t,"/feedback"):"/api/v1/".concat(t,"/feedback"),a=t===id.WRITE?"".concat(l,"?feature=TPWTW"):l;await e.post(a,n)}function ip(){let{v2:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{v2:!1},{webApiClient:t}=(0,P.p)(),{mutate:n,error:r}=(0,A.useMutation)({mutationFn:n=>{let{apiparam:r,updatedInput:l}=n;return iu(t,r,l,null!=e&&e)},onError:e=>{console.error("Error in useFeedback:",e)}}),l=(0,h.useCallback)((e,t,r,l)=>{n({apiparam:e,updatedInput:{...t,rating:r,feedback:l}})},[n]),a=(0,h.useCallback)((e,t)=>l(e,t,10),[l]);return{likeOutput:a,dislikeOutput:(0,h.useCallback)((e,t)=>l(e,t,0),[l]),commentOnOutput:(0,h.useCallback)(e=>{let{apiparam:t,feedback:n,isLike:r=!0,params:a}=e;return l(t,a,10*!!r,n)},[l]),validationError:r?(0,op.F)(r):void 0}}let ih=e=>{let{requestId:t,submissionId:n}=e,{onComment:l,onDislike:a,onLike:o,showFeedback:i}=function(e,t){let[n,r]=(0,h.useState)(!0),{likeOutput:l,dislikeOutput:a,commentOnOutput:o}=ip(),i=(0,h.useCallback)(async()=>{l(id.GENAI,{feature:tK.A9.Enum.CITE_ON_HIGHLIGHT,rating:0,requestId:e,submissionId:t})},[l,e,t]);return{onLike:i,onDislike:(0,h.useCallback)(async()=>{a(id.GENAI,{feature:tK.A9.Enum.CITE_ON_HIGHLIGHT,rating:10,requestId:e,submissionId:t})},[a,e,t]),onComment:(0,h.useCallback)(async n=>{let{comment:l,like:a}=n;o({apiparam:id.GENAI,feedback:l,isLike:a,params:{feature:tK.A9.Enum.CITE_ON_HIGHLIGHT,requestId:e,rating:10*!!a,submissionId:t}}),r(!1)},[o,e,t]),showFeedback:n}}(t,n);return i?(0,r.jsxs)("div",{className:"flex justify-center bg-gray-2 items-center gap-4 roun
1ded-b-[5px]",children:[(0,r.jsx)("p",{className:"text-gray-11 font-medium text-sm/[16px]",children:"Tell us about your experience"}),(0,r.jsx)(ic.G,{onLike:o,onDislike:a,onComment:l,buttonContainerStyle:{backgroundColor:"transparent !important"}})]}):null},im=e=>{let{refetchCountry:t,isFetching:n}=e,{t:l}=(0,a7.B)("tip-tap-web-editor-v3");return(0,r.jsxs)("div",{className:"flex flex-col justify-center items-center w-full h-full py-8 px-4 gap-4 text-center",children:[(0,r.jsx)("p",{className:"font-semibold text-sm text-blue-12",children:l("empty_china_view_message","This feature is currently unavailable in your region due to local regulations.")}),t&&(0,r.jsx)(d.$n,{onClick:t,disabled:n,className:"!px-10 !text-sm",children:n?"".concat(l("empty_china_view_retry_cta","Retry"),"..."):l("empty_china_view_retry_cta","Retry")})]})},ig={noSuggestions:"No suggestions found",noPaperFound:"No Papers Found. Try again.",findInPaper:"Search specific papers to cite."},ix=[il.SUGGESTIONS,il.LIBRARY,il.SEARCH_PAPERS],ib=R.z.object({papers:R.z.array(M.qP.transform(e=>({...e,source:"SEARCH"}))),cslJsonMap:L.$s.optional(),styleId:R.z.number().optional(),totalPapers:R.z.number().optional()}),iC=function(e,t,n,r){var l,a,o,i,s,c,d;let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10,{webApiClient:p}=(0,P.p)(),m=async e=>{let{page:t,pageSize:n,sessionId:r,searchTerm:l,sortBy:a,citationInfo:o,webApiClient:i}=e,s="/api/v3/citation/find-paper?"+"searchTerm=".concat(encodeURIComponent(l),"&sessionId=").concat(r)+"".concat(a?"&sortBy=".concat(a):"")+"".concat(o?"&citationInfo=".concat(o):"")+"&offset=".concat(t,"&size=").concat(n),c=await i.get(s);return ib.parse(c)},g=async l=>{let{pageParam:a=0}=l;return m({page:a,pageSize:u,sessionId:e,searchTerm:t,sortBy:n,citationInfo:r,webApiClient:p})},f=(0,A.useInfiniteQuery)({queryKey:["doi-title-search",t,e,n,r,u],queryFn:g,enabled:((null==t?void 0:t.length)||0)>0,refetchOnWindowFocus:!1,refetchOnMount:!1,retry:!1,getNextPageParam:(e,t)=>{let n=e.totalPapers&&e.totalPapers>200?200:e.totalPapers,r=t.length*u;return r<(null!=n?n:0)?r:void 0}});(0,h.useEffect)(()=>{if(f.error){let e=r?"Select and cite error: ":"";console.error("".concat(e,"Error while fetching searched papers"),JSON.stringify(f.error))}},[f.error]);let x=null!=(s=null==(l=f.data)?void 0:l.pages.reduce((e,t)=>{var n;return{...e,...null!=(n=t.cslJsonMap)?n:{}}},{}))?s:{};return{...f,papers:null!=(c=null==(a=f.data)?void 0:a.pages.flatMap(e=>e.papers))?c:[],cslJsonMap:x,styleId:null!=(d=null==(i=f.data)||null==(o=i.pages[0])?void 0:o.styleId)?d:-1}},iv=e=>{let{message:t,url:n}=e;return(0,r.jsxs)("div",{className:"flex flex-col justify-center items-center w-full h-full pb-8",children:[(0,r.jsx)("img",{src:null!=n?n:"https://cdn.paperpal.com/assets/images/features/edit-empty-illustration.webp",alt:"Word count exceeded"}),(0,r.jsx)("p",{className:"font-semibold text-center text-sm text-blue-11 mt-4",children:t})]})};var iy=n(56789),iw=n(96562),ij=n(44876);function iI(e,t){var n,r,l,a;if(t)return null!=(a=(null!=(l=null==e||null==(r=e.locales)||null==(n=r["en-GB"])?void 0:n.itemTypes)?l:{})[t])?a:t}var ik=n(93730),iE=n(68048),iN=n(23013);let iS=()=>{let{webApiClient:e}=(0,P.p)(),t=t=>e.post("/api/v1/citation/tracking",t);return{postTrackCitation:(0,A.useMutation)({mutationKey:["track-citation"],mutationFn:e=>t(e)}).mutateAsync}},iT=R.z.object({conversationId:R.z.string(),fileStatus:R.z.array(R.z.object({id:R.z.string(),status:R.z.boolean(),failedReason:R.z.string().optional()})).optional()}),iA=()=>{let{webApiClient:e}=(0,P.p)(),t=async t=>{let{type:n}=t,r=await e.post("/api/v3/chat-pdf/start-conversation",{type:n});return iT.parse(r)};return(0,A.useMutation)({mutationFn:t})},iR=new Map,iM=async(e,t,n)=>{try{let r=new URL(e,window.location.origin).toString(),l=iR.get(r);if(l&&!l.closed)l.focus();else{iR.delete(r);let e=window.open(r,t,n);if(e)iR.set(r,e),e.addEventListener("beforeunload",()=>{iR.delete(r)}),e.focus();else throw Error("Failed to open new window - likely blocked by popup blocker")}}catch(t){var r;console.error("Error handling tab:",t),null==(r=window.open(e,"_blank"))||r.focus()}},iL=e=>{let{initiateConversation:t,showToast:n,baseUrl:r}=e,l=(0,h.useRef)(""),[a,o]=(0,h.useState)(!1),i=(0,h.useCallback)((e,t)=>
1{r&&e&&(o(!1),iM("".concat(r,"/pdf/view?url=").concat(encodeURIComponent(e),"&").concat(t)))},[r]),s=(0,h.useCallback)(e=>{o(!1),l.current="",n({title:"Error while processing file",description:(0,op.F)(e).errorReason||"Something went wrong during processing chat. Please try again.",color:"danger"}),console.error("Functional error: Error occurred while processing chat with PDF file in research tab")},[n]);return{progress:1,startChatWithPdf:(0,h.useCallback)(async(e,n)=>{if(!e)return void s(Error("No citation IDs provided"));l.current=n;try{o(!0);let n=await t({type:"library"}),r="citationId=".concat(e.toString());i(n.conversationId,r)}catch(e){o(!1),s(e)}},[s,t,i]),startChatWithLibraryCitationAttachments:(0,h.useCallback)(async(e,n)=>{if(!e||0===e.length)return void s(Error("No attachmentsprovided"));l.current=n;try{o(!0);let n=await t({type:"library"}),r=new URLSearchParams;e.forEach(e=>r.append("uploadId",e));let l=r.toString();i(n.conversationId,l)}catch(e){o(!1),s(e)}},[s,t,i]),clickedSourceDocId:l.current,isProcessingChatWithPdf:a}},iD=(R.z.object({citationId:R.z.number(),pdfUrl:R.z.string()}),R.z.record(R.z.string(),R.z.number())),i_=()=>{let{webApiClient:e}=(0,P.p)();return async function(t){let n=t.folder?"?folder=".concat(t.folder):"";return await e.post("/api/v1/citation/user/add".concat(n),t.paper).then(e=>iD.parse(e))}},iH=()=>{let e=i_(),t=(0,A.useMutation)({mutationFn:e,retry:!1});return{insertCitationsToLibrary:(0,h.useCallback)(async(e,n)=>await t.mutateAsync({paper:e,folder:n}),[t])}},iP=()=>{let{webApiClient:e}=(0,P.p)();return{removeFromCitationLibrary:(0,A.useMutation)({mutationFn:t=>e.delete("/api/v1/citation/user/".concat(t)),retry:!1})}};var iO=n(44440),iz=n(23727);let iB=function(){let{selectedCollection:e,libraryId:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{showToast:n}=(0,z._)(),{insertCitationsToLibrary:l}=iH(),{removeFromCitationLibrary:a}=iP(),{mutateAsync:o}=function(){let{webApiClient:e}=(0,P.p)(),t=(0,A.useQueryClient)();return(0,A.useMutation)({mutationFn:async t=>{let{libraryId:n,itemIds:r}=t,l=r.map(e=>"itemIds=".concat(e)).join("&");return await e.delete("/api/v1/libraries/".concat(n,"/items/bulk?").concat(l))},onSuccess:()=>{t.invalidateQueries({queryKey:[iO.l]})}})}(),{removeCollectionItem:i}=function(e){let t=function(){let{webApiClient:e}=(0,P.p)();return{GET:function(t,n,r){var l;return(0,A.useQuery)({queryKey:null!=(l=null==r?void 0:r.queryKey)?l:[t],queryFn:async()=>{let r=await e.get(t);return n.parse(r)},retry:!1,refetchOnWindowFocus:!1,...r})},POST:async(t,n,r)=>{let l=await e.post(t,n);return r.parse(l)},PUT:async(t,n,r)=>{let l=await e.put(t,n);return r.parse(l)},PATCH:async(t,n,r)=>{let l=await e.patch(t,n);return r?r.parse(l):l},DELETE:async(t,n)=>{let r=await e.delete(t);return n?n.parse(r):r},GET_DUMMY:function(e,t,n){var r;return(0,A.useQuery)({queryKey:null!=(r=null==n?void 0:n.queryKey)?r:[e],queryFn:async()=>{let n=await fetch(e),r=await n.json();return t.parse(r)},retry:!1,refetchOnWindowFocus:!1,...n})}}}(),n=(0,A.useQueryClient)(),r=(0,A.useMutation)({mutationFn:async n=>t.PATCH("".concat("/api/v1/libraries/").concat(e,"/items/bulk/remove"),{itemIds:n.itemIds,destinationCollectionId:null,action:"remove",sourceCollectionId:n.currentParentId}),onSuccess:()=>{n.invalidateQueries({queryKey:[iO.l]})}}),l=(0,h.useCallback)(async e=>r.mutateAsync(e),[r]);return(0,h.useMemo)(()=>({removeCollectionItem:l,isRemovingCollectionItem:r.isLoading}),[l,r.isLoading])}(t);return{addToLibrary:(0,h.useCallback)(async(e,t)=>{let a=!!t;try{let o={...e,source:"INLINE"},i=await l([o],t);return a?n({color:"success",title:(0,r.jsxs)(r.Fragment,{children:["Added to collection."," ",(0,r.jsx)("a",{href:"/library",target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"underline",cursor:"pointer"},children:"Open Collection"})]})}):n({color:"success",title:"Added to library"}),i}catch(t){let{errorReason:e}=(0,op.F)(t);n({color:"danger",title:e||"Something went wrong!"}),console.error("Select and cite error: Error occurred while adding to library",JSON.stringify(t));return}},[l,n]),removeFromLibrary:(0,h.useCallback)(async(l,s)=>{try{let c=(null==e?void 0:e.locked)===!0,d=iz.env.NEXT_PUBLIC_EDIT_FOR_WEB_ORIGIN,u=d?"".concat(d,"/library"):"/library";if(void 0===s||void 0===t){await a.mutateAsync(l),n({color:"danger",title:"Removed from library"});return}if(c)await o({libraryId:t,itemIds:[s]}),n({color:"success",title:(0,r.jsxs)("span",{children:["Reference moved to"," ",(0,r.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline",cursor:"pointer"},children:"Trash"}),"."]})});else{if(!e)return;await i({itemIds:[s],currentParentId:e.id}),n({color:"success",title:(0,r.jsxs)("span",{children:["Removed from ",e.name,". Available in"," ",(0,r.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline",cursor:"pointer"},children:"Library"})," ","and other collections."]})})}}catch(t){let{errorReason:e}=(0,op.F)(t);n({color:"danger",title:e||"Something went wrong!"})}},[e,t,o,i,a,n])}};var iF=n(23727);function iV(e){var t,n;return null!=(n=null==e||null==(t=e.attachments)?void 0:t.some(e=>(null==e?void 0:e.fileType)==="pdf"))&&n}function iU(e){let{editor:t,onUpdatePaper:n,cslJsonMap:r,cardType:l,styleId:o,selectedCollection:i,library
1Id:s,sourceDocIdToItemIdMap:c}=e,{postTrackCitation:d}=iS(),{trackCommonEvent:u}=(0,tu._)(),{addToLibrary:p,removeFromLibrary:m}=iB({selectedCollection:i,libraryId:s}),{productName:f}=(0,og.Gz)(),{showToast:x}=(0,z._)(),{documentId:b}=g(),{generateCitationRender:C,citationSchema:v}=(0,t5.h)(),{triggerConfetti:y}=az(),{mutateAsync:w}=iA(),{startChatWithPdf:I,startChatWithLibraryCitationAttachments:k,progress:E,isProcessingChatWithPdf:N,clickedSourceDocId:S}=iL({initiateConversation:w,showToast:x,baseUrl:iF.env.NEXT_PUBLIC_EDIT_FOR_WEB_ORIGIN}),[T,A]=(0,h.useState)(null),R=(0,h.useCallback)(async(e,t)=>{let r=e.isBookmarked;try{if(r){A(e.sourceDocId),n({...e,isBookmarked:!1});let t=null==c?void 0:c[e.sourceDocId];await m(e.sourceDocId,t)}else n({...e,isBookmarked:!0}),await p(e,t)}catch(t){n({...e,isBookmarked:r})}finally{A(null)}},[p,n,m,c]),M=(0,h.useCallback)((e,t)=>{t&&b&&d({documentId:b,sourceDocId:t,status:e,styleId:o})},[b,d,o]),L=(0,h.useCallback)(async e=>{let{selection:o}=t.state,{from:i,to:s}=o,c=t.state.doc.textBetween(i-1,s,""),d=t.isActive(eu.Gw);"@"===c&&t.commands.deleteRange({from:i-1,to:s});let h=c&&"@"!==c?s:i-1;t.commands.setTextSelection(h);let m=null==r?void 0:r[e.sourceDocId],{id:g}=m||{};if(!g||!m){x({title:"Unable to insert citation",color:"danger"}),console.error("Select and cite error: Citation details are missing",JSON.stringify(m));return}let f=t.extensionStorage[a.A.PAPERPAL_CITATION].citationStyle||"apa";try{var b;let r={...m};r=t3(m,v.csl);let{inlineCitation:a}=await C({citations:[r],style:f});t.chain().blur().insertCitationCiteProc({id:m.id,label:(0,en.bK)(a),citations:[m]}),null==y||y(),M(H.INSERT_INLINE,g),m.source_origin||(null==(b=e.authors)?void 0:b.length)||x({title:"Author data may be incomplete—please verify this citation.",color:"danger"}),"library"===l?n({...e,isCited:!0}):(p(e),n({...e,isBookmarked:!0,isCited:!0})),d&&((0,eh.ku)(t),u({type:"click-to-track-paperpal",CTALabel:"Cite Failed Citation",sectionName:"Cite Dropdown Menu"}))}catch(e){x({title:"unable to insert citation, please try again later.",color:"danger"}),console.error("TipTap Error GC handleCite ".concat(f," "),JSON.stringify(m))}},[t,r,M,l,x,n,p,C,v,y]),D=(0,h.useCallback)(async(e,t)=>{if(t){var n;k((null==e||null==(n=e.attachments)?void 0:n.filter(e=>"pdf"===e.fileType).map(e=>e.uploadId))||[],e.sourceDocId)}else{let t=e.citationId;if("library"!==l){let n=await p(e,e.isUploadedByUser?"home":"chat");t=n?n[e.sourceDocId]:void 0}t&&I(t,e.sourceDocId)}},[p,l,I,k]);return{handleBookmark:R,handleCite:L,handleChatPdf:D,handleReadMoreClick:(0,h.useCallback)(async e=>{let t="https://discovery.researcher.life/article/".concat(e.slug,"/").concat(e.sourceDocId,"?expiry_in_minutes=5&usersource=paperpal&utm_source=paperpal&utm_medium=website&utm_campaign=organic");e&&window.open(t,"blank")},[]),handleCopyDOI:(0,h.useCallback)(e=>{let t="https://doi.org/".concat(e),n=j(t,"Research");try{(0,np.x)(n,t,f),x({color:"success",title:"DOI Copied to clipboard"})}catch(e){x({color:"danger",title:"Uh oh. Automatic copying failed. Please copy manually. Sorry about that."}),console.error("CB-CitationBuilder citation error in Copy doi",JSON.stringify(e))}},[f,x]),progress:E,isProcessingChatWithPdf:N,clickedSourceDocId:S,removingId:T}}let iW=e=>{let[t,n]=(0,h.useState)(!1),[r,l]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),i=(0,h.useCallback)(()=>{var t,r;if(!a.current)return;let{scrollTop:i,scrollHeight:s,clientHeight:c}=a.current;n(Math.abs(s-c-i)<(null!=(r=null==(t=o.current)?void 0:t.clientHeight)?r:150)),i>0&&l(!1),0===i&&e&&e()},[a,e]),s=(0,h.useCallback)(()=>{if(!a.current)return;let{scrollHeight:e,clientHeight:t}=a.current;l(!1),a.current.scrollTo({top:e-t,behavior:"smooth"})},[a]);return{scrollContainerRef:a,showScrollIndicator:r,toggleScrollIndicator:()=>{if(!a.current)return;let{scrollHeight:e,clientHeight:t}=a.current;l(e>t)},handleScroll:i,scrollToBottom:s,setIsScrollAtBottom:n,isScrollAtBottom:t,searchBoxRef:o}};var iG=n(62764),iZ=n(29525);let iq=(0,h.memo)(e=>{let{paper:t,baseActions:n,overflowActions:l,togglePreviewPaper:a,handleReadMoreClick:o,handleCopyDOI:i,cslJsonObject:s}=e,c=(0,h.useMemo)(()=>({id:"read-more",label:"Read More",onClick:()=>{o(t),null==a||a(null)},value:"read-more",disabled:!1,loadingComponent:"Redirecting...",actionState:iG.q.IDLE}),[o,t,a]),{handleScroll:d,scrollContainerRef:u,scrollToBottom:p,showScrollIndicator:m,toggleScrollIndicator:g}=iW(),{citationSchema:f}=(0,t5.h)(),{docType:x}=t,b=(0,h.useMemo)(()=>iI(f,x),[f,x]);
1return(0,r.jsx)(r.Fragment,{children:t?(0,r.jsx)(iE.T,{cardType:"full",refererenceArticle:{...t,docType:b},togglePreviewPaper:a,baseActions:n,overflowActions:l,readMoreAction:c,toggleScrollIndicator:g,ref:u,handleScroll:d,scrollToBottom:p,showScrollIndicator:m,isMinimal:!0,handleCopyDOI:i,cslJsonResponse:s}):(0,r.jsx)(iZ.P,{color:"error",children:"Something went wrong"})})}),i$=()=>(0,r.jsxs)("div",{className:"flex flex-col gap-2 p-4 w-full max-w-[400px] bg-white",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"w-5 h-5 rounded-full bg-gray-200 flex-shrink-0 animate-pulse"}),(0,r.jsx)("div",{className:"h-4 bg-gray-300 rounded w-[60%] animate-pulse"})]}),(0,r.jsx)("div",{className:"h-4 bg-gray-300 rounded w-[80%] animate-pulse"}),(0,r.jsx)("div",{className:"h-4 bg-gray-300 rounded w-[50%] animate-pulse"})]}),iK=(0,h.memo)(e=>{let{papers:t,onUpdatePaper:n,cardType:l,editor:a,cslJsonMap:o,togglePreviewPaper:i,previewPaper:s,styleId:d,selectedCollection:u,libraryId:p,sourceDocIdToItemIdMap:m,onEndReached:g,isFetchingNextPage:f,scrollParent:x}=e,{handleBookmark:b,handleChatPdf:C,handleCite:v,handleReadMoreClick:y,handleCopyDOI:w,progress:j,isProcessingChatWithPdf:I,clickedSourceDocId:k,removingId:E}
1=iU({editor:a,onUpdatePaper:n,cslJsonMap:o,cardType:l,styleId:d,selectedCollection:u,libraryId:p,sourceDocIdToItemIdMap:m}),{setEditCitationCslObject:N,setCitationEditorOverlay:S,citationSchema:T}=(0,t5.h)(),{showToast:A}=(0,z._)(),{collections:R,isCollectionsLoading:M,createCollection:L,isCreatingCollection:D,onCollectionSelect:_}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{enabled:t=!0,onSuccess:n,onError:r}=e,{collections:l,isCollectionsLoading:a,createCollection:o,isCreatingCollection:i}=(0,iw.l)(t),{mutateAsync:s}=(0,iy.z)();return{collections:l,isCollectionsLoading:a,createCollection:o,isCreatingCollection:i,onCollectionSelect:(0,h.useCallback)(async(e,t)=>{try{await s((0,iy.w)(e,t)),null==n||n(e,t)}catch(n){null==r||r(n,e,t)}},[s,n,r])}}({onSuccess:e=>{A({color:"success",title:"Added to ".concat(e.name," collection.")})},onError:(e,t)=>{var n;let r=(0,ij.d)(e)&&(null==(n=e.json)?void 0:n.errorCode)==="BIGINT_ID_ALREADY_EXISTS";A({color:r?"warning":"danger",title:r?"Already exists in ".concat(t.name,"."):"Something went wrong!"})}}),H=(0,h.useCallback)((e,t)=>{let n=iV(e),o=[{id:e.isCited?"cited":"cite",label:e.isCited?"Cited":"Cite",value:"cite",onClick:async t=>{t.stopPropagation(),v(e)},icon:(0,r.jsx)(om.I,{name:"quoteRight",variant:"solid",size:"sm"}),width:75,disabled:e.isCited},{id:e.isBookmarked?"remove-from-library":"add-to-library",label:e.isBookmarked?E===e.sourceDocId?"Deleting...":"Delete":"Add to library",value:"library",disabled:E===e.sourceDocId,loadingComponent:E===e.sourceDocId?"Deleting...":void 0,onClick:async t=>{t.stopPropagation(),await b(e)},icon:e.isBookmarked?(0,r.jsx)(om.I,{name:"trash",variant:"solid",size:"sm"}):(0,r.jsx)(om.I,{name:"buildingColumns",variant:"regular"}),width:e.isBookmarked?140:180,...!e.isBookmarked?{renderCustomButton:t=>{let{isLoading:n}=t;return(0,r.jsx)(ik.d,{icon:(0,r.jsx)(om.I,{name:"buildingColumns",variant:"regular"}),label:"Add to library",onClick:t=>{t.stopPropagation(),b(e)},isLoading:n,collections:R.filter(e=>!e.locked),isCollectionsLoading:M,onCollectionSelect:t=>{_(t,e)},onCreateCollection:L,isCreatingCollection:D})}}:{}}];if("library"===l){let n={id:"edit-citation",label:"Edit Citation",disabled:void 0,loadingComponent:void 0,onClick:async n=>{n.stopPropagation();let{selection:r}=a.state,{from:l,to:o}=r;"@"===a.state.doc.textBetween(l,o,"")&&a.commands.deleteRange({from:l,to:o}),t&&(null==N||N(t),S({mode:"csl-edit",itemId:null==m?void 0:m[e.sourceDocId]}))},value:"edit-citation",icon:(0,r.jsx)(om.I,{name:"pencile",variant:"regular"}),width:80,trackingProperties:{CTALabel:"Edit Citation Inline",sectionName:"feed-library"}};o.splice(1,0,n)}if(e.pdfURL||n){let t=I&&k===e.sourceDocId,l={id:"chat",label:t?"".concat(j,"%"):"Chat",disabled:!!t||void 0,loadingComponent:e.pdfURL?"Processing...":void 0,onClick:async t=>{t.stopPropagation(),I||await C(e,n)},value:"chat",icon:t?(0,r.jsx)(c.y,{size:15}):(0,r.jsx)(om.I,{name:"messageSmile",variant:"regular"}),toolTipText:"Get Summaries and Extract Insights",width:80};o.splice(1,0,l)}return{baseActions:o,overflowActions:[]}},[l,v,b,N,S,C,k,I,j,a,R,M,L,D,_,E,m]),P=(0,h.useMemo)(()=>s&&o?null==o?void 0:o[s.sourceDocId]:void 0,[o,s]),O=(0,h.useCallback)((e,t)=>{var n,r;let a=iI(T,null!=(r=null==o||null==(n=o[e.sourceDocId])?void 0:n.itemType)?r:e.docType),s={refererenceArticle:{...e,docType:a},cslJsonResponse:null==o?void 0:o[e.sourceDocId],...H(e,null==o?void 0:o[e.sourceDocId]),cardType:l,onMinimalCardClick:()=>{null==i||i(e)},index:t};return(0,h.createElement)(iE._,{...s,key:e.sourceDocId,isMinimal:!0})},[l,T,o,H,i]);return(0,r.jsxs)(r.Fragment,{children:[!s&&(g&&x?(0,r.jsx)(iN.aY,{customScrollParent:x,totalCount:t.length,overscan:10,endReached:g,components:{Footer:()=>f?(0,r.jsxs)("center",{className:"my-2",children:[(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{})]}):null},itemContent:e=>O(t[e],e)}):null==t?void 0:t.map(O)),s&&(0,r.jsx)(iq,{paper:s,togglePreviewPaper:i,handleCopyDOI:w,handleReadMoreClick:y,cslJsonObject:P,...H(s,P)})]})}),iY=(0,h.memo)(e=>{let{searchTerm:t,activeTab:n}=e;return n!==il.SEARCH_PAPERS?null:t?(0,r.jsx)(iX,{...e}):(0,r.jsx)(iv,{message:ig.findInPaper,url:"https://cdn.paperpal.com/assets/images/research/searchPapers.svg"})}),iX=e=>{let{searchTerm:t,editor:n,sortBy:l,previewPaper:a,togglePreviewPaper:
1o}=e,{isFetching:i,onUpdatePaper:s,papers:c,cslJsonMap:d,error:u,styleId:p}=function(e,t){let{sessionId:n}=g(),[r,l]=(0,h.useState)([]),{isFetching:a,data:o,cslJsonMap:i,error:s,styleId:c}=iC(null!=n?n:"",null!=e?e:"",t,!0),d=(0,h.useCallback)(e=>{l(t=>t.map(t=>t.sourceDocId===e.sourceDocId?e:t))},[]);return(0,h.useEffect)(()=>{if(o){var e;l(null!=(e=o.pages.flatMap(e=>e.papers))?e:[])}},[o]),{isFetching:a,papers:r,onUpdatePaper:d,cslJsonMap:i,error:s,styleId:c}}(t,l);if(i)return(0,r.jsxs)("center",{className:"my-2",children:[(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{})]});if(!(null==c?void 0:c.length)||u){var m;let e=u?null==(m=(0,op.F)(u).errorDetails)?void 0:m.message:ig.noPaperFound;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iv,{message:null!=e?e:"Error occurred while fetching papers",url:"https://cdn.paperpal.com/assets/images/research/noPaperFound.svg"}),(0,r.jsx)(iJ,{})]})}return(0,r.jsx)(iK,{editor:n,papers:c,onUpdatePaper:s,cslJsonMap:d,togglePreviewPaper:o,previewPaper:a,styleId:p})},iJ=()=>{let{setCitationEditorOverlay:e}=(0,t5.h)();return(0,r.jsxs)("div",{className:"text-gray-12 font-medium text-sm bg-blue-4 px-3 py-2 -mx-1.5 -mb-1.5 flex-shrink-0 flex items-center gap-1 rounded-b-[11px]",children:["Can’t find what you’re looking for?"," ",(0,r.jsx)(d.$n,{className:"!text-blue-9 !hover:text-blue-10 !shadow-none !bg-transparent !p-0",id:"try-citing-manually",onClick:()=>{e({mode:"csl-add"})},children:"Try citing manually"})]})},iQ=function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{getDocumentCitationStyle:n}=function(){let{webApiClient:e}=(0,P.p)();return{getDocumentCitationStyle:t=>e.get("/api/v1/citation/document/".concat(t,"/style")).then(_.parse)}}(),{data:r,isInitialLoading:l}=(0,A.useQuery)({queryKey:["document-citation-style",e],queryFn:function(){return n(e)},cacheTime:0,refetchOnWindowFocus:!1,refetchOnMount:!1,enabled:!!e&&t});return{documentCitationStyle:r,isLoadingDocumentCitationStyle:l}};var i0=n(81761);let i1=e=>{let{collections:t,selectedLibraryCollection:n,onSelectCollection:r}=e;(0,h.useEffect)(()=>{if(t&&!n){let e=t.find(e=>e.name.trim().toLowerCase()===i0.Oh.REFERENCES);e&&r(e)}},[t,n,r])};var i2=n(83672),i4=n(70077),i5=n(81993),i7=n(52501),i3=n(18696),i9=n(29404),i6=n(70224);let i8=(0,I.I4)(i7.E,{display:"inline-flex",alignItems:"center",minWidth:"10px","& svg":{width:(0,i4.D)(12),height:(0,i4.D)(12),marginRight:(0,i4.D)(4),display:"block"},variants:{size:{small:{fontSize:(0,i4.D)(10),lineHeight:"1rem",paddingLeft:(0,i4.D)(4),paddingRight:(0,i4.D)(4),paddingTop:(0,i4.D)(2),paddingBottom:(0,i4.D)(2)}},color:{yellow:{backgroundColor:I.w4.colors.yellow4,color:I.w4.colors.yellow11},gray:{backgroundColor:I.w4.colors.gray4,color:I.w4.colors.gray11},orange:{backgroundColor:I.w4.colors.orange1,color:I.w4.colors.orange2},green:{backgroundColor:I.w4.colors.green3,color:I.w4.colors.green11},red:{backgroundColor:I.w4.colors.red4,color:I.w4.colors.red10},purple:{backgroundColor:I.w4.colors.purple5,color:I.w4.colors.purple10},blue:{backgroundColor:I.w4.colors.blue3,color:I.w4.colors.blue11}}}}),se=(0,I.I4)("div",{display:"flex",width:"100%",alignItems:"center",gap:(0,i4.D)(12),marginBottom:(0,i4.D)(8),flexWrap:"wrap",justifyContent:"flex-end"}),st=(0,I.I4)(i3.$,{display:"flex",gap:"6px",alignItems:"center",fontSize:"0.875rem",lineHeight:"1.5rem",color:I.w4.colors.blue9,fontWeight:"500",borderRadius:"6px",background:"none",boxShadow:"none",padding:"6px",whiteSpace:"nowrap",minWidth:0,"&:hover":{border:"1px solid ".concat(I.w4.colors.gray7),backgroundColor:I.w4.colors.blue3},"&:disabled":{opacity:.5,cursor:"not-allowed"}}),sn=(0,I.I4)(i3.$,{display:"inline-block",background:"".concat(I.w4.colors.blue2," !important"),boxShadow:"none",paddingInline:(0,i4.D)(8),borderRadius:(0,i4.D)(12),fontSize:(0,i4.D)(12),lineHeight:(0,i4.D)(24),fontWeight:500,color:I.w4.colors.blue10,paddingBlock:0}),sr=(0,I.I4)("div",{display:"flex",alignItems:"center",color:I.w4.colors.gray11,fontSize:"0.75rem",lineHeight:"1rem",gap:"4px",flexWrap:"wrap"}),sl=(0,I.I4)("div",{padding:"3px 4px",display:"flex"}),sa=(0,I.I4)(sr,{flexWrap:"nowrap",alignItems:"flex-start"}),so=(0,I.I4)("span",{flex:1,minWidth:0}),si=(0,I.I4)("div",{maxWidth:(0,i4.D)(300)}),ss=(0,I.I4)("span",{height:"4px",width:"4px",backgroundColor:I.w4.colors.gray9,borderRadius:"50%",display:"block"}),sc=(0,I.I4)("div",{display:"flex",alignItems:"center",gap:(0,i4.D)(12),marginTop:(0,i4.D)(12),marginBottom:(0,i4.D)(8),flexWrap:"wrap"}),sd=e=>{let{icon:t,label:n,onClick:l,disabled:a}=e;return(0,r.jsxs)(st,{disabled:a,onClick:e=>{e.stopPropagation(),l(e)},children:[t,(0,r.jsx)("span",{children:n})]})},su=e=>{var t;let{paper:n}=e,{sourceField:l,sourceTooltip:a}=(0,h.useMemo)(()=>(0,nv.l)(n.sourceOrigin||n.source),[n.sourceOrigin,n.source]);return n.docType||n.isOpenAccess||n.citationsCountDyson||n.isRetracted||l?(0,r.jsxs)(se,{children:[l&&(0,r.jsx)(i9.h,{tipInfo:a,children:(0,r.jsx)(i8,{color:"Document Import"===l?"yellow":"Imported"===l?"blue":"green",children:l})}),n.isRetracted&&(0,r.jsx)(i9.h,{tipInfo:"This paper is considered unreliable for citation",children:(0,r.jsxs)(i8,{color:"red",children:[(0,r.jsx)(om.I,{name:"exclamationCircle",variant:"solid",size:"xs"}),"RETRACTED"]})}),n.docType&&(0,r.jsx)(i8,{color:"gray",children:n.docType}),n.isOpenAccess&&(0,r.jsxs)(i8,{color:"orange",children:[(0,r.jsx)(i6.P,{}),"Open Access"]}),!!n.citationsCountDyson&&(0,r.jsx)(i9.h,{tipInfo:"Citations",children:(0,r.jsxs)(i8,{color:"yellow",children:[(0,r.jsx)(om.I,{name:"quoteRight",variant:"solid",size:"xs"}),n.citationsCountDyson]})}),(null==(t=n.sjr_best_quartile)?void 0:t.value)&&(0,r.jsx)(i9.h,{tipInfo:"SCImago Journal Rank: ".concat((0,i5.Q)(n.sjr_best_quartile.value)),children:(0,r.jsx)(i8,{color:"purple",children:n.sjr_best_quartile.value})})]}):null},sp=e=>{var t,n,l,a,o,i,s;let{paper:c,showAll:d=!1}=e,u=null!=(a=null==(t=c.authors)?void 0:t.map(e=>
1e.full_name).filter(Boolean).join(", "))?a:"",p=d?null!=(o=c.authors)?o:[]:null!=(i=null==(n=c.authors)?void 0:n.slice(0,2))?i:[],h=p.map(e=>e.full_name).filter(Boolean).join(", "),m=Math.max(0,(null!=(s=null==(l=c.authors)?void 0:l.length)?s:0)-p.length);return h?(0,r.jsxs)(sa,{children:[(0,r.jsx)(sl,{children:(0,r.jsx)(om.I,{name:"user",variant:"regular"})}),(0,r.jsxs)(so,{children:[h,m>0&&(0,r.jsx)(i9.h,{tipInfo:(0,r.jsx)(si,{children:u}),children:(0,r.jsxs)("strong",{children:["\xa0+",m]})})]})]}):null},sh=e=>{var t;let{paper:n}=e;return n.publicationDate||n.journalName||n.publicationTitle?(0,r.jsxs)(sr,{children:[n.publicationDate&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sl,{children:(0,r.jsx)(om.I,{name:"Calendar",variant:"regular"})}),(0,nC.eN)(n.publicationDate)]}),(n.journalName||n.publicationTitle)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ss,{}),null!=(t=n.journalName)?t:n.publicationTitle]})]}):null},sm=e=>{let{paper:t,hasPdfAttachment:n,isChatProcessing:l,isDeleting:a,onCite:o,onChat:i,onEditCitation:s,onDeleteRequest:c}=e;return(0,r.jsxs)(sc,{children:[(0,r.jsx)(sd,{icon:(0,r.jsx)(om.I,{name:"quoteRight",variant:"solid",size:"sm"}),label:t.isCited?"Cited":"Cite",onClick:o,disabled:t.isCited}),n&&(0,r.jsx)(sd,{icon:(0,r.jsx)(om.I,{name:"messageSmile",variant:"regular",size:"sm"}),label:"Chat",onClick:i,disabled:l}),(0,r.jsx)(sd,{icon:(0,r.jsx)(om.I,{name:"pencile",variant:"regular",size:"sm"}),label:"Edit Citation",onClick:s}),(0,r.jsx)(sd,{icon:(0,r.jsx)(om.I,{name:"trash",variant:"solid",size:"sm"}),label:a?"Deleting...":"Delete",onClick:c,disabled:a})]})},sg=(0,I.I4)("div",{color:I.w4.colors.gray12,fontSize:"0.875rem",lineHeight:"1.5rem",fontWeight:600,marginBottom:"4px"}),sf=(0,I.I4)("div",{fontSize:(0,i4.D)(14),lineHeight:(0,i4.D)(24),color:I.w4.colors.gray11,fontWeight:"500",marginTop:(0,i4.D)(16)}),sx=(0,I.I4)("div",{fontSize:(0,i4.D)(14),lineHeight:(0,i4.D)(24),color:I.w4.colors.gray11,marginTop:(0,i4.D)(4),maxHeight:"220px",overflowY:"auto"}),sb=(0,I.I4)("span",{color:I.w4.colors.blue9,cursor:"pointer",textDecoration:"underline",fontSize:(0,i4.D)(12),lineHeight:(0,i4.D)(16),display:"inline-block",marginTop:(0,i4.D)(8)}),sC=(0,I.I4)(sn,{marginTop:(0,i4.D)(12),display:"inline-block"}),sv=(0,I.I4)("div",{padding:"10px 0 4px",display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"}),sy=(0,I.I4)("div",{marginTop:"auto",flexShrink:0,background:I.w4.colors.gray1,paddingTop:(0,i4.D)(4)}),sw=e=>{let{paper:t,handleCopyDOI:n,handleReadMoreClick:l,...a}=e,o=!!t.sourceDocId&&!t.sourceDocId.startsWith("edit_");return(0,r.jsxs)(sv,{children:[(0,r.jsx)(su,{paper:t}),(0,r.jsx)(sg,{children:t.title||"Untitled"}),(0,r.jsx)(sp,{paper:t,showAll:!0}),(0,r.jsx)(sh,{paper:t}),t.doi&&n&&(0,r.jsx)(sb,{onClick:()=>n(t.doi),children:"Copy DOI"}),t.abstractText&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sf,{children:"Abstract"}),(0,r.jsx)(sx,{children:t.abstractText})]}),o&&(0,r.jsx)(sC,{onClick:()=>l(t),children:"Read More"}),(0,r.jsx)(sy,{children:(0,r.jsx)(sm,{paper:t,...a})})]})},sj=(0,I.I4)("div",{color:I.w4.colors.gray12,fontSize:"0.875rem",lineHeight:"1.5rem",fontWeight:600,marginBottom:"4px",cursor:"pointer","&:hover":{textDecoration:"underline"}}),sI=(0,I.I4)(sn,{marginLeft:(0,i4.D)(6)}),sk=(0,I.I4)("div",{padding:"10px 0 4px",borderBottom:"1px solid ".concat(I.w4.colors.gray6)}),sE=e=>{let{paper:t,onOpenPreview:n,...l}=e;return(0,r.jsxs)(sk,{children:[(0,r.jsx)(su,{paper:t}),(0,r.jsxs)("div",{children:[(0,r.jsxs)(sj,{onClick:n,children:[t.title||"Untitled",(0,r.jsx)(sI,{onClick:n,children:"Read Abstract"})]}),(0,r.jsx)(sp,{paper:t}),(0,r.jsx)(sh,{paper:t})]}),(0,r.jsx)(sm,{paper:t,...l})]})};var sN=n(95424),sS=n(41360);let sT=(0,I.I4)("div",{background:I.w4.colors.gray1,borderRadius:(0,i4.D)(12),padding:(0,i4.D)(20),width:(0,i4.D)(360),maxWidth:"100%",boxShadow:"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px"}),sA=(0,I.I4)("div",{fontSize:(0,i4.D)(15),lineHeight:(0,i4.D)(20),fontWeight:600,color:I.w4.colors.gray12,marginBottom:(0,i4.D)(8)}),sR=e=>{let{close:t,confirmAction:n}=e,[l,a]=(0,h.useState)(!1),o=(0,h.useCallback)(async()=>{try{a(!0),await n(),a(!1),t()}catch(e){a(!1)}},[n,t]);return(0,r.jsx)(sN.y,{style:"fullScreenOverlay",onClose:t,children:(0,r.jsxs)(sT,{children:[(0,r.jsx)(sA,{children:"Delete 1 item"}),(0,r.jsx)(iZ.P,{css:{color:I.w4.colors.gray9,fontSize:(0,i4.D)(13)},children:"This file will move to Trash and be permanently deleted after 90 days. You can restore it any time before then."}),(0,r.jsxs)(sS.B,{css:{justifyContent:"space-between",marginTop:(0,i4.D)(16)},direction:"row",spacing:8,children:[(0,r.jsx)(i3.$,{size:"small",color:"danger",variant:"link",loading:l,onClick:o,dataId:"remove-library-item-confirm",children:"Yes, Proceed"}),(0,r.jsx)(i3.$,{size:"small",color:"secondaryBlue",disabled:l,onClick:t,dataId:"remove-library-item-cancel",children:"No, don't proceed"})]})]})})},sM=e=>{let{papers:t,editor:n,onUpdatePaper:l,cslJsonMap:a,togglePreviewPaper:
1o,previewPaper:i,styleId:s,selectedCollection:c,libraryId:d,sourceDocIdToItemIdMap:u,onEndReached:p,isFetchingNextPage:m,scrollParent:g}=e,{handleBookmark:f,handleCite:x,handleChatPdf:b,handleReadMoreClick:C,handleCopyDOI:v,isProcessingChatWithPdf:y,clickedSourceDocId:w,removingId:j}=iU({editor:n,onUpdatePaper:l,cslJsonMap:a,cardType:"library",styleId:s,selectedCollection:c,libraryId:d,sourceDocIdToItemIdMap:u}),{setEditCitationCslObject:I,setCitationEditorOverlay:k,citationSchema:E}=(0,t5.h)(),[N,S]=(0,h.useState)(null),T=(0,h.useCallback)(async()=>{N&&await f(N)},[f,N]),A=(0,h.useCallback)((e,t)=>{let{selection:r}=n.state,{from:l,to:a}=r;"@"===n.state.doc.textBetween(l,a,"")&&n.commands.deleteRange({from:l,to:a}),t&&(null==I||I(t),k({mode:"csl-edit",itemId:null==u?void 0:u[e.sourceDocId]}))},[n,I,k,u]),R=(0,h.useCallback)((e,t)=>{let n=iV(e);return{hasPdfAttachment:!!(e.pdfURL||n),isChatProcessing:y&&w===e.sourceDocId,isDeleting:j===e.sourceDocId,onCite:()=>x(e),onChat:()=>b(e,n),onEditCitation:()=>A(e,t),onDeleteRequest:()=>S(e)}},[y,w,j,x,b,A]),M=(0,h.useCallback)((e,t)=>{var n;return{...e,docType:iI(E,null!=(n=null==t?void 0:t.itemType)?n:e.docType)}},[E]),L=(0,h.useCallback)(e=>{let t=null==a?void 0:a[e.sourceDocId];return(0,r.jsx)(sE,{paper:M(e,t),onOpenPreview:()=>null==o?void 0:o(e),...R(e,t)},e.sourceDocId)},[a,o,R,M]);return(0,r.jsxs)(r.Fragment,{children:[!i&&(p&&g?(0,r.jsx)(iN.aY,{customScrollParent:g,totalCount:t.length,overscan:10,endReached:p,components:{Footer:()=>m?(0,r.jsxs)("center",{className:"my-2",children:[(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{})]}):null},itemContent:e=>L(t[e])}):null==t?void 0:t.map(L)),i&&(0,r.jsx)(sw,{paper:M(i,null==a?void 0:a[i.sourceDocId]),handleCopyDOI:v,handleReadMoreClick:C,...R(i,null==a?void 0:a[i.sourceDocId])}),N&&(0,r.jsx)(sR,{close:()=>S(null),confirmAction:T})]})},sL=(0,h.memo)(e=>e.activeTab!==il.LIBRARY?null:(0,r.jsx)(sH,{...e})),sD=e=>{var t,n,r;return(null==(t=e.paper)?void 0:t.sourceDocId)||String(null!=(r=null==(n=e.csl)?void 0:n.id)?r:e.id)},s_=e=>{var t,n,r,l;let a=e.csl;return{title:(null==a?void 0:a.title)||e.title,slug:e.key,sourceDocId:sD(e),docType:e.itemType,doi:null==a?void 0:a.DOI,journalName:null==a?void 0:a["container-title"],publicationDate:String(null!=(l=null==a||null==(r=a.issued)||null==(n=r["date-parts"])||null==(t=n[0])?void 0:t[0])?l:""),pdfURL:(null==a?void 0:a.URL)||e.url,authors:a?(0,nx.Y)(a).map(e=>({full_name:e.full_name||e.literal||"",first_name:e.given,last_name:e.family})):[]}},sH=e=>{var t,n,l;let{searchTerm:a,editor:o,sortField:i="updatedAt",sortDirection:s="desc",previewPaper:c,togglePreviewPaper:d,selectedCollection:u,onSelectCollection:p}=e,{libraryId:m,collections:f,isCollectionsLoading:x}=(0,iw.l)();i1({collections:f,selectedLibraryCollection:u,onSelectCollection:null!=p?p:()=>{}});let{documentId:b}=g(),{documentCitationStyle:C}=iQ(b),v=null!=(t=null==C?void 0:C.id)?t:-1,{data:y,isLoading:w,isFetchingNextPage:j,hasNextPage:I,fetchNextPage:k}=(0,iO.u)({libraryId:m,collectionId:null!=(n=null==u?void 0:u.id)?n:void 0,size:25,sort:{sortBy:i,sortDir:s},searchQuery:a||void 0,includePaper:!0}),[E,N]=(0,h.useState)({}),S=(0,h.useCallback)(e=>{N(t=>({...t,[e.sourceDocId]:e}))},[]),{collectionPapers:T,collectionCslJsonMap:A,sourceDocIdToItemIdMap:R}=(0,h.useMemo)(()=>{var e;let t=null!=(e=null==y?void 0:y.pages.flatMap(e=>e.data.content))?e:[],n=[],r={},l={};return t.filter(e=>{var t;return e.paper||(null==(t=e.csl)?void 0:t.title)}).forEach(e=>{var t;let a=sD(e),o=null!=(t=e.paper)?t:s_(e);n.push({...o,sourceDocId:a,isBookmarked:!0,isAddedToLibrary:!0,attachments:e.attachments.filter(e=>!!e.uploadId&&!!e.fileType).map(e=>{let{uploadId:t,fileType:n}=e;return{uploadId:t,fileType:n}})}),e.csl&&(r[a]=e.csl),l[a]=e.id}),{collectionPapers:n,collectionCslJsonMap:r,sourceDocIdToItemIdMap:l}},[y]),M=(0,h.useMemo)(()=>T.map(e=>{var t;return null!=(t=E[e.sourceDocId])?t:e}),[T,E]),L=(0,h.useCallback)(()=>{I&&!j&&k()},[I,j,k]);return x||!u?(0,r.jsxs)("center",{className:"my-2",children:[(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{})]}):(0,r.jsxs)(r.Fragment,{children:[!c&&(0,r.jsx)("div",{className:"mt-2 -mx-2",children:(0,r.jsx)(i2.w,{collections:f,selectedCollection:u,isCollectionsLoading:x,onSelect:e=>{null==p||p(e)},isInline:!0})}),w?(0,r.jsxs)("center",{className:"my-2",children:[(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{})]}):M.length?(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(sM,{papers:M,onUpdatePaper:S,editor:o,cslJsonMap:A,togglePreviewPaper:d,previewPaper:c,styleId:v,selectedCollection:u,libraryId:m,sourceDocIdToItemIdMap:R,scrollParent:e.scrollParent,isFetchingNextPage:j,onEndReached:L})}):(0,r.jsx)(iv,{message:a?ig.noPaperFound:'No citations in "'.concat(null!=(l=null==u?void 0:u.name)?l:"this collection",'"'),url:"https://cdn.paperpal.com/assets/images/features/edit-empty-illustration.webp"})]})};var sP=n(76141),sO=n(85858);let sz=R.z.object({submissionId:R.z.number(),papers:R.z.array(M.qP),cslJsonMap:L.$s,requestId:R.z.string(),styleId:R.z.number().optional(),balance:sO.s.optional()}),sB=()=>{let e=(0,A.useQueryClient)(),t=[u.x];return{updateSubscriptionQuery:function(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"genAIBalance";t.forEach(t=>{e.setQueryData([t],e=>{if(!e)return e;let t=n.usedBalance,l=n.totalBalance;return n.freeCreditsBalanceDtoList&&n.freeCreditsBalanceDtoList.forEach(e
1=>{e.featuresAndLimits.forEach(e=>{t+=e.usedFeatureLimit,l+=e.featureLimit})}),{...e,[r]:{...n,usedBalance:t,totalBalance:l}}})})}}},sF=(e,t,n)=>{let[r,l]=(0,h.useState)(),{webApiClient:a}=(0,P.p)(),{updateSubscriptionQuery:o}=sB(),i=async r=>{let i="submissionId"in r;if(!i){let{statement:e,context:t}=r;e&&t||console.error("Select and cite error: Statement or context missing.")}try{let s,c="/api/v2/citation/recommendation";i&&r.sortBy&&(c+="?sortBy=".concat(r.sortBy));let d=i?{submissionId:r.submissionId}:{...r,...n&&{source:n}},u=await a.post(c,d);try{s=sz.parse(u)}catch(e){throw console.error("Select and cite error: Failed to parse recommendation response",JSON.stringify(e)),Error("Invalid response format")}return l(s),e&&(e.current=s.submissionId),t&&(t.current=s.requestId),s.balance&&o(s.balance,"researchBalance"),s}catch(e){throw t&&(t.current=void 0),console.error("Select and cite error: Error while fetching suggested papers",JSON.stringify(e)),e}},s=(0,A.useMutation)({mutationKey:["research-recommended-papers"],mutationFn:i,retry:!1});return{mutate:s.mutate,isLoading:s.isLoading,error:s.error,suggestedPapers:r,setSuggestedPapers:l}},sV=(0,h.memo)(e=>{let{activeTab:t}=e;return t!==il.SUGGESTIONS?null:(0,r.jsx)(sU,{...e})}),sU=e=>{var t,n,l,a;let{editor:o,sortBy:i,submissionIdRef:s,requestIdRef:c,togglePreviewPaper:d,previewPaper:u,disableSuggestions:p}=e,{selectedText:m,context:f}=function(e){let{selection:t}=e.state,{state:n}=e,{from:r,to:l}=t,a=(0,r8.f)(n.doc,0,r),o=(0,r8.f)(n.doc,r,l),i=(0,r8.f)(n.doc,l,n.doc.content.size),s=a.trim().split(/\s+/),c=o.trim().split(/\s+/),d=i.trim().split(/\s+/);return{selectedText:o,context:[...s.slice(-20),...c,...d.slice(0,20)].join(" ")}}(o),{suggestedPapers:x,isLoading:b,error:C,onUpdatePaper:v}=function(e){let{sortBy:t,context:n,selectedText:r,submissionIdRef:l,requestIdRef:a,disabled:o=!1}=e,i=(0,h.useRef)(!0),{sessionId:s}=g(),{isLoading:c,error:d,suggestedPapers:u,setSuggestedPapers:p,mutate:m}=sF(l,a,tK.UG.INLINE_EDITOR),f=(0,h.useCallback)(e=>{p(t=>(null==t?void 0:t.papers)?{...t,papers:t.papers.map(t=>t.sourceDocId===e.sourceDocId?e:t)}:t)},[p]),x=(0,h.useRef)(t);return(0,h.useEffect)(()=>()=>{i.current=!1},[]),(0,h.useEffect)(()=>{if(o||!i.current&&x.current===t||c)return;x.current!==t&&(x.current=t);let e=t&&(null==l?void 0:l.current);setTimeout(()=>{m((null==l?void 0:l.current)&&!e?{sortBy:"",submissionId:l.current}:e?{sortBy:t,submissionId:null==l?void 0:l.current}:{statement:r,context:n,sessionId:s})},0)},[t]),{isLoading:c,suggestedPapers:u,onUpdatePaper:f,error:d}}({sortBy:i,context:f,selectedText:m,submissionIdRef:s,requestIdRef:c,disabled:p});if((0,h.useMemo)(()=>{let e=!x||i,t=m&&"@"!==m,n=!!(null==s?void 0:s.current);return b&&e&&!C&&(t||n)},[C,b,m,i,s,x]))return(null==s?void 0:s.current)?(0,r.jsxs)("center",{className:"my-2",children:[(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{}),(0,r.jsx)(i$,{})]}):(0,r.jsx)(sP.iS,{loop:!0,state:"canvas",color:"dark"});if(!x||(null==x?void 0:x.papers.length)===0||C){if(C instanceof Error&&(0,ij.d)(C)&&(null==(t=C.json)?void 0:t.errorCode)==="PAYMENT_REQUIRED")return(0,r.jsxs)(oi,{children:[(0,r.jsx)(ox,{selectedTab:"cite"}),(0,r.jsx)(rX,{}),(0,r.jsx)(oT,{})]});let e="https://cdn.paperpal.com/assets/images/research/noPaperFound.svg";return p?(0,r.jsx)(iv,{message:"Please select 10–200 words for clearer, relevant results.",url:e}):(0,r.jsx)(iv,{message:null!=(l=null==(n=(0,op.F)(C).errorDetails)?void 0:n.message)?l:ig.noSuggestions,url:e})}return(0,r.jsx)("div",{children:(0,r.jsx)(iK,{papers:x.papers,onUp
1datePaper:v,editor:o,cslJsonMap:x.cslJsonMap,togglePreviewPaper:d,previewPaper:u,styleId:null!=(a=x.styleId)?a:-1})})},sW=e=>{let{isChinaRegion:t,refetchCountry:n,isFetchingCountry:l}=e,a=t&&(e.activeTab===il.SUGGESTIONS||e.activeTab===il.SEARCH_PAPERS);return(0,r.jsx)("div",{className:"flex min-h-[400px] w-full",children:a?(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(im,{refetchCountry:n,isFetching:l})}):(0,r.jsxs)(r.Fragment,{children:[e.activeTab===il.SUGGESTIONS&&(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(sV,{...e})}),e.activeTab===il.LIBRARY&&(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(sL,{...e})}),e.activeTab===il.SEARCH_PAPERS&&(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(iY,{...e})})]})})};var sG=n(12457);let sZ=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})})});sZ.displayName="ChevronDownIcon";let sq=e=>{let{activeTab:t,sortBy:n,setSortBy:l}=e,[a,o]=(0,h.useState)(!1),i=(0,h.useRef)(null),s=n===it.PUBLISHING_DATE?ir.PUBLISHING_DATE:n===it.CITATION_COUNT?ir.CITATION_COUNT:n===it.RELEVANCE?ir.RELEVANCE:"Sort";return(0,h.useEffect)(()=>{function e(e){i.current&&!i.current.contains(e.target)&&o(!1)}return a&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[a]),(0,r.jsxs)("div",{className:"relative",ref:i,children:[(0,r.jsxs)(d.$n,{onClick:()=>o(e=>!e),className:"flex !items-center !justify-center !text-sm hover:!bg-gray-3 active:!bg-gray-5 font-medium !text-gray-12 !bg-gray-1 !font-sans !px-4 !py-1 !rounded-md !border-solid !border-gray-5 !border","data-testid":"sort-dropdown",children:[(0,r.jsx)("p",{className:"max-w-[64px] overflow-hidden truncate",children:s}),(0,r.jsx)(sZ,{className:"w-4 h-4 text-gray-11"})]}),a&&(0,r.jsx)("div",{className:"absolute right-0 mt-1 z-10 min-w-[10rem]",children:(0,r.jsxs)(nh,{className:"p-0 rounded-md border-0",children:[t!==il.LIBRARY&&(0,r.jsx)(d.$n,{className:"block w-full rounded text-left px-4 py-2.5 text-xs !bg-transparent hover:!bg-gray-2 leading-none",onClick:()=>{l(it.RELEVANCE),o(!1)},"data-testid":"sort-relevance","aria-label":"Sort by relevance",children:ir.RELEVANCE}),(0,r.jsx)(d.$n,{className:"block w-full rounded text-left px-4 py-2.5 text-xs !bg-transparent hover:!bg-gray-2 leading-none",onClick:()=>{l(it.PUBLISHING_DATE),o(!1)},"data-testid":"sort-publishing-date","aria-label":"Sort by publishing date",children:ir.PUBLISHING_DATE}),(0,r.jsx)(d.$n,{className:"block w-full rounded text-left px-4 py-2.5 text-xs !bg-transparent hover:!bg-gray-2 leading-none",onClick:()=>{l(it.CITATION_COUNT),o(!1)},"data-testid":"sort-citation-count","aria-label":"Sort by citation count",children:ir.CITATION_COUNT})]})})]})},s$=e=>{let{setActiveTab:t,activeTab:n,setSortBy:l,openFromCTA:a,sortBy:o,sortField:i="updatedAt",sortDirection:s="asc",onSortChange:c}=e;return"search"===a?(0,r.jsx)(sK,{}):(0,r.jsxs)("div",{className:"flex justify-between items-center px-2 ",children:[(0,r.jsx)("div",{className:"flex justify-start p-0 gap-x-1 flex-1",children:ix.map((e,l)=>(0,r.jsx)(d.$n,{onClick:()=>t(e),className:(0,eg.cn)("!border !border-gray-7 !border-solid !font-medium !rounded-md !text-sm !leading-[24px] !px-2 !py-1 !bg-gray-1",n===e?"!border-blue-11 !text-blue-11":"!text-gray-11"),children:(0,r.jsx)("span",{children:e})},l))}),n===il.LIBRARY&&c?(0,r.jsx)(sG.N,{sortField:i,sortDirection:s,onSortChange:c,iconOnly:!0}):(0,r.jsx)(sq,{activeTab:n,setSortBy:l,sortBy:o})]})},sK=()=>{let{editor:e}=nl(),{manualCitationPositions:t,activeManualCitationIndex:n}=aN(e),l=(0,h.useCallback)(()=>{e&&e.commands.prevManualCitation()&&(0,eh.kZ)(e,t,n-1)},[e,t,n]),a=(0,h.useCallback)(()=>{e&&e.commands.nextManualCitation()&&(0,eh.kZ)(e,t,n+1)},[e,t,n]);return(0,r.jsx)("div",{className:"flex justify-between items-center px-2 ",children:(0,r.jsxs)("div",{className:"flex justify-between items-center p-0 gap-x-1 flex-1",children:[(0,r.jsx)("span",{className:"text-grey-11 font-medium text-default",children:"Add Citations"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium",children:t.length>0?"".concat(n+1,"/").concat(t.length):"0/0"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(d.$n,{id:"find-prev-manual-citation","aria-label":"Find previous manual citation",onClick:l,disabled:0===n,className:"!bg-gray-1 !border !border-gray-7 !border-solid !text-xs",children:(0,r.jsx)(ew.ow,{className:"w-3 h-3"})}),(0,r.jsx)(d.$n,{id:"find-next-manual-citation","aria-label":"Find next manual citation",onClick:a,disabled:n===t.length-1,className:"!bg-gray-1 !border !border-gray-7 !border-solid !text-xs",children:(0,r.jsx)(ew.rI,{className:"w-3 h-3"})})]})]})]})})},sY=e=>{let{openFromCTA:t,currentCountry:n,isFetchingCountry:l,refetchCountry:a,...o}=e,{activeTab:i,hadleTabChange:s,librarySearchTerm:c,setLibrarySearchTerm:u,findPaperSearchTerm:p,setFindPaperSearchTerm:m,setSortBy:g,sortBy:f,sortField:x,sortDirection:b,handleLibrarySortChange:C,submissionIdRef:v,requestIdRef:y}=function(e){let[t,n]=(0,h.useState)(""),[r,l]=(0,h.useState)(""),[a,o]=(0,h.useState)(null!=e?e:il.LIBRARY),i=(0,h.useRef)(void 0),s=(0,h.useRef)(void 0),c=a!==il.LIBRARY?it.RELEVANCE:"",[d,u]=(0,h.useState)(c),[p,m]=(0,h.useState)("updatedAt"),[g,f]=(0,h.useState)("desc"),x=(0,h.useCallback)(e=>{o(e),s.current=void 0,e!==il.LIBRARY?u(it.RELEVANCE):u("")},[]),b=(0,h.useRef)(!1);return(0,h.useEffect)(()=>
1{if(!b.current){b.current=!0;return}x(null!=e?e:il.LIBRARY)},[e,x]),{librarySearchTerm:t,setLibrarySearchTerm:n,findPaperSearchTerm:r,setFindPaperSearchTerm:l,sortBy:d,setSortBy:u,sortField:p,sortDirection:g,handleLibrarySortChange:(0,h.useCallback)((e,t)=>{m(e),f(t)},[]),activeTab:a,hadleTabChange:x,submissionIdRef:i,requestIdRef:s}}("search"===t?il.SEARCH_PAPERS:"suggestion"===t?il.SUGGESTIONS:il.LIBRARY),[w,j]=(0,h.useState)(null),[I,k]=(0,h.useState)(void 0),[E,N]=(0,h.useState)(""),[S,T]=(0,h.useState)(null),A=(0,h.useRef)(""),R="CN"===n;(0,h.useEffect)(()=>{A.current&&!E&&u(""),A.current=E},[E]);let M=i===il.LIBRARY,{setCitationEditorOverlay:L}=(0,t5.h)(),D=(0,h.useCallback)(()=>{L({mode:"csl-add",collectionId:M?null==I?void 0:I.id:void 0})},[L,M,null==I?void 0:I.id]),_=(0,h.useCallback)(()=>{N(""),u("")},[N,u]),H=i===il.LIBRARY?c:p;return(0,r.jsx)("div",{className:"w-full relative block",children:(0,r.jsx)(nh,{className:"w-full !min-w-[440px] max-w-[440px] !bg-gray-1 relative !rounded-xl flex-wrap absolute justify-between paperpal-dropdown-options\n          ".concat(w?"!pt-0":"!pt-4 !max-h-[550px]"),children:(0,r.jsxs)(nm,{className:"flex-1 w-full p-0 flex flex-col min-h-0",style:{overflowY:"hidden"},children:[(0,r.jsxs)("div",{className:"w-full flex flex-col flex-1 min-h-0",children:[(0,r.jsx)("div",{className:"flex flex-col gap-2 flex-shrink-0",children:w?(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2 px-2",children:[(0,r.jsx)(d.$n,{className:"flex items-center text-gray-11",onClick:()=>j(null),id:"go-back-button","aria-label":"Go back",children:(0,r.jsx)(lG,{className:"w-5 h-5"})}),(0,r.jsx)("p",{className:"font-medium text-base/[32px] text-blue-12",children:"Abstract"})]}
1):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s$,{setActiveTab:s,activeTab:i,setSortBy:g,sortBy:f,sortField:x,openFromCTA:t,sortDirection:b,onSortChange:C}),i!==il.SUGGESTIONS&&(M?(0,r.jsx)("div",{className:"px-2",children:(0,r.jsx)(ie.r,{value:E,onChange:N,onCommit:()=>u(E),onClear:_,placeholder:"Search in collection... ",showAddCitationButton:!0,updateRoute:D})}):(0,r.jsx)(r.Fragment,{children:!R&&(0,r.jsx)(is,{setSearchTerm:m,searchTerm:p,activeTab:i})}))]})}),(0,r.jsx)("div",{ref:T,className:"flex-1 overflow-y-auto min-h-0 px-2",children:(0,r.jsx)(sW,{scrollParent:S,searchTerm:H,sortBy:f,sortField:x,sortDirection:b,submissionIdRef:v,requestIdRef:y,togglePreviewPaper:j,previewPaper:w,activeTab:i,disableSuggestions:"suggestion"!==t,isChinaRegion:R,refetchCountry:a,isFetchingCountry:l,selectedCollection:I,onSelectCollection:k,...o})})]}),i===il.SUGGESTIONS&&y.current&&(0,r.jsx)(ih,{requestId:y.current,submissionId:v.current})]})})})};sY.displayName="CiteTabView";let sX=e=>(0,r.jsx)(o8,{char:"@",pluginKey:"citeDropdownMenu",decorationClass:"tiptap-mention-decoration",selector:"tiptap-mention-dropdown-menu",...e,children:t=>(0,r.jsx)(sY,{...t,currentCountry:e.currentCountry,isFetchingCountry:e.isFetchingCountry,refetchCountry:e.refetchCountry})});n(50737);let sJ=(0,h.createContext)(void 0),sQ=()=>{let e=(0,h.useContext)(sJ);if(!e)throw Error("Avatar components must be used within an Avatar.Root");return e},s0=(e,t)=>{let n=e?"loading":"error",[r,l]=(0,h.useState)(n);return(0,h.useLayoutEffect)(()=>{if(!e)return;let n=!0,r=new window.Image,a=e=>()=>{n&&l(e)};return r.onload=a("loaded"),r.onerror=a("error"),r.src=e,t&&(r.referrerPolicy=t),()=>{n=!1}},[e,t]),r},s1=(0,h.forwardRef)((e,t)=>{let{children:n,className:l="",size:a="default",userColor:o,...i}=e,[s,c]=(0,h.useState)("idle"),d=(0,h.useCallback)(e=>{c(e)},[]),u=(0,h.useMemo)(()=>({imageLoadingStatus:s,onImageLoadingStatusChange:d,size:a}),[s,d,a]);return(0,r.jsx)(sJ.Provider,{value:u,children:(0,r.jsx)("span",{...i,ref:t,className:"tiptap-avatar ".concat(l),style:o?{"--dynamic-user-color":o}:void 0,"data-size":a,children:(0,r.jsx)("span",{className:"tiptap-avatar-item",children:n})})})});s1.displayName="Avatar",(0,h.forwardRef)((e,t)=>{let{onLoadingStatusChange:n,src:l,className:a="",...o}=e,{onImageLoadingStatusChange:i}=sQ(),s=s0(l,o.referrerPolicy);return((0,h.useLayoutEffect)(()=>{"idle"!==s&&(null==n||n(s),i(s))},[s,n,i]),"loaded"!==s)?null:(0,r.jsx)("img",{...o,ref:t,src:l,className:"tiptap-avatar-image ".concat(a)})}).displayName="AvatarImage";let s2=(0,h.forwardRef)((e,t)=>{let{delayMs:n,className:l="",children:a,...o}=e,i=sQ(),[s,c]=(0,h.useState)(void 0===n);return((0,h.useEffect)(()=>{if(void 0!==n){let e=window.setTimeout(()=>c(!0),n);return()=>window.clearTimeout(e)}},[n]),s&&"loaded"!==i.imageLoadingStatus)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-avatar-bg ".concat(l)}),(0,r.jsx)("span",{...o,ref:t,className:"tiptap-avatar-fallback ".concat(l),children:a})]}):null});s2.displayName="AvatarFallback";let s4=e=>{let{maxVisible:t,children:n,className:l="",...a}=e,o=h.Children.toArray(n),i=t?o.slice(0,t):o,s=o.length-i.length,c={};return h.Children.forEach(n,e=>{if((0,h.isValidElement)(e)&&e.type&&"string"!=typeof e.type&&"Avatar"===e.type.displayName){c={...c,...e.props};return}}),(0,r.jsxs)("div",{...a,className:"tiptap-avatar-group ".concat(l),"data-max-user-visible":t,children:[i,s>0&&(0,r.jsx)(s1,{...c,children:(0,r.jsxs)(s2,{children:["+",s]})})]})};s4.displayName="AvatarGroup";let s5=(0,h.createContext)(null),s7={isOpen:!1,shouldShowInput:!0,inputIsFocused:!1,fallbackAnchor:{element:null,rect:null}},s3=e=>{let t=e.split(".")[1];if(t){let e=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return{name:e.allowedDocumentNames[0],isReadOnlyAccess:e.isReadOnlyAccess,isOwner:e.isOwner,indicatorColor:e.indicatorColor}}return{name:"",isReadOnlyAccess:!1,isOwner:!1,indicatorColor:""}},s9=(0,h.createContext)({loggedInUserName:"",user:{color:"",id:"",name:"",avatar:""}});function s6(e){let{children:t,collabToken:n}=e,{authState:l}=(0,oa.Z)(),a=(0,h.useMemo)(()=>{var e;return"logged in"===l.name&&null!=(e=l.user.name)?e:""},[l]),o=(0,h.useMemo)(()=>{var e;return"logged in"===l.name&&null!=(e=l.user.ssoUserId)?e:""},[l]),i=(0,h.useMemo)(()=>{let e=s3(n);return{id:String(o),name:a,color:e.indicatorColor,isReadOnlyAccess:e.isReadOnlyAccess,isOwner:e.isOwner}},[n,o,a]);return(0,r.jsx)(s9.Provider,{value:{user:i,loggedInUserName:a},children:t})}let s8=()=>(0,h.useContext)(s9),ce=e=>{var t,n;let{editor:r,collabToken:l}=e,a=null==r||null==(n=r.storage)||null==(t=n.providerExtension)?void 0:t.provider,{user:o}=s8(),{authState:i}=(0,oa.Z)(),s=(0,h.useMemo)(()=>{var e;
1return"logged in"===i.name&&null!=(e=i.user.name)?e:""},[i]),c=(0,h.useMemo)(()=>{var e;return"logged in"===i.name&&null!=(e=i.user.ssoUserId)?e:""},[i]),{color:d,isOwner:u,name:p,id:m}=o,g=s3(null!=l?l:""),f=(0,h.useMemo)(()=>({indicatorColor:null!=d?d:"#BCC7DC",name:p.length?p:s,id:(null==m?void 0:m.length)?m:c}),[d,p,s,m,c]),x=(0,h.useCallback)(e=>{r&&r.chain().focus().unselectThread().setThread({content:e,commentData:{user:f,createdAt:Date.now(),updatedAt:Date.now()},data:{user:f}}).setTextSelection({from:r.state.selection.from,to:r.state.selection.to}).commentInputHide().run()},[r,f]);return{provider:a,isOwner:null!=u?u:g.isOwner,userDetails:f,createThread:x}};function ct(e){let{children:t}=e,{value:n,CommentMenuStateContext:l}=function(){let[e,t]=(0,h.useState)(s7),n=(0,h.useCallback)(e=>{t(t=>({...t,...e}))},[]),r=(0,h.useCallback)((e,t)=>{let r=t||(null==e?void 0:e.getBoundingClientRect())||null;n({fallbackAnchor:{element:e,rect:r}})},[n]),l=(0,h.useCallback)(()=>{t(s7),aT()},[]);return{value:(0,h.useMemo)(()=>
1({state:e,updateState:n,setFallbackAnchor:r,reset:l}),[e,n,r,l]),CommentMenuStateContext:s5}}();return(0,r.jsx)(l.Provider,{value:n,children:t})}function cn(e){var t;let{editor:n}=e,[l,a]=(0,h.useState)(""),{editor:o}=nl(n),{loggedInUserName:i}=s8(),{state:s,updateState:c,setFallbackAnchor:u,reset:p}=function(){let e=(0,h.useContext)(s5);if(!e)throw Error("useCommentMenuState must be used within an CommentMenuStateProvider");return e}(),{createThread:m}=ce({editor:o}),{show:g,store:f}=rC(),{commentInputVisible:x,aiGenerationIsLoading:b}=aN(o),C=(0,h.useRef)(void 0),v=(0,h.useCallback)(()=>{o&&(p(),null==f||f.hideAll(),o.commands.resetUiState(),C.current=void 0)},[o,p,f]),y=(0,h.useCallback)((e,t,n)=>{u(e,t),n&&(C.current=n)},[u]),w=(0,h.useCallback)(()=>{x&&v()},[x,v]);if(!function(e){let{editor:t,commentMenuVisible:n,showMenuAtElement:r,setMenuVisible:l,onSelectionChange:a,prevent:o=!1}=e;(0,h.useEffect)(()=>{if(!t||!n||o)return;let e=e=>{var t;let{editor:o,transaction:i}=e;if(null==(t=i.selection)?void 0:t.empty)return;let s=ll(o),c=!!(s&&n);if(l(c),c&&s){let e=s.getBoundingClientRect(),t=aA(o);null==a||a(s,e,t?t.bottom-e.bottom:void 0),r(s)}};return t.on("transaction",e),()=>{t.off("transaction",e)}},[t,n,r,l,a,o])}({editor:o,commentMenuVisible:x,showMenuAtElement:g,setMenuVisible:e=>c({isOpen:e}),onSelectionChange:y,prevent:b}),(0,h.useEffect)(()=>{x&&c({isOpen:!0,shouldShowInput:!0})},[x,c]),(0,h.useEffect)(()=>{(null==o?void 0:o.state.selection.empty)&&s.isOpen&&v()},[v,null==o?void 0:o.state.selection.empty,s.isOpen]),!o||!s.isOpen||!x)return null;let j=()=>{l.trim()&&(m(l),a(""))};return(0,r.jsx)(rj,{open:s.isOpen,placement:"bottom-start",store:f,children:(0,r.jsx)(rI,{onClickOutside:w,className:"tiptap-ai-menu",flip:!1,style:{top:C.current?C.current:"auto"},children:(0,r.jsxs)("div",{className:"tiptap-ai-prompt-input shadow-md flex flex-row items-center gap-1.5",children:[(0,r.jsx)(s1,{size:"lg",children:(0,r.jsx)(s2,{children:null==(t=i[0])?void 0:t.toUpperCase()})}),(0,r.jsx)(n8,{autoSelect:"always",autoFocus:!0,render:(0,r.jsx)(oM,{id:"comment-prompt-box",onChange:e=>a(e.target.value),value:l,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.shiftKey||(e.preventDefault(),j()))},className:"tiptap-ai-prompt-input-content",placeholder:"Add your comment"})}),(0,r.jsx)(d.$n,{onClick:j,disabled:!l.trim(),"data-style":"primary","aria-label":"Submit prompt","data-test-id":"comment-input-submit",children:(0,r.jsx)(lq,{className:"tiptap-button-icon"})})]})})})}function cr(e){let{editor:t}=e;return(0,r.jsx)(ct,{children:(0,r.jsx)(cn,{editor:t})})}let cl="hideFloatingToolbar",ca=(e,t)=>{if(!e)return;let{state:n,view:r}=e;r.dispatch(n.tr.setSelection($.nh.create(n.doc,t)).setMeta(cl,!0))},co=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.70711 5.29289C5.31658 4.90237 4.68342 4.90237 4.29289 5.29289L1.29289 8.29289C0.902369 8.68342 0.902369 9.31658 1.29289 9.70711C1.68342 10.0976 2.31658 10.0976 2.70711 9.70711L4 8.41421V16C4 16.7956 4.31607 17.5587 4.87868 18.1213C5.44129 18.6839 6.20435 19 7 19H13C13.5523 19 14 18.5523 14 18C14 17.4477 13.5523 17 13 17H7C6.73478 17 6.48043 16.8946 6.29289 16.7071C6.10536 16.5196 6 16.2652 6 16V8.41421L7.29289 9.70711C7.68342 10.0976 8.31658 10.0976 8.70711 9.70711C9.09763 9.31658 9.09763 8.68342 8.70711 8.29289L5.70711 5.29289ZM15.2929 14.2929C15.6834 13.9024 16.3166 13.9024 16.7071 14.2929L18 15.5858V8C18 7.73478 17.8946 7.48043 17.7071 7.29289C17.5196 7.10536 17.2652 7 17 7H11C10.4477 7 10 6.55228 10 6C10 5.44772 10.4477 5 11 5H17C17.7957 5 18.5587 5.31607 19.1213 5.87868C19.6839 6.44129 20 7.20435 20 8V15.5858L21.2929 14.2929C21.6834 13.9024 22.3166 13.9024 22.7071 14.2929C23.0976 14.6834 23.0976 15.3166 22.7071 15.7071L19.7071 18.7071C19.3166 19.0976 18.6834 19.0976 18.2929 18.7071L15.2929 15.7071C14.9024 15.3166 14.9024 14.6834 15.2929 14.2929Z",fill:"currentColor"})})});co.displayName="Repeat2Icon";
1let ci=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M17.293 7.29303C17.6835 6.90251 18.3165 6.90251 18.707 7.29303L22.707 11.293C22.7548 11.3408 22.7976 11.3936 22.835 11.4503C22.8597 11.4877 22.8812 11.5267 22.9004 11.5665C22.9222 11.6117 22.9412 11.6584 22.9561 11.7071C22.9622 11.7274 22.9668 11.748 22.9717 11.7686C22.9893 11.843 23 11.9203 23 12.0001C23 12.0831 22.9878 12.1632 22.9688 12.2403C22.9646 12.2572 22.9611 12.2743 22.9561 12.2911C22.9421 12.337 22.9244 12.3811 22.9043 12.4239C22.8833 12.4686 22.859 12.5119 22.8311 12.5538C22.8185 12.5726 22.8048 12.5905 22.791 12.6085C22.7649 12.6423 22.738 12.6761 22.707 12.7071L18.707 16.7071C18.3165 17.0976 17.6835 17.0975 17.293 16.7071C16.9024 16.3166 16.9025 15.6836 17.293 15.293L19.5859 13.0001H4.41406L6.70703 15.293C7.09747 15.6836 7.09753 16.3166 6.70703 16.7071C6.31654 17.0976 5.6835 17.0975 5.29297 16.7071L1.29297 12.7071C1.26185 12.676 1.23417 12.6424 1.20801 12.6085C1.19423 12.5906 1.18053 12.5726 1.16797 12.5538C1.14006 12.5119 1.11566 12.4686 1.09473 12.4239C1.07465 12.3811 1.0569 12.3369 1.04297 12.2911C1.0379 12.2743 1.03445 12.2572 1.03027 12.2403C1.01124 12.1633 1.00001 12.083 1 12.0001C1 11.9204 1.00974 11.8429 1.02734 11.7686C1.03221 11.7481 1.03678 11.7274 1.04297 11.7071C1.05787 11.6583 1.07777 11.6117 1.09961 11.5665C1.11877 11.5267 1.1403 11.4877 1.16504 11.4503C1.20242 11.3936 1.24516 11.3408 1.29297 11.293L5.29297 7.29303C5.68349 6.90251 6.31651 6.90251 6.70703 7.29303C7.09747 7.68356 7.09753 8.3166 6.70703 8.70709L4.41406 11.0001H19.5859L17.293 8.70709C16.9024 8.31657 16.9025 7.68356 17.293 7.29303Z",fill:"currentColor"})})});ci.displayName="MoveHorizontalIcon";let cs=["table","tableHandleExtension"];function cc(e){if(!e||!e.isEditable||!(0,eg.xU)(e,cs))return!1;try{return e.isActive("table")||e.isActive("tableCell")||e.isActive("tableHeader")}catch(e){return!1}}let cd=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.94924 1.68544C6.81364 1.27624 6.43108 1 6 1C5.56892 1 5.18636 1.27624 5.05076 1.68544L4.3711 3.73642C4.2717 4.03638 4.03638 4.2717 3.73642 4.3711L1.68544 5.05076C1.27624 5.18636 1 5.56892 1 6C1 6.43108 1.27624 6.81364 1.68544 6.94924L3.73642 7.6289C4.03638 7.7283 4.2717 7.96362 4.3711 8.26358L5.05076 10.3146C5.18636 10.7238 5.56892 11 6 11C6.43108 11 6.81364 10.7238 6.94924 10.3146L7.6289 8.26358C7.7283 7.96362 7.96362 7.7283 8.26358 7.6289L10.3146 6.94924C10.7238 6.81364 11 6.43108 11 6C11 5.56892 10.7238 5.18636 10.3146 5.05076L8.26358 4.3711C7.96362 4.2717 7.7283 4.03638 7.6289 3.73642L6.94924 1.68544ZM4.95595 6C5.38537 5.74447 5.74447 5.38537 6 4.95595C6.25554 5.38537 6.61463 5.74447 7.04405 6C6.61463 6.25554 6.25554 6.61463 6 7.04405C5.74447 6.61463 5.38537 6.25554 4.95595 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.9492 5.68544C14.8136 5.27624 14.4311 5 14 5C13.5689 5 13.1864 5.27624 13.0508 5.68544L11.3755 10.7408C11.2761 11.0408 11.0408 11.2761 10.7408 11.3755L5.68544 13.0508C5.27624 13.1864 5 13.5689 5 14C5 14.4311 5.27624 14.8136 5.68544 14.9492L10.7408 16.6245C11.0408 16.7239 11.2761 16.9592 11.3755 17.2592L13.0508 22.3146C13.1864 22.7238 13.5689 23 14 23C14.4311 23 14.8136 22.7238 14.9492 22.3146L16.6245 17.2592C16.7239 16.9592 16.9592 16.7239 17.2592 16.6245L22.3146 14.9492C22.7238 14.8136 23 14.4311 23 14C23 13.5689 22.7238 13.1864 22.3146 13.0508L17.2592 11.3755C16.9592 11.2761 16.7239 11.0408 16.6245 10.7408L14.9492 5.68544ZM13.274 11.3699L14 9.17903L14.726 11.3699C15.0242 12.2698 15.7302 12.9758 16.6301 13.274L18.821 14L16.6301 14.726C15.7302 15.0242 15.0242 15.7302 14.726 16.6301L14 18.821L13.274 16.6301C12.9758 15.7302 12.2698 15.0242 11.3699 14.726L9.17903 14L11.3699 13.274C12.2698 12.9758 12.9758 12.2698 13.274 11.3699Z",fill:"currentColor"})]})});cd.displayName="AiSparklesIcon";
1let cu="mod+j",cp=["aiGeneration","ai"],ch=["codeBlock","image","imageUpload"],cm=e=>{if(!e||!e.isEditable||!(0,eg.xU)(e,cp)||(0,eg.ee)(e,["image","horizontalRule"]))return!1;let{selection:t}=e.state;if(!t||t.empty)return!1;if((0,l.BQ)(t)){let e=t.node;if(ch.includes(e.type.name))return!1}return!(e.isActive("table")||e.isActive("tableCell")||e.isActive("tableHeader"))};function cg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{editor:t,hideWhenUnavailable:n=!1,onAiAsked:r}=e,{editor:l}=nl(t),a=rQ(),[o,i]=(0,h.useState)(!0),s=cm(l),c=(0,h.useCallback)(()=>{if(!l||!s)return!1;let e=l.chain().focus().aiGenerationShow().run();return e&&(null==r||r()),e},[s,l,r]);return(0,h.useEffect)(()=>{if(!l)return void i(!1);let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,cp)&&(!n||!!t.isActive("code")||cm(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]),(0,r0.vC)(cu,e=>{e.preventDefault(),c()},{enabled:o&&s,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:o,handleAiAsk:c,canAiAsk:s,label:"Ask AI Assistant",shortcutKeys:cu,Icon:cd}}n(3354),n(84275),n(39953);let cf=(0,h.forwardRef)((e,t)=>{let{variant:n,size:l="default",appearance:a="default",trimText:o=!1,className:i,children:s,...c}=e;return(0,r.jsx)("div",{ref:t,className:"tiptap-badge ".concat(i||""),"data-style":n,"data-size":l,"data-appearance":a,"data-text-trim":o?"on":"off",...c,children:s})});function cx(e){let{shortcutKeys:t=cu}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}cf.displayName="Badge";let cb=(0,h.forwardRef)(function(e,t){let{editor:n,hideWhenUnavailable:l=!1,onAiAsked:a,showShortcut:o=!1,onClick:i,children:s,...c}=e,{editor:u}=nl(n),{isVisible:p,canAiAsk:m,handleAiAsk:g,label:f,shortcutKeys:x}=cg({editor:u,hideWhenUnavailable:l,onAiAsked:a}),b=(0,h.useCallback)(e=>{null==i||i(e),e.defaultPrevented||g()},[g,i]);return p&&m?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",disabled:!m,"data-disabled":!m,role:"button",tabIndex:-1,"aria-label":f,tooltip:(0,eg.wi)({shortcutKeys:x}).join((0,eg.cX)()?"":"+"),onClick:b,"data-test-id":"paperpal-ai-button",...c,ref:t,children:null!=s?s:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ew.NB,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"hidden lg:inline xl:hidden",children:"AI"}),(0,r.jsx)("span",{className:"hidden xl:inline",children:"Paperpal AI"}),o&&(0,r.jsx)(cx,{shortcutKeys:x})]})}):null}),cC=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M15 1C16.1046 1 17 1.89543 17 3H18C18.7956 3 19.5585 3.3163 20.1211 3.87891C20.6837 4.44151 21 5.20435 21 6V20C21 20.7957 20.6837 21.5585 20.1211 22.1211C19.5585 22.6837 18.7957 23 18 23H6C5.20435 23 4.44151 22.6837 3.87891 22.1211C3.3163 21.5585 3 20.7957 3 20V6C3 5.20435 3.3163 4.44152 3.87891 3.87891C4.44152 3.3163 5.20435 3 6 3H7C7 1.89543 7.89543 1 9 1H15ZM6 5C5.73478 5 5.4805 5.10543 5.29297 5.29297C5.10543 5.4805 5 5.73478 5 6V20L5.00488 20.0986C5.02757 20.3276 5.12883 20.5429 5.29297 20.707C5.48051 20.8946 5.73478 21 6 21H18C18.2652 21 18.5195 20.8946 18.707 20.707C18.8946 20.5195 19 20.2652 19 20V6C19 5.73478 18.8946 5.48051 18.707 5.29297C18.5429 5.12883 18.3276 5.02757 18.0986 5.00488L18 5H17C17 6.10457 16.1046 7 15 7H9C7.89543 7 7 6.10457 7 5H6ZM9 5H15V3H9V5Z",fill:"currentColor"})})});cC.displayName="ClipboardIcon";let cv="mod+c";function cy(e){if(!e||!e.isEditable)return!1;let{selection:t}=e.state.tr,{empty:n}=t;return!n}async function cw(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(!e||!e.isEditable)return!1;try{let{textContent:n,htmlContent:r}=function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{selection:n}=e.state,{$anchor:r}=n,l=n.content();if(n.empty||n instanceof $.U3){let e=r.node(1);l=new tH.Ji(tH.FK.from(e),0,0)}return{textContent:l.content.textBetween(0,l.content.size,"\n"),htmlContent:t?e.view.serializeForClipboard(l).dom.innerHTML:void 0}}(e,t);return await (0,np.x)(null!=r?r:"",n),!0}catch(e){return!1}}function cj(e){let{editor:t,copyWithFormatting:n=!0,hideWhenUnavailable:r=!1,onCopied:l}=e||{},{editor:a}=nl(t),o=rQ(),[i,s]=(0,h.useState)(!0),c=cy(a);(0,h.useEffect)(()=>
1{if(!a)return;let e=()=>{s(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&(!n||!!t.isActive("code")||cy(t))}({editor:a,hideWhenUnavailable:r}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,r]);let d=(0,h.useCallback)(async()=>{if(!a)return!1;let e=await cw(a,n);return e&&(null==l||l()),e},[a,n,l]);return(0,r0.vC)(cv,e=>{e.preventDefault(),d()},{enabled:i&&c,enableOnContentEditable:!o,enableOnFormTags:!0}),{isVisible:i,handleCopyToClipboard:d,canCopyToClipboard:c,label:"Copy to clipboard",shortcutKeys:cv,Icon:cC}}function cI(e){let{shortcutKeys:t=cv}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,copyWithFormatting:a=!0,hideWhenUnavailable:o=!1,onCopied:i,showShortcut:s=!1,onClick:c,children:u,...p}=e,{editor:m}=nl(n),{isVisible:g,handleCopyToClipboard:f,label:x,shortcutKeys:b,Icon:C}=cj({editor:m,copyWithFormatting:a,hideWhenUnavailable:o,onCopied:i}),v=(0,h.useCallback)(async e=>{null==c||c(e),e.defaultPrevented||await f()},[f,c]);return g?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":x,tooltip:"Copy to clipboard",onClick:v,...p,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),s&&(0,r.jsx)(cI,{shortcutKeys:b})]})}):null}).displayName="CopyToClipboardButton";let ck="backspace";function cE(e){if(!e||!e.isEditable)return!1;let{state:t}=e,{selection:n}=t;if(n instanceof $.nh)return!0;let r=n.$anchor;for(let e=r.depth;e>0;e--){let n=r.node(e),l=r.before(e);if(t.tr.delete(l,l+n.nodeSize).doc!==t.doc)return!0}return!1}function cN(e,t,n){let r=e.chain().focus();return!!r.deleteRange({from:t,to:t+n}).run()||r.setNodeSelection(t).deleteSelection().run()}function cS(e){let{editor:t,hideWhenUnavailable:n=!1,onDeleted:r}=e||{},{editor:l}=nl(t),a=rQ(),[o,i]=(0,h.useState)(!0),s=cE(l);(0,h.useEffect)(()=>{if(!l)return;let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&(!n||!!t.isActive("code")||cE(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]);let c=(0,h.useCallback)(()=>{if(!l)return!1;let e=function(e){if(!e||!e.isEditable)return!1;try{let{state:t}=e,{selection:n}=t;if(n instanceof $.nh){let t=n.from,r=n.node;if(!r)return!1;return cN(e,t,r.nodeSize)}let r=n.$from;for(let t=r.depth;t>0;t--){let r=n.$from.node(t),l=n.$from.before(t);if(r&&r.isBlock&&"tableRow"!==r.type.name&&"tableHeader"!==r.type.name&&"tableCell"!==r.type.name)return cN(e,l,r.nodeSize)}return!1}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]);return(0,r0.vC)(ck,e=>{e.preventDefault(),c()},{enabled:o&&s,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:o,handleDeleteNode:c,canDeleteNode:s,label:"Delete",shortcutKeys:ck,Icon:lA}}function cT(e){let{shortcutKeys:t=ck}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}let cA=(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onDeleted:o,showShortcut:i=!1,onClick:s,children:c,...u}=e,{editor:p}=nl(n),{isVisible:m,handleDeleteNode:g,label:f,shortcutKeys:x,Icon:b}=cS({editor:p,hideWhenUnavailable:a,onDeleted:o}),C=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||g()},[g,s]);return m?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":f,tooltip:"Delete",onClick:C,...u,ref:t,children:null!=c?c:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i&&(0,r.jsx)(cT,{shortcutKeys:x})]})}):null});cA.displayName="DeleteNodeButton";let cR="mod+d";function cM(e){if(!e||!e.isEditable)return!1;try{let{state:t}=e,{selection:n}=t;if(n instanceof $.nh)return!!n.node;return!!n.$anchor.node(1)}catch(e){return!1}}function cL(e){let{editor:t,hideWhenUnavailable:n=!1,onDuplicated:r}=e||{},{editor:l}=nl(t),a=rQ(),[o,i]=(0,h.useState)(!0),s=cM(l);(0,h.useEffect)(()=>{if(!l)return;let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&(!n||!!t.isActive("code")||cM(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]);let c=(0,h.useCallback)(()=>
1{if(!l)return!1;let e=function(e){if(!e||!e.isEditable)return!1;try{let{state:t}=e,{selection:n}=t,r=e.chain().focus();if(n instanceof $.nh){let e=n.node,t=n.to;return r.insertContentAt(t,e.toJSON()).run(),!0}let l=n.$anchor;for(let e=1;e<=l.depth;e++){let n=l.node(e);if("doc"===n.type.name||!n.type.spec.group)continue;let a=l.start(e),o=Math.min(a+n.nodeSize,t.doc.content.size);return r.insertContentAt(o,n.toJSON()).run(),!0}return!1}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]);return(0,r0.vC)(cR,e=>{e.preventDefault(),c()},{enabled:o&&s,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:o,handleDuplicate:c,canDuplicate:s,label:"Duplicate node",shortcutKeys:cR,Icon:lD}}function cD(e){let{shortcutKeys:t=cR}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onDuplicated:o,showShortcut:i=!1,onClick:s,children:c,...u}=e,{editor:p}=nl(n),{isVisible:m,handleDuplicate:g,label:f,shortcutKeys:x,Icon:b}=cL({editor:p,hideWhenUnavailable:a,onDuplicated:o}),C=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||g()},[g,s]);return m?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":f,tooltip:"Duplicate",onClick:C,...u,ref:t,children:null!=c?c:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i&&(0,r.jsx)(cD,{shortcutKeys:x})]})}):null}).displayName="DuplicateButton";let c_=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]})});c_.displayName="HeadingFiveIcon";let cH=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]})});cH.displayName="HeadingFourIcon";let cP=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]})});cP.displayName="HeadingOneIcon";
1let cO=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]})});cO.displayName="HeadingSixIcon";let cz=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]})});cz.displayName="HeadingThreeIcon";let cB=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]})});cB.displayName="HeadingTwoIcon";
1let cF={1:cP,2:cB,3:cz,4:cH,5:c_,6:cO},cV={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function cU(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return!(!e||!e.isEditable||!(0,eg.HR)("heading",e)||(0,eg.ee)(e,["image"]))&&(n?!!(0,eg.k)(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&(t?e.can().setNode("heading",{level:t})||e.can().clearNodes():e.can().setNode("heading")||e.can().clearNodes()):t?e.can().setNode("heading",{level:t}):e.can().setNode("heading"))}function cW(e){let{editor:t,level:n,hideWhenUnavailable:r=!1,onToggled:l}=e,{editor:a}=nl(t),[o,i]=(0,h.useState)(!0),s=cU(a,n),c=!!a&&!!a.isEditable&&(Array.isArray(n)?n.some(e=>a.isActive("heading",{level:e})):n?a.isActive("heading",{level:n}):a.isActive("heading"));return(0,h.useEffect)(()=>{if(!a)return;let e=()=>{i(function(e){let{editor:t,level:n,hideWhenUnavailable:r}=e;return!!t&&!!t.isEditable&&!!(0,eg.HR)("heading",t)&&(!r||!!t.isActive("code")||(Array.isArray(n)?n.some(e=>cU(t,e)):cU(t,n)))}({editor:a,level:n,hideWhenUnavailable:r}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,n,r]),{isVisible:o,isActive:c,handleToggle:(0,h.useCallback)(()=>{if(!a)return!1;let e=function(e,t){if(!e||!e.isEditable)return!1;let n=Array.isArray(t)?t:[t],r=n.find(t=>cU(e,t));if(!r)return!1;try{var l,a,o;let t=e.view,i=t.state,s=i.tr;if(i.selection.empty){let n=null==(l=(0,eg.po)({editor:e,node:i.selection.$anchor.node(1)}))?void 0:l.pos;if(!(0,eg.u1)(n))return!1;s=s.setSelection($.nh.create(i.doc,n)),t.dispatch(s),i=t.state}let c=i.selection,d=e.chain().focus();if(c instanceof $.nh){let e=null==(a=c.node.firstChild)?void 0:a.firstChild,t=null==(o=c.node.lastChild)?void 0:o.lastChild,n=e?c.from+e.nodeSize:c.from+1,r=t?c.to-t.nodeSize:c.to-1,l=i.doc.resolve(n),s=i.doc.resolve(r);d=d.setTextSelection($.U3.between(l,s)).clearNodes()}else c.empty||(d=d.clearNodes());return(n.some(t=>e.isActive("heading",{level:t}))?d.setNode("paragraph"):d.setNode("heading",{level:r})).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch(e){return!1}}(a,n);return e&&(null==l||l()),e},[a,n,l]),canToggle:s,label:"Heading ".concat(n),shortcutKeys:cV[n],Icon:cF[n]}}let cG=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M12 2C12.5523 2 13 2.44772 13 3V14.5858L17.2929 10.2929C17.6834 9.90237 18.3166 9.90237 18.7071 10.2929C19.0976 10.6834 19.0976 11.3166 18.7071 11.7071L12.7071 17.7071C12.3166 18.0976 11.6834 18.0976 11.2929 17.7071L5.29289 11.7071C4.90237 11.3166 4.90237 10.6834 5.29289 10.2929C5.68342 9.90237 6.31658 9.90237 6.70711 10.2929L11 14.5858V3C11 2.44772 11.4477 2 12 2Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M5 20C4.44772 20 4 20.4477 4 21C4 21.5523 4.44772 22 5 22H19C19.5523 22 20 21.5523 20 21C20 20.4477 19.5523 20 19 20H5Z",fill:"currentColor"})]})});cG.displayName="ArrowDownToLineIcon";let cZ="mod+shift+d";function cq(e,t){let n=e.match(/\.([a-zA-Z0-9]+)(?:\?|#|$)/);return n&&n[1]?".".concat(n[1].toLowerCase()):t&&({"image/jpeg":".jpg","image/jpg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp"})[t.toLowerCase()]||".jpg"}function c$(e){return!!e&&!!e.isEditable&&!!(0,eg.xU)(e,["image"])&&(0,eg.ee)(e,["image"])}function cK(e){if(!e||!c$(e))return null;let{selection:t}=e.state;if(t instanceof $.nh){let e=t.node;if("image"===e.type.name)return{src:e.attrs.src,alt:e.attrs.alt,title:e.attrs.title}}return null}async function cY(e,t){try{let n=await fetch(e);if(!n.ok)return!1;let r=await n.blob(),l=URL.createObjectURL(r),a=/\.[a-zA-Z0-9]+$/.test(t)?t:t+cq(e,n.headers.get("content-type")||void 0),o=document.createElement("a");return o.href=l,o.download=a,o.style.display="none",document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(l),!0}catch(e){return console.warn("Fetch download failed:",e),!1}}function cX(e,t){try{let n=/\.[a-zA-Z0-9]+$/.test(t)?t:t+cq(e),r=document.createElement("a");return r.href=e,r.download=n,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r),!0}catch(e){return console.warn("Direct download failed:",e),!1}}function cJ(e){try{return window.open(e,"_blank"),!0}catch(e){return console.error("Failed to open image:",e),!1}}
1async function cQ(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"auto";if(!e||!c$(e))return!1;let l=cK(e);if(!(null==l?void 0:l.src))return!1;try{let e=l.src;n&&(e=await n(l.src));let a=window.location.href,o=(0,eg.Jf)(e,a);if("#"===o)return console.error("Invalid or unsafe URL after sanitization"),!1;let i=t||l.alt||l.title||"image-".concat(Date.now());switch(r){case"open":return cJ(o);case"download":if(o.startsWith(window.location.origin)||o.startsWith("data:"))return cX(o,i);return await cY(o,i)||cJ(o);default:if(o.startsWith("data:")||o.startsWith(window.location.origin))return cX(o,i);if(await cY(o,i))return!0;return cJ(o)}}catch(e){console.error("Failed to download image:",e);try{let e=window.location.href,t=(0,eg.Jf)(l.src,e);if("#"!==t)return cJ(t)}catch(e){}return!1}}function c0(e){let{editor:t,hideWhenUnavailable:n=!1,onDownloaded:r,resolveFileUrl:l,downloadMethod:a="auto"}=e||{},{editor:o}=nl(t),i=rQ(),[s,c]=(0,h.useState)(!0),d=c$(o);(0,h.useEffect)(()=>{if(!o)return;let e=()=>{c(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,["image","imageUpload"])&&(!n||c$(t))}({editor:o,hideWhenUnavailable:n}))};return e(),o.on("selectionUpdate",e),()=>{o.off("selectionUpdate",e)}},[o,n]);let u=(0,h.useCallback)(async()=>{if(!o)return!1;let e=cK(o),t=(null==e?void 0:e.alt)||(null==e?void 0:e.title),n=await cQ(o,t,l,a);return n&&(null==r||r(t)),n},[o,r,l,a]);return(0,r0.vC)(cZ,e=>{e.preventDefault(),u()},{enabled:s&&d,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:s,canDownload:d,handleDownload:u,label:"Download image",shortcutKeys:cZ,Icon:cG}}let c1=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]})});c1.displayName="ListIcon";let c2=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]})});c2.displayName="ListOrderedIcon";
1let c4=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]})});c4.displayName="ListTodoIcon";let c5={bulletList:c1,orderedList:c2,taskList:c4},c7={bulletList:"Bullet List",orderedList:"Ordered List",taskList:"Task List"},c3={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function c9(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(!e||!e.isEditable||!(0,eg.HR)(t,e)||(0,eg.ee)(e,["image"]))return!1;if(!n)switch(t){case"bulletList":return e.can().toggleBulletList();case"orderedList":return e.can().toggleOrderedList();case"taskList":return e.can().toggleList("taskList","taskItem");default:return!1}if(!(0,eg.k)(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"]))return!1;switch(t){case"bulletList":return e.can().toggleBulletList()||e.can().clearNodes();case"orderedList":return e.can().toggleOrderedList()||e.can().clearNodes();case"taskList":return e.can().toggleList("taskList","taskItem")||e.can().clearNodes();default:return!1}}function c6(e){let{editor:t,type:n,hideWhenUnavailable:r=!1,onToggled:l}=e,{editor:a}=nl(t),[o,i]=(0,h.useState)(!0),s=c9(a,n),c=function(e,t){if(!e||!e.isEditable)return!1;switch(t){case"bulletList":return e.isActive("bulletList");case"orderedList":return e.isActive("orderedList");case"taskList":return e.isActive("taskList");default:return!1}}(a,n);return(0,h.useEffect)(()=>{if(!a)return;let e=()=>{i(function(e){let{editor:t,type:n,hideWhenUnavailable:r}=e;return!!t&&!!t.isEditable&&!!(0,eg.HR)(n,t)&&(!r||!!t.isActive("code")||c9(t,n))}({editor:a,type:n,hideWhenUnavailable:r}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,n,r]),{isVisible:o,isActive:c,handleToggle:(0,h.useCallback)(()=>{if(!a)return!1;let e=function(e,t){if(!e||!e.isEditable||!c9(e,t))return!1;try{var n,r,l;let a=e.view,o=a.state,i=o.tr;if(o.selection.empty){let t=null==(n=(0,eg.po)({editor:e,node:o.selection.$anchor.node(1)}))?void 0:n.pos;if(!(0,eg.u1)(t))return!1;i=i.setSelection($.nh.create(o.doc,t)),a.dispatch(i),o=a.state}let s=o.selection,c=e.chain().focus();if(s instanceof $.nh){let e=null==(r=s.node.firstChild)?void 0:r.firstChild,t=null==(l=s.node.lastChild)?void 0:l.lastChild,n=e?s.from+e.nodeSize:s.from+1,a=t?s.to-t.nodeSize:s.to-1,i=o.doc.resolve(n),d=o.doc.resolve(a);c=c.setTextSelection($.U3.between(i,d)).clearNodes()}else s.empty||(c=c.clearNodes());if(e.isActive(t))c.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{let e={bulletList:()=>c.toggleBulletList(),orderedList:()=>c.toggleOrderedList(),taskList:()=>c.toggleList("taskList","taskItem")}[t];if(!e)return!1;e().run()}return e.chain().focus().selectTextblockEnd().run(),!0}catch(e){return!1}}(a,n);return e&&(null==l||l()),e},[a,n,l]),canToggle:s,label:c7[n],shortcutKeys:c3[n],Icon:c5[n]}}let c8=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M12 2L11.9962 2.00001C9.22213 2.01045 6.55946 3.0929 4.56496 5.02104L4.55289 5.0329L4 5.58579V3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41422L5.96097 6.45325C7.58329 4.88786 9.7473 4.00897 12.0019 4.00001C13.5835 4.00038 15.1295 4.46955 16.4446 5.34825C17.7602 6.2273 18.7855 7.47673 19.391 8.93854C19.9965 10.4003 20.155 12.0089 19.8463 13.5607C19.5376 15.1126 18.7757 16.538 17.6569 17.6569C16.538 18.7757 15.1126 19.5376 13.5607 19.8463C12.0089 20.155 10.4003 19.9965 8.93853 19.391C7.47672 18.7855 6.22729 17.7602 5.34824 16.4446C4.46919 15.129 4 13.5823 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 13.9778 2.58649 15.9112 3.6853 17.5557C4.78412 19.2002 6.3459 20.4819 8.17317 21.2388C10.0004 21.9957 12.0111 22.1937 13.9509 21.8079C15.8907 21.422 17.6725 20.4696 19.0711 19.0711C20.4696 17.6726 21.422 15.8907 21.8079 13.9509C22.1937 12.0111 21.9957 10.0004 21.2388 8.17317C20.4819 6.34591 19.2002 4.78412 17.5557 3.68531C15.9112 2.5865 13.9778 2.00001 12 2Z",fill:"currentColor"})})});c8.displayName="RotateCcwIcon";let de="mod+r";function dt(e,t){return!!e&&!!e.isEditable&&function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],{selection:n}=e,{empty:r,ranges:l}=n;if(r)return!1;for(let n of l){let r=n.$from.pos,l=n.$to.pos,a=!1;if(e.doc.nodesBetween(r,l,e=>{if(!e.isInline)return!0;for(let n of e.marks)if(!t.includes(n.type.name))return a=!0,!1;return!0}),a)return!0}return!1}(e.state.tr,t)}let dn="mod+/";function dr(e,t,n){if(!e||!e.isEditable||(0,eg.ee)(e,["image"]))return!1;if(t||(0,eg.u1)(n)){if((0,eg.u1)(n)&&n>=0)return!0;if(t)return null!==(0,eg.po)({editor:e,node:t})}return!0}function dl(e){let{shortcutKeys:t=dn}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}let da=(0,h.forwardRef)((e,t)=>{let{editor:n,node:l,nodePos:a,text:o,trigger:i="/",hideWhenUnavailable:s=!1,onTriggered:c,showShortcut:u=!1,onClick:p,children:m,...g}=e,{editor:f}=nl(n),{isVisible:x,canInsert:b,handleSlashCommand:C,label:v,shortcutKeys:y,Icon:w}=function(e){let{editor:t,node:n,nodePos:r,trigger:l="/",hideWhenUnavailable:a=!1,onTriggered:o}=e||{},{editor:i}=nl(t),s=rQ(),[c,d]=(0,h.useState)(!0),u=dr(i,n,r);(0,h.useEffect)(()=>{if(!i)return;let e=()=>{d(function(e){let{editor:t,hideWhenUnavailable:n,node:r,nodePos:l}=e;return!!t&&!!t.isEditable&&(!n||!!t.isActive("code")||dr(t,r,l))}({editor:i,hideWhenUnavailable:a,node:n,nodePos:r}))};return e(),i.on("selectionUpdate",e),()=>{i.off("selectionUpdate",e)}},[i,a,n,r]);let p=(0,h.useCallback)(()=>{if(!i)return!1;let e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if(!e||!e.isEditable||!dr(e,n,r))return!1;try{if(null!=n||(0,eg.u1)(r)){let l=(0,eg.po)({editor:e,node:n||void 0,nodePos:r||void 0});if(!l)return!1;let a="paragraph"===l.node.type.name&&0===l.node.content.size,o=a?l.pos:l.pos+l.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,o,o));let i=t.length+1,s=a?l.pos+i:l.pos+l.node.nodeSize+i;return e.commands.focus(s),!0}let{$from:l}=e.state.selection,a=l.node(),o=0===a.textContent.length,i=0===l.parentOffset,s=0===l.depth;if(!o||!i){let n=s?e.state.doc.content.size:l.after();return e.chain().insertContentAt(n,{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}return e.chain().insertContent({type:"text",text:t}).focus().run()}catch(e){return!1}}(i,l,n,r);return e&&(null==o||o(l)),e},[i,l,n,r,o]);return(0,r0.vC)(dn,e=>{e.preventDefault(),p()},{enabled:c&&u,enableOnContentEditable:!s,enableOnFormTags:!0},[c,u,p]),{isVisible:c,handleSlashCommand:p,canInsert:u,label:"Insert block",shortcutKeys:dn,trigger:l,Icon:ew.uI}}({editor:f,node:l,nodePos:a,trigger:i,hideWhenUnavailable:s,onTriggered:c}),j=(0,h.useCallback)(e=>{null==p||p(e),e.defaultPrevented||C()},[C,p]);return x?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":v,tooltip:v,onClick:j,...g,ref:t,children:null!=m?m:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{className:"tiptap-button-icon"}),o&&(0,r.jsx)("span",{className:"tiptap-button-text",children:o}),u&&(0,r.jsx)(dl,{shortcutKeys:y})]})}):null});da.displayName="SlashCommandTriggerButton";let di=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M3 4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V7C21 7.55228 20.5523 8 20 8C19.4477 8 19 7.55228 19 7V5H13V19H15C15.5523 19 16 19.4477 16 20C16 20.5523 15.5523 21 15 21H9C8.44772 21 8 20.5523 8 20C8 19.4477 8.44772 19 9 19H11V5H5V7C5 7.55228 4.55228 8 4 8C3.44772 8 3 7.55228 3 7V4Z",fill:"currentColor"})})});di.displayName="TypeIcon";let ds="mod+alt+0";function dc(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return!!e&&!!e.schema.nodes.paragraph&&(t?!!(0,eg.k)(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&(e.can().setNode("paragraph")||e.can().clearNodes()):e.can().setNode("paragraph"))}function dd(e){let{editor:t,hideWhenUnavailable:n=!1,onToggled:r}=e||{},{editor:l}=nl(t),a=rQ(),[o,i]=(0,h.useState)(!0),s=dc(l),c=!!l&&l.isActive("paragraph");(0,h.useEffect)(()=>{if(!l)return;let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.HR)("paragraph",t)&&(!n||!!t.isActive("code")||dc(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]);let d=(0,h.useCallback)(()=>{if(!l)return!1;let e=function(e){if(!e||!e.isEditable||!dc(e))return!1;try{var t,n,r;let l=e.view,a=l.state,o=a.tr;if(a.selection.empty){let n=null==(t=(0,eg.po)({editor:e,node:a.selection.$anchor.node(1)}))?void 0:t.pos;if(!(0,eg.u1)(n))return!1;o=o.setSelection($.nh.create(a.doc,n)),l.dispatch(o),a=l.state}let i=a.selection,s=e.chain().focus();if(i instanceof $.nh){let e=null==(n=i.node.firstChild)?void 0:n.firstChild,t=null==(r=i.node.lastChild)?void 0:r.lastChild,l=e?i.from+e.nodeSize:i.from+1,o=t?i.to-t.nodeSize:i.to-1,c=a.doc.resolve(l),d=a.doc.resolve(o);s=s.setTextSelection($.U3.between(c,d)).clearNodes()}else i.empty||(s=s.clearNodes());return e.isActive("paragraph")||s.setNode("paragraph").run(),e.chain().focus().selectTextblockEnd().run(),!0}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]);return(0,r0.vC)(ds,e=>{e.preventDefault(),d()},{enabled:o&&s,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:o,isActive:c,handleToggle:d,canToggle:s,label:"Text",shortcutKeys:ds,Icon:di}}var du=n(80319);n(15025);let dp=()=>{let e=dd(),t=cW({level:1}),n=cW({level:2}),r=cW({level:3}),l=c6({type:"bulletList"}),a=c6({type:"orderedList"}),o=e=>({icon:e.Icon,label:e.label,onClick:e.handleToggle,disabled:!e.canToggle,isActive:e.isActive}),i=[o(e),...[t,n,r].map(o),o(l),o(a)];return i.every(e=>e.disabled)?null:i},dh=e=>{let{icon:t,label:n,onClick:l,disabled:a=!1,isActive:o=!1,shortcutBadge:i}=e;return(0,r.jsxs)(rA,{render:(0,r.jsx)(d.$n,{"data-style":"ghost","data-active-state":o?"on":"off"}),onClick:l,disabled:a,children:[(0,r.jsx)(t,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:n}),i]})},dm=e=>{let{icon:t,label:n,children:l}=e,[a,o]=(0,h.useState)(!1);return(0,r.jsx)(rj,{open:a,onOpenChange:o,placement:"right",trigger:(0,r.jsx)(rA,{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),render:(0,r.jsx)(rk,{render:(0,r.jsxs)(d.$n,{"data-style":"ghost",children:[(0,r.jsx)(t,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:n}),(0,r.jsx)(rX,{}),(0,r.jsx)(nF,{className:"tiptap-button-icon"})]})})}),children:(0,r.jsx)(rI,{onMouseLeave:()=>o(!1),portal:!0,children:(0,r.jsx)(n9,{children:l})})})},dg=()=>{let e=dp(),{canReset:t,handleResetFormatting:n,label:l,Icon:a}=function(e){let{editor:t,preserveMarks:n,hideWhenUnavailable:r=!1,onResetAllFormatting:l}=e||{},{editor:a}=nl(t),o=rQ(),[i,s]=(0,h.useState)(!0),c=dt(a,n);(0,h.useEffect)(()=>{if(!a)return;let e=()=>{s(function(e){let{editor:t,hideWhenUnavailable:n,preserveMarks:r}=e;return!!t&&!!t.isEditable&&(!n||!!t.isActive("code")||dt(t,r))}({editor:a,hideWhenUnavailable:r,preserveMarks:n}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,r,n]);let d=(0,h.useCallback)(()=>{if(!a)return!1;let e=function(e,t){if(!e||!e.isEditable)return!1;try{let{view:n,state:r}=e,{tr:l}=r,a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],{selection:n}=e,{empty:r,ranges:l}=n;return r||l.forEach(n=>{let r=n.$from.pos,l=n.$to.pos;e.doc.nodesBetween(r,l,(n,r)=>!n.isInline||(n.marks.forEach(l=>
1{t.includes(l.type.name)||e.removeMark(r,r+n.nodeSize,l.type)}),!0))}),e}(l,t);return n.dispatch(a),e.commands.focus(),!0}catch(e){return!1}}(a,n);return e&&(null==l||l()),e},[a,l,n]);return(0,r0.vC)(de,e=>{e.preventDefault(),d()},{enabled:i&&c,enableOnContentEditable:!o,enableOnFormTags:!0}),{isVisible:i,handleResetFormatting:d,canReset:c,label:"Reset formatting",shortcutKeys:de,Icon:c8}}({hideWhenUnavailable:!0,preserveMarks:["inlineThread"]});return e||t?(0,r.jsxs)(r.Fragment,{children:[e&&(0,r.jsx)(dm,{icon:co,label:"Turn Into",children:(0,r.jsxs)(rN,{children:[(0,r.jsx)(rS,{children:"Turn into"}),e.map(e=>(0,r.jsx)(dh,{...e},e.label))]})}),t&&(0,r.jsx)(dh,{icon:a,label:l,disabled:!t,onClick:n}),(0,r.jsx)(rR,{orientation:"horizontal"})]}):null},df=()=>{let{canFitToWidth:e,handleFitToWidth:t,label:n,Icon:l}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{editor:t,hideWhenUnavailable:n=!1,onWidthAdjusted:r}=e,{editor:l}=nl(t),a=function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,cs)&&(!n||cc(t))}({editor:l,hideWhenUnavailable:n}),o=cc(l);return{isVisible:a,canFitToWidth:o,handleFitToWidth:(0,h.useCallback)(()=>{let e=function(e){let{editor:t}=e;if(!cc(t)||!t)return!1;try{return function(e){if(!cc(e)||!e)return!1;try{let t=e$(e);if(!t)return!1;let n=e.view.dom,r=getComputedStyle(n),l=parseFloat(r.paddingLeft)||0,a=parseFloat(r.paddingRight)||0,o=n.clientWidth-l-a,i=t.map.width;if(0===i)return!1;let s=0;s=Math.floor((o-i-8)/i);let c=Math.max(s,35),d=e.state.tr;return t.node.descendants((e,n)=>{if("tableCell"===e.type.name||"tableHeader"===e.type.name){let r=t.start+n,l=e.attrs.colspan||1,a=Array(l).fill(c);d.setNodeMarkup(r,void 0,{...e.attrs,colwidth:a})}}),d.docChanged&&e.view.dispatch(d),!0}catch(e){return console.error("Error setting table auto width:",e),!1}}(t)}catch(e){return console.error("Error adjusting table width:",e),!1}}({editor:l});return e&&(null==r||r()),e},[l,r]),label:"Fit to width",Icon:ci}}({hideWhenUnavailable:!0}),a=rB({resetAttrs:!0});return(0,r.jsxs)(r.Fragment,{children:[e&&(0,r.jsx)(dh,{icon:l,label:n,disabled:!e,onClick:t}),a.canClearRowColumnContent&&(0,r.jsx)(dh,{icon:a.Icon,label:"Clear all contents",disabled:!a.canClearRowColumnContent,onClick:a.handleClear})]})},dx=()=>{let{canDownload:e,handleDownload:t,label:n,Icon:l}=c0({hideWhenUnavailable:!0});return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(dh,{icon:l,label:n,disabled:!e,onClick:t}),(0,r.jsx)(rR,{orientation:"horizontal"})]}):null},db=()=>{let{handleDuplicate:e,canDuplicate:t,label:n,Icon:l}=cL(),{handleCopyToClipboard:a,canCopyToClipboard:o,label:i,Icon:s}=cj();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(rN,{children:[(0,r.jsx)(dh,{icon:l,label:n,onClick:e,disabled:!t,shortcutBadge:(0,r.jsx)(cD,{})}),(0,r.jsx)(dh,{icon:s,label:i,onClick:a,disabled:!o,shortcutBadge:(0,r.jsx)(cI,{})})]}),(0,r.jsx)(rR,{orientation:"horizontal"})]})},dC=()=>{let{handleAiAsk:e,canAiAsk:t,Icon:n}=cg();return t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rN,{children:t&&(0,r.jsx)(dh,{icon:n,label:"Ask AI",onClick:e,shortcutBadge:(0,r.jsx)(cx,{})})}),(0,r.jsx)(rR,{orientation:"horizontal"})]}):null},dv=()=>{let{handleDeleteNode:e,canDeleteNode:t,label:n,Icon:l}=cS();return(0,r.jsx)(rN,{children:(0,r.jsx)(dh,{icon:l,label:n,onClick:e,disabled:!t,shortcutBadge:(0,r.jsx)(cT,{})})})},dy=e=>{let{editor:t,withSlashCommandTrigger:n=!0,mobileBreakpoint:l=768,...a}=e,{editor:o}=nl(t),{aiGenerationActive:i,isDragging:s}=aN(o),c=rQ("max",l),[u,p]=(0,h.useState)(!1),[m,g]=(0,h.useState)(null),[f,x]=(0,h.useState)(-1),b=(0,h.useCallback)(e=>{e.node&&g(e.node),x(e.pos)},[]);(0,h.useEffect)(()=>{o&&(o.commands.setLockDragHandle(u),o.commands.setMeta("lockDragHandle",u))},[o,u]);let C=(0,h.useMemo)(()=>({middleware:[(0,t8.cY)(e=>{let{rects:t}=e,n=t.reference.height,r=t.floating.height;return{mainAxis:20,crossAxis:n>40?0:n/2-r/2}})]}),[]),v=(0,h.useCallback)(()=>{o&&o.commands.setMeta("hideDragHandle",!0)},[o]),y=(0,h.useCallback)(()=>{o&&o.commands.setIsDragging(!0)},[o]),w=(0,h.useCallback)(()=>{o&&(o.commands.setIsDragging(!1),setTimeout(()=>{o.view.dom.blur(),o.view.focus()},0))}
1,[o]);if(!o)return null;let j=no(o);return(0,r.jsx)("div",{style:{"--drag-handle-main-axis-offset":"".concat(20,"px")},children:(0,r.jsx)(du.t,{editor:o,onNodeChange:b,computePositionConfig:C,onElementDragStart:y,onElementDragEnd:w,...a,children:(0,r.jsxs)(d.e2,{orientation:"vertical",style:{...i||c||nc(o)?{opacity:0,pointerEvents:"none"}:{},...s?{opacity:0}:{}},children:[(0,r.jsx)(rj,{open:u,onOpenChange:p,placement:"left",trigger:(0,r.jsx)(rk,{render:(0,r.jsx)(d.$n,{"data-style":"ghost",tabIndex:-1,tooltip:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{children:"Click for options"}),(0,r.jsx)("div",{children:"Hold for drag"})]}),"data-weight":"small",style:{cursor:"grab",...u?{pointerEvents:"none"}:{}},onMouseDown:()=>ca(o,f),className:"border-gray-4 border-solid border",children:(0,r.jsx)(ew.ko,{className:"tiptap-button-icon"})})}),children:(0,r.jsxs)(rI,{onClose:v,autoFocusOnHide:!1,preventBodyScroll:!0,portal:!0,children:[(0,r.jsx)(n8,{style:eg.X6}),(0,r.jsxs)(n9,{style:{minWidth:"15rem"},children:[(0,r.jsxs)(rN,{children:[(0,r.jsx)(rS,{children:j}),(0,r.jsx)(lu,{}),(0,r.jsx)(rM,{}),(0,r.jsx)(df,{}),(0,r.jsx)(dg,{}),(0,r.jsx)(dx,{})]}),(0,r.jsx)(db,{}),(0,r.jsx)(dC,{}),(0,r.jsx)(dv,{})]})]})}),n&&(0,r.jsx)(da,{node:m,nodePos:f,"data-weight":"small",className:"mt-1 border-gray-4 border-solid !border"})]})})})},dw=e=>{let{editor:t,floatingOptions:n,selector:l="tiptap-suggestion-menu",children:a,maxHeight:o=384,pluginKey:i=o6.X3,...s}=e,{editor:c}=nl(t),[d,u]=(0,h.useState)(!1),[p,m]=(0,h.useState)(null),[g,f]=(0,h.useState)(null),[x,b]=(0,h.useState)([]),[C,v]=(0,h.useState)(""),[,y]=(0,h.useState)(null),{ref:w,style:j,getFloatingProps:I,isMounted:k}=nr(d,p,1e3,{placement:"bottom-start",middleware:[(0,t8.cY)(10),(0,t8.UU)({mainAxis:!0,crossAxis:!1}),(0,t8.BN)(),(0,t8.Ej)({apply(e){let{availableHeight:t,elements:n}=e;if(n.floating){let e=o?Math.min(o,t):t;n.floating.style.setProperty("--suggestion-menu-max-height","".concat(e,"px"))}}})],onOpenChange(e){e||u(!1)},...n}),E=(0,h.useRef)(s);(0,h.useEffect)(()=>{E.current=s},[s]);let N=(0,h.useCallback)(()=>{u(!1)},[]);(0,h.useEffect)(()=>{if(!c||c.isDestroyed)return;c.state.plugins.find(e=>e.spec.key===i)&&c.unregisterPlugin(i);let e=(0,o6.V0)({pluginKey:i instanceof $.hs?i:new $.hs(i),editor:c,allow(e){try{let t=c.state.doc.resolve(e.range.from);for(let e=t.depth;e>0;e--)if("image"===t.node(e).type.name||"table"===t.node(e).type.name)return!1;return!0}catch(e){return!1}},command(e){var t,n;let{editor:r,range:l,props:a}=e;if(!l)return;let{view:o,state:i}=r,{selection:s}=i;if(!r.extensionManager.extensions.some(e=>{var t,n;return"mention"===e.name&&(null==(n=e.options)||null==(t=n.suggestion)?void 0:t.char)===E.current.char})){let e=s.$from.pos,t=null==(n=s.$head)?void 0:n.nodeBefore,r=t?o9(e,t,E.current.char):s.$from.start(),l=i.tr.deleteRange(r,e);o.dispatch(l)}let c=o.state.selection.$to.nodeAfter,d=null==c||null==(t=c.text)?void 0:t.startsWith(" "),u={...l};d&&(u.to+=1),a.onSelect({editor:r,range:u,context:a.context})},render:()=>({onStart:e=>{var t;m(null!=(t=e.decorationNode)?t:null),f(()=>e.command),b(e.items),v(e.query),y(e.range),u(!0)},onUpdate:e=>{var t;m(null!=(t=e.decorationNode)?t:null),f(()=>e.command),b(e.items),v(e.query),y(e.range)},onKeyDown:e=>"Escape"===e.event.key&&(N(),!0),onExit:()=>{m(null),f(null),b([]),v(""),y(null),u(!1)}}),...E.current});return c.registerPlugin(e),()=>{c.isDestroyed||c.unregisterPlugin(i)}},[c,i,N]);let S=(0,h.useCallback)(e=>{N(),g&&g(e)},[N,g]),{selectedIndex:T}=oL({editor:c,query:C,items:x,onSelect:S});return k&&d&&c?(0,r.jsx)("div",{ref:w,style:j,...I(),"data-selector":l,className:"tiptap-suggestion-menu",role:"listbox","aria-label":"Suggestions",onPointerDown:e=>e.preventDefault(),children:a({items:x,selectedIndex:T,onSelect:S})}):null},dj=(e,t)=>e.name.localeCompare(t.name),dI=(e,t)=>{let n=e.toLowerCase().trim();return t.name.toLowerCase().includes(n)||t.shortcodes.some(e=>e.toLowerCase().includes(n))||t.tags.some(e=>e.toLowerCase().includes(n))},dk=e=>{let{query:t,emojis:n}=e,r=t.trim();return(r?n.filter(e=>dI(r,e)).slice(0,100):n.slice(0,100)).sort(dj)};n(64187);let dE=e=>{let{emoji:t,isSelected:n,onSelect:l,selector:a}=e,o=(0,h.useRef)(null);return((0,h.useEffect)(()=>{let e=document.querySelector(a);if(!o.current||!n||!e)return;let t=ni(o.current,e);"top"===t?o.current.scrollIntoView(!0):"bottom"===t&&o.current.scrollIntoView(!1)},[n,a]),t)?(0,r.jsxs)(d.$n,{ref:o,"data-style":"ghost","data-active-state":n?"on":"off",onClick:()=>l(t),children:[t.fallbackImage?(0,r.jsx)("img",{className:"tiptap-button-emoji",src:t.fallbackImage,alt:t.name}):(0,r.jsx)("span",{className:"tiptap-button-emoji",children:t.emoji}),(0,r.jsxs)("span",{className:"tiptap-button-text",children:[":",t.name,":"]})]}):null},dN=e=>(0,r.jsx)(dw,{char:":",pluginKey:"emojiDropdownMenu",decorationClass:"tiptap-emoji-decoration",selector:"tiptap-emoji-dropdown-menu",items:dS,...e,children:e=>(0,r.jsx)(dT,{...e})}),dS=async e=>{let t=e.editor.extensionStorage.emoji.emojis||[];return dk({query:e.query,emojis:t}).map(e=>({title:e.name,subtext:e.shortcodes.join(", "),context:e,onSelect:e=>{e.editor&&e.range&&e.context&&e.editor.chain().focus().setEmoji(e.context.name).run()}}))},dT=e=>{let{items:t,selectedIndex:n,onSelect:l}=e,a=(0,h.useMemo)(()=>{let e=[];return t.forEach((t,a)=>{t.context&&e.push((0,r.jsx)(dE,{emoji:t.context,index:a,isSelected:a===n,onSelect:()=>l(t),selector:"[data-selector='tiptap-emoji-dropdown-menu']"},t.title))}),e},[t,n,l]);return a.length?(0,r.jsx)(nh,{style:{maxHeight:"var(--suggestion-menu-max-height)"},children:(0,r.jsx)(nm,{children:(0,r.jsx)(d.e2,{children:a})})}):null};n(59925);let dA=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V5C20 4.44772 19.5523 4 19 4H5ZM22 14.998V5C22 3.34315 20.6569 2 19 2H5C3.34315 2 2 3.34315 2 5V19C2 20.6569 3.34315 22 5 22H5.99781C5.99927 22 6.00073 22 6.00219 22H19C20.6569 22 22 20.6569 22 19V15.002C22 15.0007 22 14.9994 22 14.998ZM20 15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20H19C19.5523 20 20 19.5523 20 19V15.4142ZM9 8C8.44772 8 8 8.44772 8 9C8 9.55228 8.44772 10 9 10C9.55228 10 10 9.55228 10 9C10 8.44772 9.55228 8 9 8ZM6 9C6 7.34315 7.34315 6 9 6C10.6569 6 12 7.34315 12 9C12 10.6569 10.6569 12 9 12C7.34315 12 6 10.6569 6 9Z",fill:"currentColor"})})});dA.displayName="ImageIcon";let dR=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 12C4 11.4477 4.44772 11 5 11H19C19.5523 11 20 11.4477 20 12C20 12.5523 19.5523 13 19 13H5C4.44772 13 4 12.5523 4 12Z",fill:"currentColor"})})});dR.displayName="MinusIcon";let dM=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 5C2 3.34315 3.34315 2 5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5ZM4 5C4 4.44772 4.44772 4 5 4H11V8H4V5ZM4 10H11V14H4V10ZM20 14V10H13V14H20ZM13 16H20V19C20 19.5523 19.5523 20 19 20H13V16ZM11 16V20H5C4.44772 20 4 19.5523 4 19V16H11ZM13 8H20V5C20 4.44772 19.5523 4 19 4H13V8Z",fill:"currentColor"})})});dM.displayName="TableIcon";let dL={ai_ask_button:{title:"Paperpal AI",subtext:"Ask AI to generate content",keywords:["write","ask","generate"],badge:ew.NB,group:""},draft_an_outline:{title:"Draft an outline",subtext:"Draft an outline for your content",keywords:["outline","draft"],badge:ew.eY,group:"Get Started"},continue_writing:{title:"Keep Writing",subtext:"Keep writing from the current position",keywords:["continue","keep","write","continue writing"],badge:ew.xg,group:"Write"},explain_this:{title:"Explain this text",subtext:"Explain from the current position",keywords:["explain","writing","write"],badge:ew.xg,group:"Write"},expand_this:{title:"Expand on this",subtext:"Expand from the current position",keywords:["expand","writing","write"],badge:ew.xg,group:"Write"},cite_a_paper:{title:"Cite a paper",subtext:"Cite a paper for your content",keywords:["cite","paper"],badge:ew.Sh,group:"Research & Cite"},ask_a_research_question:{title:"Ask a research question",subtext:"Ask a research question for your content",keywords:["ask","research","question"],badge:ew.Sh,group:"Research & Cite"},search_for_a_paper:{title:"Search for a paper",subtext:"Search for a paper for your content",keywords:["search","paper"],badge:ew.Sh,group:"Research & Cite"},cite_from_library:{title:"Cite from library",subtext:"Cite from library for your content",keywords:["cite","library"],badge:ew.Sh,group:"Research & Cite"},brainstorm:{title:"Brainstorm",subtext:"Brainstorm your idea",keywords:["brainstorm","idea"],badge:ew.oJ,group:"Templates"},generate_from_document:{title:"Generate from document",subtext:"Generate template from your document",keywords:["generarte","document"],badge:ew.Xu,group:"Templates",hasSubmenu:!0,subMenuItems:[{onSelect:()=>{},name:"template_title",title:"Title",subtext:"Generate title from your document",keywords:["generarte","title"],badge:ew.Xu,group:"Templates"},{onSelect:()=>{},name:"template_abstract",title:"Abstract",subtext:"Generate abstract from your document",keywords:["generarte","abstract"],badge:ew.Mu,group:"Templates"},{onSelect:()=>{},name:"template_keywords",title:"Keywords",subtext:"Generate keywords from your document",keywords:["generarte","keywords"],badge:ew.k5,group:"Templates"},{onSelect:()=>{},name:"template_plain_language_summary",title:"Plain language summary",subtext:"Generate plain language summary from your document",keywords:["generarte","plain","language","summary"],badge:ew.xn,group:"Templates"},{onSelect:()=>{},name:"template_summary",title:"Summary",subtext:"Generate summary from your document",keywords:["generarte","summary"],badge:ew.j2,group:"Templates"},{onSelect:()=>{},name:"template_study_highlights",title:"Study highlights",subtext:"Generate study highlights from your document",keywords:["generarte","study","highlight"],badge:ew.b1,group:"Templates"}]},more_templates:{title:"More templates",subtext:"Generate more template from your document",keywords:["generarte","email"],badge:ew.Xu,group:"Templates",hasSubmenu:!0,subMenuItems:[{onSelect:()=>{},name:"template_email",title:"Email",subtext:"Generate email",keywords:["generarte","email"],badge:ew.Rb,group:"Templates"},{onSelect:()=>{},name:"template_cover_letter",title:"Cover letter",subtext:"Generate abstract from your cover letter",keywords:["generarte","cover","letter"],badge:ew.Rb,group:"Templates"},{onSelect:()=>{},name:"template_enquiry_about_status",title:"Enquiry about status",subtext:"Generate enquiry",keywords:["generarte","enquiry","status"],badge:ew.Rb,group:"Templates"},{onSelect:()=>{},name:"template_ask_for_an_extension",title:"Ask for an extension",subtext:"Generate as for extension",keywords:["generarte","ask","extension"],badge:ew.Rb,group:"Templates"},{onSelect:()=>{},name:"template_resubmit_a_revision",title:"Resubmit a revision",subtext:"Generate revision resubmission",keywords:["generarte","revision","resubmission"],badge:ew.Rb,group:"Templates"},{onSelect:()=>{},name:"template_withdraw_the_paper",title:"Withdraw the paper",subtext:"Generate withdrawal paper",keywords:["generarte","withdraw","paper"],badge:ew.Rb,group:"Templates"}]},virtual_coach:{title:"Review document with AI",subtext:"Review your content",keywords:["review","document","ai","virtual","coach"],badge:ew.oJ,group:"Virtual Coach"},text:{title:"Text",subtext:"Regular text paragraph",keywords:["p","paragraph","text"],badge:di,group:"Format"},heading_1:{title:"Heading 1",subtext:"Top-level heading",keywords:["h","heading1","h1"],badge:cP,group:"Format"},heading_2:{title:"Heading 2",subtext:"Key section heading",keywords:["h2","heading2","subheading"],badge:cB,group:"Format"},heading_3:{title:"Heading 3",subtext:"Subsection and group heading",keywords:["h3","heading3","subheading"],badge:cz,group:"Format"},bullet_list:{title:"Bullet List",subtext:"List with unordered items",keywords:["ul","li","list","bulletlist","bullet list"],badge:c1,group:"Format"}
1,ordered_list:{title:"Numbered List",subtext:"List with ordered items",keywords:["ol","li","list","numberedlist","numbered list"],badge:c2,group:"Format"},table:{title:"Table",subtext:"Insert a table",aliases:["table","insertTable"],badge:dM,group:"Insert"},image:{title:"Image",subtext:"Resizable image with caption",keywords:["image","imageUpload","upload","img","picture","media","url"],badge:dA,group:"Insert"},divider:{title:"Separator",subtext:"Horizontal line to separate content",keywords:["hr","horizontalRule","line","separator"],badge:dR,group:"Insert"}},dD=e=>{let t=e.chain().focus(),n=lr({editor:e});null!==n&&t.setNodeSelection(n),t.run();let{state:r}=e,{selection:l}=r,{to:a}=l,o=(0,r8.f)(r.doc,0,a);return o.length>500?"...".concat(o.slice(-500)):o},d_=e=>{let{handleRoute:t,executeWriteCommand:n}=e;return{ai_ask_button:{check:e=>(0,eg.xU)(e,["ai","aiAdvanced"]),action:e=>{let{editor:t}=e,n=t.chain().focus(),r=lr({editor:t});null!==r&&n.setNodeSelection(r),n.run(),t.chain().blur().aiGenerationShow().focus().run()}},continue_writing:{check:e=>{let{hasContent:t}=lt(e);return(0,eg.xU)(e,["ai","aiAdvanced"])&&t},action:e=>{let{editor:t}=e,r=dD(t);n({command:aQ.sO.KEEP_WRITING,text:r})}},explain_this:{check:e=>{let{hasContent:t}=lt(e);return(0,eg.xU)(e,["ai","aiAdvanced"])&&t},action:e=>{let{editor:t}=e,r=dD(t);n({command:aQ.sO.EXPLAIN_THIS,text:r})}},expand_this:{check:e=>{let{hasContent:t}=lt(e);return(0,eg.xU)(e,["ai","aiAdvanced"])&&t},action:e=>{let{editor:t}=e,r=dD(t);n({command:aQ.sO.EXPAND_ON_THIS,text:r})}},draft_an_outline:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Outlines")}},cite_a_paper:{check:e=>(0,eg.HR)("paragraph",e),action:e=>{let{editor:t}=e,{view:n}=t,{from:r}=n.state.selection;t.chain().focus().insertContent("@").run(),n.dispatch(n.state.tr.setSelection($.U3.create(n.state.doc,r,r+1)))}},ask_a_research_question:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("search")}},search_for_a_paper:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("search-via-doi")}},cite_from_library:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("library-manager")}},brainstorm:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("brainstorm")}},generate_from_document:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{}},template_title:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Title")}},template_abstract:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Abstract")}},template_keywords:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Keywords")}},template_plain_language_summary:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Plain language summary")}},template_summary:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Summary")}},template_study_highlights:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Study highlights")}},more_templates:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{}},template_email:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Email")}},template_cover_letter:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Write a cover letter")}},template_enquiry_about_status:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Enquire about status")}},template_ask_for_an_extension:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Ask for an extension")}},template_resubmit_a_revision:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Resubmit a revision")}},template_withdraw_the_paper:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("Withdraw the paper")}},virtual_coach:{check:e=>(0,eg.HR)("paragraph",e),action:()=>{null==t||t("ai-review")}},text:{check:e=>(0,eg.HR)("paragraph",e),action:e=>{let{editor:t}=e;t.chain().focus().setParagraph().run()}},heading_1:{check:e=>(0,eg.HR)("heading",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleHeading({level:1}).run()}},heading_2:{check:e=>(0,eg.HR)("heading",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleHeading({level:2}).run()}},heading_3:{check:e=>(0,eg.HR)("heading",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleHeading({level:3}).run()}},bullet_list:{check:e=>(0,eg.HR)("bulletList",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleBulletList().run()}},ordered_list:{check:e=>(0,eg.HR)("orderedList",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleOrderedList().run()}},task_list:{check:e=>(0,eg.HR)("taskList",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleTaskList().run()}},quote:{check:e=>(0,eg.HR)("blockquote",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleBlockquote().run()}},code_block:{check:e=>(0,eg.HR)("codeBlock",e),action:e=>{let{editor:t}=e;t.chain().focus().toggleNode("codeBlock","paragraph").run()}},mention:{check:e=>(0,eg.xU)(e,["mention","mentionAdvanced"]),action:e=>{let{editor:t}=e;return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"@",n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if(!e||!e.isEditable||!function(e,t,n){if(!e||!e.isEditable||(0,eg.ee)(e,["image"]))return!1;if(t||(0,eg.u1)(n)){if((0,eg.u1)(n)&&n>=0)return!0;
1if(t)return null!==(0,eg.po)({editor:e,node:t})}return!0}(e,n,r))return!1;try{let{$from:l}=e.state.selection,a=l.node();if(a.isBlock&&!a.isTextblock)return function(e,t,n,r){if(null!=n||(0,eg.u1)(r)){let l=(0,eg.po)({editor:e,node:n||void 0,nodePos:r||void 0});if(!l)return!1;let a="paragraph"===l.node.type.name&&0===l.node.content.size,o=a?l.pos:l.pos+l.node.nodeSize,i=t.length+1,s=a?l.pos+i:l.pos+l.node.nodeSize+i;return e.chain().insertContentAt(a?l.pos:o,{type:"paragraph",content:[{type:"text",text:t}]}).focus(s).run()}let{$from:l}=e.state.selection;return e.chain().insertContentAt(l.after(),{type:"paragraph",content:[{type:"text",text:t}]}).focus().run()}(e,t,n,r);return function(e,t,n,r){if(null!=n||(0,eg.u1)(r)){let l=(0,eg.po)({editor:e,node:n||void 0,nodePos:r||void 0});if(!l)return!1;let a="paragraph"===l.node.type.name&&0===l.node.content.size,o=a?l.pos:l.pos+l.node.nodeSize;e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,o,o));let i=t.length+1,s=a?l.pos+i:l.pos+l.node.nodeSize+i;return e.commands.focus(s),!0}let{$from:l}=e.state.selection,a=l.node(),o=l.parentOffset>0&&" "!==a.textContent[l.parentOffset-1];return e.chain().insertContent({type:"text",text:o?" ".concat(t):t}).focus().run()}(e,t,n,r)}catch(e){return!1}}(t)}},emoji:{check:e=>(0,eg.xU)(e,["emoji","emojiPicker"]),action:e=>{let{editor:t}=e;return function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:":",r=arguments.length>2?arguments[2]:void 0,l=arguments.length>3?arguments[3]:void 0;if(!e||!e.isEditable||!(t=e)||!t.isEditable||(0,eg.ee)(t,["image"]))return!1;try{let{$from:t}=e.state.selection,a=t.node();if(a.isBlock&&!a.isTextblock){if(null!=r||(0,eg.u1)(l)){let t=(0,eg.po)({editor:e,node:r||void 0,nodePos:l||void 0});if(!t)return!1;let a="paragraph"===t.node.type.name&&0===t.node.content.size,o=t.pos+t.node.nodeSize;return e.chain().insertContentAt(a?t.pos:o,{type:"paragraph",content:[{type:"text",text:n}]}).focus(a?t.pos+2:o+n.length+1).run()}let{$from:t}=e.state.selection;return e.chain().insertContentAt(t.after(),{type:"paragraph",content:[{type:"text",text:n}]}).focus().run()}return function(e,t,n,r){if(null!=n||(0,eg.u1)(r)){let l=(0,eg.po)({editor:e,node:n||void 0,nodePos:r||void 0});if(!l)return!1;let a="paragraph"===l.node.type.name&&0===l.node.content.size,o=l.pos+l.node.nodeSize;return e.view.dispatch(e.view.state.tr.scrollIntoView().insertText(t,a?l.pos:o,a?l.pos:o)),e.commands.focus(a?l.pos+2:o+t.length+1),!0}let{$from:l}=e.state.selection,a=l.node(),o=l.parentOffset>0&&" "!==a.textContent[l.parentOffset-1];return e.chain().insertContent({type:"text",text:o?" ".concat(t):t}).focus().run()}(e,n,r,l)}catch(e){return!1}}(t)}},divider:{check:e=>(0,eg.HR)("horizontalRule",e),action:e=>{let{editor:t}=e;t.chain().focus().setHorizontalRule().run()}},table:{check:e=>(0,eg.HR)("table",e),action:e=>{let{editor:t}=e;t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}},image:{check:e=>(0,eg.HR)("image",e),action:e=>{let{editor:t}=e;t.chain().focus().insertContent({type:"imageUpload"}).run()}}}},dH=e=>{let{config:t,...n}=e,{editor:l}=nl(),{getSlashMenuItems:a}=function(e){let{config:t,editor:n}=e,{updateRoute:r}=(0,aH.G)(),{executeWriteCommand:l}=aG(n),a=(0,h.useCallback)(e=>{setTimeout(()=>{r(e,void 0,!0)},100)},[r]);return{getSlashMenuItems:(0,h.useCallback)(e=>{let n=[],r=(null==t?void 0:t.enabledItems)||Object.keys(dL),o=(null==t?void 0:t.showGroups)!==!1,i=d_({handleRoute:a,executeWriteCommand:l});r.forEach(r=>{let l=i[r],a=dL[r];if(l&&a&&l.check(e)){var s,c,d;let e={onSelect:e=>{let{editor:t}=e;return l.action({editor:t})},...a};"hasSubmenu"in a&&a.hasSubmenu&&"subMenuItems"in a&&a.subMenuItems&&(e.subMenuItems=null!=(d=null==(c=a.subMenuItems)?void 0:c.map(e=>{let t=i[e.name];return{...e,onSelect:t?e=>{let{editor:n}=e;return t.action({editor:n})}:()=>{}}}))?d:[]),(null==t||null==(s=t.itemGroups)?void 0:s[r])?e.group=t.itemGroups[r]:o||(e.group=""),n.push(e)}}),(null==t?void 0:t.customItems)&&n.push(...t.customItems);if(!o)return n.map(e=>({...e,group:""}));let s={};n.forEach(e=>{var t;let n=e.group||"";
1s[n]||(s[n]=[]),null==(t=s[n])||t.push(e)});let c=[];return Object.entries(s).forEach(e=>{let[,t]=e;c.push(...t)}),c},[t,a,l]),config:t}}({config:t,editor:l});return(0,r.jsx)(dw,{char:"/",pluginKey:"slashDropdownMenu",decorationClass:"tiptap-slash-decoration",decorationContent:"Filter...",selector:"tiptap-slash-dropdown-menu",items:e=>{let{query:t,editor:n}=e;return function(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>{var t,r;return!!(e.title.toLowerCase().includes(n)||(null==(t=e.subtext)?void 0:t.toLowerCase().includes(n))||(null==(r=e.keywords)?void 0:r.some(e=>e.toLowerCase().includes(n))))}).sort((e,t)=>{let r=e.title.toLowerCase(),l=t.title.toLowerCase();return r===n&&l!==n?-1:l===n&&r!==n?1:r.startsWith(n)&&!l.startsWith(n)?-1:l.startsWith(n)&&!r.startsWith(n)?1:0}):e}(a(n),t)},...n,children:e=>(0,r.jsx)(dz,{...e,config:t})})},dP=e=>{var t;let{item:n,isSelected:l}=e,[a,o]=(0,h.useState)(!1),i=a5(a,o),s=n.badge;return(0,r.jsx)("div",{ref:i,children:(0,r.jsx)(rj,{open:a,placement:"right",onOpenChange:o,trigger:(0,r.jsx)(rk,{onMouseEnter:()=>{o(!0)},onMouseLeave:()=>o(!1),render:(0,r.jsxs)(d.$n,{"data-style":"ghost","data-active-state":l?"on":"off",type:"button",className:"w-full",id:"inline-".concat(n.title),children:[s&&(0,r.jsx)(s,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text",children:n.title}),(0,r.jsx)(ew.Vj,{className:"tiptap-button-icon-sub"})]})}),children:(0,r.jsx)(rI,{onMouseLeave:()=>o(!1),children:(0,r.jsx)(n9,{children:(0,r.jsx)(rN,{children:null==(t=n.subMenuItems)?void 0:t.map(e=>{let t=e.badge;return(0,r.jsx)(rA,{tabIndex:-1,onClick:t=>{t.preventDefault(),o(!1),e.onSelect(e)},children:(0,r.jsxs)(d.$n,{id:"inline-".concat(e.title),className:"w-full",type:"button","data-style":"ghost",children:[t&&(0,r.jsx)(t,{className:"tiptap-button-icon"}),(0,r.jsx)("span",{className:"tiptap-button-text text-xs",children:e.title})]})},e.title)})})})})})})},dO=e=>{let{item:t,isSelected:n,onSelect:l}=e,a=(0,h.useRef)(null);(0,h.useEffect)(()=>{let e=document.querySelector('[data-selector="tiptap-slash-dropdown-menu"]');if(!a.current||!n||!e)return;let t=ni(a.current,e);"top"===t?a.current.scrollIntoView(!0):"bottom"===t&&a.current.scrollIntoView(!1)},[n]);let o=t.badge;return t.hasSubmenu?(0,r.jsx)(dP,{item:t,isSelected:n}):(0,r.jsxs)(d.$n,{ref:a,"data-style":"ghost",id:"inline-".concat(t.title),"data-active-state":n?"on":"off",onClick:l,className:"w-full",children:[o&&(0,r.jsx)(o,{className:"tiptap-button-icon"}),(0,r.jsx)("div",{className:"tiptap-button-text",children:t.title})]})},dz=e=>{let{items:t,selectedIndex:n,onSelect:l,config:a}=e,o=(0,h.useMemo)(()=>{let e=[];
1if((null==a?void 0:a.showGroups)===!1)return t.forEach((t,a)=>{e.push((0,r.jsx)(dO,{item:t,isSelected:a===n,onSelect:()=>l(t)},"item-".concat(a,"-").concat(t.title)))}),e;let o={};return t.forEach((e,t)=>{var n,r;let l=e.group||"";o[l]||(o[l]={items:[],indices:[]}),null==(n=o[l])||n.items.push(e),null==(r=o[l])||r.indices.push(t)}),Object.entries(o).forEach((t,a)=>{let[o,i]=t;a>0&&e.push((0,r.jsx)(rR,{orientation:"horizontal"},"separator-".concat(a)));let s=i.items.map((e,t)=>{let a=i.indices[t];return(0,r.jsx)(dO,{item:e,isSelected:a===n,onSelect:()=>l(e)},"item-".concat(a,"-").concat(e.title))});"Templates"===o?e.push((0,r.jsxs)("div",{children:[(0,r.jsx)(nf,{children:o}),(0,r.jsx)(r.Fragment,{children:s})]},"group-".concat(a,"-").concat(o))):o?e.push((0,r.jsxs)(ng,{children:[(0,r.jsx)(nf,{children:o}),(0,r.jsx)(d.e2,{children:s})]},"group-".concat(a,"-").concat(o))):e.push(...s)}),e},[t,n,l,null==a?void 0:a.showGroups]);return o.length?(0,r.jsx)(nh,{className:"tiptap-slash-card",style:{maxHeight:"var(--suggestion-menu-max-height)"},children:(0,r.jsx)(nm,{className:"tiptap-slash-card-body",children:o})}):null};var dB=n(13238),dF=n(84129),dV=n(15778);class dU{async initializeDebugFlag(){let e=(0,dF.c)();this.debug=!!await e.getItem(dV.j4)}static getInstance(){return dU.instance||(dU.instance=new dU),dU.instance}enableDebug(){this.debug=!0}disableDebug(){this.debug=!1}async getIsDebugLogEnabled(){return await this.initializeDebugFlag(),this.debug}log(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.debug&&console.log("[PerformanceTracker]",e,...n)}generateMarkerId(e){return[e.featureName,e.subFeature,e.operationType].filter(Boolean).join("_").toLowerCase()}cancel(e){let t=this.generateMarkerId(e);this.cleanupExistingMarker(t),this.log("Cancelled tracking: ".concat(t))}cleanupExistingMarker(e){if(this.activeMarkers.has(e))try{performance.clearMarks("".concat(e,"_start")),performance.clearMarks("".concat(e,"_end")),performance.clearMeasures("perf_".concat(e)),this.activeMarkers.delete(e)}catch(t){this.log("Error cleaning up existing marker ".concat(e,":"),t)}}start(e){let t=this.generateMarkerId(e);this.cleanupExistingMarker(t),performance.mark("".concat(t,"_start")),this.activeMarkers.set(t,e),this.log("Started tracking: ".concat(t))}end(e){let t={featureName:e.featureName,subFeature:e.subFeature,operationType:e.operationType},n=this.generateMarkerId(t),r="".concat(n,"_start"),l="".concat(n,"_end");if(!this.activeMarkers.has(n))return console.warn("No active marker found for: ".concat(n)),null;if(e.detail){let t=dV.bX.safeParse(e.detail);t.success||(console.warn("Invalid measurement details:",t.error),e.detail=void 0)}performance.mark(l);try{let t=performance.measure("perf_".concat(n),{start:r,end:l,detail:{...e.detail}});return performance.clearMarks(r),performance.clearMarks(l),this.activeMarkers.delete(n),this.log("Completed tracking: ".concat(n),e.detail),t}catch(e){return console.error("Error measuring performance for ".concat(n,":"),e),null}}getActiveMeasurements(){return Array.from(this.activeMarkers.values())}clearAll(){performance.clearMarks(),performance.clearMeasures(),this.activeMarkers.clear()}constructor(){this.debug=!1,this.activeMarkers=new Map,this.initializeDebugFlag()}}let dW=null;var dG=n(47817),dZ=n(40403),dq=n(97715),d$=n(23727);let dK=(0,h.createContext)({provider:null,isSynced:!1,ydoc:new dq.JA});dK.Consumer;let dY=()=>{let e=(0,h.useContext)(dK);if(!e)throw Error("useCollab must be used within an CollabProvider");return e},dX=e=>{let{collabToken:t,documentId:n,shouldRunOnPersistence:r,shouldClearTextOnLoad:l=!1,indexedDBName:a}=e,o=(0,h.useRef)(!1),i=(0,h.useRef)(0),s=(0,h.useRef)(!1),c=(0,h.useRef)(!1),d=(0,A.useQueryClient)(),u=function(){if(dW)return dW;let e=dU.getInstance(),t=(0,dF.c)();return dW={startPerformanceTracking:t=>{e.start(t)},endPerformanceTracking:t=>e.end(t),cancelPerformanceTracking:t=>{e.cancel(t)},toggleDebugLog:n=>{try{n?(e.enableDebug(),t.setItem(dV.j4,"true")):(e.disableDebug(),t.removeItem(dV.j4))}catch(e){console.error("Error while toggling debug log for performance tracker",e)}},getIsDebugLogEnabled:async()=>await e.getIsDebugLogEnabled()}}(),[p,m]=(0,h.useState)(null),[g,f]=(0,h.useState)(!1),{editorType:x}=az(),b=(0,h.useMemo)(()=>new dq.JA,[]),{loggedInUserName:C,user:{id:v}}=s8(),y=(0,h.useMemo)(()=>{var e,t;let n=x===et.zR.AiDetectionEditor?null!=(e=d$.env.NEXT_PUBLIC_TIPTAP_DETECTION_REPORT_BASE_URL)?e:"":null!=(t=d$.env.NEXT_PUBLIC_TIPTAP_BASE_URL)?t:"";return(0,dG.E6)()&&(n=n.replace(/^https:\/\//,"wss://")),n},[x]);return(0,h.useEffect)(()=>
1{if(!t||r)return;let e=x===et.zR.DraftEditor||x===et.zR.NotesEditor,l=new dB.d3({baseUrl:"".concat(y,"?shard=").concat(s3(t).name),name:s3(t).name,token:t,document:b,user:e?C:void 0,onSynced:()=>{f(!0)},onConnect:()=>{u.endPerformanceTracking({featureName:dV.SD.TIPTAP,operationType:dV.S5.CONNECTION,detail:{documentId:n}})},onAuthenticationFailed:()=>{console.error("TipTap Authentication Error: Failed to authenticate with collab server")},onDisconnect:e=>{var t,n;u.startPerformanceTracking({featureName:dV.SD.TIPTAP,operationType:dV.S5.CONNECTION}),(null==e||null==(n=e.event)||null==(t=n.reason)?void 0:t.includes("JWT verification failed"))&&(console.error("TipTap JWT verification failed: Failed to verify collab token"),o.current||(o.current=!0,d.invalidateQueries(["tip-tap-editor-token"])))}});return m(l),()=>{b.destroy(),l.destroy()}},[t,C,r,b]),(0,h.useEffect)(()=>{if(r){if(c.current)return;c.current=!0;let e=a||"collaborative-editor-with-indexed-db",t=null;return(async()=>{try{l&&await new Promise((t,n)=>{let r=indexedDB.deleteDatabase(e);r.onsuccess=()=>t(!0),r.onerror=()=>n(r.error)})}catch(e){console.error("Collaborative editor error: failed to clear IndexedDB:",JSON.stringify(e))}(t=new dZ.nS(e,b)).on("synced",()=>{f(!0)}),m(t)})(),()=>{t&&(b.destroy(),t.destroy())}}},[r,l,a,b]),(0,h.useEffect)(()=>{var e;if(p&&!s.current&&(null==(e=p.configuration)?void 0:e.websocketProvider)){let e=setTimeout(()=>{try{p.configuration.websocketProvider.status!==dB.UK.Connected?console.error("TipTap Connection Warning: User not connected to collaboration server after 10 seconds",JSON.stringify({status:p.configuration.websocketProvider.status,synced:p.synced,unsyncedChanges:p.unsyncedChanges})):console.log("TipTap Connection: Successfully connected to collaboration server"),s.current=!0}catch(e){console.error("Error in TipTap connection check:",e)}},1e4);return()=>clearTimeout(e)}},[p]),(0,h.useEffect)(()=>{if(!(i.current>=3)&&p&&!g){i.current+=1;let e=setTimeout(()=>{g||console.error("TipTap Sync Warning: Document not synced with collaboration server after 10 seconds",JSON.stringify({status:p.connect,synced:p.synced,unsyncedChanges:p.unsyncedChanges,userId:v,userName:C}))},15e3);return()=>clearTimeout(e)}},[p,g,v,C]),{provider:p,ydoc:b,isSynced:g}};function dJ(e){let{children:t,documentId:n,collabToken:l,shouldRunOnPersistence:a=!1,shouldClearTextOnLoad:o=!1,indexedDBName:i}=e,{provider:s,ydoc:c,isSynced:d}=dX({collabToken:l,documentId:n,shouldRunOnPersistence:a,shouldClearTextOnLoad:o,indexedDBName:i}),u=(0,h.useMemo)(()=>({ydoc:c,provider:s,isSynced:d,shouldRunOnPersistence:a}),[d,a,s,c]);return(0,r.jsx)(dK.Provider,{value:u,children:t})}var dQ=n(38101);let d0=()=>{let[e,t]=(0,h.useState)(""),[n,r]=(0,h.useState)(!1),l=(0,h.useCallback)(async()=>{try{r(!0);let e=await (0,dQ.g)();t(e)}catch(e){}finally{r(!1)}},[]);return(0,h.useEffect)(()=>
1{l()},[l]),{currentCountry:e,isFetchingCountry:n,refetchCountry:l}},d1=R.z.object({balance:sO.s,submissionId:R.z.number(),synonyms:R.z.array(R.z.string())});R.z.object({submissionId:R.z.number(),data:R.z.array(R.z.object({synonym:R.z.string(),definition:R.z.string()}))});let d2=()=>{let{webApiClient:e}=(0,P.p)();return async function(t,n){return await e.post("/api/v3/synonyms/".concat(t),n).then(d1.parse)}},d4=R.z.object({id:R.z.number(),text:R.z.string(),feedback:R.z.boolean().optional()}),d5=R.z.object({requestId:R.z.string(),submissionId:R.z.number(),balance:sO.s,query:R.z.string().optional(),fileName:R.z.string().optional()}),d7=R.z.object({requestId:R.z.string(),submissionId:R.z.number(),balance:sO.s,query:R.z.string(),fileDetails:R.z.object({totalNumberOfFiles:R.z.number(),totalFileSize:R.z.number(),files:R.z.array(R.z.object({name:R.z.string(),type:R.z.string()}))}),conversationId:R.z.string().optional()});R.z.object({outputTexts:R.z.array(d4),submissionId:R.z.number(),balance:sO.s,query:R.z.string()}),R.z.object({finish_reason:R.z.union([R.z.null(),R.z.literal("stop"),R.z.literal("length"),R.z.undefined()]),is_last_event:R.z.union([R.z.boolean(),R.z.undefined()]),processed_final_text:R.z.union([R.z.string(),R.z.undefined()]),text:R.z.string(),wordCount:R.z.union([R.z.number(),R.z.undefined()])});let d3=R.z.object({finish_reason:R.z.union([R.z.null(),R.z.literal("stop"),R.z.literal("length"),R.z.undefined()]),conversation_id:R.z.string().optional(),request_id:R.z.string().optional(),is_last_event:R.z.union([R.z.boolean(),R.z.undefined()]),processed_final_text:R.z.union([R.z.string(),R.z.undefined()]),text:R.z.string()});var d9=n(47703),d6=n(83087);async function d8(e){var t;let n,{url:r,onError:l,onSuccess:a}=e,o=localStorage.getItem("one-login-auth-token"),i=(0,d6.Q)(r)?(0,d6.M)():{};try{n=await fetch(r,{headers:{Authorization:"Bearer ".concat(o),Accept:"text/event-stream","X-Product":"paperpal-com","X-Host":(0,d9.y)(),...i},credentials:"omit"})}catch(e){l(Error("Auth SSE error: Failed to fetch: ".concat(e)));return}if(!n.ok){let e=await n.text();l(Error("Auth SSE error: HTTP Error: ".concat(n.status," - ").concat(e)));return}let s=null==(t=n.body)?void 0:t.getReader();if(!s)return void l(Error("Auth SSE error: No response body"));let c=new TextDecoder,d="";try{let e=!1;for(;!e;){let{done:t,value:n}=await s.read();if(e=t)break;d+=c.decode(n,{stream:!0});try{let e=d.split(/[\r\n]+/);for(let t of(d=e.pop()||"",e))if(t.startsWith("data:")){let e=t.slice(5).trim();try{a(e)}catch(e){l(Error("Failed to parse SSE JSON:".concat(e))),console.error("Auth SSE error: Failed to parse SSE JSON:",JSON.stringify(e))}}}catch(e){l(Error("Streaming parse error:".concat(e))),console.error("Auth SSE error: Streaming parse error:",JSON.stringify(e))}}}catch(e){l(Error("Network or stream read error: ".concat(e))),console.error("Auth SSE error: Network or stream read error:",JSON.stringify(e))}if(d.startsWith("data:"))try{let e=d.slice(5).trim();a(e)}catch(e){l(Error("Final buffer parse error:".concat(e))),console.error("Auth SSE error: Final buffer parse error:",JSON.stringify(e))}}let ue="".concat("https://edit-api.paperpal.com","/api"),ut=()=>{let e=(0,h.useRef)(void 0),t=(0,h.useRef)({}),{getSynonyms:n}=function(){let e=d2();return{getSynonyms:(0,A.useMutation)({mutationFn:t=>e(t.sessionId,t.input)}).mutateAsync}}(),{getTranslation:r,updateLastUsedLanguage:l}=function(){let{webApiClient:e}=(0,P.p)(),{updateLastUsedLanguage:t}=function(){let e=(0,A.useQueryClient)();return{updateLastUsedLanguage:(0,h.useCallback)(t=>{let n=e=>{if(!e)return e;let n=[...e.supportedLanguages.filter(e=>e!==t)],r=Array.from(new Set([t,...e.recentlyUsed])).slice(0,3);return{...e,supportedLanguages:n,recentlyUsed:r}};e.setQueryData(["language-list"],n),e.setQueryData(["translation-supported-languages"],n)},[e])}}();return{getTranslation:async function(t,n){return e.post("/api/v2/session/".concat(t,"/translate"),n).then(aX.Pu.parse)},updateLastUsedLanguage:t}}(),{fetchRewriteResponse:a,fetchWriteResponse:o}=function(){let{webApiClient:e}=(0,P.p)();return{fetchWriteResponse:async function(t){return e.post("/api/v3/write",t).then(e=>d7.parse(e))},fetchRewriteResponse:async function(t,n,r){let l=r?{...n,source:r}:n;switch(t){case tK.O5.PARAPHRASE:return e.post("/api/v2/paraphrase/rewrite",l).then(d5.parse);case tK.O5.ACADEMIC_TONE:return e.post("/api/v1/paraphrase/academic-tone",l).then(d5.parse);case tK.O5.TRIM:return e.post("/api/v2/paraphrase/trim",l).then(d5.parse);default:return e.post("/api/v2/paraphrase/rewrite",l).then(d5.parse)}},fetchTemplatesResponse:async function(t,n){if(t!==tK.O5.OUTLINES)return void console.warn("Unsupported feature: ".concat(t));{if(!("articleType"in n&&"sessionId"in n&&"subjectArea"in n&&"description"in n||"submissionId"in n))throw Error("Invalid input type for feature: ".concat(t));let r=new FormData;return n.submissionId?r.append("submissionId","".concat(n.submissionId)):(n.file&&r.append("file",n.file),n.description&&r.append("description","".concat(n.description)),r.append("subjectArea","".concat(n.subjectArea)),r.append("articleType","".concat(n.articleType)),r.append("sessionId","".concat(n.sessionId))),n.source&&r.append("source","".concat(n.source)),e.post("/api/v2/generate-outline",r).then(d5.parse)}}}}(),{updateSubscriptionQuery:i}=sB(),{incTranslationsRequested:s}=aM(),{documentId:c,sessionId:d}=g(),u=(0,h.useCallback)(async n=>{var r,l;let{option:{textOptions:s,action:u,text:p,editor:h}}=n,m=null==h?void 0:h.storage.uiState;m.requestId=void 0,m.processedFinalText="";let g="complete"===u?tK.vI.KEEP_WRITING:s.tone,f=s.regenerate,x=s.tone?function(e){switch(!0){case tK.Oe.includes(e):return null==e?void 0:e.toLowerCase();case tK.kz.includes(e):switch(e){case tK.vI.TRIM_LESS:return tK.Cm.SLIGHT;case tK.vI.TRIM_MODERATE:return tK.Cm.MODERATE;default:return tK.Cm.SIGNIFICANT}case e===tK.vI.IMPROVE_FLUENCY:return tK.Cm.FLUENCY;case e===tK.vI.SIMPLIFY:return tK.Cm.SIMPLIFY;default:return}}(s.tone):"";if(!f&&"complete"!==u){e.current=void 0;let n=Object.keys(t.current).length>0,r=g in t.current;n&&(r?t.current[g]="":t.current={})}let b=[],C=null!=(r=s.context)?r:[];"complete"===u&&(b=null!=(l=null==C?void 0:C.map(e=>e.citationId).filter(e=>!!e))?l:[]);let v="restructure"===u?tK.O5.ACADEMIC_TONE:"shorten"===u?tK.O5.TRIM:"complete"===u?tK.O5.WRITE:tK.O5.PARAPHRASE,y=tX(g);if(y&&0===Object.keys(t.current).length){let{features:e}=y;
1e.forEach(e=>{void 0===t.current[e]&&(t.current[e]="")})}let w=t.current&&t.current[g]?t.current[g]:e.current,j="complete"===u?await o({sessionId:d,userContext:f?"":p,query:s.tone,userCitationIds:b,conversationId:f?w:void 0,source:tK.UG.INLINE_EDITOR}):await a(v,w?{submissionId:parseInt(w,10),source:tK.UG.INLINE_EDITOR}:{documentId:c,sessionId:d,input:p,source:tK.UG.INLINE_EDITOR,writingMode:x});if(!j)throw console.error("TipTap Error: generateStreamResponse"),Error("Someting went wrong");e.current="".concat(j.submissionId),t.current[g]||(t.current[g]=j.submissionId.toString()),m.requestId=j.requestId;let I=v===tK.O5.WRITE?"".concat(ue,"/v3/write/sse?requestId=").concat(j.requestId):v===tK.O5.TRIM?"".concat(ue,"/v2/trim/sse?requestId=").concat(j.requestId):"".concat(ue,"/v1/gen-ai/sse?requestId=").concat(j.requestId,"&feature=").concat(v),k=new TextEncoder;return new ReadableStream({async start(n){try{await d8({url:I,onError:e=>{console.error("Inline SSE error:",JSON.stringify(e)),m.processedFinalText="",n.error(e)},onSuccess:r=>{try{let a=d3.parse(JSON.parse(r));if(a.text){let e=k.encode(a.text);n.enqueue(e)}if(a.is_last_event||"stop"===a.finish_reason){if(m&&a.processed_final_text&&(m.processedFinalText=a.processed_final_text),"complete"===u){var l;e.current=a.conversation_id,t.current[g]=null!=(l=a.conversation_id)?l:""}i(j.balance),n.close()}return a.text}catch(e){console.error("Error parsing message:",e),n.error(e)}}});try{n.close()}catch(e){}}catch(e){console.error("Stream error:",e),m.processedFinalText="",n.error(e)}}})},[c,a,o,d,i]);return{generatePlainResponse:(0,h.useCallback)(async e=>{let{option:t}=e,{textOptions:{language:a,tone:o},text:c,action:u}=t;if("translate"===u&&a){s();let e=await r(d,{text:c,targetLanguage:a,ignoreHtml:!0,source:tK.UG.INLINE_EDITOR});if(!e)throw Error("Something went wrong");return i(e.balance),l(a),e.target.text}if("simplify"===u&&o){let e=await n({sessionId:d,input:{context:c,selectedWordIndex:JSON.parse(o),source:tK.UG.INLINE_EDITOR}});if(!e)throw Error("Something went wrong");return i(e.balance),e.synonyms.join(et.Fp)}return null},[s,r,d,i,l,n]),generateStreamResponse:u}};function un(e){var t,n,r;return"complete"===e.action?tK.vI.KEEP_WRITING:"simplify"===e.action?tK.vI.SYNONYMS:null!=(r=null==(n=e.editor.storage.ai.generatedWith)||null==(t=n.options)?void 0:t.tone)?r:e.action}var ur=n(61355),ul=n(7544),ua=n(2028),uo=n(35655),ui=n(11059);n(84413);let us=(0,h.memo)(e=>{let{toggleAiWrittenText:t,isAiWrittenToggleActive:n,onQuestionClick:l}=e,a=(0,h.useCallback)(()=>{null==t||t()},[t]),{t:o}=(0,a7.B)("tip-tap-web-editor-v3");return(0,r.jsx)(i9.h,{tipInfo:"Highlights text generated or edited only by Paperpal AI",sideOffset:0,css:{marginTop:"-8px"},children:(0,r.jsxs)("div",{className:"flex px-4 py-2.5 items-center justify-between text-gray-12 text-sm gap-[4px]",id:"ai-written-toggle",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(om.I,{name:"magnifyingGlassChart",variant:"light"}),(0,r.jsx)("div",{className:"flex flex-col gap-0.25",children:(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"font-medium",children:o("ai_footprint","AI Footprint")}),(0,r.jsx)(uc,{onClick:l,trackingProperties:{CTALabel:"How-footprint-works"},dataId:"how-footprint-works-button",children:(0,r.jsx)(om.I,{name:"faq",variant:"solid",size:"lg"})})]})})]}),(0,r.jsx)(oY.j,{onClick:a,checked:n,trackingProperties:{CTALabel:"AI Footprint Toggle Turned-".concat(n?"Off":"On")}})]})})}),uc=(0,I.I4)(i3.$,{width:20,height:20,color:I.w4.colors.blue12,display:"flex",alignItems:"center",justifyContent:"center",background:"none",boxShadow:"none",padding:0,"&:hover":{background:"none",boxShadow:"none"}});var ud=n(20312),uu=n(86527);let up=e=>{let{documentId:t}=e,{likeOutput:n,dislikeOutput:l,commentOnOutput:a}=ip(),[o,i]=(0,h.useState)(!0);return o?(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsx)("p",{className:"font-medium text-xs/[16px] text-gray-11 italic",children:"Find AI Footprint useful?"}),(0,r.jsx)(ic.G,{onLike:async()=>n(id.GENAI,{feature:tK.A9.Enum.AI_FOOTPRINT,requestId:t||""}),onDislike:async()=>l(id.GENAI,{feature:tK.A9.Enum.AI_FOOTPRINT,requestId:t||""}),onComment:async e=>{let{comment:n,like:r}=e;a({apiparam:id.GENAI,feedback:n,isLike:r,params:{feature:tK.A9.Enum.AI_FOOTPRINT,rating:10*!!r,requestId:t||""}}),i(!1)},isComingOnModal:!0})]}):null},uh=e=>{let{isOpen:t,onClose:n,documentId:l}=e;return(0,r.jsx)(aC.lG,{open:t,setOpen:n,closeOnEscape:!0,css:{borderRadius:(0,i4.D)(12),boxShadow:"10.69px 5.34px 21.38px 10.69px #00000005, 2.67px 2.67px 10.69px 0px #00000014;",maxWidth:"448px",overflowX:"hidden"},children:(0,r.jsxs)("div",{className:"relative pt-6 pb-6 rounded-xl w-full flex flex-col gap-4",children:[(0,r.jsx)(d.$n,{onClick:n,id:"cancel-invite",className:"p-0 absolute top-5 right-6 cursor-pointer text-gray-12 bg-white hover:text-gray-12 hover:bg-transparent focus:bg-transparent active:bg-transparent border-0",children:(0,r.jsx)(ej,{})}),(0,r.jsxs)("div",{className:"flex gap-4 pl-6 pr-4",children:[(0,r.jsx)(ud.E,{height:44,width:32}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold text-base/[21px] text-gray-12",children:"AI Footprint"}),(0,r.jsx)("p",{className:"text-gray-11 font-semibold text-xs/[16px]",children:"Understand how Paperpal assists your writing process."})]})]}),(0,r.jsx)("div",{className:"rounded-xl w-[450px] h-[250px] mx-auto",children:(0,r.jsx)(uu.j,{src:"https://cdn.paperpal.com/assets/lottie-animation/edit/lottie_AI_Footprint.lottie",width:450,height:250})}),(0,r.jsxs)("div",{className:"pl-6 pr-4",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("p",{className:"font-semibold text-gray-12 text-xl/[26px]",children:"How it works"}),(0,r.jsx)(d.$n,{className:" bg-gray-2 pt-2 pb-2 pl-4 pr-4 rounded-xl border-0 outline-0 cursor-pointer hover:bg-gray-3 focus:bg-gray-3 active:bg-gray-3",onClick:()=>window.open("https://www.youtube.com/watch?v=3Afx37wkNKU","_blank"),id:"watch-demo-vi
1deo-button",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("p",{className:"text-gray-12 font-semibold text-sm/[16px]",children:"Watch demo video"}),(0,r.jsx)("img",{src:"https://cdn.paperpal.com/assets/images/features/youtube-logo.svg",alt:"Paperpal Prime",width:34,height:24})]})})]}),(0,r.jsxs)("div",{className:"flex gap-4 items-center mt-2",children:[(0,r.jsx)("p",{className:"h-6 w-6 rounded-full bg-blue-11 flex items-center justify-center px-2 py-1 text-xs text-gray-1 font-semibold",children:"1"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-gray-12 text-sm/[18px] font-semibold",children:"Real time highlighting"}),(0,r.jsx)("p",{className:"text-[10px]/[13px] font-semibold text-gray-11",children:"When Paperpal enhances your text, it's highlighted with subtle blue highlight."})]})]}),(0,r.jsxs)("div",{className:"flex gap-4 items-center mt-[18px]",children:[(0,r.jsx)("p",{className:"h-6 w-6 rounded-full bg-blue-11 flex items-center justify-center px-2 py-1 text-xs text-gray-1 font-semibold",children:"2"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-gray-12 text-sm/[18px] font-semibold",children:"Toggle anytime"}),(0,r.jsx)("p",{className:"text-[10px]/[13px] font-semibold text-gray-11",children:"Turn the footprint view on or off based on your preference."})]})]})]}),(0,r.jsxs)("div",{className:"bg-blue-3 pt-4 pr-4 pb-4 pl-6 gap-2 flex flex-col",children:[(0,r.jsx)("p",{className:"text-base/[21px] font-semibold text-blue-11",children:"Stay in control of your work"}),(0,r.jsx)("p",{className:"text-gray-11 font-medium text-sm/[18px]",children:"AI footprint is not an AI detector, nor does it claim any rights over the content in your document. It's a tool for transparency designed to encourage responsible use of AI."})]}),(0,r.jsxs)("div",{className:"flex justify-between items-center w-full pl-6 pr-4 h-10",children:[(0,r.jsx)(d.$n,{onClick:n,id:"got-it-button",className:" text-sm/[24px] px-11 bg-blue-9 border-0 outline-0 cursor-pointer hover:bg-blue-10 focus:bg-blue-10 active:bg-blue-10 text-white",children:"Got it"}),(0,r.jsx)(up,{documentId:l})]})]})})};var um=n(69119);function ug(){let{isExtension:e,isChromeExtension:t}=(0,og.Gz)();return{getAsset:n=>{if(e&&t){let e=n.startsWith("/")?"assets".concat(n):"assets/".concat(n);return chrome.runtime.getURL(e)}return n}}}var uf=n(98245),ux=n(90597),ub=n(52602),uC=n(6437),uv=n(99640);let uy=()=>{let{t:e}=(0,a7.B)("tip-tap-web-editor-v3");return{Language:e("language","Language"),GenAI:e("gen_ai","Gen AI"),Research:e("research","Research"),ChatPDF:e("chat_pdf","Chat PDF"),Plagiarism:e("plagiarism","Plagiarism")}},uw=()=>{let{t:e}=(0,a7.B)("tip-tap-web-editor-v3"),t=uy();return[{featureTag:t.Language,tipInfo:e("grammar_tip_info","You get 200 free grammar suggestions on the 1st of every month.")},{featureTag:t.GenAI,tipInfo:e("gen_ai_tip_info","You get 5 free uses/day across Gen AI features such as Rewrite, Write, Translate & Templates.")},{featureTag:t.Research,tipInfo:e("research_tip_info","You get 5 free uses/day for science-backed answers and citation suggestions.")},{featureTag:t.ChatPDF,tipInfo:e("chat_pdf_tip_info","You get 5 PDF uploads per month — 50 MB/100 pages per PDF. Prime users get 50x more uploads per month with support for 100 MB/500 pages per PDF.")},{featureTag:t.Plagiarism,tipInfo:e("plagiarism_tip_info","Get similarity range and top sources for 7000 words/month. Refills on 1st of every month.")}]},uj=e=>{let{onClose:t,freeUsesBalance:n,isLanguageExhausted:l,isGenExhausted:a,allExhausted:o,percentageUsed:i,isPlagiarismExhausted:s,isChatPdfFreemiumExhausted:c,isResearchExhausted:d,isCorporateEssential:u}=e,{t:p}=(0,a7.B)("tip-tap-web-editor-v3"),{navigateTo:m}=(0,aH.G)(),g=uw(),f=uy(),x=(0,h.useMemo)(()=>({[f.Language]:p("grammar_display","Grammar"),[f.Research]:p("research","Research & Cite"),[f.Plagiarism]:p("plagiarism","Plagiarism"),[f.GenAI]:p("gen_ai","Gen AI"),[f.ChatPDF]:p("chat_pdf","Chat PDF")}),[p,f]),b=(0,h.useMemo)(()=>({[f.Language]:p("grammar_tip_info","You get 200 free grammar suggestions on the 1st of every month."),[f.Research]:p("research_tip_info","You get 5 free uses/day for science-backed answers and citation suggestions."),[f.Plagiarism]:p("plagiarism_tip_info","Get similarity range and top sources for 7000 words/month. Refills on 1st of every month."),[f.GenAI]:p("gen_ai_tip_info","You get 5 free uses/day across Gen AI features such as Rewrite, Write, Translate & Templates."),[f.ChatPDF]:p("chat_pdf_tip_info","You get 5 PDF uploads per month — 50 MB/100 pages per PDF. Prime users get 50x more uploads per month with support for 100 MB/500 pages per PDF.")}),[p,f]),C=(0,h.useMemo)(()=>u?g.filter(e=>e.featureTag!==f.Language):g,[u,g,f]);return(0,r.jsxs)("div",{className:"relative flex flex-col gap-y-3 rounded-[10px] p-4 shadow-[0px_4px_8px_-6px_#2E559E40] border border-gray-6 w-[min(360px,calc(100vw-24px))]",children:[(0,r.jsx)("button",{className:"w-3 h-4 absolute top-3 right-3 flex items-center text-gray-11 border-none outline-none cursor-pointer p-0 bg-gray-1",onClick:t,id:"close",children:(0,r.jsx)(om.I,{name:"x",variant:"regular"})}),(0,r.jsxs)("div",{className:"flex items-center gap-x-3.5",children:[o?(0,r.jsx)("div",{className:"border-4 border-blue-4 border-solid h-8 w-8 rounded-full flex flex-row justify-center items-center",children:(0,r.jsx)("div",{className:"flex flex-row items-center h-5 w-5 rounded-full text-sm/5 bg-red-9 text-gray-1 font-bold justify-center",children:"!"})}):(0,r.jsx)(uv.A,{size:32,percentage:i}),(0,r.jsxs)("div",{className:"flex flex-col font-sans text-sm/5 text-blue-12",children:[(0,r.jsx)("p",{className:"font-semibold",children:p("you_are_on_paperpal_free_plan","You are on Paperpal Free Plan")}),(0,r.jsx)("p",{className:"font-normal",children:p("with_limited_free_uses","with limited free uses")})]})]}),(0,r.jsx)("div",{className:"border border-solid border-gray-6"}),(0,r.jsxs)("table",{className:"table-auto",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"text-left font-normal text-gray-11 text-sm/6 py-0.5 pl-1.5 ",children:p("all_free_uses","All free uses")}),(0,r.jsx)("th",{className:"text-right font-normal text-gray-11 text-sm/6 py-0.5 pr-1.5 ",children:p("limit","Limit")})]},"header")}),(0,r.jsx)("tbody",{children:C.map(e=>{var t,o;let i=e.featureTag===f.Language&&l||e.featureTag===f.Plagiarism&&s||e.featureTag===f.GenAI&&a||e.featureTag===f.ChatPDF&&c||e.featureTag===f.Research&&d,u=e.featureTag===f.Language?"".concat(n.languageAvailableBalance," / ").concat(n.languageTotalBalance):e.featureTag===f.ChatPDF?"".concat(n.chatPdfFreemiumBalanceAvailable," / ").concat(n.chatPdfFreemiumBalanceTotal):e.featureTag===f.Plagiarism?"".concat(n.plagiarismBalanceAvailable," / ").concat(n.plagiarismBalanceTotal):e.featureTag===f.Research?"".concat(n.researchBalanceAvailable," / ").concat(n.researchBalanceTotal):"".concat(n.genAiBalanceAvailable," / ").concat(n.genAiTotalBalance);return(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{className:"flex gap-x-1 items-center text-left font-medium py-0.5 pl-1.5 ".concat(i?e.featureTag===f.ChatPDF?"text-yellow-10":"text-red-9":"text-blue-12"," text-sm/6"),
1children:[null!=(t=x[e.featureTag])?t:e.featureTag," ",(0,r.jsx)(i9.h,{isCustomStyled:!0,tipInfo:null!=(o=null==b?void 0:b[e.featureTag])?o:e.tipInfo,children:(0,r.jsx)("div",{className:"flex items-center text-gray-11",children:(0,r.jsx)(om.I,{name:"circleInfo",variant:"regular",width:12,height:12})})})]}),(0,r.jsx)("td",{className:"text-right font-medium py-0.5 pr-1.5 ".concat(i?e.featureTag===f.ChatPDF?"text-yellow-10":"text-red-9":"text-blue-12","  text-sm/6"),children:u})]},e.featureTag)})})]}),(0,r.jsx)("div",{className:"border-[1px] border-solid border-gray-6"}),(0,r.jsxs)("div",{className:"flex gap-x-0.5 items-center font-normal  px-3",children:[(0,r.jsx)("img",{alt:"Upgrade",src:"/plans-icon.png",width:16,height:16}),(0,r.jsx)("p",{className:"text-sm/5 text-blue-12",children:p("get_unlimited_with_paperpal_prime","Upgrade to get higher limits")})]}),(0,r.jsx)(uI,{className:"font-sans font-medium text-sm/6 text-center bg-blue-9 text-gray-1 py-0.5 px-4 rounded-md border-none cursor-pointer shadow-[0px_4px_12px_-6px_#004EDF69]",onClick:()=>{(0,uf.ph)(),m("/plans")},id:"see-pricing","data-test-id":"see-pricing",trackingProperties:{CTALabel:"See Pricing",sectionName:"free-uses-dropdown"},children:p("see_pricing","See Pricing")})]})},uI=(0,um.j)((0,I.I4)("button",{})),uk=e=>{let{isMobileWeb:t=!1,disabled:n}=e,[l,a]=(0,h.useState)(!1),o=()=>a(e=>!e),{getAsset:i}=ug(),{t:s}=(0,a7.B)("tip-tap-web-editor-v3"),{navigateTo:c}=(0,aH.G)(),d=(0,u.l)(0,"free-uses-display").data,p=(0,h.useMemo)(()=>{var e;return null!=(e=d&&(null==d?void 0:d.planMachineName)==="corporate-essential")&&e},[d]),m=e=>e?{availableBalance:e.totalBalance<e.usedBalance?0:e.totalBalance-e.usedBalance,totalBalance:e.totalBalance}:{availableBalance:-1,totalBalance:5},{availableBalance:g,totalBalance:f}=(0,h.useMemo)(()=>m(null==d?void 0:d.balance),[d]),{availableBalance:x,totalBalance:b}=(0,h.useMemo)(()=>m(null==d?void 0:d.genAIBalance),[d]),{availableBalance:C,totalBalance:v}=(0,h.useMemo)(()=>m(null==d?void 0:d.researchBalance),[d]),{availableBalance:y,totalBalance:w}=(0,h.useMemo)(()=>m(null==d?void 0:d.chatPdfFreemiumBalance),[d]),{availableBalance:j,totalBalance:k}=(0,h.useMemo)(()=>m(null==d?void 0:d.plagiarismBalance),[d]),E={languageAvailableBalance:g,languageTotalBalance:f,genAiBalanceAvailable:x,genAiTotalBalance:b,chatPdfFreemiumBalanceAvailable:y,chatPdfFreemiumBalanceTotal:w,plagiarismBalanceAvailable:j,plagiarismBalanceTotal:k,researchBalanceAvailable:C,researchBalanceTotal:v},N=E.languageAvailableBalance<=0,S=E.genAiBalanceAvailable<=0,T=E.chatPdfFreemiumBalanceAvailable<=0,A=E.plagiarismBalanceAvailable<=0,R=E.researchBalanceAvailable<=0,M=N&&S&&T&&A&&R,L=E.languageAvailableBalance<E.languageTotalBalance||E.genAiBalanceAvailable<E.genAiTotalBalance||E.chatPdfFreemiumBalanceAvailable<E.chatPdfFreemiumBalanceTotal||E.plagiarismBalanceAvailable<E.plagiarismBalanceTotal||E.researchBalanceAvailable<E.researchBalanceTotal,D=N||S||T||A||R,_=(0,h.useMemo)(()=>D?66:33*!!L,[D,L]);return(null==d?void 0:d.isPrime)?null:(0,r.jsx)(ux.Bc,{delayDuration:0,skipDelayDuration:0,children:(0,r.jsx)(ux.sb,{children:(0,r.jsx)(ux.k$,{css:{all:"initial",pointerEvents:n?"none":"auto"},children:(0,r.jsx)(ub.az,{onClick:()=>!l&&o,onMouseEnter:()=>a(!0),onMouseLeave:()=>{a(!1),document.body.removeAttribute("style")},"data-test-id":"free-uses-modal",children:(0,r.jsxs)(uC.A.Root,{open:l,onOpenChange:o,children:[(0,r.jsx)(uC.A.Anchor,{noGap:!0,children:(0,r.jsxs)("div",{className:"flex gap-x-1 rounded-md items-center text-xs cursor-pointer bg-gray-2 hover:bg-black/5 active:bg-black/5 font-medium mx-0 text-blue-12 font-sans pl-1.5 pr-1 py-1 ml-1 whitespace-nowrap",children:[M?(0,r.jsx)("div",{className:"border-2 border-gray-4 border-solid h-3.5 w-3.5 rounded-full flex flex-row justify-center items-center",children:(0,r.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-red-9"})}):(0,r.jsx)(uv.A,{size:14,percentage:_}),M?"No Free Uses":s("free_uses","Free uses"),(0,r.jsx)(uE,{as:"div",role:"button",className:"font-sans font-medium text-xs bg-blue-9 text-gray-1 p-1 rounded-[4px] border-0",onClick:()=>{(0,uf.ph)(),c("/plans")},trackingProperties:{CTALabel:"Get Unlimited",sectionName:"tip-tap-editor-top-toolbar"},"data-test-id":"get-unlimited-button",children:t?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("img",{alt:"Upgrade",src:i("/plans-icon.png"),width:16,height:16}),s("upgrade","Upgrade")]}):s("get_unlimited_cta","Get Unlimited")})]})}),(0,r.jsx)(uC.A.Popup,{arrowColor:"".concat(I.w4.colors.gray1),align:"end",side:"bottom",avoidCollisions:!0,collisionPadding:12,sideOffset:4,children:(0,r.jsx)(uj,{onClose:()=>a(!1),freeUsesBalance:E,isLanguageExhausted:N,isResearchExhausted:R,isChatPdfFreemiumExhausted:T,isGenExhausted:S,isPlagiarismExhausted:A,allExhausted:M,percentageUsed:_,isCorporateEssential:p})})]})})})})})},uE=(0,um.j)((0,I.I4)("button",{display:"flex",alignItems:"center",gap:2}));function uN(e){let{enabled:t,onClickOutside:n,ref:r}=e;(0,h.useEffect)(()=>
1{if(!t)return;let e=e=>{r.current&&(r.current.contains(e.target)||n())};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[t,r])}var uS=n(38767),uT=n(77503),uA=n(69492);let uR=e=>{var t,n,l,a,o;let{sendInvite:i,isLoading:s,documentId:c,invitedEailLength:u}=e,p=(0,h.useRef)(null),[m,g]=(0,h.useState)(!1),{showToast:f}=(0,z._)(),x=(0,A.useQueryClient)(),[b,C]=(0,h.useState)([]),{t:v}=(0,a7.B)("tip-tap-web-editor-v3"),y=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),w=b.every(y),{register:j,handleSubmit:k,formState:{errors:E},reset:S,setValue:T,getValues:R,setError:M,setFocus:L}=(0,N.mN)({defaultValues:{email:"",accessType:"WRITE"}}),D=e=>{T("email",e),M("email",{type:"manual",message:""})},_=e=>{T("accessType",e),g(!1)};uN({enabled:!0,ref:p,onClickOutside:()=>{g(!1)}});let H=k(async e=>{if(c)try{await i({collaboratorEmail:b.join(","),accessType:e.accessType,documentId:c}),x.invalidateQueries([nS]),f({title:"Invitation sent successfully",color:"success"}),S(),C([])}catch(e){M("email",{type:"manual",message:(0,op.F)(e).errorReason||"Failed to send invitation"}),L("email",{shouldSelect:!1})}}),P=()=>{let e=R("email");e&&(O(e),T("email",""))},O=e=>{let t=e.trim().replace(/,$/,"");t&&!b.includes(t)&&C([...b,t])},B=e=>{C(b.filter((t,n)=>n!==e))},F=e=>{let t=b[e];t&&(C(b.filter((t,n)=>n!==e)),T("email",t,{shouldDirty:!0,shouldValidate:!0}),M("email",{type:"manual",message:""}),L("email",{shouldSelect:!1}))};return(0,r.jsx)("form",{children:(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("span",{className:"absolute inset-y-0 left-0 flex items-center pl-3 text-gray-400",children:(0,r.jsx)(om.I,{name:"Envelope",variant:"regular"})}),(0,r.jsxs)("div",{className:"w-full max-w-xl  border-gray-300 rounded-lg p-2 pl-7 flex flex-wrap gap-1 bg-white border-1 border-solid [&>div:not(.cursor-pointer)]:flex-1",children:[b.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center px-2 py-0.5 rounded-full text-sm ml-1 hover:bg-gray-300 gap-1 cursor-pointer flex-unset ".concat(y(e)?"bg-gray-200 text-gray-800":"bg-red-100 text-red-600 border border-red-400"),onClick:()=>F(t),children:[(0,r.jsx)("span",{children:e}),(0,r.jsx)(d.$n,{type:"button","aria-label":"Remove ".concat(e),className:"appearance-none bg-transparent cursor-pointer inline-flex items-center justify-center w-[14px] h-[14px] p-0 shrink-0 border border-solid border-gray-12 hover:border-gray-11 rounded-full text-gray-12 hover:text-gray-11 leading-none",onClick:e=>{e.stopPropagation(),B(t)},"data-id":"remove-email-".concat(t),children:(0,r.jsx)(ew.gz,{className:"w-[10px] h-[10px]"})})]},t)),(b.length<5-u||!b.length)&&(0,r.jsx)(uA.pd,{error:null==(n=E.email)||null==(t=n.message)?void 0:t.toString(),...j("email",{required:{value:!b.length,message:"This is a required field."}}),type:"email",noError:!0,name:"invite-collaborator",id:"inviteCollaborator",autoComplete:"off",onChange:e=>D(e.target.value),placeholder:v("enter_email_address","Enter email address"),onKeyDown:e=>{let t=R("email");if(["Enter",","," ",";"].includes(e.key))e.preventDefault(),P();else if("Backspace"===e.key&&""===t&&b.length){e.preventDefault();let t=[...b],n=t.pop();C(t),n&&(T("email",n,{shouldDirty:!0,shouldValidate:!0}),L("email",{shouldSelect:!1}))}},onBlur:P,className:"flex-grow min-w-[150px] outline-none border-none text-sm px-2 py-0 shadow-none active:shadow-none focus:shadow-none"})]})]}),(null==(l=E.email)?void 0:l.message)&&(0,r.jsx)("p",{className:"text-red-11 text-xs mt-1",children:null==(o=E.email)||null==(a=o.message)?void 0:a.toString()}),(0,r.jsxs)("div",{className:"mt-4 flex items-center justify-between gap-2",children:[(0,r.jsxs)(uM,{className:"flex-1 flex relative",children:[(0,r.jsxs)(i3.$,{css:{width:"100%",outline:"none",display:"flex",alignItems:"center",justifyContent:"space-between",color:I.w4.colors.gray12,padding:10,fontSize:12,paddingBlock:9,borderRadius:6,backgroundColor:I.w4.colors.gray2,border:"1px solid ".concat(I.w4.colors.gray7)},color:"outlined",fullWidth:!0,onClick:()=>g(!m),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(om.I,{name:"WRITE"===R("accessType")?"penClip":"Eye",variant:"regular"}),"WRITE"===R("accessType")?v("can_edit","Can edit"):"View only"]}),(0,r.jsx)(om.I,{name:"chevronDown",variant:"regular"})]}),m&&(0,r.jsx)("div",{ref:p,children:(0,r.jsx)("div",{className:"w-full absolute z-10 top-[38px] left-0",children:(0,r.jsx)(nh,{className:"py-1",children:(0,r.jsxs)(uT.B8,{css:{fontSize:12,width:"100%",li:{paddingBlock:0,button:{paddingBlock:4,marginBlock:0}},div:{minWidth:1,fontSize:12}},children:[(0,r.jsx)(uT.ck,{children:(0,r.jsxs)(uT.Wj,{onClick:()=>_("WRITE"),children:[(0,r.jsx)(uT.HM,{children:(0,r.jsx)(om.I,{name:"penClip",variant:"regular"})}),(0,r.jsx)(uT.u6,{children:v("can_edit","Can edit")})]})}),(0,r.jsx)(uT.ck,{children:(0,r.jsxs)(uT.Wj,{onClick:()=>_("READ_ONLY"),children:[(0,r.jsx)(uT.HM,{children:(0,r.jsx)(om.I,{name:"Eye",variant:"regular"})}),(0,r.jsx)(uT.u6,{children:"View only"})]})})]})})})})]}),(0,r.jsx)(i3.$,{type:"submit",color:"primary",id:"invite",size:"small",disabled:!b.length||!w||s,onClick:H,children:s?"Sending...":v("send","Send")})]})]})})},uM=(0,I.I4)("div",{"div#option-surface":{display:"none"},"&:hover":{"> div#option-surface":{display:"flex"}}}),uL=e=>{var t,n,l;let{isOpen:a,onClose:o,isOwner:i,documentId:s,collaborators:c}=e,u=(0,h.useRef)(null),{showToast:p}=(0,z._)(),{t:m}=(0,a7.B)("tip-tap-web-editor-v3"),{mutateAsync:g,isLoading:f,modifyCollaborator:x,isModifingCollaborator:b}=function(){let{webApiClient:e}=(0,P.p)();async function t(t){return e.post("/api/v1/document/collaborate",t)}async function n(t){return e.put("/api/v1/document/collaborate",t)}let{mutateAsync:r,isLoading:l}=(0,A.useMutation)({mutationFn:t}),{mutateAsync:a,isLoading:o}=(0,A.useMutation)({mutationFn:n});return{isLoading:l,mutateAsync:r,modifyCollaborator:a,isModifingCollaborator:o}}(),[C,v]=(0,h.useState)(""),y=(0,A.useQueryClient)(),{authState:w}=(0,oa.Z)();uN({enabled:!0,ref:u,onClickOutside:()=>
1{v("")}});let j=e=>{let{collaboratorEmail:t,isReadOnlyAccess:n,isRemoveCollaborator:r}=e;c.length&&y.setQueryData([nS,s],e=>{var l,a;return e?{...e,collaborators:r?null==(l=e.collaborators)?void 0:l.filter(e=>e.email!==t):null==(a=e.collaborators)?void 0:a.map(e=>e.email===t?{...e,isReadOnlyAccess:n}:e)}:e})},k=async(e,t)=>{if(s){try{j({collaboratorEmail:C,isReadOnlyAccess:"READ_ONLY"===e,isRemoveCollaborator:t}),await x({collaboratorEmail:C,accessType:e,documentId:s,isRemoveCollaborator:t}),y.invalidateQueries([nS]),p({title:t?"File access removed successfully":"File access updated successfully",color:"success"})}catch(e){p({title:(0,op.F)(e).errorReason||"Failed to update file access",color:"danger"})}v("")}};return(0,r.jsx)(aC.lG,{isMobileStickyBottom:!0,open:a,closeOnEscape:!f,setOpen:o,css:{borderRadius:6},children:(0,r.jsxs)("div",{className:"bg-white rounded shadow-lg max-w-md w-full p-4 ",children:[(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(om.I,{name:"userGroup",variant:"light"}),(0,r.jsx)("h4",{className:"font-medium",children:i?m("share_document","Share Document"):"Request the owner to share this document"})]}),i?(0,r.jsx)("p",{className:"text-gray-11 text-sm mt-3",children:m("add_people_by_email","Add people by email. Only those you share the document with can view or edit.")}):(0,r.jsx)("p",{className:"text-gray-11 text-sm mt-3",children:"For privacy reasons, only the owner can share a document. \xa0 \xa0 \xa0 \xa0"}),(0,r.jsx)(d.$n,{onClick:o,id:"cancel-invite","aria-label":'Close "Invite Collaboration" modal',className:"!p-0 line-height-1 absolute top-2.5 right-2 cursor-pointer text-gray-11 bg-white hover:text-gray-12 hover:bg-transparent focus:bg-transparent active:bg-transparent border-0",children:(0,r.jsx)(ej,{})})]}),i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(uR,{isLoading:f,sendInvite:g,documentId:s,invitedEailLength:c.length}),(0,r.jsxs)("div",{className:"mt-8",children:[(0,r.jsxs)("div",{className:"flex align-center gap-2 text-gray-11 text-sm justify-between flex-wrap",children:[(0,r.jsx)("h5",{className:"text-blue-12",children:m("shared_with","Shared with")}),(0,r.jsxs)("span",{className:"text-gray-11 text-xs",children:[m("document_upload_1","Up to")," ",5," ",m("document_upload_2","people per document")]})]}),(0,r.jsxs)("div",{className:"mt-3",children:["logged in"===w.name&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-gray-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 w-[70%]",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-blue-8 flex items-center justify-center flex-shrink-0",children:(0,r.jsx)("span",{className:"text-white text-sm font-medium",children:null==(l=w.user)||null==(n=l.email)||null==(t=n.charAt(0))?void 0:t.toUpperCase()})}),(0,r.jsx)("span",{title:w.user.email,className:"text-sm font-medium truncate block",children:w.user.email})]}),(0,r.jsx)("span",{className:"text-xs text-gray-11 font-medium",children:m("owner","Owner")})]}),!!c.length&&c.map((e,t)=>{var n;return(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-gray-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 w-[70%]",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-blue-8 flex items-center justify-center flex-shrink-0",children:(0,r.jsx)("span",{className:"text-white text-sm font-medium",children:null==(n=e.email)?void 0:n.charAt(0).toUpperCase()})}),(0,r.jsx)("span",{title:e.email,className:"text-sm font-medium truncate block",children:e.email})]}),(0,r.jsx)("span",{className:"text-xs text-gray-9",children:(0,r.jsxs)(uD,{className:"flex-1 flex relative",children:[(0,r.jsxs)(d.$n,{className:"flex w-full items-center p-3 text-xs py-0 rounded gap-2 bg-transparent min-w-[120px] justify-end text-gray-11 w-full",onClick:()=>v(e.email),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[C===e.email&&b&&(0,r.jsx)(uS.y,{color:I.w4.colors.blue11,size:12}),e.isReadOnlyAccess?"View only":"Can edit"]}),(0,r.jsx)(om.I,{name:"chevronDown",variant:"regular"})]}),C===e.email&&!b&&(0,r.jsx)("div",{ref:u,children:(0,r.jsx)("div",{className:"w-full min-w-[120px] absolute z-10 ".concat(t>=c.length-2?"top-[-110px]":"top-[18px]","  left-[-60px]"),children:(0,r.jsx)(nh,{className:"py-1",children:(0,r.jsxs)(uT.B8,{css:{fontSize:12,li:{paddingBlock:0,button:{minWidth:120,paddingBlock:4,marginBlock:0}},div:{minWidth:1,fontSize:12,color:I.w4.colors.gray12}},children:[(0,r.jsx)(uT.ck,{children:(0,r.jsxs)(uT.Wj,{onClick:()=>{k("WRITE")},children:[(0,r.jsx)(uT.u6,{children:m("can_edit","Can edit")}),!e.isReadOnlyAccess&&(0,r.jsx)(uT.MZ,{children:(0,r.jsx)(om.I,{name:"check",variant:"regular"})})]})}),(0,r.jsx)(uT.ck,{children:(0,r.jsxs)(uT.Wj,{onClick:()=>{k("READ_ONLY")},children:[(0,r.jsx)(uT.u6,{children:"View only"}),e.isReadOnlyAccess&&(0,r.jsx)(uT.MZ,{children:(0,r.jsx)(om.I,{name:"check",variant:"regular"})})]})}),(0,r.jsx)(uT.ck,{children:(0,r.jsx)(uT.Wj,{onClick:()=>{k(e.isReadOnlyAccess?"READ_ONLY":"WRITE",!0)},children:(0,r.jsx)(uT.u6,{children:"Remove Access"})})})]})})})})]})})]},e.email)})]})]})]})]})})},uD=(0,I.I4)("div",{"div#option-surface":{display:"none"},"&:hover":{"> div#option-surface":{display:"flex"}}});var u_=n(9080);let uH=()=>{let{getCitationsCslResponse:e}=(0,u_.o)();return{migrateCitations:(0,h.useCallback)(async(t,n)=>{let r=[],{state:l}=t.view;if(l.doc.descendants(e=>
1{"paperpal-inline-citation"===e.type.name&&e.attrs.id&&!r.includes(e.attrs.id)&&r.push(e.attrs.id)}),0===r.length){n&&n(!1);return}try{let o=await e({dysonIds:r});if(o){let e=l.tr;l.doc.descendants((t,n)=>{if(t.type.name===a.A.PAPERPAL_INLINE_CITATION&&t.attrs.id){let r=o[t.attrs.id];if(r){let o=l.schema.nodes[a.A.PAPERPAL_CITATION];if(o){let l=o.create({id:t.attrs.id,label:t.attrs.label,citations:r});e.replaceWith(n,n+t.nodeSize,l)}}}}),e.setMeta("addToHistory",!1),t.commands.setContent(e.doc.toJSON()),n&&n(!1)}}catch(e){n&&n(!1),console.error("Citation migration fetch failed:",e)}},[e])}},uP=e=>{try{let t=new Date(e),n=new Date,r=new Date;r.setDate(n.getDate()-1);let l=t.getHours(),a=String(t.getMinutes()).padStart(2,"0"),o=l>=12?"PM":"AM";l%=12,l=l||12;let i=String(l).padStart(2,"0");if(t.toDateString()===n.toDateString())return"Today   •   ".concat(i,":").concat(a," ").concat(o);if(t.toDateString()===r.toDateString())return"Yesterday   •   ".concat(i,":").concat(a," ").concat(o);let s=["January","February","March","April","May","June","July","August","September","October","November","December"][t.getMonth()],c=t.getDate(),d=t.getFullYear();return"".concat(s," ").concat(c,", ").concat(d," ","  •  "," ").concat(i,":").concat(a," ").concat(o)}catch(e){return"Invalid date"}};var uO=n(55367);let uz=e=>{let{title:t,date:n,isActive:l,onClick:a}=e,o=(0,eg.cn)("md:p-4 px-2 py-1 font-medium md:mb-2 mb-1 md:text-sm text-xs md:rounded-xl rounded bg-transparent w-full border-0 cursor-pointer text-gray-12 hover:bg-blue-2 flex text-left flex-col md:gap-2 gap-1",l?"bg-blue-2 text-blue-10":"bg-transparent"),i=(0,eg.cn)("md:text-sm text-xs",l?"text-blue-10":"text-gray-11");return(0,r.jsxs)("button",{"aria-label":t,onClick:a,className:o,children:[t,(0,r.jsx)("span",{className:i,children:uP(n)})]})},uB=(e,t)=>{var n;return e.name?e.name:(t?e.version===(null==(n=t[0])?void 0:n.version):0===e.version)?"Initial version":"Version ".concat(e.version)},uF=(0,h.memo)(e=>{var t,n;let{editor:l,isOpen:o,onClose:i}=e,{formattingExtensions:s}=t1(),{editor:c}=nl(l),{snapshot:{versions:u}}=null!=(t=null==c?void 0:c.storage)?t:{versions:[]},p=null!=(n=null==c?void 0:c.storage.providerExtension.provider)?n:null,m=(0,h.useMemo)(()=>(null==c?void 0:c.storage.collaborationCaret.users.map(e=>({clientId:e.clientId,id:String(e.clientId),name:e.name||"Anonymous",color:e.color||"#000000"})))||[],[null==c?void 0:c.storage.collaborationCaret.users]),{migrateCitations:g}=uH(),[f,x]=(0,h.useState)(!1),[b,C]=(0,h.useState)(!1),[v,y]=(0,h.useState)(-1),w=(0,h.useCallback)(e=>{var t;return e?(null==(t=m.filter(t=>t&&(null==t?void 0:t.name)===e&&(null==t?void 0:t.color))[0])?void 0:t.color)||"#bbf7d0":""},[m]),j=(0,ef.hG)({editable:!1,content:"",immediatelyRender:!1,onContentError:e=>
1{console.error("Error in version control modal",JSON.stringify(null==e?void 0:e.error))},extensions:[...s,ul.Ay.configure({provider:p,useLegacyWrapping:!1}),X,uO.IB.configure({provider:p,mapDiffToDecorations:e=>e.defaultMapDiffToDecorations({...e,attributes:{"data-custom-attribute":"true"}})})]}),I=(0,ef.er)({editor:j,selector:e=>{if(!e.editor)return{isDiffing:!1,users:[]};let t=e.editor.storage.snapshotCompare;return{isDiffing:t.isPreviewing,users:Array.from(t.diffs.reduce((e,t)=>{var n;let{attribution:r}=t;return(null==r?void 0:r.userId)&&(null==(n=r.id)?void 0:n.client)!==void 0&&e.set(r.userId,{userName:r.userId,clientId:r.id.client}),e},new Map).values())}}}),{isDiffing:k,users:E}=(0,h.useMemo)(()=>{var e,t;return{isDiffing:null!=(e=null==I?void 0:I.isDiffing)&&e,users:null!=(t=null==I?void 0:I.users)?t:[]}},[I]),N=(0,h.useMemo)(()=>{var e;return!!u&&u.length>0&&v===(null==(e=u.at(-1))?void 0:e.version)},[v,u]),S=(0,h.useMemo)(()=>{var e;return null!=(e=u.slice().reverse())?e:[]},[u]),T=(0,h.useMemo)(()=>-1===v?null:u.find(e=>e.version===v),[v,u]),A=(0,h.useMemo)(()=>{var e;let t=u.findIndex(e=>e.version===v);if(t<=0)return null;let n=null==(e=u[t-1])?void 0:e.version;return(0,r.jsxs)("div",{className:"text-xs bg-green-100 text-green-10 font-medium md:rounded-xl md:relative absolute top-0 left-0 md:w-[auto] w-full px-4 py-1 md:border-1 border-0 border-solid border-green-10",children:["Comparing Version ",v," & Version ",n]})},[v,u]),R=(0,h.useCallback)(e=>{var t;if(!j)return;j.chain().hideDiff().run(),y(e),C(!0);let n=u.findIndex(t=>t.version===e);if(n<=0&&p)return void(0,uO.cS)({provider:p,fromVersion:e}).then(e=>{let{prevSnapshot:t}=e;return(0,uO.Jt)({snapshot:t,prevSnapshot:t,schema:j.state.schema})}).then(e=>{j.commands.setContent(e.doc.toJSON()),C(!1)}).catch(e=>{console.error("Failed to load initial version:",e),C(!1)});let r=null==(t=u[n-1])?void 0:t.version;if(void 0===r)return void C(!1);j.chain().compareVersions({toVersion:e,fromVersion:r,hydrateUserData:e=>{let{userId:t}=e;return{color:{backgroundColor:"".concat(w(t),"B0"),delete:{color:"#77777",backgroundColor:"".concat(w(t),"50")}}}},onCompare:e=>{if(e.error){console.error("TipTap error in version modal: ".concat(e.error)),C(!1);return}j.commands.showDiff(e.tr),C(!1)}}).run()||C(!1)},[w,j,u,p]),M=(0,h.useCallback)(()=>{i(),y(-1),C(!1),null==j||j.commands.clearContent()},[i,j]),L=(0,h.useCallback)(async()=>{confirm("Are you sure you want to revert to this version? Any changes not saved to a version will be lost.")&&-1!==v&&(x(!0),null==c||c.commands.revertToVersion(v,"Revert to version ".concat(v),"Unsaved changes before revert to ".concat(v)),setTimeout(async()=>{if(c){let{schema:e}=c.state;e.nodes[a.A.PAPERPAL_INLINE_CITATION]&&await g(c),x(!1),i()}},500))},[v,c,i,g]);return(0,h.useEffect)(()=>{if(o&&-1===v&&u.length>0&&j){var e,t;R(null!=(t=null==(e=u.at(-1))?void 0:e.version)?t:0)}},[v,u,o,p,j,R]),(0,h.useEffect)(()=>{if(o&&p){let e=(0,ua.XN)(p,e=>{j&&j.commands.setContent(e)});return()=>{e()}}},[o,p,j]),(0,h.useEffect)(()=>{o||C(!1)},[o]),(0,r.jsx)(aC.lG,{isMobileStickyBottom:!0,open:!0,closeOnEscape:!f,setOpen:i,children:(0,r.jsxs)("div",{className:"bg-white overflow-hidden m-auto  min-h-[90vh] max-h-[90vh] rounded-xl grid grid-cols-4 w-[90vw] max-w-[90vw]  editor-version-modal",children:[(0,r.jsxs)("div",{className:"sidebar-options md:pt-4 pt-8 pb-2 border-0 border-r border-solid border-gray-7 max-h-[90vh] grid grid-rows-[auto_1fr_auto]",children:[(0,r.jsx)("h4",{className:"font-semibold pb-4 md:px-4 px-2 md:text-sm text-xs",children:"Document Timeline"}),(0,r.jsx)("div",{className:"versions-group overflow-y-auto md:px-4 px-2",children:S.map(e=>(0,r.jsx)(uz,{date:e.date,title:uB(e,u),onClick:()=>!b&&R(e.version),isActive:v===e.version},"version_item_".concat(e.version)))})]}),(0,r.jsxs)("div",{className:"col-span-3 md:pt-4 pt-8 pb-2 max-h-[90vh] overflow-hidden relative",children:[b&&(0,r.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-gray-11/10 pointer-events-none",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-white/80 px-3 py-2 shadow-sm border border-solid border-gray-6",children:[(0,r.jsx)(ew.x3,{className:"w-4 h-4 animate-spin text-gray-11"}),(0,r.jsx)("span",{className:"text-xs font-medium text-gray-11",children:"Loading..."})]})}),(0,r.jsxs)("div",{className:"h-full grid grid-rows-[auto_auto_auto_1fr]",children:[(0,r.jsx)("div",{className:"md:px-4 px-2 border-0 border-b border-solid border-gray-7",children:(0,r.jsxs)("div",{className:"flex flex-row items-center justify-between gap-2 md:pb-4 pb-2",children:[T&&(0,r.jsx)("p",{className:"text-gray-11 font-medium md:text-sm text-xs",children:uP(T.date)}),(0,r.jsxs)("div",{className:"flex flex-row  items-center gap-2",children:[A,(0,r.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,r.jsx)(d.$n,{"data-style":"primary",type:"button",disabled:!T||N||f,onClick:L,title:"Restore",children:(0,r.jsx)("span",{className:f?"animate-spin":"",children:f?(0,r.jsx)(ew.x3,{className:"w-3 h-3"}):(0,r.jsx)(ew.El,{className:"w-3 h-3"})})}),(0,r.jsx)(d.$n,{disabled:f,className:"cursor-pointer rounded-full md:text-xs text-sm md:px-2.5 md:py-2 p-1.5 md:relative absolute top-0 right-2 md:right-0 md:bg-gray-11 bg-transparent hover:bg-gray-12 md:text-white text-black hover:text-white border-0",onClick:M,children:(0,r.jsx)(ew.gz,{className:"w-2.5 h-5 font-solid"})})]})]})]})}),k&&(0,r.jsxs)("div",{className:"diff-users",children:[!!E.length&&(0,r.jsx)("span",{className:"text-xs font-medium text-black",children:"Contributors:"}),Array.from(E).map(e=>(0,r.jsxs)("div",{className:"diff-user",children:[(0,r.jsx)("span",{className:"diff-user-color text-xs",style:{backgroundColor:w(String(e.userName))}}),String(e.userName)]},String(e.userName)))]}),(0,r.jsx)("div",{className:"bg-yellow-100 text-center text-xs text-red-10 font-medium  px-4 py-0.5 ",children:"When you restore your document, all citations and references—including their links—will be preserved."}),(0,r.jsx)("div",{className:"overflow-y-auto min-h-0",children:b?(0,r.jsx)("div",{className:"h-full bg-gray-11/10"}):(0,r.jsx)(ef.$Z,{className:"h-full",editor:j})})]})]})]})})});uF.displayName="VersioningModal",n(20800);var uV=n(84500);let uU=e=>{let{errorToast:t}=C(),{downloadDocument:n}={downloadDocument:(0,h.useCallback)(async(e,t,n)=>{try{let r=localStorage.getItem(uV.h),l=await fetch("".concat("https://edit-api.paperpal.com","/api/v2/draft/").concat(t,"/export/").concat(e),{method:"POST",headers:{...{"X-Product":"paperpal-com"},"X-Host":(0,d9.y)(),authorization:"Bearer ".concat(r),"Content-Type":"application/json"},body:n?JSON.stringify(n):JSON.stringify({citations:[]}),credentials:"omit"});if(l.ok){let t=await l.blob(),n=function(e,t){let n=e.get("Content-Disposition"),r=n&&n.match(/filename="(.+)"/);return r&&r[1]?function(e,t){try{let t=e.replace(/\+/g," ");return decodeURIComponent(t)}catch(e){return t}}(r[1],t):t}(l.headers,"file".concat("word"===e?".docx":".pdf")),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=n,a.click(),URL.revokeObjectURL(r)}else throw console.error("Downloading document ",e,t,JSON.stringify(l)),Error("Failed to download document: ".concat(l.status," ").concat(l.statusText))}catch(n){throw console.error("Downloading document ",e,t,JSON.stringify(n)),Error("Failed to download document")}},[])},{isPrime:r,documentId:l}=g(),{exportBiblographyRef:a}=(0,t5.h)(),o=(0,h.useCallback)(()=>setTimeout(()=>
1{null==e||e.chain().focus().undo().run()}),[e]),i=(0,h.useCallback)(()=>setTimeout(()=>{null==e||e.chain().focus().redo().run()}),[e]),s=(0,h.useCallback)(()=>null==e?void 0:e.commands.selectAll(),[e]),c=(0,h.useCallback)(()=>{navigator.clipboard.readText().then(t=>{null==e||e.chain().insertContent(t).focus().run()})},[e]),d=(0,h.useCallback)(()=>{let t=0;null==e||e.chain().command(e=>{let{dispatch:n,tr:r,state:l}=e,{doc:a}=l;return t=a.content.size,!n||(r.insertText(" / ",t-1),n(r))}).focus(t+1).run()},[e]);return{onUndo:o,onRedo:i,onSelectAll:s,onPaste:c,onDownload:(0,h.useCallback)(async e=>{try{await n(e,l,r?null==a?void 0:a.current:void 0)}catch(e){t({message:"Failed to download the document. Please try again."})}},[n,l,r,a,t]),onPaperpalAIClick:d}};var uW=n(96411),uG=n(95500);let uZ={type:"doc",content:[{type:"heading",attrs:{textAlign:"left",level:1},content:[{type:"text",text:"Writing samples to get you started"}]},{type:"paragraph",attrs:{class:null,textAlign:"left"},content:[{type:"text",text:"Digital transformations has revolutionized many sectors, reshaping business models, operational process and customer interaction across many industries and geographical regions in the post-pandemic era (Chen et al., 2022). From the way we book our doctors appointments to how we pay and even how classrooms function, online tools have become embedded in our everyday lives through multi-platform integration, with recent survey data indicating that 87% of consumers now prefer digital interfaces for routine transactions in this post-digital transformation period, further highlighting nontraditional methods (P < 0.001, χ\xb2 = 45.7, df = 3)."}]},{type:"paragraph",attrs:{class:null,textAlign:"left"},content:[{type:"text",text:"Green total factor productivity (GTFP) has emerged as a crucial metric in this context, measuring the efficiency of economic growth while considering environmental factors with statistical significance observed across 15 OECD countries using multi-level modeling approaches (F(2,43) = 8.92, p = 0.004, η\xb2 = 0.29) (Kumar & Singh, 2023; Miller, 2022). GTFP evaluates how effectively an economy or industry utilizes it's resources to generate output while minimizing negative environmental impacts in both post-industrial and non-traditional sectors, thus providing a more holistic assessment of productivity in the context of sustainable development which have been validated through multiple regression analysis using multi-variate techniques (R\xb2 = 0.67, p < 0.001) (Brown & Wilson, 2023)."}]},{type:"paragraph",attrs:{class:null,textAlign:"left"},content:[{type:"text",text:"In this study we checked the affects of Novel Compound X on cellular proliferation rates in HeLa cell cultures over a 72-hour period using multi-well plate configurations, with measurements took at 24-hour intervals using standard MTT assays in post-treatment analysis (Wilson et al., 2023). The treated cells exhibited a dose-dependent response where higher concentrations of the compound resulted in decreased proliferation rates, with statistical significance observed at concentrations above 50 μM in both non-confluent and confluent cell populations (F(3,20) = 8.67, P < 0.01, η\xb2 = 0.57) compared to vehicle controls (Davis & Kumar, 2022)."}]}]},uq=(0,h.createContext)({isOpen:!1,openDrawer:()=>{},closeDrawer:()=>{}}),u$=()=>(0,h.useContext)(uq);var uK=n(44227),uY=n(41177),uX=n(43011),uJ=n(33278);let uQ=()=>({word:{label:"Install MS Word Add-in",link:"https://appsource.microsoft.com/en-us/product/office/wa200001361?exp=kyyw",title:"MS Word Add-in",description:"Write, cite and edit directly in MS Word without any formatting hassles.",ctaLabel:"Install Add-in",statsImage:"https://cdn.paperpal.com/assets/images/user-icon.webp",statistics:[{label:"320k+ downloads"},{label:"5M+ users"}]},google:{label:"Google Docs Add-in",link:"https://workspace.google.com/marketplace/app/paperpal_ai_grammar_checker_and_writing/726869145658"},overleaf:{label:"Chrome Extension",link:"https://chromewebstore.google.com/detail/paperpal-for-overleaf-bet/mhpjgcccinlocgiklkfllehilgmcnimp?utm_source=ext_app_menu",title:"Chat with PDFs as you browse",description:"Chat with PDFs as you browse",ctaLabel:"Add to Chrome",statsImage:"https://cdn.paperpal.com/assets/images/user-icon.webp",statistics:[{label:"320k+ downloads"},{label:"5M+ users"}],bulletPoints:[{bold:"Clip sources to your library",normal:" as you browse"},{bold:"Write in Google Docs, Overleaf",normal:" and more"}]},edge:{label:"Edge Add-on",link:"https://microsoftedge.microsoft.com/addons/detail/paperpal-free-grammar-ch/bklfadmbfhfklnhmgn
1degeooghjbdkpi?utm_source=ext_app_menu",title:"Chat with PDFs as you browse",description:"Chat with PDFs as you browse",ctaLabel:"Add to Edge",statsImage:"https://cdn.paperpal.com/assets/images/user-icon.webp",statistics:[{label:"320k+ downloads"},{label:"5M+ users"}],bulletPoints:[{bold:"Clip sources to your library",normal:" as you browse"},{bold:"Write in Google Docs, Overleaf",normal:" and more"}]}});var u0=n(71382),u1=n(99835),u2=n(45004),u4=n(95559);function u5(e){let{...t}=e;return(0,r.jsx)(u4.bL,{modal:!1,...t})}function u7(e){let{...t}=e;return(0,r.jsx)(u4.ZL,{...t})}n(76705);let u3=(0,h.forwardRef)((e,t)=>{let{...n}=e;return(0,r.jsx)(u4.l9,{onPointerDown:e=>{var t;null==(t=n.onPointerDown)||t.call(n,e),e.stopPropagation()},ref:t,...n})});u3.displayName=u4.l9.displayName,u4.YJ,u4.Pb,u4.z6;let u9=u4.q7,u6=u4.wv;u4.ZP,(0,h.forwardRef)((e,t)=>{let{className:n,portal:l=!0,...a}=e,o=(0,r.jsx)(u4.G5,{ref:t,className:(0,eg.cn)("tiptap-dropdown-menu",n),...a});return l?(0,r.jsx)(u7,{..."object"==typeof l?l:{},children:o}):o}).displayName=u4.G5.displayName;let u8=(0,h.forwardRef)((e,t)=>{let{className:n,sideOffset:l=4,portal:a=!1,...o}=e,i=(0,r.jsx)(u4.UC,{ref:t,sideOffset:l,onCloseAutoFocus:e=>e.preventDefault(),onFocus:e=>e.preventDefault(),className:(0,eg.cn)("tiptap-dropdown-menu",n),...o});return a?(0,r.jsx)(u7,{..."object"==typeof a?a:{},children:i}):i});function pe(e){var t;let{icon:n,label:l,title:a,description:o,ctaLabel:i,statsImage:s,statistics:c,bulletPoints:d,link:u,highlight:p,onInstallClick:h}=e,{t:m}=(0,a7.B)("tip-tap-web-editor-v3"),g=null!=(t=null!=a?a:o)?t:l;return(0,r.jsx)("div",{className:"p-2.5 rounded-md flex flex-col w-ful",children:(0,r.jsxs)("div",{className:"flex p-5 bg-blue-3 rounded-[10px] bg-[url('https://cdn.paperpal.com/assets/images/bg-gradient-blue.webp')] bg-no-repeat bg-[position:top_right] bg-[length:40%] relative",children:[(0,r.jsx)("div",{className:"absolute top-0 left-0 w-full h-full rounded-[10px] bg-[url('https://cdn.paperpal.com/assets/images/bg-gradient-blue.webp')] bg-no-repeat bg-[position:top_right] border border-solid !border-blue-7 bg-[length:40%] scale-[-1] ".concat("glow-pulse"===p?"animate-glow":"")}),(0,r.jsxs)("div",{className:"relative z-1 flex flex-col gap-3 w-full",children:[(0,r.jsxs)("div",{className:"flex gap-2.5 font-semibold text-base text-gray-12 items-center",children:[n,(0,r.jsx)("span",{className:"leading-snug",children:m(g,g)})]}),o&&(!d||0===d.length)&&(0,r.jsx)("div",{className:"text-gray-11 text-xs font-medium",children:m(o,o)}),d&&d.length>0&&(0,r.jsx)("div",{className:"flex flex-col gap-2 my-0.5",children:d.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"shrink-0",children:(0,r.jsx)("path",{d:"M13.3332 4L5.99984 11.3333L2.6665 8",stroke:"#0054F1",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{className:"font-semibold text-gray-12",children:m(e.bold,e.bold)}),(0,r.jsx)("span",{className:"text-gray-11",children:m(e.normal,e.normal)})]})]},t))}),i&&(0,r.jsx)("button",{id:l,type:"button",onClick:e=>{e.stopPropagation(),null==h||h(),iM(u,"_blank")},className:"!p-4 !py-2.5 !text-sm border-0 !font-semibold !text-white hover:!text-white !bg-blue-9 hover:!bg-blue-11 cursor-pointer !rounded-[8px] w-full",children:m(i,i)}),s&&c&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,r.jsx)("img",{src:s,alt:"stats",className:"w-8 h-4 object-contain shrink-0"}),(0,r.jsx)("div",{className:"text-xs font-medium text-gray-12 flex items-center gap-1",children:c.map((e,t)=>(0,r.jsxs)("span",{children:[m(e.label,e.label),t!==c.length-1&&" | "]},t))})]})]})]})})}function pt(e){let{icon:t,label:n,link:l,onItemClick:a}=e,{t:o}=(0,a7.B)("tip-tap-web-editor-v3");return(0,r.jsxs)("button",{type:"button",id:n,onClick:e=>{e.stopPropagation(),null==a||a(),iM(l,"_blank")},className:"!p-3 !py-2.5 !text-xs border-0 !bg-transparent w-full !rounded !justify-start flex items-center gap-2 font-medium text-gray-12 hover:!bg-blue-3 cursor-pointer",children:[t,(0,r.jsx)("span",{className:"flex-1 text-left",children:o(n,n)}),(0,r.jsx)(om.I,{name:"arrowUpRight",variant:"regular"})]})}u8.displayName=u4.UC.displayName;let pn={default:"!bg-gray-2 hover:!bg-black/5 active:!bg-black/5",white:"!bg-white hover:!bg-black/5 active:!bg-black/5 !border !border-solid !border-gray-5"};function pr(e){let{featuredApp:t="word",target:n,featuredCardDescriptionOverride:l,featuredCardHighlight:a="none",open:o,onOpenChange:i,triggerVariant:s="default",nudgeTrackingEnabled:c=!1,nudgeTrackingIntent:u=""}=e,{trackCommonEvent:p}=(0,tu._)(),{t:m}=(0,a7.B)("tip-tap-web-editor-v3"),g=(0,h.useRef)(!1),[f,x]=(0,h.useState)(!1),b=uQ(),C=(0,uJ.y)(),v=null!=n?n:"edge"===C?"edge":"chrome",y="word"!==t,w="edge"===t?"edge":"chrome",j="edge"===w?b.edge:b.overleaf,I="edge"===w?u0.G:u1.v,k="edge"===v?b.edge:b.overleaf,E="edge"===v?u0.G:u1.v,N=null!=l?l:y?j.description:b.word.description,S=y?j.label:b.word.label,T=y?j.link:b.word.link,A=(0,h.useCallback)(()=>c&&1?"nudge":"manual",[c]);(0,h.useEffect)(()=>
1{if(o){x(!0),"nudge"!==A()||g.current||(p({type:"view-to-track-paperpal",intent:u,elementName:"edge"===w?"edge-nudge":"chrome-nudge",sectionName:"apps-dropdown"}),g.current=!0);return}!1===o&&(x(!1),g.current=!1)},[A,u,o,p,w]);let R=(0,h.useCallback)(e=>{if("nudge"===e)return void p({type:"view-to-track-paperpal",intent:u,elementName:"chrome-nudge",sectionName:"apps-dropdown"});p({type:"view-to-track-paperpal",elementName:"apps-dropdown",sectionName:"apps-dropdown"})},[u,p]),M=(0,h.useCallback)(e=>{if("nudge"===A()&&c)return void p({type:"click-to-track-paperpal",intent:u,elementName:"chrome-nudge",CTALabel:e,typeofCTA:"anchor",sectionName:"apps-dropdown"});p({type:"click-to-track-paperpal",elementName:"apps-dropdown",CTALabel:e,typeofCTA:"anchor",sectionName:"apps-dropdown"})},[A,c,u,p]),L=(0,h.useCallback)(e=>{x(e),e?"nudge"===A()?g.current||(R("nudge"),g.current=!0):R("manual"):g.current=!1,null==i||i(e)},[A,i,R]);return(0,r.jsxs)(u5,{open:f,onOpenChange:L,children:[(0,r.jsx)(u3,{asChild:!0,children:(0,r.jsxs)(d.$n,{id:"ms-word-addin",tooltip:m("apps","Apps"),onClick:e=>e.stopPropagation(),className:"... ".concat(pn[s]),children:[y&&(0,r.jsx)("div",{className:"w-5 h-5 p-1 grid place-items-center rounded-full !bg-white border border-solid border-gray-7",children:(0,r.jsx)(u2.J,{})}),(0,r.jsx)("div",{className:"w-5 h-5 p-1 grid place-items-center rounded-full !bg-white border border-solid border-gray-7 ".concat(y?"-ml-5":""),children:y?(0,r.jsx)(I,{width:14}):(0,r.jsx)(u2.J,{})}),m("apps","Apps"),(0,r.jsx)(om.I,{name:"chevronDown",width:16,variant:"regular"})]})}),(0,r.jsx)(u7,{children:(0,r.jsx)(u8,{side:"bottom",align:"start",className:"rounded-md p-1 box-shadow-none border border-gray-200",children:(0,r.jsxs)(nh,{className:"p-0 min-w-[21rem] max-w-[23rem] !rounded-md !border !border-solid !border-blue-6 !shadow-none",children:[(0,r.jsx)(u9,{onClick:e=>{e.stopPropagation(),M(S),iM(T,"_blank")},children:y?(0,r.jsx)(pe,{icon:(0,r.jsx)(I,{width:28,height:28}),label:j.label,title:j.title,description:N,ctaLabel:j.ctaLabel,statsImage:j.statsImage,statistics:j.statistics,bulletPoints:j.bulletPoints,link:j.link,highlight:a,onInstallClick:()=>M(S)}):(0,r.jsx)(pe,{icon:(0,r.jsx)(u2.J,{width:28,height:28}),label:b.word.label,title:b.word.title,description:N,ctaLabel:b.word.ctaLabel,statsImage:b.word.statsImage,statistics:b.word.statistics,link:b.word.link})}),y&&(0,r.jsx)(u9,{className:"w-full",children:(0,r.jsx)(pt,{icon:(0,r.jsx)(u2.J,{width:18,height:18}),label:b.word.label,link:b.word.link,onItemClick:()=>M(b.word.label)})}),!y&&(0,r.jsx)(u9,{className:"w-full",children:(0,r.jsx)(pt,{icon:(0,r.jsx)(E,{width:18,height:18}),label:k.label,link:k.link,onItemClick:()=>M(k.label)})})]})})})]})}function pl(){let{editor:e}=nl();if(!e||!e.storage.collaborationCaret)return null;let t=e.storage.collaborationCaret.users.map(e=>({clientId:e.clientId,id:String(e.clientId),name:e.name||"",color:e.color||"#000000"})).filter(e=>e.name.trim().length);return t.length?(0,r.jsxs)(u5,{children:[(0,r.jsx)(u3,{asChild:!0,children:(0,r.jsx)(d.$n,{"data-style":"ghost","data-appearence":"subdued",style:{padding:"0.25rem"},children:(0,r.jsx)(s4,{maxVisible:3,children:t.map(e=>{var t;return(0,r.jsx)(s1,{userColor:e.color,children:(0,r.jsx)(s2,{children:null==(t=e.name)?void 0:t.toUpperCase()[0]})},e.id)})})})}),(0,r.jsx)(u8,{align:"end",children:(0,r.jsx)(nh,{children:(0,r.jsx)(nm,{children:(0,r.jsx)(ng,{children:(0,r.jsx)(d.e2,{children:t.map(e=>{var t;return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsxs)(d.$n,{"data-style":"ghost",children:[(0,r.jsx)(s1,{userColor:e.color,children:(0,r.jsx)(s2,{children:null==(t=e.name)?void 0:t.toUpperCase()[0]})}),(0,r.jsx)("span",{className:"tiptap-button-text",children:e.name})]})},e.id)})})})})})})]}):null}let pa=(0,h.lazy)(()=>Promise.all([n.e(6789),n.e(6171),n.e(1832),n.e(6852),n.e(8911),n.e(4576),n.e(6321),n.e(2233),n.e(1637),n.e(5937)]).then(n.bind(n,35937)).then(e=>({default:e.VideoPopup}))),po=(0,I.I4)("button",{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",height:"32px",padding:"0 12px",borderRadius:"6px",fontWeight:"500",fontSize:"14px",lineHeight:"20px",background:"transparent",color:I.w4.colors.blue10,border:"1px solid ".concat(I.w4.colors.blue10),cursor:"pointer",transition:"background 0.2s ease, color 0.2s ease","& svg":{width:"14px",height:"14px"}}),pi=(0,h.memo)(e=>{let{editor:t,isMobileWeb:n}=e,{editor:l}=nl(t),{isEditorEmpty:a}=(0,uW.y)(l),{setIsWordFileDownloaded:o,headerSlot:i}=az(),{words:s,selectedWords:c}=(0,uG.D)(l),{authState:u}=(0,oa.Z)(),{user:p}=s8(),{isPrime:m,documentId:f,isPrimeWriteDisabled:x,isFreeTrialPlan:b}=g(),{isOwner:C,isReadOnlyAccess:v}=p,{updateRoute:y,query:w}=(0,aH.G)(),{openCollabModal:j,...I}=w,[k,E]=(0,h.useState)(!1),[N,S]=(0,h.useState)(!1),T=(0,h.useCallback)(()=>{S(e=>!e)},[]),[A,R]=(0,h.useState)(!1),M=(0,h.useCallback)(()=>{var e;R(e=>!e);let t=null==(e=window.document.querySelector(".ProseMirror"))?void 0:e.parentElement;t&&t.classList.toggle("ai-insert-active")},[]),{t:L}=(0,a7.B)("tip-tap-web-editor-v3"),[D,_]=(0,h.useState)(!1),[H,P]=(0,h.useState)(!1),[O,B]=(0,h.useState)(!1),[F,V]=(0,h.useState)(!1),{showToast:U}=(0,z._)(),{data:W}=nT(f),{onDownload:G,onUndo:Z,onRedo:q,onPaperpalAIClick:$}=uU(l),{productName:K}=(0,og.Gz)(),Y=(0,h.useMemo)(()=>(0,uY.e)(),[]),X=(0,h.useMemo)(()=>"paperpal-lifesciences-for-web"===K,[K]),J=(0,h.useMemo)(()=>("web"===K||"word"===K||X)&&!n,[n,K,X]),Q=(0,h.useCallback)(()=>{l&&(l.commands.clearContent(),l.chain().focus().setContent(uZ).run(),l.commands.focus("end",{scrollIntoView:!0}),l.commands.insertContent(" "))},[l]),ee=(0,h.useCallback)(()=>{a&&Q()},[a,Q]),et=(0,h.useCallback)(async e=>{try{await G(e),"word"===e&&(null==o||o(!0))}catch(e){U({title:"Failed to download the document.",color:"danger"})}},[G,o,U]),en=(0,h.useCallback)(()=>{V(!0)},[]),er=(0,h.useCallback)(()=>{V(!1)},[]),el=(0,h.useMemo)(()=>"logged in"===u.name&&!!X&&15>=(u.user.daysSinceUserCreated||0),[u,X]);return(0,h.useEffect)(()=>{"logged in"!==u.name||u.user.showPersona||"true"!==j||(E(!0),y(void 0,I,!0))},[u,j,I,y]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("header",{id:"editor-info",className:"paperpal-editor-header rounded-t-md top-[58px]",children:(0,r.jsxs)("div",{className:"flex items-center justify-between w-full flex-wrap",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("div",{className:"flex items-center",children:a?(0,r.jsx)(d.$n,{id:"sample-text",onClick:ee,tooltip:L("insert_sample_text","Insert sample text"),className:"h-auto min-w-auto text-sm border-0 bg-gray-2 hover:bg-black/5 active:bg-black/5 font-medium mx-2 text-black px-1.5 py-1.5 rounded-md hidden font-sans md:block m-0",children:L("sample_text","Sample Text")}):(0,r.jsxs)("div",{className:"flex mx-1 flex-wrap text-left",children:[(0,r.jsxs)("div",{className:"text-xs font-normal text-gray-11 leading-4",children:[s," ",1===s?"word":"words"]}),!!c&&(0,r.jsxs)("div",{className:"text-xs font-normal text-gray-11 leading-4",children:["\xa0| ",c," ",1===c?"word ":"words ","selected"]})]})}),v&&(0,r.jsx)(i7.E,{css:{fontSize:10},size:"tiny",children:"View Only"}),!n&&(0,r.jsx)("div",{className:"flex flex-row items-center pointer-events-auto",children:(0,r.jsx)("div",{className:"relative flex flex-row items-center",children:(0,r.jsx)(pl,{})})})]}),(0,r.jsxs)("div",{className:"flex items-center flex-1 justify-end",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[i,el&&(0,r.jsxs)(po,{id:"watch-demo",onClick:en,className:"text-sm mx-0 text-blue-10 px-2.5 py-1.5 rounded-md font-sans hidden lg:flex items-center gap-1","data-test-id":"video-tutorial-btn",children:[(0,r.jsx)("span",{className:"text-",children:(0,r.jsx)(om.I,{name:"play",variant:"solid",height:11,width:11})}),"Tutorial"]}),!X&&(0,r.jsx)(d.$n,{id:"share",onClick:()=>E(!0),tooltip:"Share this document",className:"h-auto min-w-auto text-xs border-0 bg-gray-2 hover:bg-black/5 active:bg-black/5 font-large mx-0 text-gray-11 px-2 py-2 rounded-md font-sans hidden lg:block",children:(0,r.jsx)(om.I,{name:"shareNodes",variant:"regular"})})]}),!n&&!X&&!Y&&(0,r.jsx)(pr,{}),!m&&!b&&(0,r.jsx)(uk,{disabled:N}),(0,r.jsxs)(u5,{onOpenChange:T,open:N,children:[(0,r.jsx)(u3,{asChild:!0,children:(0,r.jsx)(d.$n,{tooltip:!k&&!O&&L("more_options","More options"),id:"more-menu-option",className:"text-sm text-gray-12 border-none bg-gray-2 hover:bg-black/5 active:bg-black/5 font-medium m-0 text-blue-12 font-sans px-[15px] rounded-md min-w-[1] relative ml-1",children:(0,r.jsx)(om.I,{name:"ellipsisVertical",variant:"regular"})})}),N&&l&&(0,r.jsx)(ps,{isPrimeWriteDisabled:x,setVersioningModalOpen:P,editor:l,isMobileWeb:n,handleDownload:et,onPaperpalAIClick:$,toggleAiWrittenText:M,isAiWrittenToggleActive:A,setIsInviteDialogOpen:E,setIsFootprintModalOpen:B,onCommentClick:()=>y("comments",void 0,!0),isOwner:!!C,onUndo:Z,onRedo:q,disableUndoButton:!l.can().undo(),disableRedoButton:!l.can().redo(),isPrime:m,shouldShowDownloadWithTrackChangesOption:J,isEditorEmpty:a,isPplsForWeb:X})]})]})]})}),H&&!n&&(0,r.jsx)(uF,{isOpen:H,onClose:()=>P(!1),editor:l}),k&&(0,r.jsx)(uL,{isOpen:k,documentId:f,onClose:()=>E(!1),isOwner:!!C,collaborators:(null==W?void 0:W.collaborators)||[]}),O&&!n&&(0,r.jsx)(uh,{isOpen:O,onClose:()=>B(!1),documentId:f}
1),F&&(0,r.jsx)(pa,{open:F,onClose:er,videoUrl:"tLoc6dDjASM",title:"Welcome to Paperpal for Life Sciences!",description:"This short demo shows how you can convert your research artifacts into structured drafts in just a few steps.",footerText:"This tutorial will be available in your editor for 15 days and can be revisited anytime from the 'Help & Resources' section on the right hand sidebar.",trackingSection:"watch-demo-button",isYouTube:!0}),D&&(0,r.jsx)(uX.j,{onClose:()=>_(!1)})]})});pi.displayName="PaperpalEditorHeader";let ps=(0,h.memo)(e=>{var t;let{editor:n,isOwner:l,isMobileWeb:a,handleDownload:o,onPaperpalAIClick:i,toggleAiWrittenText:s,isAiWrittenToggleActive:c,setIsInviteDialogOpen:u,setVersioningModalOpen:p,setIsFootprintModalOpen:m,onCommentClick:g,onUndo:f,onRedo:x,disableUndoButton:b,disableRedoButton:C,isPrime:v,isPrimeWriteDisabled:y,isEditorEmpty:w,isPplsForWeb:j,shouldShowDownloadWithTrackChangesOption:I}=e,{openDrawer:k}=u$(),[E,N]=(0,h.useState)(!1),S=(0,h.useCallback)(()=>{N(e=>!e)},[]),{getAsset:T}=ug(),{snapshot:{versions:A}}=null!=(t=null==n?void 0:n.storage)?t:{versions:[]},{t:R}=(0,a7.B)("tip-tap-web-editor-v3"),M=(0,h.useCallback)(()=>a?k():i(),[a,k,i]),L=(0,h.useCallback)(e=>{let t="Macintosh"===(0,eg.Dj)();switch(e){case"undo":return t?"⌘ + Z":"Ctrl + Z";case"redo":return t?"⇧ ⌘ + Z":"Ctrl + Y";case"paperpal_ai":return t?"⌘ + J":"Ctrl + J";default:return""}},[]),{updateRoute:D}=(0,aH.G)(),_="w-full h-auto cursor-pointer disabled:cursor-default  !justify-between  p-4 py-2.5 text-sm text-gray-12 border-0 border-gray-200 box-border bg-transparent rounded disabled:opacity-50",H="w-full h-auto cursor-pointer !justify-between outline-none p-4 py-2.5 text-sm text-gray-12 border-0 border-gray-200 box-border bg-transparent rounded";return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(u8,{side:"bottom",align:"end",className:"rounded-xl px-0 py-1 box-shadow-none border border-gray-200",children:(0,r.jsx)(uK.o,{sectionName:"header-menu",children:(0,r.jsxs)(nh,{className:"px-0 py-2  min-w-[15rem] rounded-xl border-0 border-neutral-200",children:[(0,r.jsx)(u9,{className:"w-full",onClick:f,children:(0,r.jsxs)(d.$n,{disabled:b,id:"undo","data-style":"ghost",className:_,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"arrowRotateLeft",variant:"regular"}),R("undo","Undo")]}),!a&&(0,r.jsx)("span",{className:"text-gray-9 text-xs",children:L("undo")})]})}),(0,r.jsx)(u9,{className:"w-full",onClick:x,children:(0,r.jsxs)(d.$n,{disabled:C,id:"redo","data-style":"ghost",className:_,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"arrowRotateRight",variant:"regular"}),R("redo","Redo")]}),!a&&(0,r.jsx)("span",{className:"text-gray-9 text-xs",children:L("redo")})]})}),!a&&(0,r.jsx)(u9,{className:"w-full",onClick:()=>p(!0),children:(0,r.jsx)(d.$n,{"data-style":"ghost",disabled:!(null==A?void 0:A.length)||!l,id:"document-version-history",className:_,children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"history",variant:"regular"}),R("document_timeline","Document Timeline")]})})}),!j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u6,{className:"w-[90%] h-[1px] my-1 mx-2 bg-gray-7"}),(0,r.jsx)(u9,{className:"w-full",onClick:()=>u(!0),children:(0,r.jsx)(d.$n,{id:"invite-collaborator","data-style":"ghost",className:H,children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"userGroup",variant:"light"}),R("share","Share")]})})})]}),(0,r.jsx)(u9,{onClick:e=>{e.preventDefault(),S()},className:"w-full",children:(0,r.jsxs)(d.$n,{disabled:w||!l,id:"download-document","data-style":"ghost",className:"w-full h-auto cursor-pointer disabled:cursor-default !justify-between p-4 py-2.5 text-sm text-gray-12 border-0 border-gray-200 box-border bg-transparent rounded disabled:opacity-50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"fileArrowDown",variant:"light"}),"Download File"]}),(0,r.jsx)(om.I,{name:E?"chevronUp":"chevronDown",variant:"light"})]})}),E&&(0,r.jsxs)("div",{className:"bg-gray-2",children:[(0,r.jsx)(u9,{className:"w-full",onClick:()=>o("pdf"),children:(0,r.jsx)(d.$n,{disabled:w||!l,id:"export-pdf-header","data-style":"ghost",className:_,children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"pdfFile",variant:"light"}),R("download_as_pdf","Download as PDF")]})})}),(0,r.jsx)(u9,{className:"w-full",onClick:()=>o("word"),children:(0,r.jsx)(d.$n,{disabled:w||!l,id:"export-word-header","data-style":"ghost",className:_,children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"wordFile",variant:"light"}),R("download_as_word","Download as Word")]})})}),I&&(0,r.jsx)(u9,{className:"w-full",onClick:()=>D("track-changes"),children:(0,r.jsx)(d.$n,{"data-style":"ghost",disabled:w||!l,id:"export-word-with-track-changes-header-button","data-test-id":"export-word-with-track-changes-header-button",className:_,children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[v?(0,r.jsx)(om.I,{name:"wordFile",variant:"light"}):(0,r.jsx)(i9.h,{tipInfo:"Available with prime",children:(0,r.jsx)("img",{alt:"Upgrade",src:T("/plans-icon.png"),width:14,height:14})}),"Download with Track Changes"]})})})]}),(0,r.jsx)(u6,{className:"w-[90%] h-[1px] my-1 mx-2 bg-gray-7"}),!y&&(0,r.jsx)(u9,{className:"w-full",onClick:()=>M(),children:(0,r.jsxs)(d.$n,{disabled:!l,id:"paperpal-ai","data-style":"ghost",className:H,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"bolt",variant:"light"}),R("paperpal_ai","Paperpal AI")]}),!a&&(0,r.jsx)("span",{className:"text-gray-9 text-xs",children:L("paperpal_ai")})]})}),(0,r.jsx)(u6,{className:"w-[90%] h-[1px] my-1 mx-2 bg-gray-7"}),(0,r.jsx)(u9,{className:"w-full",children:(0,r.jsx)(us,{toggleAiWrittenText:s,isAiWrittenToggleActive:c,onQuestionClick:()=>m(!0)})}),(0,r.jsx)(u6,{className:"w-[90%] h-[1px] my-1 mx-2 bg-gray-7"}),(0,r.jsx)(u9,{className:"w-full",onClick:g,children:(0,r.jsx)(d.$n,{id:"view-all-comments",className:H,"data-style":"ghost",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-gray-12",children:[(0,r.jsx)(om.I,{name:"messageDot",variant:"light"}),"All comments"]})})})]})})})})}),pc=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3V8C2 8.55228 2.44772 9 3 9H8C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7H5.41416L5.96091 6.45325C7.58323 4.88786 9.74725 4.00897 12.0018 4.00001C14.1229 4.0005 16.1569 4.8433 17.6568 6.34315C19.1571 7.84344 19.9999 9.87827 19.9999 12C19.9999 12.5523 20.4477 13 20.9999 13C21.5522 13 21.9999 12.5523 21.9999 12C21.9999 9.34784 20.9464 6.8043 19.071 4.92894C17.1956 3.05358 14.6521 2.00001 11.9999 2L11.9962 2.00001C9.22207 2.01045 6.5594 3.0929 4.5649 5.02104L4.55283 5.0329L4 5.58573V3Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M3 11C3.55228 11 4 11.4477 4 12C4 14.1217 4.84285 16.1566 6.34315 17.6569C7.84297 19.1567 9.87701 19.9995 11.998 20C14.2526 19.9911 16.4167 19.1122 18.039 17.5468L18.5858 17H16C15.4477 17 15 16.5523 15 16C15 15.4477 15.4477 15 16 15H21C21.5523 15 22 15.4477 22 16V21C22 21.5523 21.5523 22 21 22C20.4477 22 20 21.5523 20 21V18.4142L19.4471 18.9671L19.435 18.979C17.4405 20.9071 14.7779 21.9896 12.0038 22L12 22C9.34784 22 6.8043 20.9464 4.92893 19.0711C3.05357 17.1957 2 14.6522 2 12C2 11.4477 2.44772 11 3 11Z",fill:"currentColor"})]})});pc.displayName="RefreshCcwIcon";let pd=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M12 1C12.5523 1 13 1.44772 13 2V22C13 22.5523 12.5523 23 12 23C11.4477 23 11 22.5523 11 22V2C11 1.44772 11.4477 1 12 1Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M2 7C2 5.34315 3.34315 4 5 4H7C7.55228 4 8 4.44772 8 5C8 5.55228 7.55228 6 7 6H5C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H7C7.55228 18 8 18.4477 8 19C8 19.5523 7.55228 20 7 20H5C3.34315 20 2 18.6569 2 17V7Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M19 4C20.6569 4 22 5.34315 22 7V17C22 18.6569 20.6569 20 19 20H17C16.4477 20 16 19.5523 16 19C16 18.4477 16.4477 18 17 18H19C19.5523 18 20 17.5523 20 17V7C20 6.44772 19.5523 6 19 6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H19Z",fill:"currentColor"})]})});pd.displayName="AlignCenterVerticalIcon";let pu=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 1C21.5523 1 22 1.44772 22 2V22C22 22.5523 21.5523 23 21 23C20.4477 23 20 22.5523 20 22V2C20 1.44772 20.4477 1 21 1Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 7C2 5.34315 3.34315 4 5 4H14C15.6569 4 17 5.34315 17 7V17C17 18.6569 15.6569 20 14 20H5C3.34315 20 2 18.6569 2 17V7ZM5 6C4.44772 6 4 6.44772 4 7V17C4 17.5523 4.44772 18 5 18H14C14.5523 18 15 17.5523 15 17V7C15 6.44772 14.5523 6 14 6H5Z",fill:"currentColor"})]})});pu.displayName="AlignEndVerticalIcon";let pp=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M4 2C4 1.44772 3.55228 1 3 1C2.44772 1 2 1.44772 2 2V22C2 22.5523 2.44772 23 3 23C3.55228 23 4 22.5523 4 22V2Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10 4C8.34315 4 7 5.34315 7 7V17C7 18.6569 8.34315 20 10 20H19C20.6569 20 22 18.6569 22 17V7C22 5.34315 20.6569 4 19 4H10ZM9 7C9 6.44772 9.44772 6 10 6H19C19.5523 6 20 6.44772 20 7V17C20 17.5523 19.5523 18 19 18H10C9.44772 18 9 17.5523 9 17V7Z",fill:"currentColor"})]})});pp.displayName="AlignStartVerticalIcon";let ph={left:"alt+shift+l",center:"alt+shift+e",right:"alt+shift+r"},pm={left:pp,center:pd,right:pu},pg={left:"Image align left",center:"Image align center",right:"Image align right"};function pf(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"data-align";return!!e&&!!e.isEditable&&!!(0,eg.xU)(e,[n])&&e.can().updateAttributes(n,{[r]:t})}function px(e){let{align:t,shortcutKeys:n=ph[t]}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:n})})}let pb=(0,h.forwardRef)((e,t)=>{let{editor:n,align:l,text:a,extensionName:o,attributeName:i="data-align",hideWhenUnavailable:s=!1,onAligned:c,showShortcut:u=!1,onClick:p,children:m,...g}=e,{editor:f}=nl(n),{isVisible:x,handleImageAlign:b,label:C,canAlign:v,isActive:y,Icon:w,shortcutKeys:j}=function(e){let{editor:t,align:n,extensionName:r="image",attributeName:l="data-align",hideWhenUnavailable:a=!1,onAligned:o}=e,{editor:i}=nl(t),s=rQ(),[c,d]=(0,h.useState)(!0),u=pf(i,n,r,l),p=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"data-align";return!!e&&!!e.isEditable&&!!(0,eg.xU)(e,[n])&&(e.getAttributes(n)[r]||"left")===t}(i,n,r,l);(0,h.useEffect)(()=>
1{if(!i)return;let e=()=>{d(function(e){let{editor:t,hideWhenUnavailable:n,align:r,extensionName:l="image",attributeName:a="data-align"}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,[l])&&(!n||pf(t,r,l,a))}({editor:i,align:n,hideWhenUnavailable:a,extensionName:r,attributeName:l}))};return e(),i.on("selectionUpdate",e),()=>{i.off("selectionUpdate",e)}},[i,a,n,r,l]);let m=(0,h.useCallback)(()=>{if(!i)return!1;let e=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"data-align";if(!(null==e?void 0:e.isEditable)||!(0,eg.xU)(e,[n])||!pf(e,t,n,r))return!1;try{let{selection:l}=e.state,a=l instanceof $.nh,o=a?l.from:l.$anchor.pos,i=e.chain().focus().updateAttributes(n,{[r]:t}).run();return i&&a&&e.commands.setNodeSelection(o),i}catch(e){return!1}}(i,n,r,l);return e&&(null==o||o()),e},[i,n,r,l,o]);return(0,r0.vC)(ph[n],e=>{e.preventDefault(),m()},{enabled:c&&u,enableOnContentEditable:!s,enableOnFormTags:!0}),{isVisible:c,isActive:p,handleImageAlign:m,canAlign:u,label:pg[n],shortcutKeys:ph[n],Icon:pm[n]}}({editor:f,align:l,extensionName:o,attributeName:i,hideWhenUnavailable:s,onAligned:c}),I=(0,h.useCallback)(e=>{null==p||p(e),e.defaultPrevented||b()},[b,p]);return x?(0,r.jsx)(d.$n,{type:"button",disabled:!v,"data-style":"ghost","data-active-state":y?"on":"off","data-disabled":!v,role:"button",tabIndex:-1,"aria-label":C,"aria-pressed":y,tooltip:C,onClick:I,...g,ref:t,children:null!=m?m:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{className:"tiptap-button-icon"}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),u?(0,r.jsx)(px,{align:l,shortcutKeys:j}):null]})}):null});pb.displayName="ImageAlignButton";let pC=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 22C7 21.4477 7.44772 21 8 21H16C16.5523 21 17 21.4477 17 22C17 22.5523 16.5523 23 16 23H8C7.44772 23 7 22.5523 7 22Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 18C3 17.4477 3.44772 17 4 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H4C3.44772 19 3 18.5523 3 18Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 5C3 3.34315 4.34315 2 6 2H18C19.6569 2 21 3.34315 21 5V11C21 12.6569 19.6569 14 18 14H6C4.34315 14 3 12.6569 3 11V5ZM6 4C5.44772 4 5 4.44772 5 5V11C5 11.5523 5.44772 12 6 12H18C18.5523 12 19 11.5523 19 11V5C19 4.44772 18.5523 4 18 4H6Z",fill:"currentColor"})]})});function pv(e){return!!e&&!!e.isEditable&&!!(0,eg.xU)(e,["image"])&&(0,eg.ee)(e,["image"])}pC.displayName="ImageCaptionIcon";let py=h.forwardRef((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onSet:o,onClick:i,children:s,...c}=e,{editor:u}=nl(n),{isVisible:p,isActive:m,canToggle:g,handleToggleCaption:f,label:x,Icon:b}=function(e){let{editor:t,hideWhenUnavailable:n=!1,onSet:r}=e||{},{editor:l}=nl(t),[a,o]=(0,h.useState)(!0),[i,s]=(0,h.useState)(!1),c=pv(l);return(0,h.useEffect)(()=>{if(!l)return;let e=()=>{o(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,["image"])&&(!n||pv(t))}({editor:l,hideWhenUnavailable:n})),s(function(e){if(!e)return!1;try{let{selection:t}=e.state;if(!(t instanceof $.nh&&"image"===t.node.type.name))return!1;let n=t.node;return!0===n.attrs.showCaption||n.content.size>0}catch(e){return!1}}(l))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]),{isVisible:a,isActive:i,canToggle:c,handleToggleCaption:(0,h.useCallback)(()=>{if(!l)return!1;let e=function(e){if(!(null==e?void 0:e.isEditable)||!pv(e))return!1;try{let{selection:t}=e.state;if(!(t instanceof $.nh&&"image"===t.node.type.name)||!e.chain().focus().updateAttributes("image",{showCaption:!0}).run())return!1;let n=t.from;return e.chain().focus(n+1).selectTextblockEnd().run(),!0}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]),label:"Caption",Icon:pC}}({editor:u,hideWhenUnavailable:a,onSet:o}),C=h.useCallback(e=>{null==i||i(e),e.defaultPrevented||f()},[f,i]);return p?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":m?"on":"off",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":x,tooltip:x,onClick:C,...c,ref:t,children:null!=s?s:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l})]})}):null});function pw(e){let{shortcutKeys:t=cZ}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}py.displayName="ImageCaptionButton";let pj=(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onDownloaded:o,resolveFileUrl:i,showShortcut:s=!1,onClick:c,children:u,...p}=e,{editor:m}=nl(n),{isVisible:g,canDownload:f,handleDownload:x,label:b,shortcutKeys:C,Icon:v}=c0({editor:m,hideWhenUnavailable:a,onDownloaded:o,resolveFileUrl:i}),y=(0,h.useCallback)(async e=>{null==c||c(e),e.defaultPrevented||await x()},[x,c]);return g?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":b,tooltip:b,onClick:y,...p,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),s&&(0,r.jsx)(pw,{shortcutKeys:C})]})}):null});pj.displayName="ImageDownloadButton";let pI=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})})});pI.displayName="ImagePlusIcon";let pk="mod+shift+i";function pE(e){return!!e&&!!e.isEditable&&!!(0,eg.xU)(e,"imageUpload")&&e.can().insertContent({type:"imageUpload"})}function pN(e){let{shortcutKeys:t=pk}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}let pS=(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onInserted:o,showShortcut:i=!1,onClick:s,icon:c,
1children:u,...p}=e,{editor:m}=nl(n),{isVisible:g,canInsert:f,handleImage:x,label:b,isActive:C,shortcutKeys:v,Icon:y}=function(e){let{editor:t,hideWhenUnavailable:n=!1,onInserted:r}=e||{},{editor:l}=nl(t),a=rQ(),[o,i]=(0,h.useState)(!0),s=pE(l),c=!!l&&!!l.isEditable&&l.isActive("imageUpload");(0,h.useEffect)(()=>{if(!l)return;let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,"imageUpload")&&(!n||!!t.isActive("code")||pE(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]);let d=(0,h.useCallback)(()=>{if(!l)return!1;let e=function(e){if(!e||!e.isEditable||!pE(e))return!1;try{return e.chain().focus().insertContent({type:"imageUpload"}).run()}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]);return(0,r0.vC)(pk,e=>{e.preventDefault(),d()},{enabled:o&&s,enableOnContentEditable:!a,enableOnFormTags:!0}),{isVisible:o,isActive:c,handleImage:d,canInsert:s,label:"Add image",shortcutKeys:pk,Icon:pI}}({editor:m,hideWhenUnavailable:a,onInserted:o}),w=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||x()},[x,s]);return g?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":b,"aria-pressed":C,tooltip:b,onClick:w,...p,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(null!=c?c:y,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i&&(0,r.jsx)(pN,{shortcutKeys:v})]})}):null});function pT(e){let{editor:t}=e,{editor:n}=nl(t),l=(0,eg.ee)(n,["image"]);return n&&l?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(pb,{align:"left"}),(0,r.jsx)(pb,{align:"center"}),(0,r.jsx)(pb,{align:"right"}),(0,r.jsx)(rR,{}),(0,r.jsx)(py,{}),(0,r.jsx)(rR,{}),(0,r.jsx)(pj,{}),(0,r.jsx)(pS,{icon:pc,tooltip:"Replace"}),(0,r.jsx)(rR,{}),(0,r.jsx)(cA,{})]}):null}pS.displayName="ImageUploadButton";var pA=n(15761);function pR(e){let{...t}=e;return(0,r.jsx)(pA.bL,{...t})}function pM(e){let{...t}=e;return(0,r.jsx)(pA.l9,{...t})}function pL(e){let{className:t,align:n="center",sideOffset:l=4,...a}=e;return(0,r.jsx)(pA.ZL,{children:(0,r.jsx)(pA.UC,{align:n,sideOffset:l,className:(0,eg.cn)("tiptap-popover",t),...a})})}function pD(e){let{shortcutKeys:t=r1}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}n(53729),n(49389);let p_=(0,h.forwardRef)((e,t)=>{let{editor:n,highlightColor:l,text:a,hideWhenUnavailable:o=!1,mode:i="mark",onApplied:s,showShortcut:c=!1,onClick:u,children:p,style:m,...g}=e,{editor:f}=nl(n),{isVisible:x,canColorHighlight:b,isActive:C,handleColorHighlight:v,label:y,shortcutKeys:w}=r5({editor:f,highlightColor:l,label:a||"Toggle highlight (".concat(l,")"),hideWhenUnavailable:o,mode:i,onApplied:s}),j=(0,h.useCallback)(e=>{null==u||u(e),e.defaultPrevented||v()},[v,u]),I=(0,h.useMemo)(()=>({...m,"--highlight-color":l}),[l,m]);return x?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":C?"on":"off",role:"button",tabIndex:-1,disabled:!b,"data-disabled":!b,"aria-label":y,"aria-pressed":C,tooltip:y,onClick:j,style:I,...g,ref:t,children:null!=p?p:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-button-highlight",style:{"--highlight-color":l}}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),c&&(0,r.jsx)(pD,{shortcutKeys:w})]})}):null});function pH(e){let{shortcutKeys:t=r7}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}p_.displayName="ColorHighlightButton",n(63681);let pP=(0,h.forwardRef)((e,t)=>{let{editor:n,textColor:l,text:a,hideWhenUnavailable:o=!1,onApplied:i,showShortcut:s=!1,onClick:c,children:u,style:p,...m}=e,{editor:g}=nl(n),{isVisible:f,canColorText:x,isActive:b,handleColorText:C,label:v,shortcutKeys:y,Icon:w}=r6({editor:g,textColor:l,label:a||"Color text to ".concat(l),hideWhenUnavailable:o,onApplied:i}),j=(0,h.useCallback)(e=>{null==c||c(e),e.defaultPrevented||C()},[C,c]),I=(0,h.useMemo)(()=>({...p,"--color-text-button-color":l}),[l,p]);return f?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":b?"on":"off",role:"button",tabIndex:-1,disabled:!x,"data-disabled":!x,"aria-label":v,"aria-pressed":b,tooltip:v,onClick:j,style:I,...m,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-button-color-text",style:{color:l},children:(0,r.jsx)(w,{className:"tiptap-button-icon",style:{color:l,flexGrow:1}})}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),s&&(0,r.jsx)(pH,{shortcutKeys:y})]})}):null});pP.displayName="ColorTextButton",n(57485);let pO=e=>{let{colorObj:t,withLabel:n=!1,onColorChanged:l,...a}=e,o="text"===t.type?r3:r2,i=lo(t.value,o),s={tooltip:i.label,text:n?
1i.label:void 0,onApplied:()=>null==l?void 0:l({type:t.type,label:i.label,value:i.value}),...a};return"text"===t.type?(0,r.jsx)(pP,{textColor:i.value,label:i.label,...s}):(0,r.jsx)(p_,{highlightColor:i.value,...s})},pz=e=>{let{type:t,colors:n,onColorSelected:l,selectedIndex:a,startIndexOffset:o}=e;return n.map((e,i)=>(0,r.jsx)(d.e2,{orientation:"horizontal",children:e.map((e,s)=>{let c=a===o+n.slice(0,i).reduce((e,t)=>e+t.length,0)+s,d={tooltip:e.label,onApplied:()=>l({type:t,label:e.label,value:e.value}),tabIndex:c?0:-1,"data-highlighted":c,"aria-label":"".concat(e.label," ").concat("text"===t?"text":"highlight"," color")};return"text"===t?(0,r.jsx)(pP,{textColor:e.value,label:e.label,...d},"".concat(t,"-").concat(e.value,"-").concat(s)):(0,r.jsx)(p_,{highlightColor:e.value,...d},"".concat(t,"-").concat(e.value,"-").concat(s))})},"".concat(t,"-group-").concat(i)))},pB=e=>{let{recentColors:t,onColorSelected:n,selectedIndex:l}=e;return 0===t.length?null:(0,r.jsxs)(ng,{children:[(0,r.jsx)(nf,{children:"Recently used"}),(0,r.jsx)(d.e2,{orientation:"horizontal",children:t.map((e,t)=>(0,r.jsx)(pO,{colorObj:e,onColorChanged:n,tabIndex:l===t?0:-1,"data-highlighted":l===t},"recent-".concat(e.type,"-").concat(e.value)))})]})},pF=e=>{let{maxColorsPerGroup:t=5,maxRecentColors:n=3,onColorChanged:l}=e,{recentColors:a,addRecentColor:o,isInitialized:i}=li(n),s=(0,h.useRef)(null),c=(0,h.useMemo)(()=>le(r3,t),[t]),d=(0,h.useMemo)(()=>le(r2,t),[t]),u=(0,h.useMemo)(()=>c.flat(),[c]),p=(0,h.useMemo)(()=>d.flat(),[d]),m=(0,h.useMemo)(()=>i?a.length:0,[i,a.length]),g=(0,h.useMemo)(()=>m+u.length,[m,u.length]),f=(0,h.useMemo)(()=>{let e=[];return i&&a.length>0&&e.push(...a.map(e=>({type:e.type,value:e.value,label:"Recent ".concat("text"===e.type?"text":"highlight"," color"),group:"recent"}))),e.push(...u.map(e=>({type:"text",value:e.value,label:e.label,group:"text"}))),e.push(...p.map(e=>({type:"highlight",value:e.value,label:e.label,group:"highlight"}))),e},[i,a,u,p]),x=(0,h.useCallback)(e=>{let{type:t,label:n,value:r}=e;if(!s.current)return!1;let a=s.current.querySelector('[data-highlighted="true"]');a&&a.click(),o({type:t,label:n,value:r}),null==l||l({type:t,label:n,value:r})},[o,l]),{selectedIndex:b}=oL({containerRef:s,items:f,onSelect:e=>{e&&x({type:e.type,label:e.label,value:e.value})},orientation:"both",autoSelectFirstItem:!1});return(0,r.jsx)(nh,{ref:s,tabIndex:0,role:"menu",children:(0,r.jsxs)(nm,{children:[i&&(0,r.jsx)(pB,{recentColors:a,onColorSelected:x,selectedIndex:b}),(0,r.jsxs)(ng,{children:[(0,r.jsx)(nf,{children:"Text color"}),(0,r.jsx)(pz,{type:"text",colors:c,onColorSelected:x,selectedIndex:b,startIndexOffset:m})]}),(0,r.jsxs)(ng,{children:[(0,r.jsx)(nf,{children:"Highlight color"}),(0,r.jsx)(pz,{type:"highlight",colors:d,onColorSelected:x,selectedIndex:b,startIndexOffset:g})]})]})})},pV=(0,h.forwardRef)((e,t)=>{let{editor:n,hideWhenUnavailable:l=!1,onColorChanged:a,onClick:o,children:i,...s}=e,{editor:c}=nl(n),[u,p]=(0,h.useState)(!1),{isVisible:m,canToggle:g,activeTextStyle:f,activeHighlight:x,handleColorChanged:b,label:C,Icon:v}=function(e){let{editor:t,hideWhenUnavailable:n=!1,onColorChanged:r}=e||{},{editor:l}=nl(t),[a,o]=(0,h.useState)(!0),i=(0,eg.qi)("textStyle",l),s=(0,eg.qi)("highlight",l),c=ln(l,"textStyle")||{},d=ln(l,"highlight")||{},u=r9(l)||r4(l);return(0,h.useEffect)(()=>{if(!l)return;let e=()=>{o(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&(!n||!!t.isActive("code")||r9(t)||r4(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n,s,i]),{isVisible:a,canToggle:u,activeTextStyle:c,activeHighlight:d,handleColorChanged:(0,h.useCallback)(e=>{let{type:t,label:n,value:l}=e;null==r||r({type:t,label:n,value:l})},[r]),label:"Text color",Icon:rY}}({editor:c,hideWhenUnavailable:l,onColorChanged:a}),y=(0,h.useCallback)(e=>{null==o||o(e),e.defaultPrevented||p(!u)},[o,u,p]);return m?(0,r.jsxs)(pR,{open:u,onOpenChange:p,children:[(0,r.jsx)(pM,{asChild:!0,children:(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-appearance":"default",role:"button","aria-label":C,tooltip:C,disabled:!g,"data-disabled":!g,onClick:y,...s,ref:t,children:null!=i?i:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-button-color-text-popover",style:x.color?{"--active-highlight-color":x.color}:{},children:(0,r.jsx)(v,{className:"tiptap-button-icon",style:{color:f.color||void 0}})}),(0,r.jsx)(sZ,{className:"tiptap-button-dropdown-small"})]})})}),(0,r.jsx)(pL,{"aria-label":"Text color options",side:"bottom",align:"start",children:(0,r.jsx)(pF,{onColorChanged:b})})]}):null});pV.displayName="ColorTextPopover";let pU=["doc","paragraph","heading","bulletList","orderedList"],pW=[{type:"paragraph",label:"Text",isActive:e=>e.isActive("paragraph")&&!e.isActive("heading")&&!e.isActive("bulletList")&&!e.isActive("orderedList")&&!e.isActive("taskList")&&!e.isActive("blockquote")&&!e.isActive("codeBlock")},{type:"heading",label:"Heading 1",level:1,isActive:e=>e.isActive("heading",{level:1})},{type:"heading",label:"Heading 2",level:2,isActive:e=>e.isActive("heading",{level:2})}
1,{type:"heading",label:"Heading 3",level:3,isActive:e=>e.isActive("heading",{level:3})},{type:"bulletList",label:"Bulleted list",isActive:e=>e.isActive("bulletList")},{type:"orderedList",label:"Numbered list",isActive:e=>e.isActive("orderedList")}];function pG(e,t){if(!e||!e.isEditable)return!1;let n=t||pU,{selection:r}=e.state;if(r instanceof $.nh){let e=r.node.type.name;return n.includes(e)}let{$anchor:l}=r,a=l.parent.type.name;return n.includes(a)}function pZ(e){return e?pW.filter(t=>e.includes(t.type)):pW}function pq(e){let{editor:t,hideWhenUnavailable:n=!1,blockTypes:r,onOpenChange:l}=e||{},{editor:a}=nl(t),[o,i]=(0,h.useState)(!1),[s,c]=(0,h.useState)(!0),d=pG(a,r),u=function(e,t){if(!e)return pZ(t)[0];let n=pZ(t);return n.find(t=>t.isActive(e))||n[0]}(a,r),p=(0,h.useCallback)(e=>{a&&d&&(i(e),null==l||l(e))},[d,a,l]);return(0,h.useEffect)(()=>{if(!a)return;let e=()=>{c(function(e){let{editor:t,hideWhenUnavailable:n,blockTypes:r}=e;return!(!t||t.isActive("table"))&&(!n||!!t.isActive("code")||pG(t,r))}({editor:a,hideWhenUnavailable:n,blockTypes:r}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,n,r]),{isVisible:s,canToggle:d,isOpen:o,setIsOpen:i,activeBlockType:u,handleOpenChange:p,filteredOptions:pZ(r),label:"Turn into (current: ".concat((null==u?void 0:u.label)||"Text",")"),Icon:sZ}}let p$=[{label:"Sans Serif",options:[{label:"Inter",value:""},{label:"Arial",value:"Arial"},{label:"Helvetica",value:"Helvetica"}]},{label:"Serif",options:[{label:"Times New Roman",value:"Times"},{label:"Garamond",value:"Garamond"},{label:"Georgia",value:"Georgia"}]},{label:"Monospace",options:[{label:"Courier",value:"Courier"},{label:"Courier New",value:"Courier New"}]}],pK=p$.flatMap(e=>[e.options]).flat(),pY=(0,h.forwardRef)((e,t)=>{let{editor:n,hideWhenUnavailable:l=!1,blockTypes:a,onOpenChange:o,children:i,...s}=e,{editor:c}=nl(n),u=(0,ef.er)({editor:c,selector:e=>{var t,n;return{currentFont:(null==(n=e.editor)||null==(t=n.getAttributes("textStyle"))?void 0:t.fontFamily)||void 0}}}),p=(0,h.useMemo)(()=>pK.find(e=>e.value===(null==u?void 0:u.currentFont)),[null==u?void 0:u.currentFont]),m=(null==p?void 0:p.label.split(" ")[0])||"Inter",{isVisible:g,canToggle:f,isOpen:x,handleOpenChange:b,label:C,Icon:v}=pq({editor:c,hideWhenUnavailable:l,blockTypes:a,onOpenChange:o}),y=(0,h.useCallback)(e=>{if(c)return e&&0!==e.length?c.chain().focus().setFontFamily(e).run():c.chain().focus().unsetFontFamily().run()},[c]),w=(0,h.useCallback)(e=>()=>{y(e),b(!1)},[b,y]);return g?(0,r.jsxs)(u5,{open:x,onOpenChange:b,children:[(0,r.jsx)(u3,{asChild:!0,children:(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",disabled:!f,"data-disabled":!f,role:"button",tabIndex:-1,"aria-label":C,tooltip:"Text size",...s,ref:t,children:null!=i?i:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-button-text",children:m}),(0,r.jsx)(v,{className:"tiptap-button-dropdown-small"})]})})}),(0,r.jsx)(u8,{align:"start",children:(0,r.jsx)(nh,{children:(0,r.jsx)(nm,{children:(0,r.jsx)(ng,{children:(0,r.jsx)(d.e2,{children:p$.map(e=>(0,r.jsxs)("div",{className:"mt-2.5 first:mt-0 gap-0.5 flex flex-col w-full",children:[(0,r.jsx)(nf,{children:e.label}),(0,r.jsx)(d.e2,{children:e.options.map(e=>(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(d.$n,{onClick:w(e.value),type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":e.label,className:"!justify-start",children:(0,r.jsx)("span",{style:{fontFamily:e.value},children:e.label})},"".concat(e.label,"_").concat(e.value))},e.value))})]},e.label))})})})})})]}):null});pY.displayName="FontFamilyPicker";let pX=[{label:"Smaller",value:"12px"},{label:"Small",value:"14px"},{label:"Medium",value:""},{label:"Large",value:"18px"},{label:"Extra Large",value:"24px"}],pJ=(0,h.forwardRef)((e,t)=>{let{editor:n,hideWhenUnavailable:l=!1,blockTypes:a,onOpenChange:o,children:i,...s}=e,{editor:c}=nl(n),u=(0,ef.er)({editor:c,selector:e=>{var t,n;return e?{currentSize:(null==e||null==(n=e.editor)||null==(t=n.getAttributes("textStyle"))?void 0:t.fontSize)||void 0}:{currentSize:void 0}}}),p=pX.find(e=>e.value===(null==u?void 0:u.currentSize)),m=(null==p?void 0:p.label.split(" ")[0])||"Medium",{isVisible:g,canToggle:f,isOpen:x,handleOpenChange:b,label:C,Icon:v}=pq({editor:c,hideWhenUnavailable:l,blockTypes:a,onOpenChange:o}),y=(0,h.useCallback)(e=>{if(c)return e&&0!==e.length?c.chain().focus().setFontSize(e).run():c.chain().focus().unsetFontSize().run()},[c]),w=(0,h.useCallback)(e=>()=>{y(e),b(!1)},[b,y]);return g?(0,r.jsxs)(u5,{open:x,onOpenChange:b,children:[(0,r.jsx)(u3,{asChild:!0,children:(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",disabled:!f,"data-disabled":!f,role:"button",tabIndex:-1,"aria-label":C,tooltip:"Text size",...s,ref:t,children:null!=i?i:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-button-text",children:m}),(0,r.jsx)(v,{className:"tiptap-button-dropdown-small"})]})})}),(0,r.jsx)(u8,{align:"start",children:(0,r.jsx)(nh,{children:(0,r.jsx)(nm,{children:(0,r.jsxs)(ng,{children:[(0,r.jsx)(nf,{children:"Font size"}),(0,r.jsx)(d.e2,{children:pX.map((e,t)=>(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(d.$n,{onClick:w(e.value),type:"button","data-style":"ghost",role:"button",tabIndex:-1,"aria-label":e.label,className:"!justify-start",children:(0,r.jsx)("span",{style:{fontSize:e.value},children:e.label})},"".concat(e.label,"_").concat(e.value))},t))})]})})})})]}):null});pJ.displayName="FontSizePicker";let pQ=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})})});pQ.displayName="CornerDownLeftIcon";let p0=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]})});function p1(e){return!(!e||!e.isEditable||(0,eg.ee)(e,["image"],!0))&&e.can().setMark("link")}function p2(e){return!!e&&!!e.isEditable&&e.isActive("link")}p0.displayName="LinkIcon";let p4=(0,h.forwardRef)((e,t)=>{let{className:n,children:l,...a}=e;return(0,r.jsx)(d.$n,{type:"button",className:n,"data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Link",tooltip:"Link",ref:t,...a,children:l||(0,r.jsx)(p0,{className:"tiptap-button-icon"})})});p4.displayName="LinkButton";let p5=e=>{let{url:t,setUrl:n,setLink:l,removeLink:a,openLink:o,isActive:i}=e,s=rQ();return(0,r.jsx)(nh,{style:{...s?{boxShadow:"none",border:0}:{}},children:(0,r.jsx)(nm,{style:{...s?{padding:0}:{}},children:(0,r.jsxs)(ng,{orientation:"horizontal",children:[(0,r.jsx)(io,{children:(0,r.jsx)(ia,{type:"url",placeholder:"Paste a link...",value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})}),(0,r.jsx)(d.e2,{orientation:"horizontal",children:(0,r.jsx)(d.$n,{type:"button",onClick:l,title:"Ap
1ply link",disabled:!t&&!i,"data-style":"ghost",children:(0,r.jsx)(pQ,{className:"tiptap-button-icon"})})}),(0,r.jsx)(rR,{}),(0,r.jsxs)(d.e2,{orientation:"horizontal",children:[(0,r.jsx)(d.$n,{type:"button",onClick:o,title:"Open in new window",disabled:!t&&!i,"data-style":"ghost",children:(0,r.jsx)(ny,{className:"tiptap-button-icon"})}),(0,r.jsx)(d.$n,{type:"button",onClick:a,title:"Remove link",disabled:!t&&!i,"data-style":"ghost",children:(0,r.jsx)(lA,{className:"tiptap-button-icon"})})]})]})})})},p7=(0,h.forwardRef)((e,t)=>{let{editor:n,hideWhenUnavailable:l=!1,onSetLink:a,onOpenChange:o,autoOpenOnLinkActive:i=!0,onClick:s,children:c,...d}=e,{editor:u}=nl(n),[p,m]=(0,h.useState)(!1),{isVisible:g,canSet:f,isActive:x,url:b,setUrl:C,setLink:v,removeLink:y,openLink:w,label:j,Icon:I}=function(e){let{editor:t,hideWhenUnavailable:n=!1,onSetLink:r}=e||{},{editor:l}=nl(t),{isVisible:a,canSet:o,isActive:i}=function(e){let{editor:t,hideWhenUnavailable:n=!1}=e,r=p1(t),l=p2(t),[a,o]=(0,h.useState)(!0);return(0,h.useEffect)(()=>{if(!t)return;let e=()=>{o(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!(0,eg.qi)("link",t)&&!!t&&(!n||!!t.isActive("code")||p1(t))}({editor:t,hideWhenUnavailable:n}))};return e(),t.on("selectionUpdate",e),()=>{t.off("selectionUpdate",e)}},[t,n]),{isVisible:a,canSet:r,isActive:l}}({editor:l,hideWhenUnavailable:n});return{isVisible:a,canSet:o,isActive:i,label:"Link",Icon:p0,...function(e){let{editor:t,onSetLink:n}=e,[r,l]=(0,h.useState)(null);(0,h.useEffect)(()=>{if(!t)return;let{href:e}=t.getAttributes("link");p2(t)&&null===r&&l(e||"")},[t,r]),(0,h.useEffect)(()=>{if(!t)return;let e=()=>{let{href:e}=t.getAttributes("link");l(e||"")};return t.on("selectionUpdate",e),()=>{t.off("selectionUpdate",e)}},[t]);let a=(0,h.useCallback)(()=>{if(!r||!t)return;let{selection:e}=t.state,a=e.empty,o=t.chain().focus();o=o.extendMarkRange("link").setLink({href:r}),a&&(o=o.insertContent({type:"text",text:r})),o.run(),l(null),null==n||n()},[t,n,r]),o=(0,h.useCallback)(()=>{t&&(t.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),l(""))},[t]),i=(0,h.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"_blank",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"noopener,noreferrer";if(!r)return;let n=(0,eg.Jf)(r,window.location.href);"#"!==n&&window.open(n,e,t)},[r]);return{url:r||"",setUrl:l,setLink:a,removeLink:o,openLink:i}}({editor:l,onSetLink:r})}}({editor:u,hideWhenUnavailable:l,onSetLink:a}),k=(0,h.useCallback)(e=>{m(e),null==o||o(e)},[o]),E=(0,h.useCallback)(()=>{v(),m(!1)},[v]),N=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||m(!p)},[s,p]);return((0,h.useEffect)(()=>{i&&x&&m(!0)},[i,x]),g)?(0,r.jsxs)(pR,{open:p,onOpenChange:k,children:[(0,r.jsx)(pM,{asChild:!0,children:(0,r.jsx)(p4,{disabled:!f,"data-active-state":x?"on":"off","data-disabled":!f,"aria-label":j,"aria-pressed":x,onClick:N,...d,ref:t,children:null!=c?c:(0,r.jsx)(I,{className:"tiptap-button-icon"})})}),(0,r.jsx)(pL,{children:(0,r.jsx)(p5,{url:b,setUrl:C,setLink:E,removeLink:y,openLink:w,isActive:x})})]}):null});p7.displayName="LinkPopover";let p3=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})})});p3.displayName="BoldIcon";let p9=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]})});p9.displayName="Code2Icon";let p6=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})})});p6.displayName="ItalicIcon";let p8=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]})});p8.displayName="StrikeIcon";let he=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]})});he.displayName="SubscriptIcon";let ht=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]})});ht.displayName="SuperscriptIcon";let hn=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsx)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})})});hn.displayName="UnderlineIcon";let hr={bold:p3,italic:p6,underline:hn,strike:p8,code:p9,superscript:ht,subscript:he},hl={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function ha(e,t){return!(!e||!e.isEditable||!(0,eg.qi)(t,e)||(0,eg.ee)(e,["image"]))&&e.can().toggleMark(t)}function ho(e){let{type:t,shortcutKeys:n=hl[t]}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:n})})}let hi=(0,h.forwardRef)((e,t)=>{let{editor:n,type:l,text:a,hideWhenUnavailable:o=!1,onToggled:i,showShortcut:s=!1,onClick:c,children:u,...p}=e,{editor:m}=nl(n),{isVisible:g,handleMark:f,label:x,canToggle:b,isActive:C,Icon:v,shortcutKeys:y}=function(e){let{editor:t,type:n,hideWhenUnavailable:r=!1,onToggled:l}=e,{editor:a}=nl(t),[o,i]=(0,h.useState)(!0),s=ha(a,n),c=!!a&&!!a.isEditable&&a.isActive(n);return(0,h.useEffect)(()=>{if(!a)return;let e=()=>{i(function(e){let{editor:t,type:n,hideWhenUnavailable:r}=e;return!!t&&!!t.isEditable&&!!(0,eg.qi)(n,t)&&(!r||!!t.isActive("code")||ha(t,n))}({editor:a,type:n,hideWhenUnavailable:r}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,n,r]),{isVisible:o,isActive:c,handleMark:(0,h.useCallback)(()=>{if(!a)return!1;let e=!!a&&!!a.isEditable&&!!ha(a,n)&&a.chain().focus().toggleMark(n).run();return e&&(null==l||l()),e},[a,n,l]),canToggle:s,label:n.charAt(0).toUpperCase()+n.slice(1),shortcutKeys:hl[n],Icon:hr[n]}}({editor:m,type:l,hideWhenUnavailable:o,onToggled:i}),w=(0,h.useCallback)(e=>{null==c||c(e),e.defaultPrevented||f()},[f,c]);return g?(0,r.jsx)(d.$n,{type:"button",disabled:!b,"data-style":"ghost","data-active-state":C?"on":"off","data-disabled":!b,role:"button",tabIndex:-1,"aria-label":x,"aria-pressed":C,tooltip:x,onClick:w,...p,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{className:"tiptap-button-icon"}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),s&&(0,r.jsx)(ho,{type:l,shortcutKeys:y})]})}):null});hi.displayName="MarkButton";let hs={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},hc={left:nG,center:nU,right:nq,justify:nW},hd={left:"Align left",center:"Align center",right:"Align right",justify:"Align justify"};function hu(e,t){return!(!e||!e.isEditable||!(0,eg.xU)(e,"textAlign")||(0,eg.ee)(e,["image","horizontalRule"]))&&e.can().setTextAlign(t)}function hp(e){let{align:t,shortcutKeys:n=hs[t]}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:n})})}let hh=(0,h.forwardRef)((e,t)=>{let{editor:n,align:l,text:a,hideWhenUnavailable:o=!1,onAligned:i,showShortcut:s=!1,onClick:c,icon:u,children:p,...m}=e,{editor:g}=nl(n),{isVisible:f,handleTextAlign:x,label:b,canAlign:C,isActive:v,Icon:y,shortcutKeys:w}=function(e){let{editor:t,align:n,hideWhenUnavailable:r=!1,onAligned:l}=e,{editor:a}
1=nl(t),[o,i]=(0,h.useState)(!0),s=hu(a,n),c=!!a&&!!a.isEditable&&a.isActive({textAlign:n});return(0,h.useEffect)(()=>{if(!a)return;let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n,align:r}=e;return!!t&&!!t.isEditable&&!!(0,eg.xU)(t,"textAlign")&&(!n||!!t.isActive("code")||hu(t,r))}({editor:a,align:n,hideWhenUnavailable:r}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,r,n]),{isVisible:o,isActive:c,handleTextAlign:(0,h.useCallback)(()=>{if(!a)return!1;let e=function(e,t){if(!e||!e.isEditable||!hu(e,t))return!1;let n=e.chain().focus();return"setTextAlign"in n&&n.setTextAlign(t).run()}(a,n);return e&&(null==l||l()),e},[a,n,l]),canAlign:s,label:hd[n],shortcutKeys:hs[n],Icon:hc[n]}}({editor:g,align:l,hideWhenUnavailable:o,onAligned:i}),j=(0,h.useCallback)(e=>{null==c||c(e),e.defaultPrevented||x()},[x,c]);return f?(0,r.jsx)(d.$n,{type:"button",disabled:!C,"data-style":"ghost","data-active-state":v?"on":"off","data-disabled":!C,role:"button",tabIndex:-1,"aria-label":b,"aria-pressed":v,tooltip:b,onClick:j,...m,ref:t,children:null!=p?p:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(null!=u?u:y,{className:"tiptap-button-icon"}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),s&&(0,r.jsx)(hp,{align:l,shortcutKeys:w})]})}):null});hh.displayName="TextAlignButton";let hm=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]})});hm.displayName="BlockquoteIcon";let hg="mod+shift+b";function hf(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return!(!e||!e.isEditable||!(0,eg.HR)("blockquote",e)||(0,eg.ee)(e,["image"]))&&(t?!!(0,eg.k)(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&(e.can().toggleWrap("blockquote")||e.can().clearNodes()):e.can().toggleWrap("blockquote"))}function hx(e){let{shortcutKeys:t=hg}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}let hb=(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:c,...u}=e,{editor:p}=nl(n),{isVisible:m,canToggle:g,isActive:f,handleToggle:x,label:b,shortcutKeys:C,Icon:v}=function(e){let{editor:t,hideWhenUnavailable:n=!1,onToggled:r}=e||{},{editor:l}=nl(t),[a,o]=(0,h.useState)(!0),i=hf(l),s=(null==l?void 0:l.isActive("blockquote"))||!1;return(0,h.useEffect)(()=>{if(!l)return;let e=()=>{o(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.HR)("blockquote",t)&&(!n||!!t.isActive("code")||hf(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]),{isVisible:a,isActive:s,handleToggle:(0,h.useCallback)(()=>{if(!l)return!1;let e=function(e){if(!e||!e.isEditable||!hf(e))return!1;try{var t,n,r;let l=e.view,a=l.state,o=a.tr;if(a.selection.empty){let n=null==(t=(0,eg.po)({editor:e,node:a.selection.$anchor.node(1)}))?void 0:t.pos;if(!(0,eg.u1)(n))return!1;o=o.setSelection($.nh.create(a.doc,n)),l.dispatch(o),a=l.state}let i=a.selection,s=e.chain().focus();if(i instanceof $.nh){let e=null==(n=i.node.firstChild)?void 0:n.firstChild,t=null==(r=i.node.lastChild)?void 0:r.lastChild,l=e?i.from+e.nodeSize:i.from+1,o=t?i.to-t.nodeSize:i.to-1,c=a.doc.resolve(l),d=a.doc.resolve(o);s=s.setTextSelection($.U3.between(c,d)).clearNodes()}else i.empty||(s=s.clearNodes());return(e.isActive("blockquote")?s.lift("blockquote"):s.wrapIn("blockquote")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]),canToggle:i,label:"Blockquote",shortcutKeys:hg,Icon:hm}}({editor:p,hideWhenUnavailable:a,onToggled:o}),y=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||x()},[x,s]);return m?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":b,"aria-pressed":f,tooltip:"Blockquote",onClick:y,...u,ref:t,children:null!=c?c:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i&&(0,r.jsx)(hx,{shortcutKeys:C})]})}):null});hb.displayName="BlockquoteButton";let hC=(0,h.memo)(e=>{let{className:t,...n}=e;return(0,r.jsxs)("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"
1currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]})});hC.displayName="CodeBlockIcon";let hv="mod+alt+c";function hy(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return!(!e||!e.isEditable||!(0,eg.HR)("codeBlock",e)||(0,eg.ee)(e,["image"]))&&(t?!!(0,eg.k)(e,["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock"])&&(e.can().toggleNode("codeBlock","paragraph")||e.can().clearNodes()):e.can().toggleNode("codeBlock","paragraph"))}function hw(e){let{shortcutKeys:t=hv}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}let hj=(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:c,...u}=e,{editor:p}=nl(n),{isVisible:m,canToggle:g,isActive:f,handleToggle:x,label:b,shortcutKeys:C,Icon:v}=function(e){let{editor:t,hideWhenUnavailable:n=!1,onToggled:r}=e||{},{editor:l}=nl(t),[a,o]=(0,h.useState)(!0),i=hy(l),s=(null==l?void 0:l.isActive("codeBlock"))||!1;return(0,h.useEffect)(()=>{if(!l)return;let e=()=>{o(function(e){let{editor:t,hideWhenUnavailable:n}=e;return!!t&&!!t.isEditable&&!!(0,eg.HR)("codeBlock",t)&&(!n||!!t.isActive("code")||hy(t))}({editor:l,hideWhenUnavailable:n}))};return e(),l.on("selectionUpdate",e),()=>{l.off("selectionUpdate",e)}},[l,n]),{isVisible:a,isActive:s,handleToggle:(0,h.useCallback)(()=>{if(!l)return!1;let e=function(e){if(!e||!e.isEditable||!hy(e))return!1;try{var t,n,r;let l=e.view,a=l.state,o=a.tr;if(a.selection.empty){let n=null==(t=(0,eg.po)({editor:e,node:a.selection.$anchor.node(1)}))?void 0:t.pos;if(!(0,eg.u1)(n))return!1;o=o.setSelection($.nh.create(a.doc,n)),l.dispatch(o),a=l.state}let i=a.selection,s=e.chain().focus();if(i instanceof $.nh){let e=null==(n=i.node.firstChild)?void 0:n.firstChild,t=null==(r=i.node.lastChild)?void 0:r.lastChild,l=e?i.from+e.nodeSize:i.from+1,o=t?i.to-t.nodeSize:i.to-1,c=a.doc.resolve(l),d=a.doc.resolve(o);s=s.setTextSelection($.U3.between(c,d)).clearNodes()}else i.empty||(s=s.clearNodes());return(e.isActive("codeBlock")?s.setNode("paragraph"):s.toggleNode("codeBlock","paragraph")).run(),e.chain().focus().selectTextblockEnd().run(),!0}catch(e){return!1}}(l);return e&&(null==r||r()),e},[l,r]),canToggle:i,label:"Code Block",shortcutKeys:hv,Icon:hC}}({editor:p,hideWhenUnavailable:a,onToggled:o}),y=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||x()},[x,s]);return m?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",disabled:!g,"data-disabled":!g,tabIndex:-1,"aria-label":b,"aria-pressed":f,tooltip:"Code Block",onClick:y,...u,ref:t,children:null!=c?c:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i&&(0,r.jsx)(hw,{shortcutKeys:C})]})}):null});function hI(e){let{level:t,shortcutKeys:n=cV[t]}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:n})})}hj.displayName="CodeBlockButton";let hk=(0,h.forwardRef)((e,t)=>{let{editor:n,level:l,text:a,hideWhenUnavailable:o=!1,onToggled:i,showShortcut:s=!1,onClick:c,children:u,...p}=e,{editor:m}=nl(n),{isVisible:g,canToggle:f,isActive:x,handleToggle:b,label:C,Icon:v,shortcutKeys:y}=cW({editor:m,level:l,hideWhenUnavailable:o,onToggled:i}),w=(0,h.useCallback)(e=>{null==c||c(e),e.defaultPrevented||b()},[b,c]);return g?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":x?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":C,"aria-pressed":x,tooltip:C,onClick:w,...p,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{className:"tiptap-button-icon"}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),s&&(0,r.jsx)(hI,{level:l,shortcutKeys:y})]})}):null});function hE(e){let{type:t,shortcutKeys:n=c3[t]}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:n})})}hk.displayName="HeadingButton";let hN=(0,h.forwardRef)((e,t)=>{let{editor:n,type:l,text:a,hideWhenUnavailable:o=!1,onToggled:i,showShortcut:s=!1,onClick:c,children:u,...p}=e,{editor:m}=nl(n),{isVisible:g,canToggle:f,isActive:x,handleToggle:b,label:C,shortcutKeys:v,Icon:y}=c6({editor:m,type:l,hideWhenUnavailable:o,onToggled:i}),w=(0,h.useCallback)(e=>{null==c||c(e),e.defaultPrevented||b()},[b,c]);return g?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":x?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":C,"aria-pressed":x,tooltip:C,onClick:w,...p,ref:t,children:null!=u?u:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y,{className:"tiptap-button-icon"}),a&&(0,r.jsx)("span",{className:"tiptap-button-text",children:a}),s&&(0,r.jsx)(hE,{type:l,shortcutKeys:v})]})}):null});function hS(e){let{shortcutKeys:t=ds}=e;return(0,r.jsx)(cf,{children:(0,eg.wi)({shortcutKeys:t})})}hN.displayName="ListButton";let hT=(0,h.forwardRef)((e,t)=>{let{editor:n,text:l,hideWhenUnavailable:a=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:c,...u}=e,{editor:p}=nl(n),{isVisible:m,canToggle:g,isActive:f,handleToggle:x,label:b,shortcutKeys:C,Icon:v}=dd({editor:p,hideWhenUnavailable:a,onToggled:o}),y=(0,h.useCallback)(e=>{null==s||s(e),e.defaultPrevented||x()},[x,s]);return m?(0,r.jsx)(d.$n,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!g,"data-disabled":!g,"aria-label":b,"aria-pressed":f,tooltip:"Text",onClick:y,...u,ref:t,children:null!=c?c:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v,{className:"tiptap-button-icon"}),l&&(0,r.jsx)("span",{className:"tiptap-button-text",children:l}),i&&(0,r.jsx)(hS,{shortcutKeys:C})]})}):null});hT.displayName="TextButton";let hA=e=>{let{blockTypes:t,useCardLayout:n=!0}=e,l=pZ(t),a=()=>(0,r.jsx)(d.e2,{children:l.map((e,t)=>{var n;return function(e,t){switch(e.type){case"paragraph":return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hT,{showTooltip:!1,text:e.label})},t);case"heading":if(!e.level)return null;return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hk,{level:e.level||1,showTooltip:!1,text:e.label})},t);case"bulletList":return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hN,{type:"bulletList",showTooltip:!1,text:e.label})},t);case"orderedList":return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hN,{type:"orderedList",showTooltip:!1,text:e.label})},t);case"taskList":return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hN,{type:"taskList",showTooltip:!1,text:e.label})},t);case"blockquote":return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hb,{showTooltip:!1,text:e.label})},t);case"codeBlock":return(0,r.jsx)(u9,{asChild:!0,children:(0,r.jsx)(hj,{showTooltip:!1,text:e.label})},t);default:return null}}(e,"".concat(e.type,"-").concat(null!=(n=e.level)?n:t))})});return n?(0,r.jsx)(nh,{children:(0,r.jsx)(nm,{children:(0,r.jsxs)(ng,{children:[(0,r.jsx)(nf,{children:"Turn into"}),a()]})})}):a()},hR=(0,h.forwardRef)((e,t)=>{let{editor:n,hideWhenUnavailable:l=!1,blockTypes:a,useCardLayout:o=!0,onOpenChange:i,children:s,...c}=e,{editor:u}=nl(n),{isVisible:p,canToggle:h,isOpen:m,activeBlockType:g,handleOpenChange:f,label:x,Icon:b}=pq({editor:u,hideWhenUnavailable:l,blockTypes:a,onOpenChange:i});return p?(0,r.jsxs)(u5,{open:m,onOpenChange:f,children:[(0,r.jsx)(u3,{asChild:!0,children:(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",disabled:!h,"data-disabled":!h,role:"button",tabIndex:-1,"aria-label":x,tooltip:"Text options",...c,ref:t,children:null!=s?s:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"tiptap-button-text truncate max-w-xs",children:(null==g?void 0:g.label)||"Text"}),(0,r.jsx)(b,{className:"tiptap-button-dropdown-small"})]})})}),(0,r.jsx)(u8,{align:"start",children:(0,r.jsx)(hA,{blockTypes:a,useCardLayout:o})})]}):null});hR.displayName="TurnIntoDropdown";let hM=(0,h.memo)(pY),hL=(0,h.memo)(pJ);function hD(e){var t,n;let{setOpenFromCTA:a}=e,{editor:o}=nl(),i=rQ("max",480),{lockDragHandle:s,aiGenerationActive:c,commentInputVisible:u}=aN(o),{isEditorEmpty:p}=(0,uW.y)(o),{shouldShow:m,setShouldShow:g}=function(e){let{editor:t,isSelectionValid:n,extraHideWhen:r=!1}=e,[a,o]=(0,h.useState)(!1),i=(0,h.useRef)(!1);return(0,h.useEffect)(()=>
1{if(!t)return;let e=e=>{let{transaction:t}=e;t.getMeta(cl)?i.current=!0:t.selectionSet&&(i.current=!1)};return t.on("transaction",e),()=>{t.off("transaction",e)}},[t]),(0,h.useEffect)(()=>{var e;if(!t||!(null==(e=t.view)?void 0:e.dom))return;let l=t.view.dom,a=e=>{let l=t.state.selection;if(!(l instanceof $.nh))return;let a=t.view.nodeDOM(l.from);a&&a.contains(e.target)&&(i.current=!1,o(n(t,l)&&!r))};return l.addEventListener("pointerdown",a,{capture:!0}),()=>l.removeEventListener("pointerdown",a,{capture:!0})},[t,r,n]),(0,h.useEffect)(()=>{if(!t)return;let e=()=>{let{selection:e}=t.state,a=n(t,e);if(r||(0,l.BQ)(e)&&i.current||!t.isFocused)return void o(!1);o(a)};return e(),t.on("selectionUpdate",e),()=>{t.off("selectionUpdate",e)}},[t,r,n]),{shouldShow:a,setShouldShow:o}}({editor:o,isSelectionValid:ns,extraHideWhen:!!(c||u)});return s||i||p?null:(0,r.jsx)(nu,{shouldShow:m,resetTextSelectionOnClose:!1,floatingOptions:{placement:"top",middleware:[(0,t8.UU)({padding:8,boundary:null!=(t=null==o?void 0:o.view.dom.parentElement)?t:"clippingAncestors",fallbackPlacements:["bottom"]}),(0,t8.cY)(8),(0,t8.BN)({padding:20,boundary:null!=(n=null==o?void 0:o.view.dom.parentElement)?n:"clippingAncestors"})]},children:(0,r.jsxs)(o_,{variant:"floating",children:[(0,r.jsx)(oH,{children:(0,r.jsx)(cb,{"data-style":"primary",showTooltip:!0})}),!(0,eg.ee)(o,["image"],!0)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsxs)(d.$n,{className:"text-sm gap-1 !text-yellow-10 ","data-style":"ghost","aria-label":"Cite",onMouseDown:e=>e.preventDefault(),onClick:()=>{g(!1),a(!0)},children:[(0,r.jsx)(ew.jH,{className:"w-3 h-3"}),"Cite"]})}),(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsx)(d.$n,{className:"text-sm",tooltip:"Add a comment","data-style":"ghost","aria-label":"comment",trackingProperties:{CTALabel:"Comment"},"data-testid":"Comment",onClick:()=>{null==o||o.chain().focus().commentInputShow().run()},children:(0,r.jsx)(ew.by,{className:"w-4 h-4 flex-shrink-0 text-yellow-10"})})})]}),(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsx)(hR,{hideWhenUnavailable:!0})}),(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsx)(hL,{hideWhenUnavailable:!0})}),(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsx)(hM,{hideWhenUnavailable:!0})}),(0,r.jsx)(oP,{className:"hidden lg:flex"}),(0,r.jsxs)(oH,{className:"hidden lg:flex items-center gap-1",children:[(0,r.jsx)(hi,{type:"bold",hideWhenUnavailable:!0}),(0,r.jsx)(hi,{type:"italic",hideWhenUnavailable:!0}),(0,r.jsx)(hi,{type:"underline",hideWhenUnavailable:!0}),(0,r.jsx)(hi,{type:"strike",hideWhenUnavailable:!0})]}),(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsx)(pT,{})}),(0,r.jsxs)(oH,{children:[(0,r.jsx)(p7,{autoOpenOnLinkActive:!1,hideWhenUnavailable:!0}),(0,r.jsx)(pV,{hideWhenUnavailable:!0})]}),(0,r.jsx)(h_,{hideWhenUnavailable:!0})]})})}function h_(e){let{editor:t,hideWhenUnavailable:n=!1,...l}=e,{editor:a}=nl(t),[o,i]=(0,h.useState)(!1);return((0,h.useEffect)(()=>{if(!a)return;let e=()=>{i(function(e){let{editor:t,hideWhenUnavailable:n}=e;if(!t)return!1;if(n&&!t.isActive("code")){if(!t)return!1;let e=["left","center","right","justify"].some(e=>hu(t,e));return["superscript","subscript"].some(e=>ha(t,e))||e}return!!(null==t?void 0:t.isEditable)}({editor:a,hideWhenUnavailable:n}))};return e(),a.on("selectionUpdate",e),()=>{a.off("selectionUpdate",e)}},[a,n]),o&&a&&a.isEditable)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(oP,{}),(0,r.jsx)(oH,{children:(0,r.jsxs)(pR,{children:[(0,r.jsx)(pM,{asChild:!0,children:(0,r.jsx)(d.$n,{type:"button","data-style":"ghost",role:"button",tabIndex:-1,tooltip:"More options",...l,children:(0,r.jsx)(ly,{className:"tiptap-button-icon"})})}),(0,r.jsx)(pL,{side:"top",align:"end",alignOffset:4,sideOffset:4,asChild:!0,children:(0,r.jsxs)(o_,{variant:"floating",tabIndex:0,children:[(0,r.jsxs)(oH,{children:[(0,r.jsx)(hi,{type:"superscript"}),(0,r.jsx)(hi,{type:"subscript"})]}),(0,r.jsx)(oP,{}),(0,r.jsxs)(oH,{children:[(0,r.jsx)(hh,{align:"left"}),(0,r.jsx)(hh,{align:"center"}),(0,r.jsx)(hh,{align:"right"}),(0,r.jsx)(hh,{align:"justify"})]}),(0,r.jsx)(oP,{})]})})]})})]}):null}function hH(e){let{text:t="Connecting...",editorType:n}=e;return(0,r.jsx)("div",{"data-style":n,className:"spinner-container animate-pulse",children:(0,r.jsxs)("div",{className:"spinner-content gap-0.5",children:[(0,r.jsx)("span",{className:"w-4 h-4 border-2 border-solid border-blue-11 border-t-transparent roun
1ded-full animate-spin"}),(0,r.jsx)("div",{className:"spinner-loading-text",children:t})]})})}function hP(e){let{isMobileWeb:t,documentId:n}=e,[l,a]=(0,h.useState)(!1),{editorType:o}=az(),{editor:i}=(0,h.useContext)(ef.pl),{aiGenerationIsLoading:s,aiGenerationIsSelection:c,aiGenerationHasMessage:d,isDragging:u}=aN(i),{user:{isReadOnlyAccess:p}}=s8(),{currentCountry:m,isFetchingCountry:g,refetchCountry:f}=d0();return((0,h.useEffect)(()=>{i&&!s&&c&&d&&(i.chain().focus().aiAccept().run(),i.commands.resetUiState())},[d,s,c,i]),!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{editor:t,onTargetFound:n=()=>{},onTargetNotFound:r=()=>{}}=e,{editor:l}=nl(t),a=(0,h.useCallback)(e=>{var t,n,r;if(!l)return!1;let a=null!=(r=null==(n=function(e,t){if(!e)return null;let n=e.extensionManager.extensions.find(e=>e.name===t);return n||(console.warn('Extension "'.concat(t,'" not found in the editor schema. Ensure it is included in the editor configuration.')),null)}(l,"uniqueID"))||null==(t=n.options)?void 0:t.attributeName)?r:"data-id",o=null;return l.state.doc.descendants((t,n)=>{var r;return(null==(r=t.attrs)?void 0:r[a])!==e||(o=n,!1)}),null!==o&&(ca(l,o),setTimeout(()=>{let e=l.view.nodeDOM(o);e&&e.scrollIntoView({behavior:"smooth",block:"center"})},0),!0)},[l]),o=(0,h.useCallback)(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,l=null==(e=window.location.hash)?void 0:e.substring(1);l&&setTimeout(()=>{a(l)?n(l):r(l)},t)},[a,n,r]);(0,h.useEffect)(()=>{var e,t;if(!l)return;let n=null==(t=l.extensionManager.extensions.find(e=>"collaborationCaret"===e.name))||null==(e=t.options)?void 0:e.provider;if(null==n?void 0:n.on){let e=()=>o(500);return n.on("synced",e),()=>{var t;null==(t=n.off)||t.call(n,"synced",e)}}o(500)},[l,o]),(0,h.useEffect)(()=>{let e=()=>o(),t=()=>o(500);return window.addEventListener("hashchange",e),window.addEventListener("pageshow",t),window.addEventListener("popstate",e),()=>{window.removeEventListener("hashchange",e),window.removeEventListener("pageshow",t),window.removeEventListener("popstate",e)}},[o])}(),i)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ef.$Z,{editor:i,role:"presentation",id:"tip-tap-editor","data-test-id":"tip-tap-editor",disabled:d||s,style:{cursor:u?"grabbing":"auto"},children:o===et.zR.DraftEditor&&(0,r.jsxs)(r.Fragment,{children:[!t&&(0,r.jsx)(pi,{isMobileWeb:t}),(0,r.jsx)(o3,{}),(0,r.jsx)(cr,{}),(0,r.jsx)(sX,{openFromCTA:l,setOpenFromCTA:a,currentCountry:m,isFetchingCountry:g,refetchCountry:f}),(0,r.jsx)(dH,{}),!p&&(0,r.jsx)(hD,{setOpenFromCTA:a}),(0,r.jsx)(dy,{}),(0,r.jsx)(dN,{}),(0,r.jsx)(nk,{editor:i})]})},o),o===et.zR.DraftEditor&&!p&&!i.isEmpty&&n&&(0,r.jsx)(nH,{editor:i,documentId:n})]}):null}function hO(e){let{provider:t,ydoc:n,updateInlineCitations:l,placeholder:o,shouldRunOnPersistence:i}=e,{user:c}=s8(),{setDocumentcontroller:d,handleSelectionUpdate:u}=(0,x.R1)(),{editorType:p,syncDocumentCitationStyle:m,isEditable:f,setPastedTextLength:C,handleRedirectToLanguageTab:v,handleRedirectToCommentThread:y}=az(),{documentId:w,aiToken:j}=g(),{isMobileWeb:I}=(0,ui.m)(),k=null!=o?o:I?"Write or paste text to improve grammar, tone, and clarity.":"Write or paste text to improve grammar, tone, and clarity. ".concat((0,eg.cX)()?"⌘J":"Ctrl+J"," for AI assistance"),{generateStreamResponse:E,generatePlainResponse:N}=ut(),{insertCitationsToLibrary:S}=iH(),{insertCitationsToDocument:T}=tR(),{documentCitationStyle:R}=iQ(w,p===et.zR.DraftEditor||!0===m);if(R){let e=n.getMap("citationStyle"),t=e.get("style"),r=!0===m&&(null==t?void 0:t.key)!==R.key;(!t||r)&&e.set("style",R)}let{formattingExtensions:M}=t1({updateInlineCitations:l,ydoc:n}),L=(0,h.useMemo)(()=>[ul.xg.configure({provider:t}),uo.Z.configure({provider:t,user:{id:c.id,name:c.name,color:c.color}})],[t,c]),D=(0,h.useRef)(""),_=(0,h.useCallback)(N,[N]),H=(0,h.useCallback)(E,[E]),P=(0,h.useMemo)(()=>p===et.zR.DraftEditor?[...L,ur.Ai.configure({token:j,autocompletion:!1,showDecorations:!0,hideDecorationsOnStreamEnd:!1,aiCompletionResolver:async e=>_({option:e}),aiStreamResolver:async e=>H({option:e}),onLoading:e=>{let t=un(e);
1e.editor.commands.uiStateSetActiveFeature(t,!0),e.editor.commands.uiStateUpdateResult(t,""),e.editor.commands.aiGenerationSetIsLoading(!0),e.editor.commands.aiGenerationHasMessage(!1)},onChunk:e=>{var t,n,r,l;if(!(null==(t=e.editor.storage.uiState)?void 0:t.aiGenerationActive)){null==(r=e.editor.commands)||null==(n=r.resetUiState)||n.call(r),D.current="";return}let a=null!=(l=e.response)?l:"";if(!D.current){let t=un(e);D.current=t,e.editor.commands.uiStateUpdateResultRequestIds(t),e.editor.commands.aiGenerationSetIsLoading(!0),e.editor.commands.aiGenerationHasMessage(!0)}requestAnimationFrame(()=>{D.current&&e.editor.commands.uiStateUpdateResult(D.current,a)})},onSuccess:e=>{let t=e.editor.storage.uiState;if(!(null==t?void 0:t.aiGenerationActive)){var n,r;null==(r=e.editor.commands)||null==(n=r.resetUiState)||n.call(r),D.current="";return}let l=t.processedFinalText||e.response,a=un(e);e.editor.commands.uiStateUpdateResult(a,null!=l?l:""),t.processedFinalText="",e.editor.commands.aiGenerationSetIsLoading(!1),e.editor.commands.aiGenerationHasMessage(!!l),e.editor.commands.uiStateResetRequestId(),D.current=""},onError:(e,t)=>{D.current="";let{errorCode:n,errorReason:r}=(0,op.F)(e),l="PAYMENT_REQUIRED"===n||n===oc.a.REWRITE_WORD_COUNT_LIMIT_EXCEEDED?n:null!=r?r:"Something went wrong";t.editor.commands.aiGenerationSetIsLoading(!1),t.editor.commands.aiGenerationSetError(l),t.editor.commands.uiStateResetRequestId()}}),nE.configure({provider:t}),ed.configure({handleRedirect:v}),X.configure({handleRedirectToCommentThread:y}),s.configure({ydoc:n}),ei.configure({updateInlineCitations:l,documentId:w,insertCitationsToDocument:T,insertCitationsToLibrary:S,setPastedTextLength:C})]:p===et.zR.NotesEditor?[...L]:[],[j,w,p,_,H,l,y,v,T,S,t,C,n,L]),O=(0,ef.hG)({immediatelyRender:!1,enableContentCheck:!0,shouldRerenderOnTransaction:!1,autofocus:!I,editable:f,editorProps:{handleKeyDown:(e,t)=>{if(c.isReadOnlyAccess)return t.preventDefault(),!0},attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off",class:(0,eg.cn)("flex-1 paperpal-editor",I?"pp-editor-mobile":""),role:"textbox","aria-multiline":"true","aria-label":"Write your content here"}},extensions:[tm.OV.configure({document:n}),ua.Ay.configure({provider:t}),tN.Or.configure({placeholder:k,emptyNodeClass:"is-empty with-slash"}),...M,...P],onCreate:e=>{e.editor.view.dom.setAttribute("spellcheck","false")},onSelectionUpdate:e=>{let{editor:t}=e;u&&u(t)},onUpdate:e=>{let{editor:t}=e,n=t.state,r=n.doc.textBetween(n.selection.$from.pos-1,n.selection.$from.pos);" "===r&&t.isActive("superscript")&&t.chain().focus().toggleSuperscript().run()," "===r&&t.isActive("subscript")&&t.chain().focus().toggleSubscript().run()},onContentError:e=>{let{editor:t,error:n,disableCollaboration:r}=e;if(!(null==t?void 0:t.isEditable)){console.error("Error in Editor onContentError disable: ".concat(n)),r();return}try{if(window.document&&"function"==typeof window.document.hasFocus&&"visible"===document.visibilityState)return void console.error("Error in Editor onContentError success: ".concat(n));r(),null==t||t.setEditable(!1,!1),setTimeout(()=>{console.error("Error in Editor onContentError reloading : ".concat(n)),window.location.reload()},1e3)}catch(e){console.error("Error in Editor in Catch : ".concat(e))}}}),z=(0,A.useQueryClient)();(0,h.useEffect)(()=>{if(!n||!O)return;let e=n.getMap("citationStyle"),t=O.extensionStorage[a.A.PAPERPAL_CITATION],r=async()=>{let n=e.get("style");n&&t.citationStyle!==n.key&&(O.commands.updateCitationStyle(n),z&&w&&z.setQueryData(["document-citation-style",w],e=>e?{...e,name:n.name,key:n.key,id:n.id}:e))};return e.observe(r),()=>e.unobserve(r)},[n,O,w,z]),(0,h.useEffect)(()=>{O&&d&&d(O)},[O,d]),(0,h.useEffect)(()=>()=>{null==O||O.destroy()},[O]);let B=(0,h.useRef)(!1);return((0,h.useEffect)(()=>{if(!O||!t||i||"function"!=typeof t.createVersion||"function"!=typeof t.on||"function"!=typeof t.off)return;let e=()=>{var e;if(B.current)return;let n=null==(e=t.document)?void 0:e.getArray("__tiptapcollab__versions");n&&!(n.length>0)&&(B.current=!0,O.commands.saveVersion("Initial version"))};return t.on("synced",e),t.synced&&e(),()=>{var n;return null==(n=t.off)?void 0:n.call(t,"synced",e)}},[O,t,i]),O)?(0,r.jsxs)(ef.pl.Provider,{value:{editor:O},children:[(0,r.jsx)(hP,{isMobileWeb:I,documentId:w}),p===et.zR.DraftEditor&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lv,{}),(0,r.jsx)(ac,{}),(0,r.jsx)(ab,{showResizeHandles:!0,cellMenu:e=>(0,r.jsx)(lm,{editor:e.editor,onMouseDown:t=>{var n;return null==(n=e.onResizeStart)?void 0:n.call(e,"br")(t)}})}),(0,r.jsx)(G,{editor:O}),(0,r.jsx)(t4,{editor:O}),(0,r.jsx)(b.l$,{})]})]}):(0,r.jsx)(hH,{editorType:p,text:"Initializing editor"})}
1function hz(e){let{collabToken:t,placeholder:n,aiToken:l,documentId:a,sessionId:o,shouldRunOnPersistence:i,editorSkeletonLoader:s,shouldClearTextOnLoad:c,indexedDBName:d,...u}=e;return(0,r.jsx)(s6,{collabToken:t,children:(0,r.jsx)(aO,{...u,children:(0,r.jsx)(dJ,{collabToken:t,documentId:a,shouldRunOnPersistence:i,shouldClearTextOnLoad:c,indexedDBName:d,children:(0,r.jsx)(f,{aiToken:l,sessionId:o,documentId:a,children:(0,r.jsx)(hB,{placeholder:n,editorSkeletonLoader:s})})})})})}function hB(e){let{placeholder:t,editorSkeletonLoader:n}=e,{aiToken:l,documentId:a,sessionId:o}=g(),{editorType:i}=az(),{provider:s,ydoc:c,isSynced:d,shouldRunOnPersistence:u}=dY();return s&&d&&(l||u)&&(i!==et.zR.DraftEditor||o)?i===et.zR.AiDetectionEditor||i===et.zR.GuestEditor?(0,r.jsx)(hF,{ydoc:c,provider:s,placeholder:t,shouldRunOnPersistence:u},"".concat(i,"-").concat(a)):(0,r.jsx)(hV,{ydoc:c,provider:s,placeholder:t,shouldRunOnPersistence:u},"".concat(i,"-").concat(a)):null!=n?n:(0,r.jsx)(hH,{editorType:i,text:"Initializing the editor..."})}let hF=e=>(0,r.jsx)(hO,{...e}),hV=e=>{let{updateInlineCitations:t}=t6();return(0,r.jsx)(hO,{...e,updateInlineCitations:t})}}
1,85552:(e,t,n)=>{"use strict";n.d(t,{R:()=>u});var r=n(80263),l=n(53239),a=n(16679),o=n(70077),i=n(67106),s=n(11808),c=n(38767);let d=e=>{var t;let{collection:n,depth:l,expandedIds:a,onToggle:o,onSelect:s}=e,c=!!(null==(t=n.children)?void 0:t.length),u=a.has(n.id);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(x,{onClick:()=>s(n),style:{paddingLeft:"".concat(12+16*l,"px")},children:[(0,r.jsx)(b,{children:n.name}),c&&(0,r.jsx)(C,{onClick:e=>{e.stopPropagation(),o(n.id)},"data-expanded":u,children:(0,r.jsx)(i.I,{name:"chevronDown",variant:"regular",width:12,height:12})})]}),c&&u&&(0,r.jsx)(v,{children:n.children.map(e=>(0,r.jsx)(d,{collection:e,depth:l+1,expandedIds:a,onToggle:o,onSelect:s},e.id))})]})},u=e=>{let{collections:t,isCollectionsLoading:n=!1,onCollectionSelect:o,onCreateCollection:u,isCreatingCollection:C=!1,isExtension:v=!1,rootContainer:E,onCreateDialogOpenChange:N}=e,[S,T]=(0,l.useState)(""),[A,R]=(0,l.useState)(new Set),[M,L]=(0,l.useState)(!1),D=(0,l.useRef)(null);(0,l.useEffect)(()=>{setTimeout(()=>{var e;null==(e=D.current)||e.focus({preventScroll:!0})},50)},[]);let _=(0,l.useMemo)(()=>(0,s.c)(t),[t]),H=(0,l.useMemo)(()=>S.trim().toLowerCase(),[S]),P=(0,l.useMemo)(()=>H?_.filter(e=>e.collection.name.toLowerCase().includes(H)):_,[_,H]),O=(0,l.useCallback)(e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),z=(0,l.useCallback)(e=>{o(e)},[o]),B=(0,l.useCallback)(()=>{L(!0),null==N||N(!0)},[N]),F=(0,l.useCallback)(()=>{L(!1),null==N||N(!1)},[N]),V=(0,l.useCallback)(e=>{o(e)},[o]),U=H.length>0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(p,{"data-tiptap-cite-portal":"true",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)(j,{children:"Add to Collection"}),(0,r.jsxs)(h,{children:[(0,r.jsx)(m,{children:(0,r.jsx)(i.I,{name:"search",variant:"regular",width:14,height:14})}),(0,r.jsx)(g,{ref:D,id:"search",placeholder:"Search Collections...",value:S,onChange:e=>T(e.target.value),autoComplete:"off","data-test-id":"collection-selector-search-input"})]}),(0,r.jsx)(f,{children:n?(0,r.jsx)(y,{children:(0,r.jsx)(c.y,{size:16,color:a.w4.colors.blue10})}):U?0===P.length?(0,r.jsx)(w,{children:"No collections found"}):P.map(e=>(0,r.jsxs)(x,{onClick:()=>z(e.collection),style:{paddingLeft:"".concat(12+16*e.depth,"px")}
1,children:[(0,r.jsx)(i.I,{name:"listTree",variant:"light",width:14,height:14}),(0,r.jsx)(b,{children:e.collection.name})]},e.collection.id)):0===t.length?(0,r.jsx)(w,{children:"No collections found"}):t.map(e=>(0,r.jsx)(d,{collection:e,depth:0,expandedIds:A,onToggle:O,onSelect:z},e.id))}),(0,r.jsx)(I,{children:(0,r.jsxs)(k,{css:{textAlign:"center"},onClick:B,children:[(0,r.jsx)(i.I,{name:"Plus",variant:"solid",width:14,height:14}),"Create Collection"]})})]}),(0,r.jsx)(s.X,{open:M,onClose:F,collections:t,onSubmit:u,onSuccess:V,isCreating:C,isExtension:v,rootContainer:E})]})},p=(0,a.I4)("div",{display:"flex",flexDirection:"column",width:(0,o.D)(260),maxHeight:(0,o.D)(336)}),h=(0,a.I4)("div",{margin:"".concat((0,o.D)(0)," ").concat((0,o.D)(10)),padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(0)),position:"relative",borderBottom:"1px solid ".concat(a.w4.colors.gray5)}),m=(0,a.I4)("div",{position:"absolute",left:(0,o.D)(10),top:"50%",transform:"translateY(-50%)",color:a.w4.colors.gray9,pointerEvents:"none",fontSize:(0,o.D)(12)}),g=(0,a.I4)("input",{width:"100%",border:"1px solid ".concat(a.w4.colors.gray7),borderRadius:(0,o.D)(6),padding:"".concat((0,o.D)(6)," ").concat((0,o.D)(8)),paddingLeft:(0,o.D)(28),fontSize:(0,o.D)(13),outline:"none",color:a.w4.colors.gray12,"&::placeholder":{color:a.w4.colors.gray9},"&:focus":{borderColor:a.w4.colors.blue9}}),f=(0,a.I4)("div",{flex:1,overflowY:"auto",maxHeight:(0,o.D)(200)}),x=(0,a.I4)("div",{display:"flex",alignItems:"center",gap:(0,o.D)(8),padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(12)),cursor:"pointer",fontSize:(0,o.D)(14),fontWeight:500,color:a.w4.colors.gray12,transition:"background-color 0.15s",position:"relative",paddingRight:(0,o.D)(48),minHeight:(0,o.D)(32),"&:hover":{backgroundColor:a.w4.colors.blue3}}),b=(0,a.I4)("span",{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,lineHeight:1.4}),C=(0,a.I4)("button",{position:"absolute",right:(0,o.D)(0),top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center",padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(10)),border:"none",background:"none",cursor:"pointer",color:a.w4.colors.gray9,borderRadius:(0,o.D)(4),transition:"transform 0.2s ease",pointerEvents:"auto",'&[data-expanded="true"]':{transform:"translateY(-50%) rotate(180deg)"},"&:hover":{backgroundColor:a.w4.colors.gray4}}),v=(0,a.I4)("div",{overflow:"hidden"}),y=(0,a.I4)("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:(0,o.D)(16)}),w=(0,a.I4)("div",{padding:(0,o.D)(16),textAlign:"center",fontSize:(0,o.D)(13),color:a.w4.colors.gray9}),j=(0,a.I4)("div",{padding:"14px 12px 6px 14px",fontSize:(0,o.D)(12),fontWeight:600,color:a.w4.colors.blue12,letterSpacing:"0.5px"}),I=(0,a.I4)("div",{borderTop:"1px solid ".concat(a.w4.colors.gray6),padding:"".concat((0,o.D)(0)," ").concat((0,o.D)(0))}),k=(0,a.I4)("button",{display:"flex",alignItems:"center",justifyContent:"center",gap:(0,o.D)(6),width:"100%",padding:"".concat((0,o.D)(8)," ").concat((0,o.D)(12)),border:"none",background:"none",cursor:"pointer",fontSize:(0,o.D)(13),fontWeight:500,color:a.w4.colors.blue9,borderRadius:(0,o.D)(4),minHeight:(0,o.D)(36),"&:hover":{backgroundColor:a.w4.colors.blue3}})},86407:()=>{},86527:(e,t,n)=>{"use strict";n.d(t,{j:()=>a});var r=n(80263),l=n(53239);let a=e=>{let{width:t,height:a,src:o,rendererSettings:i}=e,[s,c]=(0,l.useState)(void 0);return((0,l.useEffect)(()=>{Promise.all([n.e(3103),n.e(9326)]).then(n.bind(n,89326)).then(e=>{c(()=>e.DotLottieReact)})},[]),s)?(0,r.jsx)(s,{width:t,height:a,src:o,loop:!0,autoplay:!0,rendererSettings:i}):null}},87094:(e,t,n)=>{"use strict";n.d(t,{m:()=>l});var r=n(4518);let l=()=>{let{t:e}=(0,r.B)();return{discountDefaultCampaignName:e("offer_banner.discount_offer_default_campaign_name","Special discount for you!"),durationDefaultCampaignName:e("offer_banner.duration_offer_default_campaign_name","Special Offer for you!"),upgradeLabel:e("offer_banner.upgrade_label","Enjoy upto {{currentDiscountValue}}% off on select plans."),endSoonLabel:e("offer_banner.end_date_soon","Ends very soon."),endDateLabel:e("offer_banner.end_date","Ends {{expiryDate}}."),discountCodeLabelForDisableAutoApply:e("offer_banner.discount_code_label_for_disable_auto_apply","Use code {{discountCode}} on checkout."),discountCodeLabelForAutoApply:e("offer_banner.discount_code_label_for_auto_apply","Code {{discountCode}} auto-applied on checkout."),upgradeCtaLabel:e("offer_banner.upgrade_btn_text","Upgrade Now"),differentialTextForDisableAutoApply:e("offer_banner.differential_text_for_disable_auto_apply","Get upto {{highestDiscountPercentage}}% OFF on already reduced prices in {{country}}."),differentialTextForAutoApply:e("offer_banner.differential_text_for_auto_apply","Enjoy upto {{highestDiscountPercentage}}% OFF in {{country}}."),nonDifferentialPitchForAllPacks:e("offer_banner.non_differential_text_discount_pitch_all","Enjoy {{currentDiscountValue}}% off on all plans."),nonDifferentialPitchForSinglePack:e("offer_banner.non_differential_text_discount_pitch_single","Enjoy {{currentDiscountValue}}% off on {{singlePlan}} plan."),nonDifferentialPitchForMultiplePacks:e("offer_banner.non_differential_text_discount_pitch_multiple","Enjoy {{currentDiscountValue}}% off on {{planList}} and {{lastPlan}} plans."),offerAutoAppliedLabel:e("offer_banner.offer_auto_applied_label","Offer auto-applied on checkout."),codeAutoAppliedLabel:e("offer_banner.code_auto_applied","Code auto-applied on checkout."),claimOfferCtaLabel:e("offer_banner.claim_offer_cta","Claim"),durationPitchForAllPacks:e("offer_banner.duration_label_all_plans","Get {{duration}} {{durationType}} extra on all packs"),durationPitchForSinglePack:e("offer_banner.duration_label_single_plan","Get {{duration}} {{durationType}} extra on the individual {{singlePlan}} plan."),durationPitchForMultiplePacks:e("offer_banner.duration_label_multiple_plans","Get {{duration}} {{durationType}} extra on the individual {{planList}} and {{lastPlan}} plans."),monthLabel:e("offer_banner.month_label","month"),quarterlyPackLabel:e("offer_banner.quarterly_plan","Quarterly"),annualPackLabel:e("offer_banner.annual_plan","Annual"),monthlyPack:e("offer_banner.monthly_plan","Monthly"),semiAnnualPack:e("offer_banner.6_months_plan","6 Months"),selectPlansLabel:e("offer_banner.select_plans_label","select"),autoApplyPlansPitch:e("offer_banner.auto_apply_plans_pitch","Enjoy {{highestDiscountPercentage}}% off on {{plansLabel}} plans."),endsInLabel:e("offer_banner.ends_in_label","Ends in"),daysLeftLabel:e("offer_banner.days_left_label","Ends in {{daysLeft}} days")}}},87387:(e,t,n)=>{"use strict";n.d(t,{w:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsx)("svg",{viewBox:"0 0 10 10",xmlns:"http://www.w3.org/2000/svg",fill:"
1currentColor",...e,children:(0,r.jsx)("path",{d:"M9.10156 7.64844C9.45703 7.97656 9.45703 8.55078 9.10156 8.87891C8.9375 9.04297 8.71875 9.125 8.5 9.125C8.25391 9.125 8.03516 9.04297 7.87109 8.87891L5 6.00781L2.10156 8.87891C1.9375 9.04297 1.71875 9.125 1.5 9.125C1.25391 9.125 1.03516 9.04297 0.871094 8.87891C0.515625 8.55078 0.515625 7.97656 0.871094 7.64844L3.74219 4.75L0.871094 1.87891C0.515625 1.55078 0.515625 0.976562 0.871094 0.648438C1.19922 0.292969 1.77344 0.292969 2.10156 0.648438L5 3.51953L7.87109 0.648438C8.19922 0.292969 8.77344 0.292969 9.10156 0.648438C9.45703 0.976562 9.45703 1.55078 9.10156 1.87891L6.23047 4.77734L9.10156 7.64844Z"})})},88904:()=>{},90100:(e,t,n)=>{"use strict";n.d(t,{K:()=>d});var r=n(80263),l=n(73991),a=n(16679),o=n(70077),i=n(18696),s=n(67106),c=n(90597);let d=e=>{let{onClick:t,loading:n,name:o,disabled:i,selected:d,variant:p,label:h,isMinimalScreen:m,disableGa4Tracking:g,supportMobileTap:f}=e;return(0,r.jsxs)(c.sb,{supportMobileTap:f,children:[(0,r.jsx)(c.k$,{asChild:!0,children:(0,r.jsx)(u,{disabled:i,onClick:t,loading:n,color:"tertiary",size:"small",isMinimalScreen:m,dataId:o,disableGa4Tracking:g,children:(0,r.jsx)(l.P.div,{animate:{scale:d?1.2:1,color:i?a.w4.colors.gray7.value:d?a.w4.colors.blue11.value:a.w4.colors.gray11.value,opacity:i?"20%":"100%",width:20,height:20},children:(0,r.jsx)(s.I,{label:h,name:o,variant:p,width:20,height:20})})})}),h&&(0,r.jsx)(c.KL,{children:(0,r.jsxs)(c.ZI,{size:"big",children:[(0,r.jsx)(c.PR,{}),(0,r.jsx)("span",{children:h})]})})]})},u=(0,a.I4)(i.$,{paddingTop:"10px !important",paddingBottom:"10px !important",paddingLeft:"10px !important",paddingRight:"10px !important",borderRadius:(0,o.D)(6),border:"1px solid ".concat(a.w4.colors.gray1),"&:hover":{border:"1px solid ".concat(a.w4.colors.gray7),background:a.w4.colors.gray2},"@smallHeight":{paddingTop:"4px !important",paddingBottom:"4px !important"},variants:{isMinimalScreen:{true:{paddingTop:"4px !important",paddingBottom:"4px !important",paddingLeft:"4px !important",paddingRight:"4px !important"}}}})},90981:(e,t,n)=>{"use strict";function r(e){switch(e){case"USER_ADDED":return{sourceField:"Manual",sourceTooltip:"Manually added citation"};case"USER_EDITED":return{sourceField:"Edited",sourceTooltip:"Edited citation"};case"USER_IMPORTED":return{sourceField:"Imported",sourceTooltip:"Citation imported from another source"};case"DOCUMENT_IMPORT":return{sourceField:"Document Import",sourceTooltip:"Citation converted from uploaded document"};default:return{sourceField:"",sourceTooltip:""}}}n.d(t,{l:()=>r})},91280:(e,t,n)=>{"use strict";n.d(t,{T:()=>u,u:()=>p});var r=n(80263),l=n(53239),a=n(16679),o=n(67106),i=n(38767),s=n(29404),c=n(27267),d=n(54541);let u=(0,l.forwardRef)((e,t)=>{let{children:n,setIsPopupOpen:a,filesList:o,onRemove:i,isRestrictionError:s,isOnDashboard:c,isUngated:u,setRestrictionErrorMessage:h,shouldShowPaywall:m}=e,g=(0,l.useRef)(null);(0,l.useEffect)(()=>{o.length&&(null==a||a(!1),g.current&&g.current.scrollTo({left:g.current.scrollWidth,behavior:"smooth"}))},[o.length]),(0,l.useEffect)(()=>{s&&(null==a||a(!1),null==h||h(void 0))},[s]);let f=!!n||o.length>0;return(0,r.jsx)(d.QP,{showBackDropFilter:f,ref:t,isOnDashboardBackDrop:c&&f,isUngated:u,shouldShowPaywall:m,children:(0,r.jsx)(d.p6,{children:(0,r.jsxs)(d.nn,{ref:g,children:[n&&n,(0,r.jsx)(p,{filesList:o,onRemove:i})]})})})});u.displayName="S3FileScroller";let p=(0,l.memo)(e=>{let{filesList:t,onRemove:n}=e,u=(0,l.useRef)({}
1),p=e=>{var t;null==(t=u.current[e])||t.scrollIntoView({behavior:"smooth",inline:"center"})};return(0,r.jsx)(r.Fragment,{children:t.map((e,t)=>{let l=!e.error&&100!==e.progress.percentage,h=l||!!e.meta.processing;return(0,r.jsx)(s.h,{tipInfo:null==e?void 0:e.name,children:(0,r.jsxs)(d.vu,{ref:e=>u.current[t]=e,onClick:()=>p(t),variant:e.error?"error":l?"loading":"default",children:[(0,r.jsxs)(d.L5,{variant:"doc",children:[!l&&(0,r.jsx)(c.M,{type:e.type}),h&&(0,r.jsx)("div",{style:{position:"absolute",inset:0,zIndex:1},children:(0,r.jsx)(i.y,{color:l?a.w4.colors.blue9:a.w4.colors.yellow10,size:20})})]}),(0,r.jsx)("span",{children:null==e?void 0:e.name}),(0,r.jsx)(d.nj,{size:"tiny",tabIndex:-1,onClick:t=>{t.stopPropagation(),n(e.id)},children:(0,r.jsx)(o.I,{name:"x",variant:"regular"})})]})},t)})})});p.displayName="S3FileListView"},91548:(e,t,n)=>{"use strict";n.d(t,{GO:()=>o,Kj:()=>p,l5:()=>x,pT:()=>f});var r=n(80263),l=n(53239),a=n(16679);function o(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(e=>String(null!=e?e:"")).join("|")}let i=(0,a.I4)("div",{display:"contents",'& [data-streamdown="code-block"]':{borderColor:a.w4.colors.gray5},'& [data-streamdown="code-block-header"]':{backgroundColor:a.w4.colors.gray2,color:a.w4.colors.gray10},'& [data-streamdown="code-block-copy-button"], & [data-streamdown="code-block-download-button"]':{appearance:"none",background:"transparent",border:"none",borderRadius:"6px",color:a.w4.colors.gray9,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px","&:hover":{backgroundColor:a.w4.colors.gray4,color:a.w4.colors.gray12}}}),s=null,c=!1,d=new Set,u=()=>(s||(s=n.e(7498).then(n.bind(n,67498))).then(()=>{c=!0,d.forEach(e=>e())},()=>{s=null}),s);function p(){return u().then(()=>void 0)}let h=e=>(d.add(e),()=>{d.delete(e)}),m=()=>c,g=()=>!1;function f(){let e=(0,l.useSyncExternalStore)(h,m,g);return(0,l.useEffect)(()=>{e||p()},[e]),e}let x=(0,l.lazy)(()=>u().then(e=>{let t=Object.values(e.defaultRehypePlugins),n=new WeakMap;return{default:l=>{let{rehypePlugins:a,...o}=l,s=a?n.get(a):t;return a&&!s&&(s=[...t,...a],n.set(a,s)),(0,r.jsx)(i,{children:(0,r.jsx)(e.Streamdown,{...o,rehypePlugins:null!=s?s:t})})}}}))},92137:(e,t,n)=>{"use strict";n.d(t,{O:()=>w});var r=n(80263),l=n(10070),a=n(14866),o=n(4230),i=n(37786),s=n(77274),c=n(53239),d=n(16679),u=n(18696),p=n(67106),h=n(17288),m=n(36932),g=n(67449),f=n(12672),x=n(16755),b=n(80415);let C=e=>{let t=[];for(let r of e)for(let e of(r.uploadId&&r.fileType&&t.push({name:r.title||"Untitled File",type:r.fileType,uploadId:r.uploadId,userCitationId:r.userCitationId,parentItemId:null}),r.attachments.filter(e=>e.uploadId&&e.fileType))){var n;t.push({name:e.title||"Untitled File",type:e.fileType,uploadId:e.uploadId,userCitationId:e.userCitationId,parentItemId:null!=(n=e.parentItemId)?n:null})}return t},v=e=>{let{featureName:t,onClose:n}=e,{addFile:r,removeFile:l,updateFileMeta:a,triggerLibraryAttach:i,files:s}=(0,x.v)(),{extractS3FileContent:d}=(0,f.nu)(),{showToast:u}=(0,b._)();return(0,c.useCallback)(async e=>{let c=C(e),p=[],h=c.filter(e=>{let t=Object.values(s).some(t=>{var n;return(null==(n=t.meta)?void 0:n.uploadId)===e.uploadId});return t&&p.push({name:e.name,uploadId:e.uploadId}),!t});if(p.length>0&&u({title:1===p.length?"".concat(p[0].name," is already attached"):"".concat(p.length," files are already attached"),color:"warning"}),0===h.length)return void n();if(t===o.A9.Enum.AI_CHAT){n(),await i(c.map(e=>({uploadId:e.uploadId,name:e.name,type:e.type,parentItemId:e.parentItemId})));return}let m=new Map,g=[],f=1;
1for(let e of h){let t=e.name.includes("full_text")?e.name.replace("full_text","document".concat(f)):e.name,n=r({name:t,type:e.type,data:new File([new Blob([""],{type:e.type})],t,{type:e.type}),meta:{name:e.name,type:e.type,isRecentFile:!0,uploadId:e.uploadId,processing:!e.userCitationId,citationInfo:e.userCitationId?{citationId:e.userCitationId,s3FileId:e.uploadId,resourceType:"LIBRARY"}:void 0}});n&&!e.userCitationId&&(m.set(e.uploadId,n),g.push({uploadId:e.uploadId})),f++}if(n(),g.length>0&&t)try{let e=await d(g.map(e=>({fileId:e.uploadId})),t),n=new Map(e.fileExtractionDetails.map(e=>[e.fileId,e]));for(let e of g){let t=n.get(e.uploadId),r=m.get(e.uploadId);if(r){if((null==t?void 0:t.status)&&t.userCitationId&&t.userCitationId>0){a(r,{processing:!1,citationInfo:{citationId:t.userCitationId,s3FileId:e.uploadId,resourceType:"LIBRARY"}});continue}l(r)}}}catch(e){u({title:"Failed to attach file from library",color:"danger"}),g.forEach(e=>{let n=m.get(e.uploadId);n&&(l(n),console.error("VIEW_LIBRARY_MODAL: ".concat(t," Error extracting file content from S3 for uploadId ").concat(e.uploadId)))})}},[r,d,n,l,a,t,i,s,u])},y=["PAPERPAL_DOCUMENT","CITATION_WITH_ATTACHMENT","CITATION"],w=e=>{let{open:t,setOpen:n,isMobileWeb:d,featureName:u,isExtension:f=!1}=e,x=(0,c.useRef)(null),[b,C]=(0,c.useState)("library"),[w,k]=(0,c.useState)(""),[E,N]=(0,c.useState)(""),[S,T]=(0,c.useState)(!1),[A,R]=(0,c.useState)(null),M=(0,c.useCallback)(()=>{n(!1)},[n]),L=v({featureName:u,onClose:M});(0,c.useLayoutEffect)(()=>{if(!f)return;let e=(0,s.M)();e&&R(e)},[f]);let D=(0,c.useCallback)(()=>{N(w.trim())},[w]),_=(0,c.useCallback)(()=>{var e;k(""),N(""),null==(e=x.current)||e.focus()},[]),H=(0,c.useCallback)(e=>{C(e)},[]);function P(e){return e===o.A9.Enum.WRITE?{maxFiles:i.Qf.maxFiles,supportedTypes:i.kT.split(","),maxFileSize:i.Qf.maxFileSize}:e===o.A9.Enum.AI_CHAT?{maxFiles:i.hT.maxFiles,supportedTypes:i.$s.split(","),maxFileSize:i.hT.maxFileSize}:{maxFiles:5,supportedTypes:[],maxFileSize:0x1900000}}return(0,r.jsx)(l.Root,{open:t,onOpenChange:e=>!e&&n(!1),children:(0,r.jsxs)(l.Portal,{container:f?A:void 0,children:[(0,r.jsx)(l.AlertDialogTitle,{}),(0,r.jsx)(l.AlertDialogDescription,{}),(0,r.jsx)(l.Overlay,{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>n(!1)}),(0,r.jsx)(l.Content,{className:"fixed inset-x-0 bottom-0 sm:inset-auto sm:top-1/2 sm:left-1/2 sm:-translate-x-1/2 sm:-translate-y-1/2 bg-white dark:bg-gray-11 rounded-t-3xl sm:rounded-lg shadow-lg w-full sm:w-[90vw] lg:w-[70vw] sm:max-w-[calc(100vw-2rem)] h-[92vh] sm:h-[70vh] max-h-[92vh] sm:max-h-[720px] overflow-hidden animate-in slide-in-from-bottom sm:animate-none duration-300 min-h-[400px] flex flex-col",style:{display:"flex",flexDirection:"column"},children:(0,r.jsxs)(a.Tabs,{value:b,onValueChange:H,className:"flex flex-col flex-1 gap-4 pt-4 min-h-0",style:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[(0,r.jsxs)("div",{className:"relative flex w-full flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-x-2 sm:pr-10",children:[(0,r.jsxs)(a.TabsList,{className:"flex gap-6 h-auto px-4",children:[(0,r.jsxs)(j,{value:"library",children:[(0,r.jsx)(p.I,{name:"buildingColumns",size:"xl",variant:"duotone"}),"Library"]}),(0,r.jsxs)(j,{value:"upload",children:[(0,r.jsx)(p.I,{name:"upload",size:"xl",variant:"duotone"}),"Upload New"]})]}),(0,r.jsxs)("div",{className:"flex w-full sm:w-auto sm:flex-1 min-w-0 flex-col sm:flex-row sm:items-center gap-3 sm:gap-2",children:[(0,r.jsx)(I,{onClick:M,"aria-label":"Close",children:(0,r.jsx)(p.I,{name:"x",size:"lg",variant:"regular"})}),"library"===b&&(0,r.jsx)("div",{className:"order-3 sm:order-none w-full sm:flex-1 min-w-0 sm:min-w-[140px] sm:max-w-[220px] md:max-w-[300px] lg:max-w-[400px] flex justify-center sm:justify-end sm:ml-auto sm:mr-1 px-4 sm:px-0",children:(0,r.jsx)(h.r,{inputRef:x,value:w,onChange:e=>{k(e),e||N("")},onCommit:D,onClear:_,placeholder:"Search in Files",disabled:S})})]})]}),(0,r.jsx)(a.TabsContent,{value:"upload",forceMount:!0,className:"data-[state=inactive]:hidden data-[state=active]:flex flex-col flex-1 min-h-0 overflow-hidden px-4 pb-4",style:{flexDirection:"column",flex:1,minHeight:0,overflow:"hidden"},children:(0,r.jsx)(g.Z,{fileConfiguration:P(u),onFilesAdded:M})}),(0,r.jsx)(a.TabsContent,{value:"library",forceMount:!0,className:"data-[state=inactive]:hidden data-[state=active]:flex flex-col flex-1 min-h-0 overflow-hidden",style:{flexDirection:"column",flex:1,minHeight:0,overflow:"hidden",height:"100%"},children:(0,r.jsx)(m.Y,{isActive:"library"===b,searchQuery:E,excludeFilterTypes:u===o.A9.Enum.WRITE||u===o.A9.Enum.AI_CHAT?y:[],attachmentItemTypes:u===o.A9.Enum.WRITE||u===o.A9.Enum.AI_CHAT?["CITATION_WITH_ATTACHMENT","PDF","WORD","EXCEL","POWERPOINT","IMAGE"]:void 0,onCancel:M,onAttach:L,isMobileWeb:d,featureName:u,fileConfiguration:{...P(u)},isExtension:f,portalContainer:A,onUploadLimitExceededChange:T})})]})})]})})},j=(0,d.I4)(a.TabsTrigger,{backgroundColor:"transparent",border:"none",borderBottom:"3px solid transparent",curs
1or:"pointer",padding:"8px",height:"auto",textAlign:"center",fontSize:"14px",fontWeight:400,borderRadius:0,color:d.w4.colors.gray12,outline:"none",gap:"10px",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundColor:d.w4.colors.blue2},'&[data-state="active"]':{borderBottomColor:d.w4.colors.blue11,color:d.w4.colors.blue11,fontWeight:500}}),I=(0,d.I4)(u.$,{position:"absolute",top:0,right:"8px",zIndex:20,backgroundColor:"transparent",border:"none",padding:"4px",cursor:"pointer",color:d.w4.colors.gray9,transition:"color 0.2s ease",boxShadow:"none","&:hover":{color:d.w4.colors.gray11}})},92152:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",...e,children:[(0,r.jsx)("path",{d:"M14.6704 3.69658L5.7543 1.39618C4.90624 1.17738 4.04137 1.68749 3.82257 2.53555L1.52217 11.4517C1.30337 12.2997 1.81348 13.1646 2.66154 13.3834L11.5776 15.6838C12.4257 15.9026 13.2906 15.3925 13.5094 14.5444L15.8098 5.62831C16.0286 4.78025 15.5185 3.91538 14.6704 3.69658Z",fill:"url(#paint0_linear_800_7971)",fillOpacity:"0.4"}),(0,r.jsx)("path",{d:"M11.2826 2.35474H1.58584C0.710003 2.35474 0 3.06474 0 3.94057V13.6373C0 14.5131 0.710003 15.2231 1.58584 15.2231H11.2826C12.1584 15.2231 12.8684 14.5131 12.8684 13.6373V3.94057C12.8684 3.06474 12.1584 2.35474 11.2826 2.35474Z",fill:"url(#paint1_linear_800_7971)"}),(0,r.jsx)("path",{d:"M9.91831 7.44885L7.6849 7.13985L6.68654 5.21302C6.65926 5.16026 6.61438 5.11756 6.55896 5.09159C6.42 5.02629 6.2511 5.08073 6.18161 5.21302L5.1832 7.13985L2.94982 7.44885C2.88824 7.45722 2.83195 7.48485 2.78884 7.52676C2.73673 7.57774 2.70802 7.64633 2.70901 7.71746C2.71 7.78858 2.74061 7.85641 2.79412 7.90609L4.41003 9.40586L4.02824 11.5236C4.01932 11.5729 4.02503 11.6236 4.04477 11.6699C4.06455 11.7162 4.09754 11.7563 4.14004 11.7857C4.1825 11.8151 4.23281 11.8325 4.28518 11.8361C4.3376 11.8397 4.38997 11.8292 4.43639 11.8058L6.43407 10.806L8.43171 11.8058C8.48626 11.8335 8.54958 11.8427 8.61027 11.8326C8.76335 11.8075 8.86627 11.6693 8.83986 11.5236L8.45811 9.40586L10.074 7.90609C10.118 7.86506 10.147 7.81146 10.1558 7.75282C10.1796 7.60629 10.0723 7.47062 9.91831 7.44885Z",fill:"url(#paint2_linear_800_7971)"}),(0,r.jsxs)("defs",{children:[(0,r.jsxs)("linearGradient",{id:"paint0_linear_800_7971",x1:"14.934",y1:"5.1104",x2:"2.70327",y2:"13.3941",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.0480121",stopColor:"#ECB441"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#FFF1D6"})]}),(0,r.jsxs)("linearGradient",{id:"paint1_linear_800_7971",x1:"11.8525",y1:"3.7093",x2:"-5.07962",y2:"19.9641",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{offset:"0.0480121",stopColor:"#ECB441"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#FFF1D6"})]}),(0,r.jsxs)("linearGradient",{id:"paint2_linear_800_7971",x1:"2.70898",y1:"14.3766",x2:"15.4784",y2:"-1.85479",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#956A11"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#CC9014",stopOpacity:"0.08"})]})]})]})},93730:(e,t,n)=>{"use strict";n.d(t,{d:()=>c});var r=n(80263),l=n(53239),a=n(16679),o=n(67106),i=n(6437),s=n(85552);let c=e=>{let{icon:t,label:n,onClick:a,disabled:c=!1,isLoading:m=!1,loadingComponent:g,collections:f,isCollectionsLoading:x=!1,onCollectionSelect:b,onCreateCollection:C,isCreatingCollection:v=!1,onOpenChange:y}=e,[w,j]=(0,l.useState)(!1),[I,k]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{null==y||y(w||I)},[w,I,y]),(0,r.jsxs)(d,{onClick:e=>e.stopPropagation(),children:[(0,r.jsx)(u,{onClick:e=>{e.stopPropagation(),a(e)},disabled:c||m,"data-test-id":n,children:m&&g||(0,r.jsxs)(r.Fragment,{children:[t,n]})}),(0,r.jsx)(p,{}),(0,r.jsxs)(i.A.Root,{open:w,onOpenChange:e=>{j(e)},children:[(0,r.jsx)(i.A.Anchor,{children:(0,r.jsx)(h,{onClick:e=>{e.stopPropagation(),j(e=>!e)},disabled:c||m,"data-test-id":"split-button-chevron",children:(0,r.jsx)(o.I,{name:"chevronDown",variant:"regular",width:12,height:12})})}),(0,r.jsx)(i.A.Popup,{align:"end",hideArrow:!0,children:(0,r.jsx)(s.R,{collections:f,isCollectionsLoading:x,onCollectionSelect:e=>{b(e),j(!1)},onCreateCollection:C,isCreatingCollection:v,isExtension:!1,onCreateDialogOpenChange:k})})]})]})},d=(0,a.I4)("div",{display:"flex",alignItems:"center",borderRadius:"6px",maxHeight:"40px",flexShrink:0}),u=(0,a.I4)("button",{display:"flex",gap:"6px",alignItems:"center",fontSize:"0.875rem",lineHeight:"1.5rem",color:a.w4.colors.blue9,fontWeight:"500",background:"none",border:"none",padding:"6px",cursor:"pointer",whiteSpace:"nowrap",borderRadius:"6px 0 0 6px",transition:"background-color 0.2s",minWidth:0,overflow:"hidden","&:hover":{backgroundColor:a.w4.colors.blue3},"&:disabled":{opacity:.5,cursor:"not-allowed"}}),p=(0,a.I4)("div",{width:"1px",height:"24px",backgroundColor:a.w4.colors.gray7,flexShrink:0}),h=(0,a.I4)("button",{display:"flex",alignItems:"center",justifyContent:"center",color:a.w4.colors.blue9,background:"none",border:"none",padding:"6px 4px",cursor:"pointer",borderRadius:"0 6px 6px 0",transition:"background-color 0.2s",flexShrink:0,"&:hover":{backgroundColor:a.w4.colors.blue3},"&:disabled":{opacity:.5,cursor:"not-allowed"}})},93903:(e,t,n)=>{"use strict";n.d(t,{Y:()=>l});var r=n(72984);function l(e){return r.JL.flatMap(t=>{var n;return(null!=(n=e[t])?n:[]).map(e=>({...e,full_name:"".concat(e.given||""," ").concat(e.family||"").trim()}))})}},94568:()=>{},95124:(e,t,n)=>{"use strict";n.d(t,{d:()=>s,o:()=>i});var r=n(78773),l=n(96088),a=n(53239),o=n(64014);let i="get-citation-mapping";function s(e,t){let{webApiClient:n}=(0,o.p)(),s=(0,a.useCallback)(async e=>n.get("/api/v1/tiptap/citation-mapping?documentId=".concat(e)).then(l.wf.parse).catch(e=>{throw console.error("Failed to fetch citation mapping data:",e),e}),[n]);return(0,r.useQuery)({queryKey:[i,e],queryFn:()=>s(e),enabled:!!e&&!!t,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:!1,refetchOnMount:"always",select:e=>{let t=new Set(e.flatMap(e=>e.sources.map(e=>e.id)));return{citations:e,uniqueSourceCount:t.size}}})}}
1,95152:(e,t,n)=>{"use strict";n.d(t,{$K:()=>x,AW:()=>M,CO:()=>N,Gp:()=>k,NQ:()=>S,Nc:()=>L,O9:()=>u,OS:()=>c,U7:()=>h,X6:()=>y,Yv:()=>D,aR:()=>m,cL:()=>v,cl:()=>w,d7:()=>f,eq:()=>A,hE:()=>b,hh:()=>I,ie:()=>R,ln:()=>E,nC:()=>g,oZ:()=>s,qj:()=>d,r2:()=>C,r6:()=>j,tJ:()=>p,vn:()=>T,xw:()=>H});var r=n(16679),l=n(70077),a=n(52501),o=n(18696),i=n(29525);let s=(0,r.I4)(o.$,{paddingLeft:8}),c=(0,r.I4)(o.$,{fontSize:"0.875rem",color:r.w4.colors.blue9,background:r.w4.colors.blue3,fontWeight:"500",lineHeight:"0.75rem",border:"none",borderRadius:"4px",boxShadow:"none",paddingInline:"4px",paddingBlock:"6px",marginTop:"12px"}),d=(0,r.I4)("div",{paddingLeft:(0,l.D)(12)}),u=(0,r.I4)("div",{paddingLeft:(0,l.D)(20),paddingRight:(0,l.D)(80),fontWeight:"300"}),p=(0,r.I4)(o.$,{color:r.w4.colors.gray11,display:"flex",fontSize:(0,l.D)(14),paddingLeft:(0,l.D)(20),padding:(0,l.D)(12),background:r.w4.colors.gray2,stroke:"transparent",width:"100%",border:"none","&:hover":{background:r.w4.colors.gray2}}),h=(0,r.I4)("div",{display:"flex",flexDirection:"column",padding:"4px 0px",borderBottom:"1px solid ".concat(r.w4.colors.gray6),variants:{cardType:{default:{},"reference-paper":{},"related-paper":{},library:{},full:{borderBottom:"none",display:"grid",gridTemplateRows:"auto 1fr auto",height:"70vh",position:"relative"}},isMinimal:{true:{background:r.w4.colors.gray1,cursor:"revert",paddingInline:0,paddingTop:(0,l.D)(10),paddingBottom:(0,l.D)(4)}}},compoundVariants:[{cardType:"full",isMinimal:!0,css:{height:"100%",paddingBlock:0}}]}),m=(0,r.I4)("div",{display:"flex",flexGrow:1,justifyContent:"space-between",alignItems:"center",marginBottom:"12px",variants:{isRelatedPapers:{true:{justifyContent:"end"}},isMinimal:{true:{marginRight:(0,l.D)(4),marginBottom:(0,l.D)(8),justifyContent:"end"}}}}),g=(0,r.I4)("strong",{color:r.w4.colors.blue12,fontSize:"small",lineHeight:"1rem"}),f=(0,r.I4)("div",{display:"inline-flex",alignItems:"center",gap:"8px",height:(0,l.D)(20),variants:{cardType:{default:{marginLeft:"auto"},library:{marginLeft:"auto"},"reference-paper":{},"related-paper":{},full:{}}}}),x=(0,r.I4)(a.E,{variants:{size:{small:{fontSize:(0,l.D)(10),lineHeight:"1rem",padding:"".concat((0,l.D)(2)," ").concat((0,l.D)(4)),display:"inline-flex",alignItems:"center",minWidth:"10px","& svg":{width:(0,l.D)(12),height:(0,l.D)(12),marginRight:(0,l.D)(4),display:"block"}}}
1,color:{yellow:{backgroundColor:r.w4.colors.yellow4,color:r.w4.colors.yellow11},gray:{backgroundColor:r.w4.colors.gray4,color:r.w4.colors.gray11},orange:{backgroundColor:r.w4.colors.orange1,color:r.w4.colors.orange2},green:{backgroundColor:r.w4.colors.green3,color:r.w4.colors.green11},red:{backgroundColor:r.w4.colors.red4,color:r.w4.colors.red10},purple:{backgroundColor:r.w4.colors.purple5,color:r.w4.colors.purple10},blue:{backgroundColor:r.w4.colors.blue3,color:r.w4.colors.blue11}},isMinimal:{true:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}}),b=(0,r.I4)(i.P,{whiteSpace:"pre-wrap",wordBreak:"break-word",color:r.w4.colors.gray12,fontSize:"0.875rem",lineHeight:"1.5rem",fontWeight:600,marginBottom:"4px"}),C=(0,r.I4)("div",{paddingInline:"6px"}),v=(0,r.I4)("span",{height:"4px",width:"4px",backgroundColor:r.w4.colors.gray9,borderRadius:"50%",display:"block"}),y=(0,r.I4)("div",{display:"flex",alignItems:"center",color:r.w4.colors.gray11,fontSize:"0.75rem",lineHeight:"1rem",gap:"4px",flexWrap:"wrap"}),w=(0,r.I4)("div",{display:"inline-flex",alignItems:"center",gap:"4px"}),j=(0,r.I4)("div",{display:"inline-flex",alignItems:"center",gap:"5px"}),I=(0,r.I4)("div",{padding:"3px 4px"}),k=(0,r.I4)("div",{marginTop:(0,l.D)(16)}),E=(0,r.I4)("div",{fontSize:(0,l.D)(14),lineHeight:(0,l.D)(24),color:r.w4.colors.gray11,fontWeight:"500"}),N=(0,r.I4)("div",{fontSize:(0,l.D)(14),lineHeight:(0,l.D)(24),color:r.w4.colors.gray11,marginTop:(0,l.D)(4)}),S=(0,r.I4)("div",{"&::-webkit-scrollbar":{width:"8px",height:"8px"},"&::-webkit-scrollbar-track":{borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{borderRadius:"4px","&:hover":{}},scrollbarWidth:"thin",variants:{cardType:{default:{"&:hover":{"> div":{borderColor:r.w4.colors.blue10},'p[aria-label="title"]':{color:r.w4.colors.blue10,textDecoration:"underline"}},cursor:"pointer"},"reference-paper":{"&:hover":{"> div":{borderColor:r.w4.colors.blue10},'p[aria-label="title"]':{color:r.w4.colors.blue10,textDecoration:"underline"}},cursor:"pointer"},"related-paper":{"&:hover":{"> div":{borderColor:r.w4.colors.blue10},'p[aria-label="title"]':{color:r.w4.colors.blue10,textDecoration:"underline"}},cursor:"pointer"},library:{"&:hover":{"> div":{borderColor:r.w4.colors.blue10},'p[aria-label="title"]':{color:r.w4.colors.blue10,textDecoration:"underline"}},cursor:"pointer"},full:{gridRow:"2",overflowY:"auto",minHeight:0,paddingBottom:"16px",paddingRight:"16px"}},isMinimal:{true:{"&:hover":{"> div":{borderColor:r.w4.colors.blue10},'p[aria-label="title"]':{color:r.w4.colors.gray12,textDecoration:"none"}},cursor:"revert"}}},compoundVariants:[{cardType:"full",isMinimal:!0,css:{maxHeight:(0,l.D)(300)}},{cardType:"library",isMinimal:!0,css:{cursor:"revert","&:hover":{"> div":{borderColor:r.w4.colors.blue10},'p[aria-label="title"]':{color:r.w4.colors.gray12,textDecoration:"none"}}}}]}),T=(0,r.I4)("div",{variants:{cardType:{default:{},"reference-paper":{},"related-paper":{},library:{},full:{gridRow:"3",position:"relative",backgroundColor:"white",zIndex:10}}}}),A=(0,r.I4)("span",{color:r.w4.colors.blue9,cursor:"pointer",textDecoration:"underline",fontSize:(0,l.D)(12),lineHeight:(0,l.D)(16),display:"inline-block"}),R=(0,r.I4)("div",{position:"absolute",bottom:"66px",left:"50%",transform:"translateX(-50%)",width:"24px",height:"24px",borderRadius:"50%",color:"".concat(r.w4.colors.gray11),backgroundColor:"".concat(r.w4.colors.blue6),boxShadow:"0px 4px 12px -6px rgba(0, 78, 223, 0.412)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:11,transition:"opacity 0.2s ease-in-out",opacity:0,pointerEvents:"none",cursor:"pointer",border:"1px solid ".concat(r.w4.colors.gray6),variants:{visible:{true:{opacity:1,pointerEvents:"auto"}}}}),M=(0,r.I4)("span",{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),L=(0,r.I4)(o.$,{display:"inline-block",background:"".concat(r.w4.colors.blue2," !important"),boxShadow:"none",paddingInline:(0,l.D)(8),borderRadius:(0,l.D)(12),fontSize:(0,l.D)(12),lineHeight:(0,l.D)(24),fontWeight:500,color:r.w4.colors.blue10,paddingBlock:0,"@:hover":{background:"".concat(r.w4.colors.blue2," !important"),boxShadow:"none"}}),D=(0,r.I4)("div",{maxWidth:(0,l.D)(300)}),_=(0,r.i7)({"0%":{transform:"scale(0.8)"},"50%":{transform:"scale(1.3)"},"75%":{transform:"scale(0.8)"},"100%":{transform:"scale(1)"}}),H=(0,r.I4)("span",{fontSize:"inherit",display:"inline-block",position:"absolute",top:3,right:-7,width:(0,l.D)(6),height:(0,l.D)(6),borderRadius:(0,l.D)(3),backgroundColor:r.
1w4.colors.green10,variants:{color:{blue:{backgroundColor:r.w4.colors.blue10}},animate:{true:{animation:"".concat(_,"  4s linear 2")}},red:{true:{backgroundColor:r.w4.colors.red9,top:0},false:{top:0}},isExperimental:{true:{top:-4,right:-10}},isResearch:{true:{top:5,right:10}}}})},95424:(e,t,n)=>{"use strict";n.d(t,{Y:()=>m,y:()=>h});var r=n(80263),l=n(53239),a=n(77385),o=n(47332),i=n(70415),s=n(78041),c=n(68423),d=n(21595),u=n(16679),p=n(70077);let h=e=>{let{children:t,isDismissable:n=!0,onClose:d,shouldCenter:u,shadowDOMCompatMode:p=!1,containFocus:h=!0}=e,m=l.useCallback(()=>{p||null==d||d()},[d,p]),x=l.useRef(null),{overlayProps:b,underlayProps:C}=(0,a.e)({isDismissable:!p&&n,isOpen:!0,onClose:m},x);(0,o.H)();let{modalProps:v}=(0,i.hS)(),{dialogProps:y}=(0,s.s)({role:"dialog"},x),w=l.useCallback(t=>{if(t.target===t.currentTarget&&n){var r;null==(r=e.onClose)||r.call(e)}},[n,e]),j=l.useCallback(e=>{e.target===e.currentTarget&&e.stopPropagation()},[]);return(0,r.jsx)(f,{...C,style:e.style,shouldCenter:u,...p&&{onClick:w},children:(0,r.jsx)(c.n1,{contain:!p&&h,restoreFocus:!p,children:(0,r.jsx)(g,{...b,...y,...v,ref:x,children:p?(0,r.jsx)("div",{onClick:j,children:t}):t})})})};function m(e){return(0,d.T)(e)}let g=(0,u.I4)("div",{borderRadius:"inherit",flexGrow:1,"&:focus":{outline:"none"}}),f=(0,u.I4)("div",{padding:(0,p.D)(32),zIndex:100,top:0,left:0,bottom:0,right:0,background:"rgba(255, 255, 255, 0.9)",display:"flex",alignItems:"center",justifyContent:"center",variants:{style:{fullScreen:{position:"fixed"},contained:{position:"absolute",pointerEvents:"auto"},containedFlush:{position:"absolute",pointerEvents:"auto",padding:"0px",alignItems:"unset",background:"rgba(255, 255, 255)"},containedStart:{alignItems:"flex-start",position:"absolute"},popover:{position:"absolute",alignItems:"flex-end",padding:(0,p.D)(16),zIndex:"100000"},popoverBlack:{position:"fixed",alignItems:"flex-end",left:0,padding:(0,p.D)(16),zIndex:1001,background:"rgba(0, 0, 0, 0.5)"},fullScreenOverlay:{position:"fixed",backdropFilter:"blur(2px)",background:"rgba(0, 0, 0, 0.5)",zIndex:1001},screenCover:{position:"fixed",backdropFilter:"blur(2px)",background:"rgba(0, 0, 0, 0.5)",zIndex:1001,padding:"0px"},bottomSheetOverlay:{padding:(0,p.D)(16),position:"absolute",maxHeight:"40vh"},mobileScreenOverlay:{position:"fixed",alignItems:"flex-start",left:0,padding:(0,p.D)(16),zIndex:1001,background:"rgba(0, 0, 0, 0.5)"}},shouldCenter:{true:{}}},compoundVariants:[{style:"popoverBlack",shouldCenter:!0,css:{alignItems:"center"}}]})},95500:(e,t,n)=>{"use strict";n.d(t,{D:()=>a});var r=n(79002),l=n(17916);let a=e=>{let t=(0,r.er)({editor:e,selector:t=>{if(!e||null===t.editor)return{characters:0,words:0,selectedWords:0};try{var n,r,a,o;let{characters:e,words:i}=(null==(n=t.editor)?void 0:n.storage.characterCount)||{characters:()=>0,words:()=>0},s=null==(a=t.editor)||null==(r=a.state)?void 0:r.selection,c=0;return s&&!s.empty&&(c=(0,l.f)(null==(o=t.editor)?void 0:o.state.doc,s.from,s.to).trim().split(/\s+/).filter(Boolean).length),{characters:e(),words:i(),selectedWords:c}}catch(e){return console.error("TipTap Error: useEditorWordCount",JSON.stringify(e)),{characters:0,words:0,selectedWords:0}}}});return{words:(null==t?void 0:t.words)||0,selectedWords:(null==t?void 0:t.selectedWords)||0}}},96088:(e,t,n)=>{"use strict";n.d(t,{Lz:()=>s,wf:()=>o});var r=n(11445);let l=r.z.enum(["SAMPLE_DOCUMENT","NOTE","UPLOAD_DOCUMENT","COLLABORATION_DOCUMENT"]),a=r.z.enum(["SLATE","TIPTAP"]),o=r.z.array(r.z.object({index:r.z.number(),text:r.z.string(),sources:r.z.array(r.z.object({id:r.z.string(),title:r.z.string(),type:r.z.string().optional(),dyson_id:r.z.string().optional(),author:r.z.array(r.z.object({literal:r.z.string().optional().default(""),given:r.z.string().optional().default(""),family:r.z.string().optional().default("")})).optional(),DOI:r.z.string().optional(),sourceOrigin:r.z.string().optional(),abstract:r.z.string().optional(),issued:r.z.object({"date-parts":r.z.array(r.z.array(r.z.number()))}).optional()}))})),i=r.z.object({email:r.z.string(),isReadOnlyAccess:r.z.boolean()}),s=r.z.object({documentId:r.z.string(),creationTime:r.z.number(),latestUpdate:r.z.number(),snippet:r.z.string(),title:r.z.string(),editorType:a.optional(),documentTag:l.optional(),isReadOnly:r.z.boolean().optional(),documentStyle:r.z.string().optional(),collaborators:r.z.array(i).optional()});r.z.enum(["PAPERPAL_PUBLIC","PAPERPAL_DASHBOARD"])},96411:(e,t,n)=>{"use strict";n.d(t,{y:()=>l});var r=n(53239);function l(e){let[t,n]=(0,r.useState)(!0);return(0,r.useEffect)(()=>
1{if(!e)return void n(!0);let t=()=>{try{let t=e.getText({blockSeparator:"\n"}),r=e.isEmpty&&""===t.trim()&&t.length<=0;n(r)}catch(e){console.error("TipTap Error: checkIfEditorIsEmpty",JSON.stringify(e)),n(!0)}};return t(),e.on("update",t),()=>{e.off("update",t)}},[e]),{isEditorEmpty:t}}},96562:(e,t,n)=>{"use strict";n.d(t,{l:()=>u});var r=n(53239),l=n(78773),a=n(81761),o=n(64014),i=n(27442),s=n(40704),c=n(84129);let d="paperpal-library-id",u=function(){var e;let t=!(arguments.length>0)||void 0===arguments[0]||arguments[0],{data:n,isLoading:u,isError:p}=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],{webApiClient:t}=(0,o.p)(),{isExtension:n}=(0,s.Gz)();return(0,l.useQuery)({queryKey:["library-id",n],queryFn:async()=>{if(n)try{let e=await (0,c.c)().getItem(d);if(e)return Number(e)}catch(e){}let e=await t.get("/api/v1/libraries/stats"),{data:r}=a.ek.parse(e);if(n)try{await (0,c.c)().setItem(d,String(r.libraryId))}catch(e){}return r.libraryId},enabled:e,staleTime:1/0,retry:1,retryDelay:2e3,refetchOnWindowFocus:!1})}(t),{data:h,isLoading:m,isError:g}=(0,i.L)(n,t),{mutateAsync:f,isLoading:x}=function(e){let{webApiClient:t}=(0,o.p)(),n=(0,l.useQueryClient)();return(0,l.useMutation)({mutationFn:async n=>{let r=await t.post("/api/v1/libraries/".concat(e,"/collections"),n);return a.Rc.parse(r)},onSuccess:()=>{n.invalidateQueries([i.H])}})}(n);return{libraryId:n,collections:null!=(e=null==h?void 0:h.data)?e:[],isCollectionsLoading:m&&!p,isLibraryIdLoading:u,isError:p||g,createCollection:(0,r.useCallback)(async(e,t)=>await f({name:e,parentId:t}),[f]),isCreatingCollection:x}}},99640:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(80263),l=n(53239),a=n(16679);let o=(0,l.memo)(e=>{let{percentage:t=0,size:n=14}=e,l=0===t?"conic-gradient(".concat(a.w4.colors.blue9," 360deg, ").concat(a.w4.colors.gray4," 0deg)"):t<=33?"conic-gradient(".concat(a.w4.colors.yellow10," ").concat((100-t)*3.6,"deg, ").concat(a.w4.colors.blue4," 0deg)"):t<=66?"conic-gradient(".concat(a.w4.colors.red9," ").concat((100-t)*3.6,"deg, ").concat(a.w4.colors.blue4," 0deg)"):"conic-gradient(".concat(a.w4.colors.red9," 0deg, 360deg)");return(0,r.jsx)("div",{className:"relative flex items-center justify-center rounded-full ",style:{height:"".concat(n,"px"),width:"".concat(n,"px"),background:l},children:(0,r.jsx)("div",{className:"absolute rounded-full bg-gray-1",style:{width:"".concat(n-6,"px"),height:"".concat(n-6,"px")}})})})},99835:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(80263);n(53239);let l=e=>(0,r.jsxs)("svg",{viewBox:"0 0 37 37",width:"1em",height:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,r.jsxs)("g",{clipPath:"url(#chromeClip)",children:[(0,r.jsx)("path",{d:"M18.5 27.7458C23.6086 27.7458 27.75 23.6045 27.75 18.4958C27.75 13.3872 23.6086 9.24585 18.5 9.24585C13.3914 9.24585 9.25 13.3872 9.25 18.4958C9.25 23.6045 13.3914 27.7458 18.5 27.7458Z",fill:"white"}),(0,r.jsx)("path",{d:"M18.5005 9.25004H34.5193C32.8961 6.43756 30.561 4.10202 27.7488 2.47827C24.9366 0.854511 21.7465 -0.000226525 18.4992 4.5032e-08C15.252 0.000226615 12.062 0.855409 9.25002 2.47956C6.43807 4.10371 4.1033 6.43957 2.48047 9.25227L10.4899 23.125L10.4971 23.1232C9.68229 21.7182 9.25232 20.1232 9.25049 18.499C9.24867 16.8748 9.67505 15.2789 10.4867 13.872C11.2983 12.4652 12.4664 11.2972 13.8734 10.4857C15.2803 9.67424 16.8763 9.24803 18.5005 9.25004Z",fill:"#D93025"}),(0,r.jsx)("path",{d:"M18.4997 25.8228C22.544 25.8228 25.8226 22.5443 25.8226 18.4999C25.8226 14.4556 22.544 11.177 18.4997 11.177C14.4553 11.177 11.1768 14.4556 11.1768 18.4999C11.1768 22.5443 14.4553 25.8228 18.4997 25.8228Z",fill:"#1A73E8"}),(0,r.jsx)("path",{d:"M26.5098 23.1273L18.5004 37.0001C21.7477 37.0005 24.9378 36.146 27.7501 34.5224C30.5624 32.8989 32.8976 30.5635 34.5211 27.7512C36.1445 24.9388 36.9989 21.7486 36.9983 18.5014C36.9977 15.2541 36.1422 12.0642 34.5178 9.25244H18.499L18.4971 9.25961C20.1212 9.25648 21.7175 9.68159 23.125 10.4921C24.5325 11.3026 25.7015 12.4698 26.5141 13.8761C27.3266 15.2824 27.7541 16.8781 27.7533 18.5023C27.7526 20.1265 27.3237 21.7217 26.5098 23.1273Z",fill:"#FBBC04"}),(0,r.jsx)("path",{d:"M10.4906 23.1274L2.4812 9.25464C0.857149 12.0666 0.00207415 15.2567 0.00195314 18.5039C0.00183212 21.7512 0.856669 24.9413 2.48051 27.7534C4.10435 30.5656 6.43995 32.9006 9.25248 34.5237C12.065 36.1469 15.2553 37.0009 18.5026 37L26.512 23.1272L26.5068 23.122C25.6974 24.5301 24.5311 25.7 23.1255 26.5137C21.7198 27.3273 20.1245 27.756 18.5003 27.7566C16.8761 27.7571 15.2805 27.3295 13.8743 26.5168C12.4681 25.7041 11.301 24.535 10.4906 23.1274Z",fill:"#34A853"})]}),(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:"chromeClip",children:(0,r.jsx)("rect",{width:"37",height:"37",fill:"white"})})})]})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.