1import{j as e}from"./vendor-radix-primitives-B70V19yX.js";import{a as t,u as i,d as r,c as n}from"./vendor-react-DcdsEcWn.js";import{h as a,t as s,u as l,o,b as c}from"../index-WFWn4sD1.js";import{s as d,a as u}from"./scripts.service-CCi5w92N.js";import{p}from"./ChartPreview-DQCRvIcI.js";import{U as h}from"./UnifiedTooltip-f569lhqb.js";import{n as g}from"./normalize-DlG8pWxK.js";const x="aig:prompt-history";function m(e){if("undefined"!=typeof window)try{window.localStorage.setItem(x,JSON.stringify(e))}catch{}}const b="aig:last-generation";function f(e){if("undefined"!=typeof window)try{null===e?window.localStorage.removeItem(b):window.localStorage.setItem(b,JSON.stringify(e))}catch{}}const v=({size:t,className:i,color:r})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 256 256",fill:r||"currentColor",className:i,"aria-hidden":"true",children:e.jsx("path",{d:"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"})}),y=({size:t,className:i,color:r})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 256 256",fill:r||"currentColor",className:i,"aria-hidden":"true",children:e.jsx("path",{d:"M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H72a8,8,0,0,1,0,16H32v64H224V136H184a8,8,0,0,1,0-16h40A16,16,0,0,1,240,136Zm-117.66-2.34a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,108.69V24a8,8,0,0,0-16,0v84.69L85.66,74.34A8,8,0,0,0,74.34,85.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z"})}),j=({size:t,className:i,color:r})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 256 256",fill:r||"currentColor",className:i,"aria-hidden":"true",children:e.jsx("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"})});function w(e,t){return e&&e.trim()?function(e){const t=e.toLowerCase();return/^\s*\d{3}\s*[{[]/.test(e)||t.includes("invalid_request_error")||t.includes("credit balance")||t.includes("anthropic")||t.includes('"type":"error"')||t.includes("rate_limit")||t.includes("overloaded")||t.includes("request_id")||t.includes("<!doctype")||t.includes("<html")}(e)?t:e:t}const k={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:16200},S={position:"relative",width:"min(600px, 88vw)",maxHeight:"80vh",overflow:"auto",borderRadius:12,border:"1px solid rgba(255,255,255,0.08)",backgroundColor:"rgba(17,19,21,0.5)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",boxShadow:"0 10px 40px rgba(0,0,0,0.35)",padding:"20px 22px",display:"flex",flexDirection:"column",gap:"16px",zIndex:16201},C={display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:4},N={fontSize:16,fontWeight:600,opacity:.9,color:"#fff",margin:0,letterSpacing:.2},L={width:28,height:28,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"rgba(255,255,255,0.4)",cursor:"pointer",transition:"all 0.15s ease"},z={fontSize:13,color:"rgba(255,255,255,0.7)",display:"block",marginBottom:6,letterSpacing:.2},_={width:"100%",background:"rgba(255,255,255,0.04)",border:"none",borderRadius:8,padding:"10px 12px",color:"#fff",fontSize:14,lineHeight:"18px",outline:"none",transition:"background 0.15s"},G={..._,minHeight:100,fontFamily:"inherit",resize:"vertical",lineHeight:1.5},M={height:36,padding:"0 16px",borderRadius:999,border:"none",cursor:"pointer",fontWeight:500,fontSize:13,letterSpacing:.2,display:"flex",alignItems:"center",gap:8,transition:"all 0.15s"},T={...M,background:"#F6F7FB",color:"#0B1020"},W={...M,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.14)",color:"rgba(255,255,255,0.85)"};function R({isOpen:s,onClose:c,code:u,title:g=""}){const{t:x}=l(),m=i(),[b,f]=t.useState(g),[M,R]=t.useState(""),[E]=t.useState("Indicadores"),[I,H]=t.useState("open_source"),[A,B]=t.useState(500),[F,P]=t.useState(""),[O,D]=t.useState(!1),[V,$]=t.useState(null),Z=t.useRef({}),[U,q]=t.useState(null),[J,K]=t.useState(!1),[X,Q]=t.useState(!1),Y=t.useRef(null),ee=t.useCallback(async()=>{var e;if(!u||u.trim().length<10)q(x("publishScript.errors.codeTooShort"));else{Q(!0),q(null);try{const t=a(),i=await fetch(`${t}/scripts/describe`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({code:u})}),r=await i.json();if(!i.ok||!(null==r?void 0:r.success)){const t=w(null==(e=null==r?void 0:r.error)?void 0:e.message,x("publishScript.errors.generateDescriptionFailed"));return q(t),void o.error(t)}R(r.data.description),o.success(x("publishScript.toasts.descriptionGenerated"))}catch(t){const e=w(t instanceof Error?t.message:null,x("publishScript.errors.generateDescriptionError"));q(e),o.error(e)}finally{Q(!1)}}},[u]),te=t.useCallback(async()=>{var e,t;if(b.trim())if(M.trim())if("invite_only"===I&&F.trim().length<20)q(
1x("publishScript.errors.accessInstructionsTooShort"));else{if("paid"===I){if(!A||A<100)return void q(x("publishScript.errors.priceMin"));if(A>5e4)return void q(x("publishScript.errors.priceMax"))}D(!0),q(null);try{let r;if(Y.current){const n=Y.current,a=2e4,s=100,l=performance.now();for(;performance.now()-l<a&&!(null==(e=n.isReady)?void 0:e.call(n));)await new Promise(e=>setTimeout(e,s));null==(t=n.isReady)||t.call(n);try{const e=await n.captureScreenshot();e&&"string"==typeof e&&(r=await d.uploadThumbnail(e))}catch(i){}}const n=await d.create({title:b.trim(),description:M.trim(),code:u,category:E,is_open_source:"open_source"===I,visibility_type:I,..."invite_only"===I&&F.trim()?{access_instructions:F.trim()}:{},..."paid"===I?{price_coins:A}:{},thumbnail:r});o.success(x("publishScript.toasts.published")),ie(),(null==n?void 0:n.id)&&m(`/scripts/${n.id}`)}catch(i){q(w(null==i?void 0:i.message,x("publishScript.errors.publishError")))}finally{D(!1)}}else q(x("publishScript.errors.descriptionRequired"));else q(x("publishScript.errors.titleRequired"))},[b,M,u,E,I,F,A]),ie=()=>{f(g),R(""),H("open_source"),P(""),K(!1),q(null),c()};return s?r.createPortal(e.jsx("div",{style:k,onClick:ie,children:e.jsxs("div",{style:S,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[e.jsxs("div",{style:C,children:[e.jsx("h2",{style:N,children:x("publishScript.title")}),e.jsx("button",{onClick:ie,"aria-label":x("common.close"),style:L,onMouseEnter:e=>{e.currentTarget.style.background="rgba(255,255,255,0.08)",e.currentTarget.style.color="rgba(255,255,255,0.9)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.color="rgba(255,255,255,0.4)"},children:e.jsx(v,{size:16,weight:"bold"})})]}),e.jsx("div",{"aria-hidden":"true",style:{position:"fixed",top:0,left:0,width:800,height:450,opacity:0,pointerEvents:"none",overflow:"hidden",zIndex:-1},children:e.jsx(p,{ref:Y,code:u,useMockFallback:!0})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:z,children:x("createScript.labels.title")}),e.jsx("input",{type:"text",value:b,onChange:e=>f(e.target.value),placeholder:x("publishScript.titlePlaceholder"),style:_,disabled:O})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6,gap:8},children:[e.jsx("label",{style:{...z,marginBottom:0},children:x("createScript.labels.description")}),e.jsx("button",{type:"button",onClick:ee,disabled:O||X||!u||u.trim().length<10,"aria-label":x("publishScript.generateWithAiAria"),style:{display:"inline-flex",alignItems:"center",gap:6,height:24,padding:"0 10px",fontSize:12,fontWeight:500,letterSpacing:.2,color:X?"rgba(255,255,255,0.5)":"rgba(255,255,255,0.85)",background:"rgba(255,255,255,0.04)",border:"none",borderRadius:999,cursor:O||X||!u||u.trim().length<10?"not-allowed":"pointer",opacity:O||!u||u.trim().length<10?.4:1,transition:"background 0.15s ease, color 0.15s ease"},onMouseEnter:e=>{X||O||!u||u.trim().length<10||(e.currentTarget.style.background="rgba(255,255,255,0.08)")},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.04)"},children:X?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"3"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.8s",repeatCount:"indefinite"})})]}),e.jsx("span",{children:x("publishScript.generating")})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 2l1.8 5.4L19 9l-5.2 1.6L12 16l-1.8-5.4L5 9l5.2-1.6L12 2zm7 12l.9 2.7L22 18l-2.1.9L19 22l-.9-2.1L16 18l2.1-.9L19 14zM5 14l.9 2.7L8 18l-2.1.9L5 22l-.9-2.1L2 18l2.1-.9L5 14z"})}),e.jsx("span",{children:x("publishScript.generateWithAi")})]})})]}),e.jsx("textarea",{value:M,onChange:e=>R(e.target.value),placeholder:x("publishScript.descriptionPlaceholder"),style:G,disabled:O||X})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("label",{style:{...z,marginBottom:0},children:x("createScript.steps.visibility")}),e.jsx("div",{style:{display:"flex",gap:"8px"},children:[{value:"open_source",label:x("publishScript.visibility.openSource.label"),desc:x("publishScript.visibility.openSource.desc"),tooltip:x("publishScript.visibility.openSource.tooltip"),locked:!1,isPaid:!1},{value:"invite_only",label:x("publishScript.visibility.inviteOnly.label"),desc:x("publishScript.visibility.inviteOnly.desc"),tooltip:x("publishScript.visibility.inviteOnly.tooltip"),locked:!1,isPaid:!1},{value:"paid",label:x("publishScript.visibility.paid.label"),desc:"Marketplace",tooltip:x("publishScript.visibility.paid.tooltip"),locked:!1,isPaid:!0}].map(t=>e.jsxs(n.Fragment,{children:[e.jsxs("button",{ref:e=>{Z.current[`vis-${t.value}`]=e},onClick:()=>{t.locked||H(t.value)},onMouseEnter:()=>$(`vis-${t.value}`),onMouseLeave:()=>$(null),disabled:O||t.locked,"aria-disabled":t.locked,style:{flex:1,padding:"10px 8px",borderRadius:8,border:"none",background:I===t.value?"rgba(41, 98, 255, 0.18)":"rgba(255,255,255,0.04)",cursor:t.locked?"not-allowed":"pointer",opacity:t.locked?.45:1,display:"flex",flexDirection:"column",alignItems:"center",gap:4,transition:"all 0.15s",position:"relative"},children:[t.isPaid&&e.jsx("span",{style:{position:"absolute",top:-5,right:-5,fontSize:8,fontWeight:700,letterSpacing:.4,padding:"2px 5px",borderRadius:999,background:"rgba(108, 158, 248, 0.85)",color:"#fff",textTransform:"uppercase",lineHeight:1},children:x("publishScript.badgeNew")}),e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:I===t.value?"#6c9ef8":"rgba(255,255,255,0.85)",display:"inline-flex",alignItems:"center",gap:4},children:[t.locked&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M208,80H176V56a48,48,0,0,0-96,0V80H48A16,16,0,0,0,32,96V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V96A16,16,0,0,0,208,80ZM96,56a32,32,0,0,1,64,0V80H96ZM208,208H48V96H208V208Z"})}),t.label]}
1),e.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:t.desc})]}),e.jsx(h,{content:t.tooltip,isOpen:V===`vis-${t.value}`,onClose:()=>$(null),targetRef:{current:Z.current[`vis-${t.value}`]},zIndex:99999,position:"top"})]},t.value))}),"paid"===I&&e.jsxs("div",{style:{marginTop:4,padding:12,borderRadius:8,background:"rgba(41, 98, 255, 0.06)"},children:[e.jsx("label",{style:{fontSize:"12px",color:"rgba(255,255,255,0.7)",display:"block",marginBottom:"6px"},children:x("publishScript.priceLabel")}),e.jsx("p",{style:{fontSize:11,color:"rgba(255,255,255,0.45)",margin:"0 0 8px 0",lineHeight:1.4},children:x("publishScript.priceHint")}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("input",{type:"number",min:100,max:5e4,step:100,value:A,onChange:e=>B(Number(e.target.value)||0),disabled:O,placeholder:"500",style:{flex:1,background:"rgba(0, 0, 0, 0.3)",border:"none",borderRadius:8,padding:"10px 12px",color:"#fff",fontSize:14,outline:"none"}}),e.jsxs("div",{style:{textAlign:"right",flexShrink:0},children:[e.jsx("div",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:x("publishScript.equivalent")}),e.jsxs("div",{style:{fontSize:14,fontWeight:600,color:"#6c9ef8"},children:["R$ ",(.01*A).toFixed(2).replace(".",",")]})]})]}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",marginTop:8},children:[x("publishScript.youReceivePrefix")," ",e.jsxs("span",{style:{color:"#6c9ef8",fontWeight:600},children:[Math.round(.85*A)," ",x("publishScript.futuracoinsUnit")]})," ","(R$ ",(.85*A*.01).toFixed(2).replace(".",","),")"," ",x("publishScript.youReceiveSuffix")]})]}),"invite_only"===I&&e.jsxs("div",{style:{marginTop:4},children:[e.jsx("label",{style:{fontSize:"12px",color:"rgba(255,255,255,0.5)",display:"block",marginBottom:"4px"},children:x("publishScript.accessInstructionsLabel")}),e.jsx("textarea",{value:F,onChange:e=>P(e.target.value),placeholder:x("publishScript.accessInstructionsPlaceholder"),style:{...G,minHeight:60},disabled:O})]})]}),U&&e.jsxs("div",{style:{padding:"12px",backgroundColor:"rgba(255, 68, 68, 0.1)",borderRadius:"8px",display:"flex",alignItems:"start",gap:"8px",color:"#ff4444",fontSize:"13px"},children:[e.jsx(j,{size:16,weight:"fill",style:{flexShrink:0,marginTop:"2px"}}),e.jsx("span",{children:U})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:ie,style:W,disabled:O,children:x("common.cancel")}),e.jsxs("button",{onClick:te,style:T,disabled:O,children:[e.jsx(y,{size:16,weight:"fill"}),x(O?"userProfile.posts.publishing":"aiGenerate.publish")]})]})]})}),document.body):null}function E({text:i}){const{t:n}=l(),[a,s]=t.useState(!1),[o,c]=t.useState({top:0,left:0}),d=t.useRef(null),u="undefined"!=typeof window&&window.matchMedia("(hover: hover)").matches,p=t.useCallback(()=>{const e=d.current;if(!e)return;const t=e.getBoundingClientRect(),i=Math.min(260,.78*window.innerWidth)/2;let r=t.left+t.width/2;r=Math.max(8+i,Math.min(window.innerWidth-8-i,r)),c({top:t.top-8,left:r})},[]);return t.useEffect(()=>{if(a)return p(),document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};function e(e){d.current&&!d.current.contains(e.target)&&s(!1)}},[a,p]),e.jsxs("span",{ref:d,style:{position:"relative",display:"inline-flex",alignItems:"center"},onMouseEnter:u?()=>s(!0):void 0,onMouseLeave:u?()=>s(!1):void 0,children:[e.jsx("button",{type:"button","aria-label":n("aiGenerate.monetizationInfoLabel"),"aria-expanded":a,onClick:()=>s(e=>!e),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:15,height:15,padding:0,border:"none",background:"transparent",color:a?"oklch(85% 0.13 85)":"rgba(255, 255, 255, 0.4)",cursor:"pointer"},children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})}),a&&r.createPortal(e.jsx("span",{role:"tooltip",style:{position:"fixed",top:o.top,left
1:o.left,transform:"translate(-50%, -100%)",width:"min(260px, 78vw)",padding:"8px 11px",background:"oklch(18% 0.012 260 / 0.97)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:8,boxShadow:"0 6px 22px rgba(0, 0, 0, 0.45)",fontSize:11.5,fontWeight:400,lineHeight:1.45,letterSpacing:"normal",textTransform:"none",color:"rgba(255, 255, 255, 0.8)",textAlign:"center",zIndex:2147483647,pointerEvents:"none"},children:i}),document.body)]})}const I=Array.from({length:20},(e,t)=>`aiGenerate.pool${t+1}`);function H(e,t){return[...e].sort(()=>Math.random()-.5).slice(0,t)}const A=({size:t=16})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14M13 6l6 6-6 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),B=({size:t=20})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M6 6l12 12M6 18L18 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),F=({size:t=14})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M3 12a9 9 0 1 0 3.5-7.1M3 4v5h5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),P=({size:t=12})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),O=({size:t=12})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M12 4v12M6 10l6 6 6-6M4 20h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),D=({size:t=14})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M12 7v5l3 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]}),V=({size:t=12})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M4 7h16M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})}),$=({size:t=12})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M12 16V4m0 0l-4 4m4-4l4 4M4 20h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Z=({isOpen:n,onClose:o,onInsertCode:h,previewCandles:v})=>{const{t:y}=l(),{user:j}=c(),w=i(),k=!(1!==(null==j?void 0:j.is_royal)&&!0!==(null==j?void 0:j.is_royal)),[S,C]=t.useState([]);t.useEffect(()=>{if(!n||k)return;let e=!1;return d.list({visibility_type:"paid",sort:"popular",limit:8}).then(t=>{e||C(t.items||[])}).catch(()=>{}),()=>{e=!0}},[n,k]);const[N,L]=t.useState(""),[z,_]=t.useState(""),{generate:G,cancel:M,code:T,isGenerating:W,isReviewing:Z,error:U,reset:q,setCodeManual:J,validationErrors:K,validationWarnings:X,autoFixApplied:Q}=function(){const[e,i]=t.useState(""),[r,n]=t.useState(!1),[l,o]=t.useState(!1),[c,d]=t.useState(null),[u,p]=t.useState([]),[h,g]=t.useState([]),[x,m]=t.useState(!1),b=t.useRef(null),f=t.useRef(!1),v=t.useCallback(()=>{i(""),d(null),n(!1),o(!1),p([]),g([]),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),y=t.useCallback(()=>{b.current&&(b.current.abort(),b.current=null),n(!1),o(!1),f.current||(i(""),p([]),g([]),m(!1))},[]);return{generate:t.useCallback((e,t)=>{b.current&&b.current.abort();const r=new AbortController;b.current=r,i(""),d(null),p([]),g([]),m(!1),o(!1),n(!0),f.current=!1;const l=a(),c={prompt:e};t&&t.trim().length>0&&(c.previousCode=t.trim()),fetch(`${l}/scripts/generate`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(c),signal:r.signal}).then(async e=>{var t;if(!e.ok){try{const i=await e.json(),r=null==(t=null==i?void 0:i.error)?void 0:t.code;"VIP_REQUIRED"===r?d(s("aiGenerate.errVipOnly")):"RATE_LIMIT"===r||429===e.status?d(s("aiGenerate.errRateLimit")):d(s("aiGenerate.errGeneration"))}catch{d(s("aiGenerate.errGeneration"))}return void n(!1)}if(!e.body)return d(s("aiGenerate.errStreaming")),void n(!1);const r=e.body.getReader(),a=new TextDecoder;let l="";try{for(;;){const{done:e,value:t}=await r.read();if(e)break;l+=a.decode(t,{stream:!0});const c=l.split("\n");l=c.pop()||"";let u="";for(const r of c)if(r.startsWith("event:"))u=r.slice(6).trim();else if(r.startsWith("data:")){const e=r.slice(5).trim();if(!e)continue;try{const t=JSON.parse(e);if("text"===u&&t.delta)i(e=>e+t.delta);else if("reviewing"===u)o(!0);else if("fixed_code"===u)"string"==typeof t.code&&(i(t.code),m(!0)),o(!1);else if("validation"===u)Array.isArray(t.errors)&&p(t.errors),Array.isArray(t.warnings)&&g(t.warnings);else{if("error"===u)return t.message,d(s("aiGenerate.errGeneration")),n(!1),void o(!1);if("done"===u)return f.current=!0,n(!1),void o(!1)}}catch{}}}}catch(c){"AbortError"!==(null==c?void 0:c.name)&&d(s("aiGenerate.errConnectionLost"))}n(!1)}).catch(e=>{"AbortError"!==(null==e?void 0:e.name)&&(d(s("aiGenerate.errConnection")),n(!1))})}
1,[]),cancel:y,code:e,isGenerating:r,isReviewing:l,error:c,reset:v,setCodeManual:t.useCallback(e=>{i(e),d(null),n(!1)},[]),validationErrors:u,validationWarnings:h,autoFixApplied:x}}(),{history:Y,addPrompt:ee,removePrompt:te,clearAll:ie}=function(){const[e,i]=t.useState([]);return t.useEffect(()=>{i(function(){if("undefined"==typeof window)return[];try{const e=window.localStorage.getItem(x);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>"string"==typeof(null==e?void 0:e.text)&&e.text.trim().length>0&&"number"==typeof(null==e?void 0:e.timestamp)).slice(0,10):[]}catch{return[]}}())},[]),{history:e,addPrompt:t.useCallback(e=>{const t=e.trim();0!==t.length&&i(e=>{const i=e.filter(e=>e.text!==t),r=[{text:t,timestamp:Date.now()},...i].slice(0,10);return m(r),r})},[]),removePrompt:t.useCallback(e=>{i(t=>{const i=t.filter(t=>t.text!==e);return m(i),i})},[]),clearAll:t.useCallback(()=>{m([]),i([])},[])}}(),{lastGeneration:re,save:ne,clear:ae}=function(){const[e,i]=t.useState(null);return t.useEffect(()=>{i(function(){if("undefined"==typeof window)return null;try{const e=window.localStorage.getItem(b);if(!e)return null;const t=JSON.parse(e);return"string"!=typeof(null==t?void 0:t.prompt)||"string"!=typeof(null==t?void 0:t.code)||"number"!=typeof(null==t?void 0:t.timestamp)||0===t.code.trim().length||Date.now()-t.timestamp>864e5?null:t}catch{return null}}())},[]),{lastGeneration:e,save:t.useCallback((e,t)=>{const r=e.trim(),n=t.trim();if(0===r.length||0===n.length)return;const a={prompt:r,code:n,timestamp:Date.now()};f(a),i(a)},[]),clear:t.useCallback(()=>{f(null),i(null)},[])}}(),se=t.useRef(null),le=t.useRef(null),[oe,ce]=t.useState(!1),[de,ue]=t.useState("code"),[pe,he]=t.useState(!1),[ge,xe]=t.useState(()=>H(I,3).map(e=>y(e)));t.useEffect(()=>{le.current&&W&&(le.current.scrollTop=le.current.scrollHeight)},[T,W]),t.useEffect(()=>{if(n){const e=setTimeout(()=>{var e;return null==(e=se.current)?void 0:e.focus()},120);return()=>clearTimeout(e)}},[n]),t.useEffect(()=>{if(!n)return;let e=!1;return(async()=>{const t=await async function(){var e;try{const t=a(),i=await fetch(`${t}/scripts/aigen/suggestions`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!i.ok)return[];const r=await i.json();return r.success&&(null==(e=r.data)?void 0:e.suggestions)?r.data.suggestions:[]}catch{return[]}}();if(!e)if(t.length>=3)xe(t.slice(0,3));else{const e=H(I.map(e=>y(e)).filter(e=>!t.includes(e)),3-t.length);xe([...t,...e].slice(0,3))}})(),()=>{e=!0}},[n]),t.useEffect(()=>{n||(q(),L(""),_(""),ce(!1),ue("code"),he(!1))},[n,q]),t.useEffect(()=>{W&&ue("code")},[W]),t.useEffect(()=>{T.trim().length>0&&!W&&(ue("preview"),L(""))},[T,W]),t.useEffect(()=>{if(se.current){se.current.style.height="auto";const e=Math.min(se.current.scrollHeight,120);se.current.style.height=`${Math.max(50,e)}px`}},[N]);const me=N.trim().length,be=me>=10&&!W&&k,fe=me>0&&me<10&&!W,ve=K.length>0,ye=t.useMemo(()=>g(T),[T]),je=T.trim().length>0&&!W,we=t.useCallback(()=>{if(!be)return;const e=N.trim(),t=je?ye:void 0;q(),je||(ee(e),_(e)),G(e,t)},[N,be,G,q,ee,je,ye]);t.useEffect(()=>{T.trim().length>0&&!W&&z&&ne(z,ye)},[T,ye,W,z,ne]);const ke=t.useCallback(()=>{re&&(_(re.prompt),J(re.code),ue("preview"))},[re,J]),Se=t.useCallback(()=>{ae()},[ae]),Ce=t.useCallback(()=>{W?M():we()},[W,M,we]),Ne=t.useCallback(()=>{if(!N.trim())return;const e=je?ye:void 0;q(),G(N.trim(),e)},[N,G,q,je,ye]),Le=t.useCallback(e=>{var t;L(e),null==(t=se.current)||t.focus()},[]),ze=t.useCallback((e,t)=>{e.stopPropagation(),te(t)},[te]),_e=t.useCallback(()=>{ye.trim()&&(h(ye),o())},[ye,h,o]),Ge=t.useCallback(async()=>{if(T.trim())try{await navigator.clipboard.writeText(T.trim()),ce(!0),setTimeout(()=>ce(!1),1500)}catch{}},[T]),Me=t.useCallback(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),we()),"Escape"===e.key&&e.stopPropagation()},[we]),Te=t.useCallback(e=>{var t;L(e),null==(t=se.current)||t.focus()},[]);if(t.useEffect(()=>{if(!n)return;const e=e=>{"Escape"!==e.key||e.defaultPrevented||(W?M():o())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,W,M,o]),!n)return null;const We=T.trim().length>0,Re=We&&!W,Ee=!We&&!W&&!U;return e.jsxs(e.Fragment,{children:[r.createPortal(e.jsx("div",{className:"aig-modal-overlay",onClick:e=>{e.target!==e.currentTarget||W||o()},children:e.jsx("div",{className:"aig-dialog dark animation",role:"dialog","aria-modal":"true","aria-label":"FUTURA AI",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:e.jsxs("div",{className:"aig-panel "+(Ee?"no-chat":""),children:[e.jsxs("div",{className:"aig-header",children:[e.jsx("div",{className:"aig-header-spacer","aria-hidden":"true"}),e.jsx("div",{className:"aig-header-slogan",children:e.jsxs("div",{"aria-label":"FUTURA AI",style:{display:"inline-flex",alignItems:"center",gap:6,lineHeight:1},children:[e.jsx("span",{style:{fontFamily:"'FuturaSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:20,fontWeight:500,letterSpacing:"0.2em",color:"#fff",lineHeight:1,display:"inline-flex",alignItems:"center",height:24,textRendering:"optimizeLegibility"},children:"FUTURA"}),e.jsxs("svg",{width:"36",height:"24",viewBox:"108 0 38 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("path",{d:"M124.249 1.47949C124.456 1.47949 124.646 1.59348 124.744 1.77606L135.39 21.695C135.59 22.0687 135.319 22.5206 134.895 22.5206H131.794C131.587 22.5206 131.396 22.4065 131.299 22.2239L122.698 6.1323L118.737 13.543H123.064C123.27 13.543 123.46 13.6567 123.558 13.8389L125.025 16.5743C125.226 16.9481 124.955 17.4006 124.531 17.4006H116.675L114.097 22.2239C114 22.4065 113.81 22.5206 113.603 22.5206H110.501C110.077 22.5206 109.806 22.0687 110.006 21.695L120.653 1.77606C120.75 1.59348 120.94 1.47949 121.147 1.47949H124.249Z",fill:"#F2F4F6"}),e.jsx("path",{d:"M139.575 12.7014C139.782 12.7014 139.972 12.8154 140.07 12.998L144.718 21.695C144.918 22.0687 144.647 22.5206 144.223 22.5206H141.122C140.915 22.5206 140.725 22.4065 140.627 22.2239L135.979 13.527C135.779 13.1532 136.05 12.7014 136.473 12.7014H139.575Z",fill:"#F2F4F6"}),e.jsx("path",{d:"M134.356 0.701544C134.562 0.336012 135.088 0.336022 135.294 0.701544L136.622 3.05504C136.67 3.14062 136.741 3.21135 136.826 3.25963L139.18 4.58702C139.545 4.7932 139.545 5.31968 139.18 5.52586L136.826 6.85326C136.741 6.90154 136.67 6.97231 136.622 7.05791L135.294 9.41134C135.088 9.77688 134.562 9.77689 134.356 9.41134L133.028 7.05791C132.98 6.97232
1132.909 6.90154 132.824 6.85326L130.47 5.52586C130.105 5.31968 130.105 4.7932 130.47 4.58702L132.824 3.25963C132.909 3.21135 132.98 3.14061 133.028 3.05504L134.356 0.701544Z",fill:"#F2F4F6"})]})]})}),e.jsx("div",{className:"aig-operates",children:e.jsx("button",{type:"button",className:"aig-operate","aria-label":y("common.close"),onClick:o,disabled:W,children:e.jsx("span",{className:"fs0",children:e.jsx(B,{size:20})})})})]}),Ee&&!k&&e.jsxs("div",{className:"aig-content",children:[e.jsxs("div",{className:"aig-slogan",children:[e.jsx("div",{className:"aig-logo",children:e.jsx("div",{className:"aibot-sprite-hero","aria-hidden":"true"})}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 9px",background:"oklch(82% 0.15 80 / 0.14)",borderRadius:999,fontSize:10,fontWeight:700,color:"oklch(85% 0.13 85)",letterSpacing:"0.08em",textTransform:"uppercase",marginBottom:10},children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),y("aiGenerate.exclusiveBadge")]}),e.jsx("h2",{className:"aig-title",children:y("aiGenerate.upsellTitle")}),e.jsx("p",{style:{fontSize:12.5,color:"rgba(255, 255, 255, 0.5)",margin:"6px 0 0",lineHeight:1.5,maxWidth:420},children:y("aiGenerate.upsellDescription")})]}),e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",flexWrap:"wrap",justifyContent:"center",gap:"6px 10px",marginTop:16,fontSize:11,color:"rgba(255, 255, 255, 0.55)"},children:[e.jsx("span",{children:y("aiGenerate.flowCreate")}),e.jsx("span",{"aria-hidden":"true",style:{opacity:.35},children:"â"}),e.jsx("span",{children:y("aiGenerate.flowPublish")}),e.jsx("span",{"aria-hidden":"true",style:{opacity:.35},children:"â"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,whiteSpace:"nowrap"},children:[e.jsx("span",{style:{color:"oklch(85% 0.13 85)",fontWeight:600},children:y("aiGenerate.flowProfit")}),e.jsx(E,{text:y("aiGenerate.monetizationHint")})]})]}),e.jsx("button",{type:"button",onClick:()=>{o(),w("/royal")},style:{marginTop:16,padding:"8px 18px",background:"transparent",border:"1px solid rgba(255, 255, 255, 0.16)",borderRadius:6,color:"rgba(255, 255, 255, 0.85)",fontSize:12,fontWeight:500,cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.borderColor="rgba(255, 255, 255, 0.3)",e.currentTarget.style.background="rgba(255, 255, 255, 0.04)",e.currentTarget.style.color="rgba(255, 255, 255, 1)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="rgba(255, 255, 255, 0.16)",e.currentTarget.style.background="transparent",e.currentTarget.style.color="rgba(255, 255, 255, 0.85)"},children:y("aiGenerate.upsellCta")}),S.length>0&&e.jsxs("div",{style:{marginTop:32,width:"100%"},children:[e.jsxs("div",{style:{marginBottom:16,padding:"0 4px"},children:[e.jsx("h3",{style:{fontSize:15,fontWeight:600,color:"rgba(255, 255, 255, 0.92)",margin:0,lineHeight:1.3},children:y("aiGenerate.marketplaceHeading")}),e.jsx("p",{style:{fontSize:12,color:"rgba(255, 255, 255, 0.5)",margin:"4px 0 0",lineHeight:1.4},children:y("aiGenerate.marketplaceSubtitle")})]}),e.jsx("div",{style:{display:"flex",gap:12,padding:"0 4px 4px",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch"},className:"aig-marketplace-slider",children:S.map(t=>{var i,r,n,a;const s=Number(t.total_sales||0);return e.jsxs("button",{type:"button",onClick:()=>{o(),w(u(Number(t.id),t.title))},style:{display:"flex",flexDirection:"column",background:"rgba(255, 255, 255, 0.03)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:10,padding:0,cursor:"pointer",overflow:"hidden",textAlign:"left",width:180,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.borderColor="rgba(255, 255, 255, 0.16)",e.currentTarget.style.background="rgba(255, 255, 255, 0.05)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)",e.currentTarget.style.background="rgba(255, 255, 255, 0.03)"},children:[e.jsxs("div",{style:{width:"100%",aspectRatio:"16 / 9",background:"rgba(0, 0, 0, 0.3)",position:"relative",overflow:"hidden"},children:[t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.title,loading:"lazy",decoding:"async",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):null,e.jsxs("span",{style:{position:"absolute",top:8,right:8,display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",background:"rgba(0, 0, 0, 0.75)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",borderRadius:6,fontSize:11,fontWeight:700,color:"#fff",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em"}
1,children:[(l=Number(t.price_coins||0),l.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})),e.jsx("span",{style:{fontSize:"0.85em",fontWeight:700,color:"oklch(92% 0.01 260)",letterSpacing:"0.04em"},children:"FTC"}),e.jsx("span",{"aria-hidden":"true",style:{display:"block",width:14,height:14,backgroundImage:"url(/images/market/sequence.webp)",backgroundSize:"auto 100%",backgroundRepeat:"no-repeat",backgroundPositionX:0}})]})]}),e.jsxs("div",{style:{padding:"10px 12px 12px",display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsx("h4",{style:{fontSize:13,fontWeight:600,color:"rgba(255, 255, 255, 0.95)",margin:0,lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",minHeight:34},children:t.title}),((null==(i=t.author)?void 0:i.nickname)||(null==(r=t.author)?void 0:r.name))&&e.jsx("span",{style:{fontSize:11,color:"rgba(255, 255, 255, 0.5)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y("aiGenerate.scriptAuthor",{author:(null==(n=t.author)?void 0:n.nickname)||(null==(a=t.author)?void 0:a.name)||""})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:"auto",paddingTop:8,borderTop:"1px solid rgba(255, 255, 255, 0.05)",fontSize:11,color:"rgba(255, 255, 255, 0.62)",fontVariantNumeric:"tabular-nums",flexWrap:"wrap"},children:[e.jsx("span",{children:y(1===s?"aiGenerate.salesCount.one":"aiGenerate.salesCount.other",{count:s.toLocaleString("pt-BR")})}),"number"==typeof t.views&&t.views>0&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),t.views.toLocaleString("pt-BR")]})]})]})]},t.id);var l})})]})]}),Ee&&k&&e.jsxs("div",{className:"aig-content",children:[e.jsxs("div",{className:"aig-slogan",children:[e.jsx("div",{className:"aig-logo",children:e.jsx("div",{className:"aibot-sprite-hero","aria-hidden":"true"})}),e.jsx("h2",{className:"aig-title",children:y("aiGenerate.premiumTitle")}),e.jsx("p",{className:"aig-desc",children:y("aiGenerate.premiumDescription")})]}),re&&e.jsxs("div",{className:"aig-resume",children:[e.jsx("div",{className:"aig-resume__icon","aria-hidden":"true",children:e.jsx(D,{size:14})}),e.jsxs("div",{className:"aig-resume__content",children:[e.jsx("span",{className:"aig-resume__label",children:y("aiGenerate.resumeLabel")}),e.jsx("span",{className:"aig-resume__prompt",children:re.prompt})]}),e.jsx("button",{type:"button",className:"aig-resume__action",onClick:ke,children:y("aiGenerate.resumeAction")}),e.jsx("button",{type:"button",className:"aig-resume__dismiss","aria-label":y("aiGenerate.dismiss"),onClick:Se,children:e.jsx(B,{size:14})})]}),e.jsx("div",{className:"aig-recommended-list-container",children:e.jsx("div",{className:"aig-recommended-list aig-recommended-list--large",children:ge.map(t=>e.jsx("div",{className:"aig-question-item-container",children:e.jsxs("button",{type:"button",className:"aig-question-item",onClick:()=>Te(t),children:[e.jsx("span",{className:"aig-question-item__text",children:t}),e.jsx("span",{className:"aig-question-item__arrow",children:e.jsx(A,{size:16})})]})},t))})}),Y.length>0&&e.jsxs("div",{className:"aig-history",children:[e.jsxs("div",{className:"aig-history-header",children:[e.jsxs("span",{className:"aig-history-label",children:[e.jsx(D,{size:12}),y("aiGenerate.recent")]}),e.jsx("button",{type:"button",className:"aig-history-clear",onClick:ie,children:y("aiGenerate.clear")})]}),e.jsx("ul",{className:"aig-history-list",children:Y.map(t=>e.jsxs("li",{className:"aig-history-item",children:[e.jsx("button",{type:"button",className:"aig-history-pick",onClick:()=>Le(t.text),title:t.text,children:e.jsx("span",{className:"aig-history-text",children:t.text})}),e.jsx("button",{type:"button",className:"aig-history-remove","aria-label":y("aiGenerate.removeFromHistory"),onClick:e=>ze(e,t.text),children:e.jsx(V,{size:12})})]},t.timestamp))})]})]}),W&&!Z&&e.jsxs("div",{className:"aig-generating-status",children:[e.jsx("span",{className:"aig-spinner"}),y("aiGenerate.generatingStatus")]}),Z&&e.jsxs("div",{className:"aig-generating-status",children:[e.jsx("span",{className:"aig-spinner"}),y("aiGenerate.reviewingStatus")]}),Q&&!W&&!Z&&e.jsxs("div",{className:"aig-autofix-badge",children:[e.jsx("span",{className:"aig-autofix-badge__dot"}),y("aiGenerate.autoFixed")]}),!W&&!Z&&(K.length>0||X.length>0)&&e.jsxs("div",{className:"aig-validation",children:[K.length>0&&e.jsxs("div",{className:"aig-validation__group aig-validation__group--error",children:[e.jsx("strong",{children:K.length>1?y("aiGenerate.errorsDetected.other",{count:K.length}):y("aiGenerate.errorsDetected.one",{count:K.length})}),e.jsxs("ul",{children:[K.slice(0,3).map(t=>e.jsxs("li",{children:[t.line?`L${t.line}: `:"",t.message,t.suggestion&&e.jsxs("span",{className:"aig-validation__hint",children:[" â ",t.suggestion]})]},`err-${t.line??0}-${t.message}`)),K.length>3&&e.jsx("li",{className:"aig-validation__more",children:y("aiGenerate.moreErrors",{count:K.length-3})})]})]}),X.length>0&&e.jsxs("div",{className:"aig-validation__group aig-validation__group--warn",children:[e.jsx("strong",{children:X.length>1?y("aiGenerate.warningsCount.other",{count:X.length}
1):y("aiGenerate.warningsCount.one",{count:X.length})}),e.jsx("ul",{children:X.slice(0,2).map(t=>e.jsxs("li",{children:[t.line?`L${t.line}: `:"",t.message]},`warn-${t.line??0}-${t.message}`))})]})]}),U&&!W&&e.jsxs("div",{className:"aig-error",children:[e.jsx("span",{className:"aig-error-text",children:U}),e.jsxs("button",{type:"button",className:"aig-error-retry",onClick:Ne,children:[e.jsx(F,{size:12}),y("aiGenerate.retry")]})]}),(We||W)&&e.jsxs("div",{className:"aig-code-area",children:[e.jsxs("div",{className:"aig-code-header",children:[e.jsxs("div",{className:"aig-output-tabs",children:[e.jsx("button",{type:"button",className:"aig-output-tab "+("preview"===de?"active":""),onClick:()=>ue("preview"),disabled:!Re,title:Re?"":y("aiGenerate.waitGeneration"),children:y("aiGenerate.tabPreview")}),e.jsx("button",{type:"button",className:"aig-output-tab "+("code"===de?"active":""),onClick:()=>ue("code"),children:y("aiGenerate.tabCode")})]}),e.jsxs("div",{className:"aig-code-header-actions",children:[e.jsxs("button",{type:"button",className:"aig-code-action-btn",onClick:Ge,disabled:!We||W,children:[e.jsx(P,{size:12}),y(oe?"aiGenerate.copied":"aiGenerate.copy")]}),Re&&e.jsxs("button",{type:"button",className:"aig-code-action-btn",onClick:()=>he(!0),disabled:ve,title:ve?y("aiGenerate.fixBeforePublish"):void 0,children:[e.jsx($,{size:12}),y("aiGenerate.publish")]}),Re&&e.jsxs("button",{type:"button",className:"aig-code-action-btn "+(ve?"":"primary"),onClick:_e,title:ve?y("aiGenerate.insertWithErrors"):void 0,children:[e.jsx(O,{size:12}),y("aiGenerate.insertIntoEditor")]})]})]}),Re&&e.jsx("div",{className:"aig-preview-wrapper",style:{display:"preview"===de?"block":"none"},children:e.jsx(p,{code:ye,candles:v})}),("code"===de||W||!Re)&&e.jsxs("pre",{className:"aig-code-pre",ref:le,children:[(W?T:ye)||"",W&&e.jsx("span",{className:"aig-cursor-blink",children:"|"})]})]}),k&&e.jsxs("div",{className:"aig-input-container",children:[je&&e.jsxs("div",{className:"aig-refine-hint",children:[e.jsx("span",{className:"aig-refine-hint__dot","aria-hidden":"true"}),y("aiGenerate.refineHint")]}),e.jsxs("div",{className:"aig-input__mini "+(je?"refine":""),children:[e.jsx("textarea",{ref:se,className:"aig-input__input dark",value:N,onChange:e=>L(e.target.value),onKeyDown:Me,placeholder:y(je?"aiGenerate.refinePlaceholder":"aiGenerate.promptPlaceholder"),disabled:W,maxLength:2e3,rows:1}),e.jsx("button",{type:"button",className:`aig-input__send dark ${W?"sending":""} ${be?"active":""}`,onClick:Ce,"aria-label":y(W?"aiGenerate.stopGeneration":"aiGenerate.send"),title:!W&&fe?y("aiGenerate.minCharsHint",{min:10}):void 0,disabled:!be&&!W,children:e.jsx("span",{className:"aig-input__send-icon"})})]}),fe&&e.jsx("div",{className:"aig-input__hint",children:y("aiGenerate.minCharsHint",{min:10})})]})]})})}),document.body),e.jsx(R,{isOpen:pe,onClose:()=>he(!1),code:ye})]})},U=Object.freeze(Object.defineProperty({__proto__:null,AIGenerateModal:Z},Symbol.toStringTag,{value:"Module"}));export{Z as A,R as P,U as a};
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.