module.exports=[70586,a=>{"use strict";var b=a.i(87924),c=a.i(82892),d=a.i(72131),e=a.i(37196);a.s(["default",0,()=>{let[a,f]=(0,d.useState)([]),[g,h]=(0,d.useState)("");(0,d.useEffect)(()=>{i()},[]);let i=async()=>{try{let a=await (0,c.default)("/api/script/all-widget");a?.success&&f(a.data)}catch(a){console.error("Failed to fetch widgets:",a)}},j=async a=>{if(a?.length>0){let b=`<script async src="https://tool.chatknot.com${a}"></script>`;try{await navigator.clipboard.writeText(b),(0,e.default)("Success!","Script copied to clipboard!","success")}catch(c){console.error("Clipboard API failed:",c);let a=document.createElement("textarea");a.value=b,document.body.appendChild(a),a.select();try{document.execCommand("copy")?alert("Script copied to clipboard!"):alert("Copy failed.")}catch(a){console.error("Fallback copy error:",a),alert("Failed to copy script to clipboard.")}finally{document.body.removeChild(a)}}}else alert("No script available to copy.")},k=a.filter(a=>a?.brand_name?.toLowerCase().includes(g.toLowerCase()));return(0,b.jsxs)("div",{className:"container-fluid table-container table-responsive",children:[(0,b.jsx)("h2",{className:"my-3",children:"Widgets"}),(0,b.jsx)("div",{className:"mb-3",children:(0,b.jsx)("input",{type:"text",className:"form-control",placeholder:"Search by Brand Name",value:g,onChange:a=>h(a.target.value)})}),(0,b.jsxs)("table",{className:"table table-striped mt-4",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{children:"#"}),(0,b.jsx)("th",{children:"Brand Name"}),(0,b.jsx)("th",{children:"Script"}),(0,b.jsx)("th",{children:"Action"})]})}),(0,b.jsxs)("tbody",{children:[k.map((a,c)=>(0,b.jsxs)("tr",{children:[(0,b.jsx)("td",{children:c+1}),(0,b.jsx)("td",{children:a?.brand_name||"N/A"}),(0,b.jsx)("td",{children:(0,b.jsx)("code",{className:"d-block text-truncate",style:{maxWidth:"400px"},children:`<script async src="https://tool.chatknot.com${a.file_path}"></script>`})}),(0,b.jsx)("td",{children:(0,b.jsx)("button",{className:"btn btn-sm btn-outline-primary",onClick:()=>j(a.file_path),children:"Copy Script"})})]},c)),0===k.length&&(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:"4",className:"text-center",children:"No widgets found."})})]})]})]})}])}];

//# sourceMappingURL=app_%28dashboard%29_all-widgets_page_ea83cfaa.js.map