1import{b as Q,bH as fe,r as a,j as e,am as ce,L as de,S as k,U as ue,B as W,P as H,an as be,z as D,bK as ye,i as ve,g as le,W as L,V as pe,d as xe,u as je,H as J,bw as Ce,av as _e,bz as Pe}from"./index-DN4Mwqf7.js";import{S as Ge}from"./SiteConfigurationPane-Bx7Ab4y4.js";import{y as Te,L as A,aV as we,C as Ie}from"./Parameter-DD2b9kxf.js";import{D as Se}from"./SelectOptions-CX_-i7or.js";import{C as u}from"./Card-cLjeqwtT.js";import{F as se,C as Me,a as ne,M as he}from"./index-CeTPcGzX.js";import{P as Ee,a as Ae}from"./ParameterBuilder-D6MDV4qs.js";import{P as Le}from"./PlusScriptView-CbHSws3c.js";import"./index-Bq1GzDBn.js";import"./ace-Dlf-vt7D.js";import"./types-0x_1vaZr.js";import"./Popup-CI8dlaUY.js";import"./Support-BHZo4W1C.js";import"./usePrompt-B0EunRfp.js";import"./SpreadsheetViewer-0aBpyk4X.js";import"./ValidationsEditor-9eUU24Dk.js";import"./types-C-48g5o1.js";import"./toConsumableArray-u9GFSwrg.js";import"./MailingList-DYDdBp4u.js";import"./AppWebsiteV2-ClyCSvQD.js";import"./useAudioPosition-CPloxytS.js";import"./sanitizeCss-DDeV3a_4.js";import"./ThemeEditor-WHlrAEfK.js";import"./outputActions-FyfPcXwd.js";import"./Tab-UZsBiH8e.js";import"./style-BRPsycUQ.js";import"./OptimizerPane-CgzJuXhG.js";import"./AppMenu-BKz22tte.js";import"./Placeholder-BfICVJLU.js";import"./SplitPaneLayout-CYe7S9cP.js";import"./useMobile-D8fDk965.js";import"./index-Cu4DO8L0.js";import"./motion-j9FxiGRE.js";import"./AdminEditActionModal-DqdnxGQG.js";import"./StreamViewer-DTrl6OAL.js";import"./StreamEChart-xITwTqqn.js";import"./ReactECharts-BtHj0bXP.js";import"./FileViewer-vY3FOqMN.js";import"./JSONViewer-Bu0_hIJH.js";import"./papaparse.min-D6Gm67i-.js";import"./StreamTriggerDataHandler-Cs0IsTmf.js";import"./CustomTemplateModal-Ds-_T8OI.js";import"./mode-css-ZyOVlraq.js";import"./mode-text-owca_3Io.js";import"./StripeDataHandler-7dQUdFN5.js";import"./CssAiChat-BvsiERFR.js";/* empty css */import"./StreamSelectorV2-CMYzFjhf.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./applications-4-Xsf5u6.js";var me;const De=be("useandom26T198340PX75pxJACKVERYMINDBUSHWOLFGQZbfghjklqvwyzrict",5);(me=void 0)==null||me.toLowerCase();function ke({groupIds:v=[],onUpdate:b=async()=>{},refreshApps:S}){const{hostname:g,support_email:X}=Q(),{getMenuGroups:N,saveMenuGroups:F,saveMenuMapping:x}=fe(),{loading:h,applications:c}=Te(),[w,P]=a.useState(!1),[G,j]=a.useState(!1),[f,I]=a.useState(""),[l,y]=a.useState([]),[R,B]=a.useState(void 0),[Y,O]=a.useState(void 0),[K,M]=a.useState(""),[V,U]=a.useState(l.map(t=>t.id)),[C,E]=a.useState({}),[s,n]=a.useState(!1);console.log({applications:c}),a.useEffect(()=>{U(l.map(t=>t.id))},[l]);const o=t=>{t&&(P(!0),N(t).then(({menu_groups:p,mapping:i})=>{console.log({menuGroups:l,mapping:i}),y(p),E(i)}).catch(()=>{console.error("Unable to fetch Menu Groups"),y([]),E({})}).finally(()=>P(!1)))};a.useEffect(()=>{o(g)},[g]);const d=async(t,p)=>{if(t)return j(!0),F(g,t,p).then(({menu_groups:i,mapping:m})=>{y(i),E(m),S&&S()}).catch(()=>D.error("Failed to update Menu Groups")).finally(()=>j(!1))},T=()=>{if(f&&f.length>0){const t=[...l,{id:De(3),icon:"circle",label:f}];d(t,C).then(()=>I(""))}},q=t=>{B(t.id),M(t.label)},Z=t=>{const p=l.map(i=>i.id===R?{...i,label:K}:i);d(p,C),B(void 0)},$=t=>{if(t){const p=l.filter(m=>m.id!==t.id),i=Object.fromEntries(Object.entries(C).filter(([m,z])=>z!==t.id));d(p,i)}},ee=(t,p)=>{const i={...C};p==="uncategorized"?delete i[t]:i[t]=p,n(!0),x(g,i).then(m=>{E(m),S&&S()}).catch(()=>D.error("Failed to update Menu Groups")).finally(()=>n(!1))},te=t=>{U(t);const p=t.reduce((i,m)=>{const z=l.find(r=>r.id===m);return z?[...i,z]:i},[]);d(p,C)},ae=[{id:"uncategorized",label:"Uncategorized"},...l];return e.jsxs(u.Group,{doubling:!0,itemsPerRow:2,children:[e.jsxs(u,{className:"site-config-groups",children:[e.jsx(ce,{active:w,inverted:!0,children:e.jsx(de,{})}),e.jsx(u.Content,{style:{flexGrow:1},children:e.jsxs(u.Description,{children:[e.jsx(k,{inverted:!0,style:{background:"#333435"},children:e.jsx(se,{inverted:!0,children:e.jsxs(se.Field,{style:{flexGrow:1},children:[e.jsx("label",{children:"Group Label"}),e.jsx(ue,{fluid:!0,placeholder:"Enter a Menu Group Label",action:{color:"teal",icon:"plus",loading:G,onClick:T},value:f,onChange:(t,{value:p})=>I(p),style:{flexGrow:1}})]})})}),l.length>0?e.jsx(A,{divided:!0,verticalAlign:"middle",className:"draggable-group",children:e.jsx(Se,{order:V,onChangeOrder:te,children:l.map(t=>e.jsxs(A.Item,{className:"draggable-menu-group",children:[e.jsxs(A.Content,{floated:"right",style:{userSelect:"none"},children:[t.id!==R?e.jsx(W,{icon:!0,size:"tiny",onClick:()=>q(t),children:e.jsx(H,{name:"edit"})}):e.jsx(W,{icon:!0,size:"tiny",color:"teal",onClick:()=>Z(),children:e.jsx(H,{name:"save"})}),e.jsx(W,{icon:!0,size:"tiny",color:"google plus",onClick:()=>$(t),style:{margin:0},children:e.jsx(H,{name:"delete"})})]}),e.jsx(A.Content,{style:{lineHeight:"2.25rem"},children:t.id!==R?e.jsx("span",{children:t.label}):e.jsx(ue,{transparent:!0,value:K,onChange:(p,{value:i})=>M(i)})})]},t.id))})}):e.jsx(k,{basic:!0,style:{padding:0,lineHeight:"2.25rem"},children:"No Menu Groups defined"})]})})]}),e.jsxs(u,{className:"site-config-groups",children:[e.jsx(ce,{active:h,inverted:!0,children:e.jsx(de,{})}),e.jsx(u.Content,{style:{flexGrow:1},children:e.jsx(u.Description,{children:c.length>0?e.jsx(A,{divided:!0,children:c.map(({object_id:t,icon:p,label:i})=>e.jsxs(A.Item,{children:[e.jsx(A.Content,{floated:"right",children:e.jsx(se.Select,{compact:!0,options:ae.map(m=>({key:m.id,value:m.id,text:m.label})),value:C[t]||"uncategorized",onChange:(m,{value:z})=>ee(t,z),loading:s})}),e.jsx(A.Icon,{name:p||"box"}),e.jsx(A.Content,{children:i||t})]},t))}):e.jsx(k,{basic:!0,style:{padding:0,lineHeight:"2.25rem"},children:"No Applications loaded"})})})]})]})}var ge;const re=be("useandom26T198340PX75pxJACKVERYMINDBUSHWOLFGQZbfghjklqvwyzrict",5);(ge=void 0)==null||ge.toLowerCase();function Ne({onUpdate:v=async()=>{}}){const{hostname:b,support_email:S}
1=Q(),{getToolbarParams:g,saveToolbarParams:X}=fe(),{refreshToolbar:N}=ye(),[F,x]=a.useState(!1),[h,c]=a.useState([]),[w,P]=a.useState([]),[G,j]=a.useState(!1),[f,I]=a.useState(new Map),[l,y]=a.useState(!1);a.useEffect(()=>{I(s=>{const n=new Map(s);for(const o of h)n.has(o.var_name)||n.set(o.var_name,re(5));return n})},[h]),a.useEffect(()=>{const s=h.reduce((n,o)=>{const d=f.get(o.var_name);return d?[...n,d]:n},[]);P(s)},[f]);const R=s=>{P(s);const n=s.reduce((o,d)=>{const T=h.find(q=>f.get(q.var_name)===d);return o=T?[...o,T]:o,o},[]);c(n),y(!0)},B=s=>{s&&(j(!0),g(s).then(n=>{c(n)}).catch(()=>{console.error("Unable to fetch Toolbar Parameters"),c([])}).finally(()=>j(!1)))};a.useEffect(()=>{B(b)},[b]);const Y=async s=>{if(s)return x(!0),X(b,s).then(n=>{D.success("Toolbar Parameters have been updated"),c(n),y(!1),N(),v&&v(n)}).catch(()=>D.error("Failed to update Toolbar Parameters")).finally(()=>x(!1))},O=function(s=L.STRING){const n=pe.fromObject({ptype:s,var_name:"@param_".concat(re(5))});c(o=>[...o,n]),y(!0)},K=function(s,n){I(o=>{const d=new Map(o),T=d.get(h[n].var_name);return d.set(s.var_name,T||re(5)),d}),c(o=>{const d=o.map(T=>pe.fromObject(T.toObject()));return d[n]=s,d}),y(!0)},M=function(s){I(n=>{const o=new Map(n);return o.has(s.var_name)&&o.delete(s.var_name),o}),c(n=>n.filter(d=>d.var_name!==s.var_name)),y(!0)},V=s=>{const{label:n}=s;return!(!n||n.length===0||n.startsWith(" "))},U=a.useMemo(()=>{for(const s of h)if(!V(s))return!1;return!0},[h]),C=()=>{Y(h)},E=h&&h.length>0;return e.jsxs(k,{loading:G,children:[e.jsx("div",{style:{marginBottom:"1rem"},children:e.jsx(ve,{color:"orange",size:"small",children:"Beta testing"})}),E?e.jsx("div",{className:"draggable-group",children:e.jsx(Se,{order:w,onChangeOrder:R,children:h.map((s,n)=>e.jsxs("div",{className:"parameter-wrapper draggable",children:[e.jsx(Ee,{parameter:s,onUpdateParameter:o=>K(o,n),onDeleteParameter:M}),!V(s)&&e.jsx("div",{style:{color:"red",marginBottom:"10px"},children:"Please enter input value. It shouldn't be empty or start with space"})]},f.get(s.var_name)))})}):e.jsx(le,{info:!0,style:{textAlign:"left",padding:"0.75rem 1rem"},children:e.jsx("p",{children:"For a simplified user experience, leave this area blank. Should you have a need for a global configuration (e.g. Region), a dynamic Toolbar can service your needs."})}),e.jsx(Ae,{defaultPType:L.STRING,showSave:!0,disableSave:!l,disabled:!U,onClickAddParameter:O,onClickSave:C})]})}const oe=(v="Global Chatbot Script")=>{const b="static_dialog_type";return _e.fromObject({version:"1.0.0",icon:"comments",label:v,short_desc:"Global Chatbot PlusScript",inputs:[{var_name:"message",label:"Message",ptype:L.STRING,optional:!1},{var_name:"upload",label:"Upload",ptype:L.KEY,optional:!0}],outputs:[{var_name:"reply",label:"Reply",ptype:L.STRING,optional:!1},{var_name:"file",label:"File",ptype:L.KEY,optional:!0},{var_name:"dialog_type",label:"Dialog Type",ptype:L.FIXED_LIST_SINGLE_SELECT,data_sources:[{label:"Standard",value:"Standard"},{label:"Error",value:"Error"}],sdefault:"Standard",optional:!1}],nodes:[{ntype:Pe.STATIC,unique_id:b,label:"Dialog Type",value:{ptype:L.FIXED_LIST_SINGLE_SELECT,sval:"Standard"},layout:{x:500,y:150},outputs:[{var_name:"dialog_type",label:"Dialog Type",ptype:L.FIXED_LIST_SINGLE_SELECT,data_sources:[{label:"Standard",value:"Standard"},{label:"Error",value:"Error"}],sdefault:"Standard"}]}],links:[{source:b,sourceHandle:"dialog_type",target:"mainOutput",targetHandle:"dialog_type"}]})};function Fe({refreshApps:v}){const b=xe(),{hostname:S}=Q(),{username:g}=je(),[X,N]=a.useState(!0),[F,x]=a.useState(!1),[h,c]=a.useState(!1),[w,P]=a.useState(!1),[G,j]=a.useState("comments"),[f,I]=a.useState("#2185d0"),[l,y]=a.useState(void 0),[R,B]=a.useState({}),[Y,O]=a.useState(oe("Global Chatbot")),[K,M]=a.useState(!1),[V,U]=a.useState(!1),[C,E]=a.useState(!1),[s,n]=a.useState(!1),[o,d]=a.useState(!1);a.useEffect(()=>{T()},[S]),a.useEffect(()=>{l&&g&&q()},[l,g]);const T=async()=>{try{N(!0);const r=await b.getSiteConfiguration(S);B(r),P(r.global_chatbot_enabled||!1),j(r.global_chatbot_icon||"comments"),I(r.global_chatbot_color||"#2185d0"),y(r.global_chatbot_plusscript_id||void 0)}catch(r){console.error("Failed to load chatbot configuration:",r),D.error("Failed to load chatbot configuration")}finally{N(!1)}},q=async()=>
1{if(!(!l||!g))try{E(!0);const r=l.split(".").pop()||"",_=await b.loadPlusScriptActionById(g,r);if(_)O(_),d(!1);else{const ie=oe("Global Chatbot");ie.object_id=l,O(ie)}}catch(r){console.error("Failed to load PlusScript:",r)}finally{E(!1)}},Z=async()=>{try{x(!0);const r={...R,global_chatbot_enabled:w,global_chatbot_icon:G,global_chatbot_color:f,global_chatbot_plusscript_id:l};await b.saveSiteConfiguration(S,r),B(r),c(!1),D.success("Chatbot configuration saved"),window.dispatchEvent(new CustomEvent("globalChatbotConfigChanged")),v&&v()}catch(r){console.error("Failed to save chatbot configuration:",r),D.error("Failed to save chatbot configuration")}finally{x(!1)}},$=r=>{P(r),c(!0)},ee=r=>{j(r),c(!0)},te=r=>{I(r),c(!0)},ae=()=>{!Y.object_id&&!l&&O(oe("Global Chatbot")),M(!0)},t=()=>{o?U(!0):M(!1)},p=()=>{U(!1),M(!1)},i=()=>{U(!1)},m=async r=>{try{if(n(!0),!g||!r)throw new Error("Unable to save PlusScript");(!r.label||r.label==="")&&(r.label="Global Chatbot");const _=await b.savePlusScript(g,"global-chatbot",r);O(_),_.object_id&&_.object_id!==l&&(y(_.object_id),c(!0)),d(!1),D.success("PlusScript saved")}catch(_){D.error(_.message||"Unable to save PlusScript")}finally{n(!1)}},z=async()=>{o&&await m(Y),M(!1)};return e.jsx("section",{className:"global-chatbot-pane",style:{overflow:"auto",height:"100%"},children:e.jsxs(k,{basic:!0,loading:X,children:[e.jsx(J,{as:"h3",children:e.jsxs(J.Content,{children:["Global Chatbot",e.jsx(J.Subheader,{children:"Configure a chatbot that appears on all pages of your site"})]})}),e.jsxs(u.Group,{doubling:!0,itemsPerRow:2,children:[e.jsx(u,{children:e.jsxs(u.Content,{children:[e.jsx(u.Header,{as:"h4",textAlign:"left",children:"Enable Chatbot"}),e.jsxs(u.Description,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"1rem 0"},children:[e.jsx("span",{children:w?"Chatbot is visible on all pages":"Chatbot is hidden"}),e.jsx(Me,{toggle:!0,checked:w,onChange:(r,{checked:_})=>$(!!_)})]}),e.jsx("p",{style:{color:"#666",fontSize:"0.9em"},children:"When enabled, a chatbot avatar will appear in the lower right corner of every page. Users can click it to open the chat interface."})]})]})}),e.jsx(u,{children:e.jsxs(u.Content,{children:[e.jsx(u.Header,{as:"h4",textAlign:"left",children:"Avatar Appearance"}),e.jsx(u.Description,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",padding:"1rem 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[e.jsx("label",{style:{minWidth:"60px"},children:"Icon:"}),e.jsx(we,{value:G,onSelect:ee,btnContent:e.jsxs(e.Fragment,{children:[e.jsx(H,{name:G})," Change Icon"]})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[e.jsx("label",{style:{minWidth:"60px"},children:"Color:"}),e.jsx("input",{type:"color",value:f,onChange:r=>te(r.target.value),style:{width:"3rem",height:"2rem",border:"1px solid #ccc",borderRadius:"4px",cursor:"pointer"}}),e.jsx("span",{style:{color:"#666"},children:f})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",marginTop:"0.5rem"},children:[e.jsx("label",{style:{minWidth:"60px"},children:"Preview:"}),e.jsx("div",{style:{width:"50px",height:"50px",borderRadius:"50%",backgroundColor:f,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",cursor:"pointer"},children:e.jsx(H,{size:"large",name:G,style:{color:"white",margin:0}})})]})]})})]})}),e.jsx(u,{fluid:!0,children:e.jsxs(u.Content,{children:[e.jsx(u.Header,{as:"h4",textAlign:"left",children:"Chatbot (PlusScript)"}),e.jsx(u.Description,{children:e.jsxs("div",{style:{padding:"1rem 0"},children:[e.jsx("p",{children:"Configure the PlusScript that powers this chatbot. The script receives user messages and returns responses."}),e.jsxs(k,{placeholder:!0,style:{minHeight:"150px",marginTop:"1rem"},children:[e.jsx(J,{icon:!0,children:l?"PlusScript Configured":"No PlusScript Configured"}),e.jsxs("div",{style:{marginTop:"1rem"},children:[e.jsxs("p",{style:{fontSize:"0.9em",color:"#666"},children:[e.jsx("strong",{children:"Input:"})," Message (text), Upload (file)",e.jsx("br",{}),e.jsx("strong",{children:"Output:"})," Reply (text), File, Dialog Type (Standard/Error)"]}),e.jsx(W,{primary:!0,icon:"code",content:l?"Edit PlusScript":"Create PlusScript",onClick:ae,loading:C,style:{marginTop:"1rem"}}),l&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:"0.85em",color:"#666"},children:[e.jsx("strong",{children:"Script ID:"})," ",l]})]})]})]})})]})})]}),e.jsx("div",{style:{marginTop:"2rem",textAlign:"right"},children:e.jsxs(W,{primary:!0,onClick:Z,loading:F,disabled:!h,children:[e.jsx(H,{name:"save"}),"Save Configuration"]})}),e.jsxs(ne,{open:K,onClose:t,size:"fullscreen",children:[e.jsxs(ne.Content,{style:{minHeight:"60vh",position:"relative",backgroundColor:"#f4f5f6"},children:[e.jsx(Ie,{header:"Your changes will be abandoned",content:"Are you sure?",open:V,onCancel:i,onConfirm:p}),e.jsx(k,{basic:!0,style:{position:"absolute",left:0,right:0,top:0,bottom:0},children:e.jsx(Le,{title:"Edit Global Chatbot PlusScript",showMiniMap:!1,showRun:!1,pending:C||s,dirty:o,onSetDirty:d,scriptType:Ce.GLOBAL_CHATBOT,plusScript:Y,onSetPlusScript:O,onSaveScript:m})})]}),e.jsxs(ne.Actions,{children:[e.jsxs(W,{onClick:t,children:[e.jsx(H,{name:"cancel"}),"Cancel"]}),e.jsxs(W,{icon:!0,color:"teal",labelPosition:"right",loading:s,onClick:z,children:[e.jsx(H,{name:"checkmark"}),"Save"]})]})]})]})})}function Dt({application:v,onAddedApp:b,refreshApps:S,advertiser:g,rnp:X}){const{hostname:N}=Q(),{username:F}=je();xe();
1const[x,h]=a.useState("Site Configuration"),c=()=>{F&&S&&S(F)};if(!v||v.owner!=="sys.user.".concat(N,".").concat(F,".apps"))return e.jsxs(k,{style:{height:"100%"},children:[e.jsx("h2",{children:"Error"}),e.jsxs(le,{error:!0,children:[e.jsx(le.Header,{style:{textAlign:"left"},children:"This app is unavailable"}),e.jsx("p",{children:"Your account has no rights to access this app."})]})]});const w={},P={},G=["Site Configuration","Chatbot","Menu","Toolbar"];return e.jsx("section",{className:"sys-admin-app",style:w,children:e.jsxs("main",{className:"admin-tabs",children:[e.jsx(he,{attached:"top",tabular:!0,children:G.map(j=>e.jsx(he.Item,{name:j,active:x===j,onClick:()=>h(j),style:P},j))}),e.jsxs(k,{attached:"bottom",className:"tab",children:[x==="Menu"&&e.jsx(ke,{refreshApps:c}),x==="Toolbar"&&e.jsx(Ne,{onUpdate:c}),x==="Site Configuration"&&e.jsx(Ge,{refreshApps:c}),x==="Chatbot"&&e.jsx(Fe,{refreshApps:c})]})]})})}export{Dt as default};
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.