PageSourceSearch

https://canaranews.com/_next/static/chunks/app/dashboard/news-mana…/edit/%5Bid%5D/page-0beec091f2486144.js

js canaranews.com collected 2026-10-03 01:13:04 UTC 29,885 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3470],{1407:(e,t,r)=>{"use strict";r.d(t,{q:()=>f});var a=r(55972);let i="user-storage",n=()=>{try{let e=sessionStorage.getItem(i);if(!e)return null;let t=JSON.parse(e);if(!t.state||!t.state.data||!t.state.data.access_token)return console.warn("Invalid auth data in storage"),null;return t}catch(e){return console.error("Failed to parse user-storage:",e),null}},l=()=>{sessionStorage.removeItem(i)},s="/refresh",o="/canara-login",c=["Unauthenticated"],u=!1,d=[],h=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[...d];d=[],r.forEach(r=>{let{resolve:a,reject:i}=r;e?i(e):a(t)})},m=e=>{let t=(()=>{var e;return null==(e=n())?void 0:e.state.data.access_token})(),r=e.headers;return t&&r&&("object"==typeof r&&null!==r&&"set"in r&&"function"==typeof r.set?r.set("Authorization","Bearer ".concat(t)):r.Authorization="Bearer ".concat(t)),e},g=e=>Promise.reject(e),x=e=>e,p=async e=>{var t,r,m;let g=e.config;if((null==(t=e.response)?void 0:t.status)!==401)return Promise.reject(e);if(null==(r=g.url)?void 0:r.includes(s))return l(),window.location.href=o,Promise.reject(e);let x=null==(m=e.response)?void 0:m.data,p=(null==x?void 0:x.message)||(null==x?void 0:x.error)||e.message;if(!c.some(e=>p&&p.includes(e)))return console.log("Not a token expiration error, rejecting..."),Promise.reject(e);if(!u){u=!0;try{let e=await a.u.post(s),{token:t}=e.data||{};if(console.log("New token:",e,t),!t)throw Error("No access token received in refresh response");(e=>{let t=n();if(t){var r={...t,state:{...t.state,data:{...t.state.data,access_token:e.accessToken}}};try{sessionStorage.setItem(i,JSON.stringify(r))}catch(e){console.error("Failed to update user-storage:",e)}}})({accessToken:t}),h(null,t);let r=g.headers;return r&&("object"==typeof r&&null!==r&&"set"in r&&"function"==typeof r.set?r.set("Authorization","Bearer ".concat(t)):r.Authorization="Bearer ".concat(t)),await (0,a.u)(g)}catch(e){return console.log("Refresh error:",e),h(e,null),l(),window.location.href=o,Promise.reject(e)}finally{u=!1}}return new Promise((e,t)=>{d.push({resolve:e,reject:t})}).then(e=>{"headers"in g&&g.headers||(g.headers={});let t=g.headers;return"object"==typeof t&&null!==t&&"set"in t&&"function"==typeof t.set?t.set("Authorization","Bearer ".concat(String(e))):t&&"object"==typeof t&&(t.Authorization="Bearer ".concat(String(e))),console.log("[api-interceptors] Retrying failed request with new token:",e,g.url),(0,a.u)(g)}).catch(e=>Promise.reject(e))},f=e=>(e.interceptors.request.use(m,g),e.interceptors.response.use(x,p),e)},34344:(e,t,r)=>{"use strict";r.d(t,{u:()=>a.u});var a=r(55972);r(1407)},35712:(e,t,r)=>{"use strict";r.d(t,{A:()=>N});var a=r(95155),i=r(12115),n=r(46098),l=r(43791),s=r(41574),o=r(80317),c=r(27747),u=r(2021),d=r(99496),h=r(50355),m=r(66370),g=r(27855),x=r(89041),p=r(50301),f=r(60193),j=r(84389),y=r(98631),A=r(17342),v=r(97001),b=r(51310),w=r(17126),C=r(90729),k=r(14880),S=r(34977),I=r(8994),_=r(86013),E=r(24403),F=r(12830),D=r(32394),q=r(50390),L=r(80530),U=r(61343),T=r(5333),W=r(98863);let P=(0,i.memo)(e=>{let{editor:t,helperText:r,error:p,minHeight:f="300px",maxHeight:j="600px",onImageUpload:v,videoUrl:b,onVideoUrlChange:w}=e,[C,k]=(0,i.useState)(!1),[S,I]=(0,i.useState)(""),[_,E]=(0,i.useState)(!1),[F,D]=(0,i.useState)(!1),[q,L]=(0,i.useState)(b||""),[U,T]=(0,i.useState)(!1),[W,P]=(0,i.useState)({}),N=(0,i.useCallback)(()=>{S&&(null==t||t.chain().focus().extendMarkRange("link").setLink({href:S}).run()),k(!1),I("")},[t,S]),B=async e=>{let r=Array.from(e.target.files||[]);if(r.length>0&&v&&t){T(!0);let e={};r.forEach(t=>{e[t.name]=0}),P(e);try{for(let e of r)try{let r=await v(e),a="https://api-prod-news.canaranews.com/api".replace(/\/api\/?$/,"")+r;t.chain().focus().setImage({src:a,"data-align":"center","data-float":"none",alt:e.name||"Uploaded image"}).createParagraphNear().run(),P(t=>({...t,[e.name]:100}))}catch(t){console.error("Upload failed for ".concat(e.name,":"),t)}E(!1)}catch(e){console.error("Image uploads failed:",e)}finally{T(!1),P({})}}},R=(0,i.useCallback)(()=>{let e=(q||"").trim();if(!e||!t)return void D(!1);null==w||w(e);let r=(e=>{try{let t=new URL(e);if("youtu.be"===t.hostname){let e=t.pathname.replace("/","");return"https://www.youtube.com/embed/".concat(e)}if(t.hostname.includes("youtube.com")){let e=t.searchParams.get("v");if(e)return"https://www.youtube.com/embed/".concat(e);
1if(t.pathname.startsWith("/embed/"))return t.href}}catch(e){}return null})(e),a=(e=>{try{let t=new URL(e);if(t.hostname.includes("vimeo.com")){let e=t.pathname.split("/").filter(Boolean)[0];if(e)return"https://player.vimeo.com/video/".concat(e)}}catch(e){}return null})(e),i=r||a;i?t.chain().focus().insertContent({type:"paragraph",content:[{type:"text",text:""}]}).insertContent('<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;border-radius:8px;">\n  <iframe src="'.concat(i,'" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen style="position:absolute;top:0;left:0;width:100%;height:100%"></iframe>\n</div>')).createParagraphNear().run():t.chain().focus().insertContent('<p><a href="'.concat(e,'" target="_blank" rel="noopener noreferrer">Video link</a></p>')).run(),D(!1)},[t,q,w]);return t?(0,a.jsxs)(s.default,{sx:{border:1,borderColor:p?"error.main":"grey.400",borderRadius:1},children:[(0,a.jsx)(z,{editor:t,onLinkClick:()=>k(!0),onImageClick:()=>E(!0),onVideoClick:()=>{L(b||""),D(!0)}}),(0,a.jsx)(s.default,{sx:{p:1,minHeight:f,maxHeight:j,overflowY:"auto","& .ProseMirror":{"& > * + *":{marginTop:"1rem"},"& .custom-image-wrapper":{display:"block",margin:"1.5rem 0","& img":{maxWidth:"100%",height:"auto",display:"block",borderRadius:"4px",'&[data-align="center"]':{margin:"0 auto"},'&[data-align="left"]':{float:"left",margin:"0 1rem 1rem 0"},'&[data-align="right"]':{float:"right",margin:"0 0 1rem 1rem"},'&[data-float="left"]':{float:"left",margin:"0 1rem 1rem 0"},'&[data-float="right"]':{float:"right",margin:"0 0 1rem 1rem"},"&.ProseMirror-selectednode":{outline:"2px solid #4CAF50",outlineOffset:"2px"}},"&:after":{content:'""',display:"table",clear:"both"}}}},children:(0,a.jsx)(n.$Z,{editor:t})}),r&&(0,a.jsx)(o.default,{variant:"caption",sx:{p:1,color:p?"error.main":"text.secondary"},children:r}),(0,a.jsxs)(c.A,{open:C,onClose:()=>k(!1),fullWidth:!0,maxWidth:"sm",children:[(0,a.jsx)(u.A,{children:"Set Link"}),(0,a.jsx)(d.A,{children:(0,a.jsx)(h.A,{autoFocus:!0,margin:"dense",label:"URL",type:"url",fullWidth:!0,value:S,onChange:e=>I(e.target.value),onKeyDown:e=>"Enter"===e.key&&N()})}),(0,a.jsxs)(m.A,{children:[(0,a.jsx)(g.A,{onClick:()=>k(!1),children:"Cancel"}),(0,a.jsx)(g.A,{onClick:N,children:"Set Link"})]})]}),(0,a.jsxs)(c.A,{open:_,onClose:()=>E(!1),fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(u.A,{children:"Insert Image"}),(0,a.jsx)(d.A,{children:(0,a.jsxs)(s.default,{sx:{p:2,textAlign:"center"},children:[(0,a.jsxs)(g.A,{variant:"contained",component:"label",startIcon:(0,a.jsx)(y.A,{}),disabled:U,children:["Upload Files",(0,a.jsx)("input",{type:"file",hidden:!0,multiple:!0,accept:"image/*",onChange:B})]}),U&&(0,a.jsx)(s.default,{sx:{mt:2},children:Object.entries(W).map(e=>{let[t,r]=e;return(0,a.jsxs)(s.default,{sx:{mb:1},children:[(0,a.jsx)(o.default,{variant:"caption",display:"block",gutterBottom:!0,children:t}),(0,a.jsx)(x.A,{variant:r>0?"determinate":"indeterminate",value:r})]},t)})})]})})]}),(0,a.jsxs)(c.A,{open:F,onClose:()=>D(!1),fullWidth:!0,maxWidth:"sm",children:[(0,a.jsx)(u.A,{children:"Insert Video"}),(0,a.jsxs)(d.A,{children:[(0,a.jsx)(h.A,{autoFocus:!0,margin:"dense",label:"Video URL",type:"url",fullWidth:!0,value:q,onChange:e=>L(e.target.value),placeholder:"Paste YouTube or Vimeo URL",onKeyDown:e=>"Enter"===e.key&&R()}),(0,a.jsx)(o.default,{variant:"caption",color:"text.secondary",children:"YouTube and Vimeo links will be embedded automatically; other URLs will be inserted as links."})]}),(0,a.jsxs)(m.A,{children:[(0,a.jsx)(g.A,{onClick:()=>D(!1),children:"Cancel"}),(0,a.jsx)(g.A,{onClick:R,variant:"contained",startIcon:(0,a.jsx)(A.A,{}),children:"Insert"})]})]})]}):(0,a.jsx)(l.A,{variant:"rectangular",width:"100%",height:f})});P.displayName="TipTapEditor";let z=e=>{let{editor:t,onLinkClick:r,onImageClick:i,onVideoClick:n}=e;return(0,a.jsxs)(s.default,{sx:{p:1,display:"flex",flexWrap:"wrap",gap:1},children:[(0,a.jsx)(p.A,{title:"Bold",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleBold().run(),color:t.isActive("bold")?"primary":"default",children:(0,a.jsx)(v.A,{})})}),(0,a.jsx)(p.A,{title:"Italic",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleItalic().run(),color:t.isActive("italic")?"primary":"default",children:(0,a.jsx)(b.A,{})})}),(0,a.jsx)(p.A,{title:"Underline",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleUnderline().run(),color:t.isActive("underline")?"primary":"default",children:(0,a.jsx)(w.A,{})})}
1),(0,a.jsx)(p.A,{title:"Strike",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleStrike().run(),color:t.isActive("strike")?"primary":"default",children:(0,a.jsx)(C.A,{})})}),(0,a.jsx)(p.A,{title:"Code",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleCode().run(),color:t.isActive("code")?"primary":"default",children:(0,a.jsx)(k.A,{})})}),(0,a.jsx)(p.A,{title:"Link",children:(0,a.jsx)(f.A,{onClick:r,color:t.isActive("link")?"primary":"default",children:(0,a.jsx)(S.A,{})})}),(0,a.jsx)(p.A,{title:"Image",children:(0,a.jsx)(f.A,{onClick:i,children:(0,a.jsx)(I.A,{})})}),(0,a.jsx)(p.A,{title:"Video",children:(0,a.jsx)(f.A,{onClick:n,children:(0,a.jsx)(A.A,{})})}),(0,a.jsx)(j.A,{orientation:"vertical",flexItem:!0}),(0,a.jsx)(p.A,{title:"Heading 1",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),color:t.isActive("heading",{level:1})?"primary":"default",children:(0,a.jsx)(_.A,{})})}),(0,a.jsx)(p.A,{title:"Heading 2",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),color:t.isActive("heading",{level:2})?"primary":"default",children:(0,a.jsx)(o.default,{children:"H2"})})}),(0,a.jsx)(p.A,{title:"Bullet List",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleBulletList().run(),color:t.isActive("bulletList")?"primary":"default",children:(0,a.jsx)(E.A,{})})}),(0,a.jsx)(p.A,{title:"Ordered List",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleOrderedList().run(),color:t.isActive("orderedList")?"primary":"default",children:(0,a.jsx)(F.A,{})})}),(0,a.jsx)(p.A,{title:"Blockquote",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleBlockquote().run(),color:t.isActive("blockquote")?"primary":"default",children:(0,a.jsx)(D.A,{})})}),(0,a.jsx)(p.A,{title:"Code Block",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),color:t.isActive("codeBlock")?"primary":"default",children:(0,a.jsx)(k.A,{})})}),(0,a.jsx)(j.A,{orientation:"vertical",flexItem:!0}),(0,a.jsx)(p.A,{title:"Align Left",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().setTextAlign("left").run(),color:t.isActive({textAlign:"left"})?"primary":"default",children:(0,a.jsx)(q.A,{})})}),(0,a.jsx)(p.A,{title:"Align Center",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().setTextAlign("center").run(),color:t.isActive({textAlign:"center"})?"primary":"default",children:(0,a.jsx)(L.A,{})})}),(0,a.jsx)(p.A,{title:"Align Right",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().setTextAlign("right").run(),color:t.isActive({textAlign:"right"})?"primary":"default",children:(0,a.jsx)(U.A,{})})}),(0,a.jsx)(p.A,{title:"Align Justify",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),color:t.isActive({textAlign:"justify"})?"primary":"default",children:(0,a.jsx)(T.A,{})})}),(0,a.jsx)(j.A,{orientation:"vertical",flexItem:!0}),(0,a.jsx)(p.A,{title:"Clear Format",children:(0,a.jsx)(f.A,{onClick:()=>t.chain().focus().unsetAllMarks().run(),children:(0,a.jsx)(W.A,{})})})]})},N=P},55972:(e,t,r)=>{"use strict";r.d(t,{u:()=>i});var a=r(95125);let i=(0,r(1407).q)(a.A.create({headers:{"Content-type":"application/json"},paramsSerializer:{indexes:null},baseURL:"https://api-prod-news.canaranews.com/api"}))},65731:(e,t,r)=>{"use strict";r.d(t,{Ao:()=>j,H4:()=>b,HM:()=>A,Jr:()=>u,_9:()=>v,_D:()=>g,ne:()=>h,p$:()=>o,u8:()=>p});var a=r(22454),i=r(99776),n=r(80549),l=r(34344);let s=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,n=arguments.length>5?arguments[5]:void 0,{data:s}=await l.u.get("/news",{params:{page:e,pageSize:t,...r?{category:r}:{},...a?{location:a}:{},...i?{status:i}:{},...n?{searchTerm:n}:{}}});return s},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0,l=arguments.length>5?arguments[5]:void 0,o=["news",{page:e,pageSize:t,category:r,location:i,status:n,searchTerm:l}];return(0,a.I)({queryKey:o,queryFn:()=>s(e,t,r,i,n,l)})},c=async e=>{let{data:t}=await l.u.get("/news/".concat(e));return t},u=e=>(0,a.I)({queryKey:["news",e],queryFn:()=>c(e),enabled:!!e}),d=async e=>{let{data:t}=await l.u.post("/news",e);return t},h=()=>{let e=(0,i.jE)();return(0,n.n)({mutationFn:d,onSuccess:()=>
1{e.invalidateQueries({queryKey:["news"]})}})},m=async e=>{let{id:t,...r}=e,{data:a}=await l.u.put("/news/".concat(t),r);return a},g=()=>{let e=(0,i.jE)();return(0,n.n)({mutationFn:m,onSuccess:(t,r)=>{e.invalidateQueries({queryKey:["news"]}),e.invalidateQueries({queryKey:["news",r.id]})}})},x=async e=>{await l.u.delete("/news/".concat(e))},p=()=>{let e=(0,i.jE)();return(0,n.n)({mutationFn:x,onSuccess:()=>{e.invalidateQueries({queryKey:["news"]})}})},f=async e=>{let t=new FormData;t.append("image",e);let{data:r}=await l.u.post("news/upload/image",t,{headers:{"Content-Type":"multipart/form-data"}});return r},j=()=>(0,n.n)({mutationFn:f,onError:e=>{console.error("Error uploading image:",e)}}),y=async e=>{await l.u.post("/news/".concat(e,"/show-hide"))},A=()=>{let e=(0,i.jE)();return(0,n.n)({mutationFn:y,onSuccess:()=>{e.invalidateQueries({queryKey:["news"]})}})},v=()=>(0,a.I)({queryKey:["comments"],queryFn:async()=>{let{data:e}=await l.u.get("/admin/news/comments");return e}}),b=()=>{let e=(0,i.jE)();return(0,n.n)({mutationFn:async e=>{let{id:t,show:r}=e;await l.u.post("/admin/news/comments/".concat(t),{show:r})},onSuccess:()=>{e.invalidateQueries({queryKey:["comments"]})}})}},68147:(e,t,r)=>{"use strict";r.d(t,{Ck:()=>o,GK:()=>g,at:()=>u,bZ:()=>p,jh:()=>A,xZ:()=>j,yQ:()=>h});var a=r(34344),i=r(22454),n=r(99776),l=r(80549);let s=async()=>{let{data:e}=await a.u.get("/categories");return e},o=()=>(0,i.I)({queryKey:["categories"],queryFn:s}),c=async()=>{let{data:e}=await a.u.get("/categories/news-count");return e},u=()=>(0,i.I)({queryKey:["categories-news-count"],queryFn:c}),d=async e=>{let{data:t}=await a.u.get("/categories/".concat(e));return t},h=e=>(0,i.I)({queryKey:["categories",e],queryFn:()=>d(e),enabled:!!e}),m=async e=>{let{data:t}=await a.u.post("/categories",e);return t},g=()=>{let e=(0,n.jE)();return(0,l.n)({mutationFn:m,onSuccess:()=>{e.invalidateQueries({queryKey:["categories"]})}})},x=async e=>{let{id:t,...r}=e,{data:i}=await a.u.put("/categories/".concat(t),r);return i},p=()=>{let e=(0,n.jE)();return(0,l.n)({mutationFn:x,onSuccess:t=>{e.invalidateQueries({queryKey:["categories"]}),e.invalidateQueries({queryKey:["categories",t.id]})}})},f=async e=>{await a.u.delete("/categories/".concat(e))},j=()=>{let e=(0,n.jE)();return(0,l.n)({mutationFn:f,onSuccess:()=>{e.invalidateQueries({queryKey:["categories-news-count"]})}})},y=async e=>{await a.u.post("/categories/".concat(e,"/show-hide"))},A=()=>{let e=(0,n.jE)();return(0,l.n)({mutationFn:y,onSuccess:()=>{e.invalidateQueries({queryKey:["categories-news-count"]})}})}},89954:(e,t,r)=>{Promise.resolve().then(r.bind(r,97303))},92889:(e,t,r)=>{"use strict";r.d(t,{A:()=>g});var a=r(95155);r(12115);var i=r(41574),n=r(62995),l=r(68060),s=r(51404),o=r(21844),c=r(23405),u=r(13664),d=r(19131),h=r(50355);let m=["BANNER","HOME","MOST_VIEWED","BREAKING","TRENDING"];function g(e){let{location:t,sort:r,onLocationChange:g,onSortChange:x,errorLocation:p,errorSort:f,helperLocation:j,helperSort:y}=e;return(0,a.jsxs)(i.default,{sx:{display:"flex",gap:2,mb:2},children:[(0,a.jsxs)(n.A,{fullWidth:!0,error:p,children:[(0,a.jsx)(l.A,{id:"location-multi-label",children:"Location"}),(0,a.jsx)(s.A,{labelId:"location-multi-label",multiple:!0,value:t,onChange:e=>g("string"==typeof e.target.value?e.target.value.split(","):e.target.value),input:(0,a.jsx)(o.A,{label:"Location"}),renderValue:e=>e.join(", "),children:m.map(e=>(0,a.jsxs)(c.A,{value:e,children:[(0,a.jsx)(u.A,{checked:t.indexOf(e)>-1}),(0,a.jsx)(d.A,{primary:e})]},e))}),j&&(0,a.jsx)("span",{style:{color:"red",fontSize:12},children:j})]}),(0,a.jsx)(h.A,{type:"number",label:"Sort Order",value:r,onChange:e=>x(Number(e.target.value)),error:f,helperText:y||"Integer for sorting (lower = higher priority)",fullWidth:!0,inputProps:{min:0}})]})}},97303:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>eb});var a=r(95155),i=r(12115),n=r(20063),l=r(46098),s=r(21960),o=r(8618),c=r(43419),u=r(49143),d=r(44918),h=r(93777),m=r(75699),g=r(78336),x=r(79371),p=r(22984),f=r(67327),j=r(85210),y=r(56135),A=r(23023),v=r(77004),b=r(30232),w=r(34508),C=r(84741),k=r(55792),S=r(21670),I=r(8624),_=r(93759),E=r(12751),F=r(19148),D=r(55404),q=r(31363),L=r(91933),U=r(63374),T=r(28336),W=r(97738),P=r(3594),z=r(41574),N=r(98638),B=r(80317),R=r(60193),K=r(66088),O=r(75970),H=r(50355),Q=r(27855),M=r(43791),V=r(41942),J=r(62995),$=r(65654),G=r(68060),Z=r(51404),Y=r(23405),X=r(12827),ee=r(74193),et=r(41477),er=r(49571),ea=r(76541),ei=r(86013),en=r(8994),el=r(72177),es=r(66280),eo=r(70692),ec=r(97052),eu=r(94913),ed=r(86596),eh=r(15239),em=r(68147),eg=r(95595),ex=r(10091),ep=r(56222),ef=r(92889),ej=r(65731),ey=r(35712);let eA=(0,L.$)();eA.register("html",U.A),eA.register("css",T.A),eA.register("js",W.A),eA.register("ts",P.A);let ev=o.y.extend({content:"block+"});function eb(){let e=(0,n.useRouter)(),t=(0,n.useParams)().id,{data:r,isLoading:o,isError:L}=(0,ej.Jr)(t),{mutateAsync:U,isPending:T}=(0,ej._D)(),{mutateAsync:W}=(0,ej.Ao)(),{data:P=[]}=(0,em.Ck)(),[eb,ew]=(0,i.useState)([]),[eC,ek]=(0,i.useState)(""),[eS,eI]=(0,i.useState)(null),[e_,eE]=(0,i.useState)(""),[eF,eD]=(0,i.useState)({}),[eq,eL]=(0,i.useState)({id:"",title:"",summary:"",image:"",videoUrl:"",category:"",date:null,author:"",content:"",fullContent:"",tags:[],status:"draft",isFeatured:!1,allowComments:!0,metaTitle:"",metaDescription:"",views:0,shares:0,publishDate:new Date,createdAt:null,updatedAt:null,location:[],sort:0,news_id:""});(0,i.useEffect)(()=>{r&&(eL({id:String(r.id)||"",title:r.title||"",summary:r.article_summary||"",image:r.featured_image||"",videoUrl:r.video_url||"",category:String(r.category_id)||"",date:r.publish_date||null,author:r.author||"",content:r.full_content||"",fullContent:r.full_content||"",tags:r.tags||[],status:r.status||"draft",isFeatured:r.is_featured||!1,allowComments:r.allow_comments||!0,metaTitle:r.meta_title||"",metaDescription:r.meta_description||"",views:0,shares:0,publishDate:r.publish_date?new Date(r.publish_date):new Date,createdAt:r.created_at||null,location:r.location?r.location.split(","):[],sort:"number"==typeof r.sort?r.sort:0,news_id:String(r.id)||""}),ew(r.tags||[]),eE(r.featured_image?"".concat("https://api-prod-news.canaranews.com/api".replace(/\/api\/?$/,"")).concat(r.featured_image.startsWith("/")?"":"/").concat(r.featured_image):""))},[r]);let eU=(0,i.useCallback)(e=>{eL(t=>({...t,fullContent:e})),eF.content&&eD(e=>({...e,content:""}))},[eF.content]),eT=(0,i.useMemo)(()=>[ev,s.W.configure({document:!1}),c.z,u.n,d.Cy,D.E,q.Z,_.a,I.xJ,S.Q,E.f4.configure({multicolor:!0}),F.n.configure({types:["heading","paragraph","image"]}),h.d.configure({lowlight:eA,defaultLanguage:"javascript"}),m.XI.configure({resizable:!0}),g.H,x.A,p.n,f._,j.L.configure({nested:!0}),y.N_.configure({openOnClick:!1,linkOnPaste:!0,autolink:!0}),A.A,v.O.configure({placeholder:"Start writing your article here..."}),b.n.configure({limit:2e4}),w.Q.configure({width:2,color:"#3B82F6"}),C.v,k.d],[]),eW=(0,l.hG)({extensions:eT,content:eq.fullContent,immediatelyRender:!1,onUpdate:e=>{let{editor:t}=e;eU(t.getHTML())}});(0,i.useEffect)(()=>{eW&&eq.fullContent&&eq.fullContent!==eW.getHTML()&&eW.commands.setContent(eq.fullContent)},[eW,eq.fullContent]);let eP=e=>{let{name:t,value:r}=e.target;eL(e=>({...e,[t]:r})),eF[t]&&eD(e=>({...e,[t]:""}))},ez=e=>{let{name:t,checked:r}=e.target;eL(e=>({...e,[t]:r}))},eN=()=>{eC.trim()&&!eb.includes(eC.trim())&&(ew([...eb,eC.trim()]),ek(""))},eB=(0,i.useCallback)(async e=>{try{return(await W(e)).path}catch(e){throw console.error("Image upload failed:",e),e}},[W]),eR=async function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"draft";if(r.preventDefault(),(()=>{let e={};if(eq.title.trim()||(e.title="Title is required"),eq.summary.trim()||(e.summary="Summary is required"),eq.videoUrl&&eq.videoUrl.trim())try{new URL(eq.videoUrl.trim())}catch(t){e.videoUrl="Enter a valid URL (e.g., https://youtu.be/...)"}return eq.category||(e.category="Category is required"),eq.author||(e.author="Author is required"),eq.fullContent&&"<p></p>"!==eq.fullContent.trim()||(e.content="Content is required"),eq.location&&0!==eq.location.length||(e.location="Select at least one location"),void 0===eq.sort||null===eq.sort||isNaN(eq.sort)?e.sort="Sort order is required":(!Number.isInteger(eq.sort)||eq.sort<0)&&(e.sort="Sort order must be a non-negative integer"),eD(e),0===Object.keys(e).length})())try{let r=eq.image;if(eS)try{r=await eB(eS)}catch(e){console.error("Error uploading image:",e),eD(e=>({...e,image:"Failed to upload image. Please try again."}));return}let i={title:eq.title,article_summary:eq.summary,featured_image:r,category_id:eq.category,publish_date:"published"===a?(eq.publishDate||new Date).toISOString():null,author:eq.author,full_content:eq.fullContent,video_url:eq.videoUrl&&eq.videoUrl.trim()?eq.videoUrl.trim():void 0,tags:eb,status:a,is_featured:eq.isFeatured,allow_comments:eq.allowComments,meta_title:eq.metaTitle||eq.title,meta_description:eq.metaDescription||eq.summary,location:Array.isArray(eq.location)?eq.location.join(","):eq.location,sort:eq.sort};await U({id:t,...i}),e.push("/dashboard/news-management")}catch(e){console.error("Error updating news:",e),eD(e=>({...e,submit:"Failed to update article. Please try again."}))}};return o?(0,a.jsx)(z.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:300},children:(0,a.jsx)(N.A,{})}):L||!r?(0,a.jsx)(B.default,{color:"error",children:"Failed to load news article. Please try again."}):(0,a.jsx)(ex.$J,{dateAdapter:ep.h,children:(0,a.jsxs)(z.default,{sx:{mx:"auto"},children:[(0,a.jsxs)(z.default,{sx:{mb:3,display:"flex",alignItems:"center",gap:2},children:[(0,a.jsx)(R.A,{onClick:()=>e.back(),sx:{mr:1},children:(0,a.jsx)(ea.A,{})}),(0,a.jsx)(B.default,{variant:"h4",component:"h1",children:"Edit News Article"})]}),(0,a.jsx)("form",{onSubmit:e=>eR(e,"published"),children:(0,a.jsxs)(K.A,{container:!0,spacing:3,children:[(0,a.jsx)(K.A,{size:{xs:12,md:8,lg:8},children:(0,a.jsxs)(O.A,{sx:{p:3,mb:3},children:[(0,a.jsxs)(B.default,{variant:"h6",sx:{mb:2,display:"flex",alignItems:"center"},children:[(0,a.jsx)(ei.A,{sx:{mr:1}})," Article Details"]}
1),(0,a.jsx)(ef.A,{location:eq.location,sort:eq.sort,onLocationChange:e=>eL(t=>({...t,location:e})),onSortChange:e=>eL(t=>({...t,sort:e})),errorLocation:!!eF.location,errorSort:!!eF.sort,helperLocation:eF.location,helperSort:eF.sort}),(0,a.jsx)(H.A,{fullWidth:!0,label:"Title",name:"title",value:eq.title,onChange:eP,margin:"normal",variant:"outlined",required:!0,error:!!eF.title,helperText:eF.title,placeholder:"Enter article title"}),(0,a.jsxs)(B.default,{variant:"h6",sx:{mb:2,display:"flex",alignItems:"center"},children:[(0,a.jsx)(en.A,{sx:{mr:1}})," Featured Image"]}),(0,a.jsxs)(z.default,{sx:{mb:2},children:[(0,a.jsx)("input",{accept:"image/*",style:{display:"none"},id:"featured-image-upload",type:"file",onChange:e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];if(r){if(r.size>5242880)return void eD(e=>({...e,image:"Image size should be less than 5MB"}));eI(r);let e=new FileReader;e.onloadend=()=>{eE(e.result)},e.readAsDataURL(r),eF.image&&eD(e=>({...e,image:""}))}}}),(0,a.jsx)("label",{htmlFor:"featured-image-upload",children:(0,a.jsx)(Q.A,{variant:"outlined",component:"span",startIcon:(0,a.jsx)(en.A,{}),sx:{mb:2},children:"Choose Featured Image"})}),eF.image&&(0,a.jsx)(B.default,{color:"error",variant:"caption",sx:{display:"block",mt:1},children:eF.image})]}),e_&&(0,a.jsx)(z.default,{sx:{mt:2,mb:2},children:(0,a.jsx)(eh.default,{src:e_,alt:"Preview",width:600,height:200,style:{height:"auto"},unoptimized:!0})}),(0,a.jsx)(H.A,{fullWidth:!0,label:"Summary",name:"summary",value:eq.summary,onChange:eP,margin:"normal",variant:"outlined",multiline:!0,rows:3,required:!0,error:!!eF.summary,helperText:eF.summary||"Brief description of the article",placeholder:"Enter article summary"}),(0,a.jsxs)(z.default,{sx:{mt:3,mb:2},children:[(0,a.jsxs)(B.default,{variant:"h6",sx:{mb:2,display:"flex",alignItems:"center"},children:[(0,a.jsx)(el.A,{sx:{mr:1}})," Content"]}),eW?(0,a.jsx)(ey.A,{editor:eW,onImageUpload:eB,videoUrl:eq.videoUrl||"",onVideoUrlChange:e=>eL(t=>({...t,videoUrl:e}))}):(0,a.jsx)(M.A,{variant:"rectangular",width:"100%",height:300}),eF.content&&(0,a.jsx)(B.default,{color:"error",variant:"caption",sx:{mt:1,display:"block"},children:eF.content})]})]})}),(0,a.jsxs)(K.A,{size:{xs:12,lg:4},children:[(0,a.jsxs)(V.A,{spacing:3,children:[(0,a.jsxs)(z.default,{sx:{display:"flex",gap:2},children:[(0,a.jsx)(Q.A,{type:"submit",variant:"contained",startIcon:(0,a.jsx)(es.A,{}),disabled:T,fullWidth:!0,children:T?(0,a.jsx)(N.A,{size:20}):"Update & Publish"}),(0,a.jsx)(Q.A,{variant:"outlined",startIcon:(0,a.jsx)(eo.A,{}),onClick:e=>{eR(e,"draft")},disabled:T,fullWidth:!0,children:"Save Draft"})]}),eF.submit&&(0,a.jsx)(B.default,{color:"error",variant:"body2",children:eF.submit})]}),(0,a.jsxs)(O.A,{sx:{p:3,mb:3},children:[(0,a.jsxs)(B.default,{variant:"h6",sx:{mb:2,display:"flex",alignItems:"center"},children:[(0,a.jsx)(ec.A,{sx:{mr:1}})," Author & Date"]}),(0,a.jsxs)(J.A,{fullWidth:!0,size:"small",margin:"normal",children:[(0,a.jsx)(H.A,{fullWidth:!0,label:"Author",name:"author",value:eq.author,onChange:eP,margin:"normal",variant:"outlined",placeholder:"Enter author name"}),eF.author&&(0,a.jsx)($.A,{error:!0,children:eF.author})]}),(0,a.jsx)(eg.l,{label:"Publish Date",value:eq.publishDate?new Date(eq.publishDate):new Date,onChange:e=>{eL(t=>({...t,publishDate:e||new Date})),eF.publishDate&&eD(e=>({...e,publishDate:""}))},slotProps:{textField:{fullWidth:!0,size:"small",margin:"normal"}}})]}),(0,a.jsxs)(O.A,{sx:{p:3,mb:3},children:[(0,a.jsxs)(B.default,{variant:"h6",sx:{mb:2,display:"flex",alignItems:"center"},children:[(0,a.jsx)(eu.A,{sx:{mr:1}})," Categories"]}),(0,a.jsxs)(J.A,{fullWidth:!0,size:"small",margin:"normal",children:[(0,a.jsx)(G.A,{id:"category-label",children:"Select Category"}),(0,a.jsx)(Z.A,{labelId:"category-label",id:"category",name:"category",value:eq.category,label:"Select Category",onChange:e=>{let{name:t,value:r}=e.target;eL(e=>({...e,[t]:r})),eF[t]&&eD(e=>({...e,[t]:""}))},error:!!eF.category,children:P.length>0?P.map(e=>(0,a.jsx)(Y.A,{value:e.id,children:e.name},e.id)):(0,a.jsx)(Y.A,{disabled:!0,children:"No categories found"})}),eF.category&&(0,a.jsx)($.A,{error:!0,children:eF.category})]})]}),(0,a.jsxs)(O.A,{sx:{p:3,mb:3},children:[(0,a.jsx)(B.default,{variant:"h6",sx:{mb:2},children:"Tags"}),(0,a.jsx)(z.default,{sx:{display:"flex",gap:1,mb:2},children:(0,a.jsx)(H.A,{fullWidth:!0,size:"small",value:eC,onChange:e=>ek(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eN())},placeholder:"Add tags...",InputProps:{endAdornment:(0,a.jsx)(X.A,{position:"end",children:(0,a.jsx)(R.A,{size:"small",onClick:eN,disabled:!eC.trim(),children:(0,a.jsx)(ed.A,{})})})}})}),(0,a.jsx)(z.default,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1},children:eb.map(e=>(0,a.jsx)(ee.A,{label:e,onDelete:()=>{ew(eb.filter(t=>t!==e))},size:"small",variant:"outlined"},e))})]}),(0,a.jsxs)(O.A,{sx:{p:3},children:[(0,a.jsx)(B.default,{variant:"h6",sx:{mb:2},children:"Options"}),(0,a.jsxs)(z.default,{sx:{display:"flex",flexDirection:"column",gap:2},children:[(0,a.jsx)(et.A,{control:(0,a.jsx)(er.A,{checked:eq.isFeatured,onChange:ez,name:"isFeatured",color:"primary"}),label:"Featured Article"}),(0,a.jsx)(et.A,{control:(0,a.jsx)(er.A,{checked:eq.allowComments,onChange:ez,name:"allowComments",color:"primary"}),label:"Allow Comments"})]})]}),(0,a.jsxs)(O.A,{sx:{p:3,mb:{xs:3,lg:0}},children:[(0,a.jsx)(B.default,{variant:"h6",sx:{mb:2},children:"Search Engine Optimization"}),(0,a.jsx)(H.A,{fullWidth:!0,label:"Meta Title",name:"metaTitle",value:eq.metaTitle,onChange:eP,margin:"normal",variant:"outlined",placeholder:"Enter meta title",helperText:"If empty, the article title will be used"}),(0,a.jsx)(H.A,{fullWidth:!0,label:"Meta Description",name:"metaDescription",value:eq.metaDescription,onChange:eP,margin:"normal",variant:"outlined",multiline:!0,rows:3,placeholder:"Enter meta description",helperText:"If empty, the article excerpt will be used"})]})]})]})})]})})}}},e=>{e.O(0,[5004,277,7578,7743,1057,6236,2454,4810,1988,7855,3683,6855,355,6088,1521,5039,848,5722,6394,5555,301,6599,4530,5712,7793,4296,6972,8441,1255,7358],()=>e(e.s=89954)),_N_E=e.O()}]);

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.