codicent-app-sdk 0.4.25 → 0.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAiB5D,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,kHAAkH;IAClH,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAC1B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrD;AAqLD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7D,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gHAAgH;IAChH,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC7B,2HAA2H;IAC3H,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,oIAAoI;IACpI,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MA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I,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChH,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC;CAC1E;AAID,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAqf5C,CAAC;;AAGF,wBAAoC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@fluentui/react-components"),i=require("@fluentui/react-icons"),r=require("../services/codicent.js"),o=require("../hooks/useLocalization.js");const l=n.makeStyles({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),a=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},s=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},c=({data:c,columns:d,canEdit:p,onEdit:h,onDelete:u,onToggleCheckbox:x,onEnumChange:m,onFilteredDataChange:f})=>{const g=l(),{visibleColumns:y,defaultSortIndex:j,defaultSortDirection:b}=t.useMemo((()=>{const e=c&&c.length>0?Array.from(new Set(c.flatMap((e=>Object.keys(e))))):[],t=(d||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[c,d]),[w,k]=t.useState(j>=0?j:null),[C,S]=t.useState(b),[v,N]=t.useState(!1),[W,$]=t.useState({title:"",text:""}),[D,I]=t.useState({}),[M,T]=t.useState(0),{t:A}=o.default(),O=e=>e.title?A(e.title):Array.isArray(e.key)?e.key[0]:e.key,B=e=>{const t=[];return e.hideOnMobile&&t.push(g.hideOnMobile),t.join(" ")},F=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),L=t.useMemo((()=>{const e=[...c];if(null!==w&&C){const t=y[w];e.sort(((e,n)=>{const i=s(e,t.key),r=s(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=a(i),t=a(r);if(null!==e&&null!==t)o=e-t;else{const e=Number(i.trim()),t=Number(r.trim());o=""!==i.trim()&&""!==r.trim()&&isFinite(e)&&isFinite(t)?e-t:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===C?o:-o}))}return e}),[c,w,C,y]),q=t.useMemo((()=>L.filter((e=>{for(const[t,n]of Object.entries(D)){const i=parseInt(t),r=y[i],o=s(e,r.key),l=F(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[L,D,y]);t.useEffect((()=>{f&&f(q)}),[q,f]);const z="undefined"!=typeof window?window.innerHeight-250:600,E=Math.max(0,Math.floor(M/49)-5),H=Math.min(q.length,Math.ceil((M+z)/49)+5),P=q.slice(E,H),R=49*q.length,Y=49*E,_=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(y.slice(0,3).map((t=>String(s(e,t.key)??""))).join("-"))}`};return c&&0!==c.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:g.container,onScroll:e=>{T(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:e.jsxs("table",{className:g.table,children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[y.map(((t,n)=>{const i=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsxs("th",{className:`${g.th} ${B(t)}`.trim(),style:i,onClick:()=>(e=>{w===e?"asc"===C?S("desc"):"desc"===C&&(k(null),S(null)):(k(e),S("asc"))})(n),children:[O(t),w===n&&e.jsx("span",{className:g.sortIndicator,children:"asc"===C?"▲":"▼"})]},n)})),p&&e.jsx("th",{className:`${g.th} ${g.actionsColumn}`,style:{width:"100px"},children:A("Actions")})]}),e.jsxs("tr",{children:[y.map(((t,i)=>{const r=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsx("th",{className:B(t),style:r,children:t.filterable&&e.jsxs("div",{className:g.filterWrapper,children:[e.jsx("input",{type:"text",className:g.filterInput,placeholder:A("Filter")+"...",value:D[i]||"",onChange:e=>((e,t)=>{I((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(D[i]||"").length>0&&e.jsx(n.Button,{appearance:"subtle",className:g.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{I((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),p&&e.jsx("th",{className:g.actionsColumn})]})]}),e.jsxs("tbody",{children:[E>0&&e.jsx("tr",{style:{height:`${Y}px`},children:e.jsx("td",{colSpan:y.length+(p?1:0),style:{padding:0,border:"none"}})}),P.map(((t,o)=>{const l=t._index,a="number"==typeof l?l:E+o;return e.jsxs("tr",{className:g.tr,children:[y.map(((i,o)=>{const l=s(t,i.key),c=i.format?i.format(l):F(l),d=i.maxWidth?`${g.td} ${g.tdTruncated} ${B(i)}`.trim():`${g.td} ${B(i)}`.trim(),p=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&c.length>0&&($({title:O(i),text:c}),N(!0))};if("file"===i.type&&c)return e.jsx("td",{className:d,onClick:p,children:e.jsx("a",{href:r.CodicentService.getFileUrl(c),target:"_blank",rel:"noopener noreferrer",children:A("Download")})},o);if("checkbox"===i.type){const r=!0===l||"true"===l||"yes"===l||"1"===l;return e.jsx("td",{className:d,children:e.jsx(n.Checkbox,{checked:r,onChange:(e,n)=>{x&&x(t,i.key,!0===n.checked,a)}})},o)}if("enum"===i.type&&i.enumOptions)return e.jsx("td",{className:d,children:e.jsxs(n.Select,{value:c,"aria-label":i.title?A(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,n)=>{m&&m(t,i.key,n.value,a)},style:{width:"100%"},children:[!i.enumOptions.includes(c)&&c&&e.jsx("option",{value:c,children:c}),i.enumOptions.map((t=>e.jsx("option",{value:t,children:A(t)},t)))]})},o);const h=()=>i.maxWidth&&c.length>0?e.jsx(n.Tooltip,{content:{children:c,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e.jsx("span",{children:c})}):c;return e.jsx("td",{className:d,onClick:p,children:i.action?e.jsxs("div",{className:g.cellWithAction,children:[e.jsx("span",{className:g.cellText,children:h()}),(()=>{if(!i.action)return null;const r=i.action,o=i.action.icon,l=e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(o,{}),className:g.actionIcon,onClick:e=>{e.stopPropagation(),r.onClick(t)},size:"small"});return r.tooltip?e.jsx(n.Tooltip,{content:A(r.tooltip),relationship:"label",children:l}):l})()]}):h()},o)})),p&&(h||u)&&e.jsx("td",{className:`${g.td} ${g.actionsColumn}`,children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[h&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Edit24Regular,{}),className:g.editButton,onClick:()=>h(t,a),title:A("Edit")}),u&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Delete24Regular,{}),className:g.editButton,onClick:()=>u(t,a),title:A("Delete")})]})})]},_(t,a))})),H<q.length&&e.jsx("tr",{style:{height:R-Y-49*P.length+"px"},children:e.jsx("td",{colSpan:y.length+(p?1:0),style:{padding:0,border:"none"}})})]})]})}),e.jsx(n.Dialog,{open:v,onOpenChange:(e,t)=>N(t.open),children:e.jsx(n.DialogSurface,{children:e.jsxs(n.DialogBody,{children:[e.jsx(n.DialogTitle,{children:W.title}),e.jsx(n.DialogContent,{className:g.dialogContent,children:W.text})]})})})]}):e.jsx("div",{className:g.emptyState,children:A("No data to display")})};var d=t.memo(c);exports.ListView=c,exports.default=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@fluentui/react-components"),i=require("@fluentui/react-icons"),r=require("../services/codicent.js"),o=require("../hooks/useLocalization.js");const l=n.makeStyles({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),a=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},s=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},c=({data:c,columns:d,canEdit:p,onEdit:h,onDelete:u,onToggleCheckbox:x,onEnumChange:m,onFilteredDataChange:f})=>{const g=l(),{visibleColumns:y,defaultSortIndex:j,defaultSortDirection:b}=t.useMemo((()=>{const e=c&&c.length>0?Array.from(new Set(c.flatMap((e=>Object.keys(e))))):[],t=(d||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[c,d]),[w,k]=t.useState(j>=0?j:null),[C,S]=t.useState(b),[v,N]=t.useState(!1),[W,$]=t.useState({title:"",text:""}),[D,I]=t.useState({}),[M,T]=t.useState(0),{t:A}=o.default(),O=e=>e.title?A(e.title):Array.isArray(e.key)?e.key[0]:e.key,B=e=>{const t=[];return e.hideOnMobile&&t.push(g.hideOnMobile),t.join(" ")},F=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),L=t.useMemo((()=>{const e=[...c];if(null!==w&&C){const t=y[w];e.sort(((e,n)=>{const i=s(e,t.key),r=s(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=a(i),t=a(r);if(null!==e&&null!==t)o=e-t;else{const e=i.trim().replace(/[\s\u00a0]/g,"").replace(/,/g,""),t=r.trim().replace(/[\s\u00a0]/g,"").replace(/,/g,""),n=Number(e),l=Number(t);o=""!==e&&""!==t&&isFinite(n)&&isFinite(l)?n-l:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===C?o:-o}))}return e}),[c,w,C,y]),q=t.useMemo((()=>L.filter((e=>{for(const[t,n]of Object.entries(D)){const i=parseInt(t),r=y[i],o=s(e,r.key),l=F(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[L,D,y]);t.useEffect((()=>{f&&f(q)}),[q,f]);const z="undefined"!=typeof window?window.innerHeight-250:600,E=Math.max(0,Math.floor(M/49)-5),H=Math.min(q.length,Math.ceil((M+z)/49)+5),P=q.slice(E,H),R=49*q.length,Y=49*E,_=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(y.slice(0,3).map((t=>String(s(e,t.key)??""))).join("-"))}`};return c&&0!==c.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:g.container,onScroll:e=>{T(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:e.jsxs("table",{className:g.table,children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[y.map(((t,n)=>{const i=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsxs("th",{className:`${g.th} ${B(t)}`.trim(),style:i,onClick:()=>(e=>{w===e?"asc"===C?S("desc"):"desc"===C&&(k(null),S(null)):(k(e),S("asc"))})(n),children:[O(t),w===n&&e.jsx("span",{className:g.sortIndicator,children:"asc"===C?"▲":"▼"})]},n)})),p&&e.jsx("th",{className:`${g.th} ${g.actionsColumn}`,style:{width:"100px"},children:A("Actions")})]}),e.jsxs("tr",{children:[y.map(((t,i)=>{const r=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsx("th",{className:B(t),style:r,children:t.filterable&&e.jsxs("div",{className:g.filterWrapper,children:[e.jsx("input",{type:"text",className:g.filterInput,placeholder:A("Filter")+"...",value:D[i]||"",onChange:e=>((e,t)=>{I((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(D[i]||"").length>0&&e.jsx(n.Button,{appearance:"subtle",className:g.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{I((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),p&&e.jsx("th",{className:g.actionsColumn})]})]}),e.jsxs("tbody",{children:[E>0&&e.jsx("tr",{style:{height:`${Y}px`},children:e.jsx("td",{colSpan:y.length+(p?1:0),style:{padding:0,border:"none"}})}),P.map(((t,o)=>{const l=t._index,a="number"==typeof l?l:E+o;return e.jsxs("tr",{className:g.tr,children:[y.map(((i,o)=>{const l=s(t,i.key),c=i.format?i.format(l):F(l),d=i.maxWidth?`${g.td} ${g.tdTruncated} ${B(i)}`.trim():`${g.td} ${B(i)}`.trim(),p=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&c.length>0&&($({title:O(i),text:c}),N(!0))};if("file"===i.type&&c)return e.jsx("td",{className:d,onClick:p,children:e.jsx("a",{href:r.CodicentService.getFileUrl(c),target:"_blank",rel:"noopener noreferrer",children:A("Download")})},o);if("checkbox"===i.type){const r=!0===l||"true"===l||"yes"===l||"1"===l;return e.jsx("td",{className:d,children:e.jsx(n.Checkbox,{checked:r,onChange:(e,n)=>{x&&x(t,i.key,!0===n.checked,a)}})},o)}if("enum"===i.type&&i.enumOptions&&i.editable)return e.jsx("td",{className:d,children:e.jsxs(n.Select,{value:c,"aria-label":i.title?A(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,n)=>{m&&m(t,i.key,n.value,a)},style:{width:"100%"},children:[!i.enumOptions.includes(c)&&c&&e.jsx("option",{value:c,children:c}),i.enumOptions.map((t=>e.jsx("option",{value:t,children:A(t)},t)))]})},o);const h=()=>i.maxWidth&&c.length>0?e.jsx(n.Tooltip,{content:{children:c,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e.jsx("span",{children:c})}):c;return e.jsx("td",{className:d,onClick:p,children:i.action?e.jsxs("div",{className:g.cellWithAction,children:[e.jsx("span",{className:g.cellText,children:h()}),(()=>{if(!i.action)return null;const r=i.action,o=i.action.icon,l=e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(o,{}),className:g.actionIcon,onClick:e=>{e.stopPropagation(),r.onClick(t)},size:"small"});return r.tooltip?e.jsx(n.Tooltip,{content:A(r.tooltip),relationship:"label",children:l}):l})()]}):h()},o)})),p&&(h||u)&&e.jsx("td",{className:`${g.td} ${g.actionsColumn}`,children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[h&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Edit24Regular,{}),className:g.editButton,onClick:()=>h(t,a),title:A("Edit")}),u&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Delete24Regular,{}),className:g.editButton,onClick:()=>u(t,a),title:A("Delete")})]})})]},_(t,a))})),H<q.length&&e.jsx("tr",{style:{height:R-Y-49*P.length+"px"},children:e.jsx("td",{colSpan:y.length+(p?1:0),style:{padding:0,border:"none"}})})]})]})}),e.jsx(n.Dialog,{open:v,onOpenChange:(e,t)=>N(t.open),children:e.jsx(n.DialogSurface,{children:e.jsxs(n.DialogBody,{children:[e.jsx(n.DialogTitle,{children:W.title}),e.jsx(n.DialogContent,{className:g.dialogContent,children:W.text})]})})})]}):e.jsx("div",{className:g.emptyState,children:A("No data to display")})};var d=t.memo(c);exports.ListView=c,exports.default=d;
@@ -1 +1 @@
1
- {"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCodicentApp.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAyB,MAAM,UAAU,CAAC;AACpG,OAAyB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAA2B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGnD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI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MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,eAAO,MAAM,cAAc,wCAAyC,qBAAqB,KA6KlF,gBACN,CAAC"}
@@ -1 +1 @@
1
- "use strict";var e=require("react");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime");var t=require("../utils/appState.js");require("../_virtual/index.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../utils/cacheManager.js");var r=require("./useAudioRecorder.js"),s=require("./useAuthState.js"),n=require("./useRealtimeVoiceAI.js"),a=require("./useTools.js");exports.useCodicentApp=({auth0:c,toolsConfig:u,authOptions:i})=>{const o=s.default(c,i),l=e.useRef(t.createAppStateMachine(o.codicentService,(()=>{}))),[d,p]=e.useState(),{service:m,context:f}=l.current,{nickname:h,name:k,error:v,errorType:A,selectedApp:g}=f,b=e.useCallback(((e,t)=>{const r=e.get("file").name;m.uploadFile(r,e).then((e=>{m.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[m]),C=r.useAudioRecorder(b),[S,q]=e.useState(),[w,j]=e.useState(),[y,x]=e.useState(!1),T=e.useMemo((()=>new Audio("./notification.mp3")),[]),N=e.useCallback((()=>x(!0)),[]),R=a.default(m,q,j,T,S,N,u),M=n.default(m,R);e.useEffect((()=>{y&&(M?.disconnectConversation(),x(!1))}),[y,M]),e.useEffect((()=>{o.isAuthenticated&&o.user&&o.accessToken&&l.current.updateContext({isAuthenticated:o.isAuthenticated,user:{sub:o.user.sub,email:o.user.email},accessToken:o.accessToken})}),[o.isAuthenticated,o.user,o.accessToken]);const _=e.useRef(o.isAuthenticated);e.useEffect((()=>{const e=!0===_.current,t=!0===o.isAuthenticated;e&&!t&&l.current.logout(),_.current=o.isAuthenticated}),[o.isAuthenticated]),e.useEffect((()=>l.current.updateContext({nickname:o.nickname})),[o.nickname]),e.useEffect((()=>{l.current.update();let e,t=l.current.getCurrentStateName();p(l.current.getCurrentStateName()),JSON.stringify(l.current.context);let r=!1;const s=n=>setInterval((()=>{const n=l.current.getCurrentStateName();if("hasAccess"===n&&!r)return console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),r=!0,clearInterval(e),void(e=s(1e3));if("hasAccess"!==n&&r)return console.log("🚨 Left stable state - switching to fast polling (200ms)"),r=!1,clearInterval(e),void(e=s(200));const a=JSON.stringify(l.current.context);l.current.update();const c=JSON.stringify(l.current.context),u=l.current.getCurrentStateName();u===t&&a===c||(p(u),t=u)}),n);return e=s(200),()=>clearInterval(e)}),[]);const I=e.useCallback((e=>e.replace("{nickname}",h||"unknown").replace("{token}",encodeURIComponent(o.accessToken||"unknown")).replace("{app}",g||"unknown")),[h,o.accessToken,g]),E=e.useCallback((e=>{l.current.updateContext({isAnonymous:e})}),[]),O=e.useCallback((()=>l.current.isBusy()),[]);return e.useMemo((()=>({audio:C,auth:o,currentStateName:d,stateMachine:l.current,service:m,context:f,state:d,nickname:h,name:k,error:v,errorType:A,fixAppUrl:I,setAnonymous:E,allStates:l.current.allStates,isBusy:O,voice:M,html:S,setHtml:q,script:w})),[d,h,k,v,A,S,w,o.isAuthenticated,o.isLoading,C.isRecording,M?.isConnected,I,E,O])};
1
+ "use strict";var e=require("react");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime");var t=require("../utils/appState.js");require("../_virtual/index.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../utils/cacheManager.js");var r=require("./useAudioRecorder.js"),s=require("./useAuthState.js"),n=require("./useRealtimeVoiceAI.js"),a=require("./useTools.js");exports.useCodicentApp=({auth0:c,toolsConfig:u,authOptions:i})=>{const o=s.default(c,i),l=e.useRef(t.createAppStateMachine(o.codicentService,(()=>{}))),[d,m]=e.useState(),{service:p,context:h}=l.current,{nickname:f,name:A,error:g,errorType:k,selectedApp:v}=h,C=e.useCallback(((e,t)=>{const r=e.get("file").name;p.uploadFile(r,e).then((e=>{p.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[p]),S=r.useAudioRecorder(C),[b,q]=e.useState(),[w,j]=e.useState(),[y,x]=e.useState(!1),N=e.useMemo((()=>new Audio("./notification.mp3")),[]),T=e.useCallback((()=>x(!0)),[]),R=a.default(p,q,j,N,b,T,u),M=n.default(p,R);e.useEffect((()=>{y&&(M?.disconnectConversation(),x(!1))}),[y,M]),e.useEffect((()=>{o.isAuthenticated&&o.user&&o.accessToken&&l.current.updateContext({isAuthenticated:o.isAuthenticated,user:{sub:o.user.sub,email:o.user.email},accessToken:o.accessToken})}),[o.isAuthenticated,o.user,o.accessToken]);const _=e.useRef(o.isAuthenticated);e.useEffect((()=>{const e=!0===_.current,t=!0===o.isAuthenticated;e&&!t&&l.current.logout(),_.current=o.isAuthenticated}),[o.isAuthenticated]),e.useEffect((()=>l.current.updateContext({nickname:o.nickname})),[o.nickname]),e.useEffect((()=>{l.current.update();let e,t=l.current.getCurrentStateName();m(l.current.getCurrentStateName()),JSON.stringify(l.current.context);let r="hasAccess"===l.current.getCurrentStateName();const s=n=>setInterval((()=>{const n=l.current.getCurrentStateName();"hasAccess"!==n||r?"hasAccess"!==n&&r&&(console.log("🚨 Left stable state - switching to fast polling (200ms)"),r=!1,clearInterval(e),e=s(200)):(console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),r=!0,clearInterval(e),e=s(1e3));const a=JSON.stringify(l.current.context);l.current.update();const c=JSON.stringify(l.current.context),u=l.current.getCurrentStateName();u===t&&a===c||(m(u),t=u)}),n);return e=s(r?1e3:200),()=>clearInterval(e)}),[]);const I=e.useCallback((e=>e.replace("{nickname}",f||"unknown").replace("{token}",encodeURIComponent(o.accessToken||"unknown")).replace("{app}",v||"unknown")),[f,o.accessToken,v]),E=e.useCallback((e=>{l.current.updateContext({isAnonymous:e})}),[]),O=e.useCallback((()=>l.current.isBusy()),[]);return e.useMemo((()=>({audio:S,auth:o,currentStateName:d,stateMachine:l.current,service:p,context:h,state:d,nickname:f,name:A,error:g,errorType:k,fixAppUrl:I,setAnonymous:E,allStates:l.current.allStates,isBusy:O,voice:M,html:b,setHtml:q,script:w})),[d,f,A,g,k,b,w,o.isAuthenticated,o.isLoading,S.isRecording,M?.isConnected,I,E,O])};
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/pages/Chat.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAa3D,OAAO,EACL,gBAAgB,EAOjB,MAAM,UAAU,CAAC;AAuClB,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IACnB,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAsSA,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/pages/Chat.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAa3D,OAAO,EACL,gBAAgB,EAOjB,MAAM,UAAU,CAAC;AAuClB,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IACnB,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAuSA,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@fluentui/react-components"),n=require("react-router-dom"),s=require("@fluentui/react-icons");require("../components/Markdown.js"),require("../components/Textarea.js"),require("../components/Button.js"),require("../components/CompoundButton.js"),require("../components/Spinner.js");var o=require("../components/TextHeader.js"),a=require("../components/TypingIndicator.js"),i=require("../components/Prompt.js"),l=require("../components/ChatInput.js"),c=require("../components/CombinedPlaceholderDialog.js"),u=require("../components/ChatMessage.js");require("../components/Header.js");var d=require("../hooks/useStateWithLocalStorage.js"),p=require("../services/codicent.js");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var m=require("../config/index.js");require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("./AppFrame.js"),require("./Compose.js"),require("./Snap.js"),require("./Search.js"),require("./Login.js"),require("./CrmPage.js"),require("./CrmPagePersistent.js"),require("./ImageView.js"),require("./FormInvite.js"),require("./FormAccept.js"),require("./Sales.js"),require("./Purchase.js"),require("../components/Content.js");var g=require("../components/Page.js");require("./QrScan.js");var h=require("../hooks/useLocalization.js");require("../components/FileThumbnail.js"),require("react-dom/client"),require("../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js");var j=require("../hooks/useChat.js"),f=require("../hooks/useTemplateVariables.js");require("../hooks/useAppStyles.js"),require("../components/MessageInput.js"),require("../components/UploadFile.js"),require("../components/SnapFooter.js"),require("../components/Profile.js"),require("../components/MessageItem.js"),require("../components/AiInput.js"),require("../components/SearchBox.js"),require("../components/DataMessagePicker.js"),require("../components/HtmlView.js"),require("../components/Footer.js"),require("../components/QrCodeDialog.js"),require("../components/QrScanner.js"),require("../components/OfflineMessage.js"),require("../components/LanguageSelector.js"),require("../components/ListView.js"),require("../components/RecordModal.js"),require("../components/BulkUploadDialog.js"),require("../components/CookieBanner.js");const q=t.makeStyles({chatContainer:{width:"100%",flex:1,maxWidth:"1600px",height:"100%",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},"@media (max-width: 480px)":{},backgroundPosition:"calc(50%) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",touchAction:"pan-y"},chatMessages:{display:"flex",flexDirection:"column",flex:1,padding:"16px",overflowY:"auto",touchAction:"pan-y"}});exports.default=({state:t,hideFooter:x,codicent:C,title:S,welcomeMessage:b})=>{const v=q(),{t:w,tAsync:y,getLanguageInfo:P}=h.default(),k=n.useNavigate(),F=r.useRef(null),[T,_]=n.useSearchParams(),I=T.get("codicent"),A=I||C,{messages:M,isBotTyping:V,handleSend:R,newChat:L,openChat:E}=j.useChat(t.stateMachine,A||void 0),[H,B]=r.useState(null),[N,U]=r.useState(!1),[D,O]=r.useState(!1),{service:W,currentStateName:z}=t,[Q,G]=r.useState([]),[Y,$]=r.useState([]),[K,J]=r.useState(!1),[X,Z]=r.useState(),[ee,re]=d.default(t.context.selectedApp+"_prompts",[]),[te,ne]=r.useState(!1),{extractTemplateVariables:se,replaceTemplateVariables:oe,extractFilePlaceholders:ae,replaceFilePlaceholders:ie,handleSelectFiles:le}=f.useTemplateVariables(W.uploadFile),ce=r.useRef(!1),ue=r.useRef(null);r.useEffect((()=>{const e=window.history.length>1,r=Boolean(document.referrer&&document.referrer!==window.location.href);O(e||r)}),[]);r.useEffect((()=>{m.getConfigValue("SHOW_CHAT_PROMPTS")&&0===M.length&&t.service.getAppPrompts().then(re).catch((e=>{console.error("Failed to get prompts",e)}))}),[t.service,re,M.length]),r.useEffect((()=>{setTimeout((()=>{F.current?.scrollIntoView({behavior:"smooth"})}),10)}),[M]),r.useEffect((()=>{if(ce.current)return;ce.current=!0;const e=T.get("text"),r=T.get("id"),t=T.get("fid");if(I){console.log("Using temporary codicent from URL param:",I);const e=new URLSearchParams(T);e.delete("codicent"),_(e,{replace:!0})}if(e){(async()=>{const r=ae(e),t=se(e);L(),r.length>0||t.length>0?($(r),G(t),J(!0),B(w(e))):B(w(e))})()}else r?E(r):t&&Z(t)}),[]),r.useEffect((()=>{X&&"anonymous"===z&&ue.current!==X&&(ue.current=X,W.getFormById(X).then((async e=>{L();const r=P().language,t=e.prompt.replace("{{fid}}",X).replace("{{fname}}",e.name).replace("{{language}}",r);ne(!0);const n=await y(t);ne(!1),B(n),O(!1)})))}),[X,L,W,B,z,y,P,ne]),r.useEffect((()=>{if(H&&!K){let e=H;Y.length>0&&(e=ie(e,Y)),Q.length>0&&(e=oe(e,Q)),R(e),_({},{replace:!0}),B(null),G([]),$([])}}),[H,K,R,_,ie,oe,Y,Q]);const de=e=>{const r=T.get("append");r&&(e+="\n---\n"+r),R(e)};return e.jsxs(g.Page,{hideHeader:!0,hideFooter:!!X||x,children:[e.jsxs("div",{id:"chat-container",className:v.chatContainer,style:{backgroundImage:`url(${m.getConfigValue("CHAT_BACKGROUND_IMAGE_URL")})`},children:[D&&e.jsx("button",{onClick:()=>{D&&k(-1)},"aria-label":w("Tillbaka"),style:{position:"absolute",top:12,left:12,zIndex:100,background:"var(--colorNeutralBackground1)",border:"none",cursor:"pointer",padding:8,borderRadius:8,boxShadow:"0 2px 8px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(s.CalendarWeekStart24Regular,{style:{transform:"rotate(180deg)"}})}),e.jsx("div",{style:{marginLeft:D?40:0},children:e.jsx(o.default,{title:S||w(m.getConfigValue("APP_CHAT_TITLE")||"Chatt"),onNewChat:X?void 0:()=>U(!0)})}),e.jsxs("div",{className:v.chatMessages,children:[b&&e.jsx(u.default,{sender:"bot",content:b}),m.getConfigValue("SHOW_CHAT_PROMPTS")&&ee.length>0&&0===M.length&&e.jsx(u.default,{sender:"bot",content:w(m.getConfigValue("CHAT_WELCOME")||w("Välkommen!")),children:ee.map(((r,t)=>e.jsxs("div",{children:["> ",e.jsx("a",{href:"./#/chat",onClick:()=>{de(r.title+"\n---\n"+r.prompt)},children:w(r.title)}),e.jsx("br",{})]},`prompt-${t}`)))}),M.map(((r,t)=>e.jsxs("div",{children:[(V&&t===M.length-1||!V&&t===M.length-2)&&e.jsx("div",{ref:F}),e.jsx(u.default,{sender:r.sender,content:r.content,isNew:r.isNew,showSuggestions:t===M.length-1,onSuggestionClicked:R},r.id)]},r.id))),te&&e.jsx(u.default,{sender:"user",content:w("Översätter...")}),V&&e.jsx(a.default,{})]}),e.jsx(l.default,{codicent:A||t.context.selectedApp,disableSend:V,onSend:de,onSelectFiles:le,getImageUrl:p.CodicentService.getImageUrl,getFileInfo:e=>W.getFileInfo(e)})]}),e.jsx(i.default,{open:N,title:w("Vill du rensa chatten?"),content:w("En ny startas, men chatten kommer först sparas."),onYes:()=>{U(!1),L()},onNo:()=>U(!1)}),e.jsx(c.CombinedPlaceholderDialog,{open:K,templateVariables:Q,filePlaceholders:Y,onTemplateVariablesChange:G,onFilePlaceholdersChange:$,onConfirm:()=>J(!1),onCancel:()=>{J(!1),B(null),G([]),$([])},uploadFile:W.uploadFile})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@fluentui/react-components"),n=require("react-router-dom"),s=require("@fluentui/react-icons");require("../components/Markdown.js"),require("../components/Textarea.js"),require("../components/Button.js"),require("../components/CompoundButton.js"),require("../components/Spinner.js");var o=require("../components/TextHeader.js"),a=require("../components/TypingIndicator.js"),i=require("../components/Prompt.js"),l=require("../components/ChatInput.js"),c=require("../components/CombinedPlaceholderDialog.js"),u=require("../components/ChatMessage.js");require("../components/Header.js");var d=require("../hooks/useStateWithLocalStorage.js"),p=require("../services/codicent.js");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var m=require("../config/index.js");require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("./AppFrame.js"),require("./Compose.js"),require("./Snap.js"),require("./Search.js"),require("./Login.js"),require("./CrmPage.js"),require("./CrmPagePersistent.js"),require("./ImageView.js"),require("./FormInvite.js"),require("./FormAccept.js"),require("./Sales.js"),require("./Purchase.js"),require("../components/Content.js");var g=require("../components/Page.js");require("./QrScan.js");var h=require("../hooks/useLocalization.js");require("../components/FileThumbnail.js"),require("react-dom/client"),require("../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js");var j=require("../hooks/useChat.js"),f=require("../hooks/useTemplateVariables.js");require("../hooks/useAppStyles.js"),require("../components/MessageInput.js"),require("../components/UploadFile.js"),require("../components/SnapFooter.js"),require("../components/Profile.js"),require("../components/MessageItem.js"),require("../components/AiInput.js"),require("../components/SearchBox.js"),require("../components/DataMessagePicker.js"),require("../components/HtmlView.js"),require("../components/Footer.js"),require("../components/QrCodeDialog.js"),require("../components/QrScanner.js"),require("../components/OfflineMessage.js"),require("../components/LanguageSelector.js"),require("../components/ListView.js"),require("../components/RecordModal.js"),require("../components/BulkUploadDialog.js"),require("../components/CookieBanner.js");const q=r.makeStyles({chatContainer:{width:"100%",flex:1,maxWidth:"1600px",height:"100%",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},"@media (max-width: 480px)":{},backgroundPosition:"calc(50%) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",touchAction:"pan-y"},chatMessages:{display:"flex",flexDirection:"column",flex:1,padding:"16px",overflowY:"auto",touchAction:"pan-y"}});exports.default=({state:r,hideFooter:x,codicent:C,title:S,welcomeMessage:b})=>{const v=q(),{t:w,tAsync:y,getLanguageInfo:P}=h.default(),k=n.useNavigate(),F=t.useRef(null),[T,_]=n.useSearchParams(),[I]=t.useState((()=>T.get("codicent"))),A=I||C,{messages:M,isBotTyping:V,handleSend:R,newChat:L,openChat:E}=j.useChat(r.stateMachine,A||void 0),[H,B]=t.useState(null),[N,U]=t.useState(!1),[D,O]=t.useState(!1),{service:W,currentStateName:z}=r,[Q,G]=t.useState([]),[Y,$]=t.useState([]),[K,J]=t.useState(!1),[X,Z]=t.useState(),[ee,te]=d.default(r.context.selectedApp+"_prompts",[]),[re,ne]=t.useState(!1),{extractTemplateVariables:se,replaceTemplateVariables:oe,extractFilePlaceholders:ae,replaceFilePlaceholders:ie,handleSelectFiles:le}=f.useTemplateVariables(W.uploadFile),ce=t.useRef(!1),ue=t.useRef(null);t.useEffect((()=>{const e=window.history.length>1,t=Boolean(document.referrer&&document.referrer!==window.location.href);O(e||t)}),[]);t.useEffect((()=>{m.getConfigValue("SHOW_CHAT_PROMPTS")&&0===M.length&&r.service.getAppPrompts().then(te).catch((e=>{console.error("Failed to get prompts",e)}))}),[r.service,te,M.length]),t.useEffect((()=>{setTimeout((()=>{F.current?.scrollIntoView({behavior:"smooth"})}),10)}),[M]),t.useEffect((()=>{if(ce.current)return;ce.current=!0;const e=T.get("text"),t=T.get("id"),r=T.get("fid");if(I){console.log("Using temporary codicent from URL param:",I);const e=new URLSearchParams(T);e.delete("codicent"),_(e,{replace:!0})}if(e){(async()=>{const t=ae(e),r=se(e);L(),t.length>0||r.length>0?($(t),G(r),J(!0),B(w(e))):B(w(e))})()}else t?E(t):r&&Z(r)}),[]),t.useEffect((()=>{X&&"anonymous"===z&&ue.current!==X&&(ue.current=X,W.getFormById(X).then((async e=>{L();const t=P().language,r=e.prompt.replace("{{fid}}",X).replace("{{fname}}",e.name).replace("{{language}}",t);ne(!0);const n=await y(r);ne(!1),B(n),O(!1)})))}),[X,L,W,B,z,y,P,ne]),t.useEffect((()=>{if(H&&!K){let e=H;Y.length>0&&(e=ie(e,Y)),Q.length>0&&(e=oe(e,Q)),R(e),_({},{replace:!0}),B(null),G([]),$([])}}),[H,K,R,_,ie,oe,Y,Q]);const de=e=>{const t=T.get("append");t&&(e+="\n---\n"+t),R(e)};return e.jsxs(g.Page,{hideHeader:!0,hideFooter:!!X||x,children:[e.jsxs("div",{id:"chat-container",className:v.chatContainer,style:{backgroundImage:`url(${m.getConfigValue("CHAT_BACKGROUND_IMAGE_URL")})`},children:[D&&e.jsx("button",{onClick:()=>{D&&k(-1)},"aria-label":w("Tillbaka"),style:{position:"absolute",top:12,left:12,zIndex:100,background:"var(--colorNeutralBackground1)",border:"none",cursor:"pointer",padding:8,borderRadius:8,boxShadow:"0 2px 8px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(s.CalendarWeekStart24Regular,{style:{transform:"rotate(180deg)"}})}),e.jsx("div",{style:{marginLeft:D?40:0},children:e.jsx(o.default,{title:S||w(m.getConfigValue("APP_CHAT_TITLE")||"Chatt"),onNewChat:X?void 0:()=>U(!0)})}),e.jsxs("div",{className:v.chatMessages,children:[b&&e.jsx(u.default,{sender:"bot",content:b}),m.getConfigValue("SHOW_CHAT_PROMPTS")&&ee.length>0&&0===M.length&&e.jsx(u.default,{sender:"bot",content:w(m.getConfigValue("CHAT_WELCOME")||w("Välkommen!")),children:ee.map(((t,r)=>e.jsxs("div",{children:["> ",e.jsx("a",{href:"./#/chat",onClick:()=>{de(t.title+"\n---\n"+t.prompt)},children:w(t.title)}),e.jsx("br",{})]},`prompt-${r}`)))}),M.map(((t,r)=>e.jsxs("div",{children:[(V&&r===M.length-1||!V&&r===M.length-2)&&e.jsx("div",{ref:F}),e.jsx(u.default,{sender:t.sender,content:t.content,isNew:t.isNew,showSuggestions:r===M.length-1,onSuggestionClicked:R},t.id)]},t.id))),re&&e.jsx(u.default,{sender:"user",content:w("Översätter...")}),V&&e.jsx(a.default,{})]}),e.jsx(l.default,{codicent:A||r.context.selectedApp,disableSend:V,onSend:de,onSelectFiles:le,getImageUrl:p.CodicentService.getImageUrl,getFileInfo:e=>W.getFileInfo(e)})]}),e.jsx(i.default,{open:N,title:w("Vill du rensa chatten?"),content:w("En ny startas, men chatten kommer först sparas."),onYes:()=>{U(!1),L()},onNo:()=>U(!1)}),e.jsx(c.CombinedPlaceholderDialog,{open:K,templateVariables:Q,filePlaceholders:Y,onTemplateVariablesChange:G,onFilePlaceholdersChange:$,onConfirm:()=>J(!1),onCancel:()=>{J(!1),B(null),G([]),$([])},uploadFile:W.uploadFile})]})};
@@ -1 +1 @@
1
- {"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,UAAU,QAAS,MAAM,SAgBrC,CAAC;AAEF,eAAO,MAAM,cAAc,SAAU,MAAM,SAU1C,CAAC;AA+BF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAA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MAAM,KAC1B,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAqF9D;IAEF,QAAQ,QAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAMlC;IAEF,WAAW,OAAc,MAAM,mBAO7B;IAGF,OAAO,CAAC,kBAAkB;IAM1B,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAiB/E;IAEF,gBAAgB,cAAqB,MAAM,UAAU,MAAM,GAAG,QAAQ,sBAcpE;IAEI,uBAAuB,CAAC,KAAK,GAAE,MAAgB,EAAE,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB9F,iBAAiB,CACrB,QAAQ,GAAE,MAAiB,GAC1B,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAoBpE;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,SACd,MAAM,kBACI,MAAM,YACb,MAAM,KACd,OAAO,CAAC,mBAAmB,CAAC,CA0B7B;CACH"}
@@ -1 +1 @@
1
- "use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),o=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("react"),require("../_virtual/index.js"),require("../config/index.js"),require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-";const i=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,r=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},c=t=>{t&&"string"==typeof t&&(a=t,i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a}))},h=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:n,signalRHost:a}),!0);let d=h();if(!d){const t=setInterval((()=>{d=h(),d&&clearInterval(t)}),100)}class l{constructor(t){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,n,a,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const o=await e.text();return JSON.parse(o)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const e=new o.default(t.content).content.split("\n"),n=e[0],a=e.slice(1).join("\n");return{id:t.id,title:n,content:a}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const o=await fetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0,s,i=0)=>{const r=await this.request(`${n}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,o,s)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,o,a)=>{const s=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=(await t.json()).filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))));return e}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,i=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const a=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const s=await fetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const o=await fetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})},this.getToken=()=>s,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),o&&o>0&&(a.trialPeriodDays=o);const s=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async t=>{const o=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(t),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.request(`${n}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=t,r(t.API_BASE_URL),t.PUBSUB_URL&&c(t.PUBSUB_URL)}async request(t,e,o={}){const n={};o.headers&&o.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...o,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${n}realtime/session?voice=${t}&provider=${e}`,a=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}t=l,l.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,l.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,l.downloadFile=async e=>{fetch(t.getFileUrl(e.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((t=>{const o=window.URL.createObjectURL(t),n=document.createElement("a");n.style.display="none",n.href=o,n.download=e.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},l.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let a={project:e,message:t};o&&(a.messageId=o);const i=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(a)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},l.getMiniChatReply=async(t,e="codicent-mini",o,a=3e5,i=2e3,r)=>{const c={project:e,message:t};let h;o&&(c.messageId=o),r&&(c.previousResponseId=r);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(c)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(h=(await t.json()).promptMessageId,!h)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const d=Date.now();for(;Date.now()-d<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json(),a=o.content??o.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:o.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},l.getTranslations=async(t,e,o="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${s}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()},exports.CodicentService=l,exports.setBaseUrl=r,exports.setSignalRHost=c;
1
+ "use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),o=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("react"),require("../_virtual/index.js"),require("../config/index.js"),require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-";const i=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,r=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},c=t=>{t&&"string"==typeof t&&(a=t,i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a}))},h=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:n,signalRHost:a}),!0);let d=h();if(!d){const t=setInterval((()=>{d=h(),d&&clearInterval(t)}),100)}class l{constructor(t){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,n,a,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const o=await e.text();return JSON.parse(o)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>[...(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const e=new o.default(t.content).content.split("\n"),n=e[0],a=e.slice(1).join("\n");return{id:t.id,title:n,content:a}})),...(await window.Codicent.getDataMessages({tags:["skill"],codicent:this.codicent})).map((t=>t.data)).filter((t=>t.name&&t.title)).map((t=>({id:t.name,title:t.title,content:t.content||t.description||""})))],this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const o=await fetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0,s,i=0)=>{const r=await this.request(`${n}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,o,s)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,o,a)=>{const s=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=(await t.json()).filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))));return e}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,i=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const a=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const s=await fetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const o=await fetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})},this.getToken=()=>s,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),o&&o>0&&(a.trialPeriodDays=o);const s=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async t=>{const o=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(t),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.request(`${n}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=t,r(t.API_BASE_URL),t.PUBSUB_URL&&c(t.PUBSUB_URL)}async request(t,e,o={}){const n={};o.headers&&o.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...o,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${n}realtime/session?voice=${t}&provider=${e}`,a=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}t=l,l.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,l.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,l.downloadFile=async e=>{fetch(t.getFileUrl(e.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((t=>{const o=window.URL.createObjectURL(t),n=document.createElement("a");n.style.display="none",n.href=o,n.download=e.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},l.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let a={project:e,message:t};o&&(a.messageId=o);const i=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(a)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},l.getMiniChatReply=async(t,e="codicent-mini",o,a=3e5,i=2e3,r)=>{const c={project:e,message:t};let h;o&&(c.messageId=o),r&&(c.previousResponseId=r);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(c)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(h=(await t.json()).promptMessageId,!h)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const d=Date.now();for(;Date.now()-d<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json(),a=o.content??o.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:o.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},l.getTranslations=async(t,e,o="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${s}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()},exports.CodicentService=l,exports.setBaseUrl=r,exports.setSignalRHost=c;
@@ -1 +1 @@
1
- {"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAiB5D,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,kHAAkH;IAClH,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAC1B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrD;AAqLD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YA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Checkbox as d,Select as s,Dialog as p,DialogSurface as h,DialogBody as u,DialogTitle as m,DialogContent as f,Tooltip as x}from"@fluentui/react-components";import{Edit24Regular as g,Delete24Regular as y}from"@fluentui/react-icons";import{CodicentService as b}from"../services/codicent.js";import w from"../hooks/useLocalization.js";const k=a({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),C=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},v=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},S=({data:i,columns:a,canEdit:S,onEdit:N,onDelete:W,onToggleCheckbox:$,onEnumChange:I,onFilteredDataChange:A})=>{const j=k(),{visibleColumns:O,defaultSortIndex:M,defaultSortDirection:T}=r((()=>{const e=i&&i.length>0?Array.from(new Set(i.flatMap((e=>Object.keys(e))))):[],t=(a||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[i,a]),[D,F]=o(M>=0?M:null),[B,z]=o(T),[L,H]=o(!1),[E,Y]=o({title:"",text:""}),[P,R]=o({}),[_,J]=o(0),{t:U}=w(),X=e=>e.title?U(e.title):Array.isArray(e.key)?e.key[0]:e.key,q=e=>{const t=[];return e.hideOnMobile&&t.push(j.hideOnMobile),t.join(" ")},G=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),K=r((()=>{const e=[...i];if(null!==D&&B){const t=O[D];e.sort(((e,n)=>{const i=v(e,t.key),r=v(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=C(i),t=C(r);if(null!==e&&null!==t)o=e-t;else{const e=Number(i.trim()),t=Number(r.trim());o=""!==i.trim()&&""!==r.trim()&&isFinite(e)&&isFinite(t)?e-t:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===B?o:-o}))}return e}),[i,D,B,O]),Q=r((()=>K.filter((e=>{for(const[t,n]of Object.entries(P)){const i=parseInt(t),r=O[i],o=v(e,r.key),l=G(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[K,P,O]);l((()=>{A&&A(Q)}),[Q,A]);const V="undefined"!=typeof window?window.innerHeight-250:600,Z=Math.max(0,Math.floor(_/49)-5),ee=Math.min(Q.length,Math.ceil((_+V)/49)+5),te=Q.slice(Z,ee),ne=49*Q.length,ie=49*Z,re=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(O.slice(0,3).map((t=>String(v(e,t.key)??""))).join("-"))}`};return i&&0!==i.length?t(n,{children:[e("div",{className:j.container,onScroll:e=>{J(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:t("table",{className:j.table,children:[t("thead",{children:[t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return t("th",{className:`${j.th} ${q(n)}`.trim(),style:r,onClick:()=>(e=>{D===e?"asc"===B?z("desc"):"desc"===B&&(F(null),z(null)):(F(e),z("asc"))})(i),children:[X(n),D===i&&e("span",{className:j.sortIndicator,children:"asc"===B?"▲":"▼"})]},i)})),S&&e("th",{className:`${j.th} ${j.actionsColumn}`,style:{width:"100px"},children:U("Actions")})]}),t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return e("th",{className:q(n),style:r,children:n.filterable&&t("div",{className:j.filterWrapper,children:[e("input",{type:"text",className:j.filterInput,placeholder:U("Filter")+"...",value:P[i]||"",onChange:e=>((e,t)=>{R((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(P[i]||"").length>0&&e(c,{appearance:"subtle",className:j.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{R((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),S&&e("th",{className:j.actionsColumn})]})]}),t("tbody",{children:[Z>0&&e("tr",{style:{height:`${ie}px`},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})}),te.map(((n,i)=>{const r=n._index,o="number"==typeof r?r:Z+i;return t("tr",{className:j.tr,children:[O.map(((i,r)=>{const l=v(n,i.key),a=i.format?i.format(l):G(l),p=i.maxWidth?`${j.td} ${j.tdTruncated} ${q(i)}`.trim():`${j.td} ${q(i)}`.trim(),h=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&a.length>0&&(Y({title:X(i),text:a}),H(!0))};if("file"===i.type&&a)return e("td",{className:p,onClick:h,children:e("a",{href:b.getFileUrl(a),target:"_blank",rel:"noopener noreferrer",children:U("Download")})},r);if("checkbox"===i.type){return e("td",{className:p,children:e(d,{checked:!0===l||"true"===l||"yes"===l||"1"===l,onChange:(e,t)=>{$&&$(n,i.key,!0===t.checked,o)}})},r)}if("enum"===i.type&&i.enumOptions)return e("td",{className:p,children:t(s,{value:a,"aria-label":i.title?U(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,t)=>{I&&I(n,i.key,t.value,o)},style:{width:"100%"},children:[!i.enumOptions.includes(a)&&a&&e("option",{value:a,children:a}),i.enumOptions.map((t=>e("option",{value:t,children:U(t)},t)))]})},r);const u=()=>i.maxWidth&&a.length>0?e(x,{content:{children:a,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e("span",{children:a})}):a;return e("td",{className:p,onClick:h,children:i.action?t("div",{className:j.cellWithAction,children:[e("span",{className:j.cellText,children:u()}),(()=>{if(!i.action)return null;const t=i.action,r=i.action.icon,o=e(c,{appearance:"subtle",icon:e(r,{}),className:j.actionIcon,onClick:e=>{e.stopPropagation(),t.onClick(n)},size:"small"});return t.tooltip?e(x,{content:U(t.tooltip),relationship:"label",children:o}):o})()]}):u()},r)})),S&&(N||W)&&e("td",{className:`${j.td} ${j.actionsColumn}`,children:t("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[N&&e(c,{appearance:"subtle",icon:e(g,{}),className:j.editButton,onClick:()=>N(n,o),title:U("Edit")}),W&&e(c,{appearance:"subtle",icon:e(y,{}),className:j.editButton,onClick:()=>W(n,o),title:U("Delete")})]})})]},re(n,o))})),ee<Q.length&&e("tr",{style:{height:ne-ie-49*te.length+"px"},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})})]})]})}),e(p,{open:L,onOpenChange:(e,t)=>H(t.open),children:e(h,{children:t(u,{children:[e(m,{children:E.title}),e(f,{className:j.dialogContent,children:E.text})]})})})]}):e("div",{className:j.emptyState,children:U("No data to display")})};var N=i.memo(S);export{S as ListView,N as default};
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import i,{useMemo as r,useState as o,useEffect as l}from"react";import{makeStyles as a,Button as c,Checkbox as d,Select as s,Dialog as p,DialogSurface as h,DialogBody as u,DialogTitle as m,DialogContent as f,Tooltip as x}from"@fluentui/react-components";import{Edit24Regular as g,Delete24Regular as y}from"@fluentui/react-icons";import{CodicentService as b}from"../services/codicent.js";import w from"../hooks/useLocalization.js";const k=a({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),C=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},v=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},S=({data:i,columns:a,canEdit:S,onEdit:N,onDelete:W,onToggleCheckbox:$,onEnumChange:I,onFilteredDataChange:A})=>{const j=k(),{visibleColumns:O,defaultSortIndex:M,defaultSortDirection:T}=r((()=>{const e=i&&i.length>0?Array.from(new Set(i.flatMap((e=>Object.keys(e))))):[],t=(a||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[i,a]),[D,F]=o(M>=0?M:null),[B,z]=o(T),[L,H]=o(!1),[E,Y]=o({title:"",text:""}),[P,R]=o({}),[_,J]=o(0),{t:U}=w(),X=e=>e.title?U(e.title):Array.isArray(e.key)?e.key[0]:e.key,q=e=>{const t=[];return e.hideOnMobile&&t.push(j.hideOnMobile),t.join(" ")},G=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),K=r((()=>{const e=[...i];if(null!==D&&B){const t=O[D];e.sort(((e,n)=>{const i=v(e,t.key),r=v(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=C(i),t=C(r);if(null!==e&&null!==t)o=e-t;else{const e=i.trim().replace(/[\s\u00a0]/g,"").replace(/,/g,""),t=r.trim().replace(/[\s\u00a0]/g,"").replace(/,/g,""),n=Number(e),l=Number(t);o=""!==e&&""!==t&&isFinite(n)&&isFinite(l)?n-l:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===B?o:-o}))}return e}),[i,D,B,O]),Q=r((()=>K.filter((e=>{for(const[t,n]of Object.entries(P)){const i=parseInt(t),r=O[i],o=v(e,r.key),l=G(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[K,P,O]);l((()=>{A&&A(Q)}),[Q,A]);const V="undefined"!=typeof window?window.innerHeight-250:600,Z=Math.max(0,Math.floor(_/49)-5),ee=Math.min(Q.length,Math.ceil((_+V)/49)+5),te=Q.slice(Z,ee),ne=49*Q.length,ie=49*Z,re=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(O.slice(0,3).map((t=>String(v(e,t.key)??""))).join("-"))}`};return i&&0!==i.length?t(n,{children:[e("div",{className:j.container,onScroll:e=>{J(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:t("table",{className:j.table,children:[t("thead",{children:[t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return t("th",{className:`${j.th} ${q(n)}`.trim(),style:r,onClick:()=>(e=>{D===e?"asc"===B?z("desc"):"desc"===B&&(F(null),z(null)):(F(e),z("asc"))})(i),children:[X(n),D===i&&e("span",{className:j.sortIndicator,children:"asc"===B?"▲":"▼"})]},i)})),S&&e("th",{className:`${j.th} ${j.actionsColumn}`,style:{width:"100px"},children:U("Actions")})]}),t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return e("th",{className:q(n),style:r,children:n.filterable&&t("div",{className:j.filterWrapper,children:[e("input",{type:"text",className:j.filterInput,placeholder:U("Filter")+"...",value:P[i]||"",onChange:e=>((e,t)=>{R((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(P[i]||"").length>0&&e(c,{appearance:"subtle",className:j.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{R((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),S&&e("th",{className:j.actionsColumn})]})]}),t("tbody",{children:[Z>0&&e("tr",{style:{height:`${ie}px`},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})}),te.map(((n,i)=>{const r=n._index,o="number"==typeof r?r:Z+i;return t("tr",{className:j.tr,children:[O.map(((i,r)=>{const l=v(n,i.key),a=i.format?i.format(l):G(l),p=i.maxWidth?`${j.td} ${j.tdTruncated} ${q(i)}`.trim():`${j.td} ${q(i)}`.trim(),h=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&a.length>0&&(Y({title:X(i),text:a}),H(!0))};if("file"===i.type&&a)return e("td",{className:p,onClick:h,children:e("a",{href:b.getFileUrl(a),target:"_blank",rel:"noopener noreferrer",children:U("Download")})},r);if("checkbox"===i.type){return e("td",{className:p,children:e(d,{checked:!0===l||"true"===l||"yes"===l||"1"===l,onChange:(e,t)=>{$&&$(n,i.key,!0===t.checked,o)}})},r)}if("enum"===i.type&&i.enumOptions&&i.editable)return e("td",{className:p,children:t(s,{value:a,"aria-label":i.title?U(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,t)=>{I&&I(n,i.key,t.value,o)},style:{width:"100%"},children:[!i.enumOptions.includes(a)&&a&&e("option",{value:a,children:a}),i.enumOptions.map((t=>e("option",{value:t,children:U(t)},t)))]})},r);const u=()=>i.maxWidth&&a.length>0?e(x,{content:{children:a,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e("span",{children:a})}):a;return e("td",{className:p,onClick:h,children:i.action?t("div",{className:j.cellWithAction,children:[e("span",{className:j.cellText,children:u()}),(()=>{if(!i.action)return null;const t=i.action,r=i.action.icon,o=e(c,{appearance:"subtle",icon:e(r,{}),className:j.actionIcon,onClick:e=>{e.stopPropagation(),t.onClick(n)},size:"small"});return t.tooltip?e(x,{content:U(t.tooltip),relationship:"label",children:o}):o})()]}):u()},r)})),S&&(N||W)&&e("td",{className:`${j.td} ${j.actionsColumn}`,children:t("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[N&&e(c,{appearance:"subtle",icon:e(g,{}),className:j.editButton,onClick:()=>N(n,o),title:U("Edit")}),W&&e(c,{appearance:"subtle",icon:e(y,{}),className:j.editButton,onClick:()=>W(n,o),title:U("Delete")})]})})]},re(n,o))})),ee<Q.length&&e("tr",{style:{height:ne-ie-49*te.length+"px"},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})})]})]})}),e(p,{open:L,onOpenChange:(e,t)=>H(t.open),children:e(h,{children:t(u,{children:[e(m,{children:E.title}),e(f,{className:j.dialogContent,children:E.text})]})})})]}):e("div",{className:j.emptyState,children:U("No data to display")})};var N=i.memo(S);export{S as ListView,N as default};
@@ -1 +1 @@
1
- {"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCodicentApp.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAyB,MAAM,UAAU,CAAC;AACpG,OAAyB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAA2B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGnD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY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AAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,eAAO,MAAM,cAAc,wCAAyC,qBAAqB,KA6KlF,gBACN,CAAC"}
@@ -1 +1 @@
1
- import{useRef as e,useState as t,useCallback as n,useMemo as r,useEffect as s}from"react";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import{createAppStateMachine as o}from"../utils/appState.js";import"../_virtual/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../utils/cacheManager.js";import{useAudioRecorder as i}from"./useAudioRecorder.js";import a from"./useAuthState.js";import c from"./useRealtimeVoiceAI.js";import u from"./useTools.js";const l=({auth0:l,toolsConfig:m,authOptions:p})=>{const d=a(l,p),h=e(o(d.codicentService,(()=>{}))),[g,v]=t(),{service:A,context:f}=h.current,{nickname:k,name:w,error:j,errorType:y,selectedApp:b}=f,S=n(((e,t)=>{const n=e.get("file").name;A.uploadFile(n,e).then((e=>{A.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[A]),x=i(S),[C,T]=t(),[N,_]=t(),[I,R]=t(!1),M=r((()=>new Audio("./notification.mp3")),[]),O=n((()=>R(!0)),[]),J=u(A,T,_,M,C,O,m),B=c(A,J);s((()=>{I&&(B?.disconnectConversation(),R(!1))}),[I,B]),s((()=>{d.isAuthenticated&&d.user&&d.accessToken&&h.current.updateContext({isAuthenticated:d.isAuthenticated,user:{sub:d.user.sub,email:d.user.email},accessToken:d.accessToken})}),[d.isAuthenticated,d.user,d.accessToken]);const L=e(d.isAuthenticated);s((()=>{const e=!0===L.current,t=!0===d.isAuthenticated;e&&!t&&h.current.logout(),L.current=d.isAuthenticated}),[d.isAuthenticated]),s((()=>h.current.updateContext({nickname:d.nickname})),[d.nickname]),s((()=>{h.current.update();let e,t=h.current.getCurrentStateName();v(h.current.getCurrentStateName()),JSON.stringify(h.current.context);let n=!1;const r=s=>setInterval((()=>{const s=h.current.getCurrentStateName();if("hasAccess"===s&&!n)return console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),n=!0,clearInterval(e),void(e=r(1e3));if("hasAccess"!==s&&n)return console.log("🚨 Left stable state - switching to fast polling (200ms)"),n=!1,clearInterval(e),void(e=r(200));const o=JSON.stringify(h.current.context);h.current.update();const i=JSON.stringify(h.current.context),a=h.current.getCurrentStateName();a===t&&o===i||(v(a),t=a)}),s);return e=r(200),()=>clearInterval(e)}),[]);const U=n((e=>e.replace("{nickname}",k||"unknown").replace("{token}",encodeURIComponent(d.accessToken||"unknown")).replace("{app}",b||"unknown")),[k,d.accessToken,b]),$=n((e=>{h.current.updateContext({isAnonymous:e})}),[]),F=n((()=>h.current.isBusy()),[]);return r((()=>({audio:x,auth:d,currentStateName:g,stateMachine:h.current,service:A,context:f,state:g,nickname:k,name:w,error:j,errorType:y,fixAppUrl:U,setAnonymous:$,allStates:h.current.allStates,isBusy:F,voice:B,html:C,setHtml:T,script:N})),[g,k,w,j,y,C,N,d.isAuthenticated,d.isLoading,x.isRecording,B?.isConnected,U,$,F])};export{l as useCodicentApp};
1
+ import{useRef as e,useState as t,useCallback as n,useMemo as r,useEffect as s}from"react";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import{createAppStateMachine as o}from"../utils/appState.js";import"../_virtual/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../utils/cacheManager.js";import{useAudioRecorder as a}from"./useAudioRecorder.js";import c from"./useAuthState.js";import i from"./useRealtimeVoiceAI.js";import u from"./useTools.js";const l=({auth0:l,toolsConfig:m,authOptions:p})=>{const d=c(l,p),h=e(o(d.codicentService,(()=>{}))),[g,A]=t(),{service:k,context:v}=h.current,{nickname:f,name:w,error:j,errorType:y,selectedApp:S}=v,b=n(((e,t)=>{const n=e.get("file").name;k.uploadFile(n,e).then((e=>{k.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[k]),C=a(b),[x,N]=t(),[T,_]=t(),[I,R]=t(!1),M=r((()=>new Audio("./notification.mp3")),[]),O=n((()=>R(!0)),[]),J=u(k,N,_,M,x,O,m),B=i(k,J);s((()=>{I&&(B?.disconnectConversation(),R(!1))}),[I,B]),s((()=>{d.isAuthenticated&&d.user&&d.accessToken&&h.current.updateContext({isAuthenticated:d.isAuthenticated,user:{sub:d.user.sub,email:d.user.email},accessToken:d.accessToken})}),[d.isAuthenticated,d.user,d.accessToken]);const L=e(d.isAuthenticated);s((()=>{const e=!0===L.current,t=!0===d.isAuthenticated;e&&!t&&h.current.logout(),L.current=d.isAuthenticated}),[d.isAuthenticated]),s((()=>h.current.updateContext({nickname:d.nickname})),[d.nickname]),s((()=>{h.current.update();let e,t=h.current.getCurrentStateName();A(h.current.getCurrentStateName()),JSON.stringify(h.current.context);let n="hasAccess"===h.current.getCurrentStateName();const r=s=>setInterval((()=>{const s=h.current.getCurrentStateName();"hasAccess"!==s||n?"hasAccess"!==s&&n&&(console.log("🚨 Left stable state - switching to fast polling (200ms)"),n=!1,clearInterval(e),e=r(200)):(console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),n=!0,clearInterval(e),e=r(1e3));const o=JSON.stringify(h.current.context);h.current.update();const a=JSON.stringify(h.current.context),c=h.current.getCurrentStateName();c===t&&o===a||(A(c),t=c)}),s);return e=r(n?1e3:200),()=>clearInterval(e)}),[]);const U=n((e=>e.replace("{nickname}",f||"unknown").replace("{token}",encodeURIComponent(d.accessToken||"unknown")).replace("{app}",S||"unknown")),[f,d.accessToken,S]),$=n((e=>{h.current.updateContext({isAnonymous:e})}),[]),F=n((()=>h.current.isBusy()),[]);return r((()=>({audio:C,auth:d,currentStateName:g,stateMachine:h.current,service:k,context:v,state:g,nickname:f,name:w,error:j,errorType:y,fixAppUrl:U,setAnonymous:$,allStates:h.current.allStates,isBusy:F,voice:B,html:x,setHtml:N,script:T})),[g,f,w,j,y,x,T,d.isAuthenticated,d.isLoading,C.isRecording,B?.isConnected,U,$,F])};export{l as useCodicentApp};
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/pages/Chat.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAa3D,OAAO,EACL,gBAAgB,EAOjB,MAAM,UAAU,CAAC;AAuClB,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IACnB,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAsSA,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/pages/Chat.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAa3D,OAAO,EACL,gBAAgB,EAOjB,MAAM,UAAU,CAAC;AAuClB,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IACnB,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAuSA,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useRef as t,useState as n,useEffect as r}from"react";import{makeStyles as s}from"@fluentui/react-components";import{useNavigate as i,useSearchParams as a}from"react-router-dom";import{CalendarWeekStart24Regular as m}from"@fluentui/react-icons";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/CompoundButton.js";import"../components/Spinner.js";import p from"../components/TextHeader.js";import c from"../components/TypingIndicator.js";import l from"../components/Prompt.js";import d from"../components/ChatInput.js";import{CombinedPlaceholderDialog as h}from"../components/CombinedPlaceholderDialog.js";import g from"../components/ChatMessage.js";import"../components/Header.js";import u from"../hooks/useStateWithLocalStorage.js";import{CodicentService as j}from"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as f}from"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"./AppFrame.js";import"./Compose.js";import"./Snap.js";import"./Search.js";import"./Login.js";import"./CrmPage.js";import"./CrmPagePersistent.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"./Purchase.js";import"../components/Content.js";import{Page as b}from"../components/Page.js";import"./QrScan.js";import C from"../hooks/useLocalization.js";import"../components/FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import{useChat as x}from"../hooks/useChat.js";import{useTemplateVariables as w}from"../hooks/useTemplateVariables.js";import"../hooks/useAppStyles.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/DataMessagePicker.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/QrCodeDialog.js";import"../components/QrScanner.js";import"../components/OfflineMessage.js";import"../components/LanguageSelector.js";import"../components/ListView.js";import"../components/RecordModal.js";import"../components/BulkUploadDialog.js";import"../components/CookieBanner.js";const S=s({chatContainer:{width:"100%",flex:1,maxWidth:"1600px",height:"100%",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},"@media (max-width: 480px)":{},backgroundPosition:"calc(50%) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",touchAction:"pan-y"},chatMessages:{display:"flex",flexDirection:"column",flex:1,padding:"16px",overflowY:"auto",touchAction:"pan-y"}}),v=({state:s,hideFooter:v,codicent:y,title:k,welcomeMessage:P})=>{const F=S(),{t:T,tAsync:I,getLanguageInfo:_}=C(),A=i(),M=t(null),[L,H]=a(),V=L.get("codicent"),B=V||y,{messages:R,isBotTyping:N,handleSend:U,newChat:D,openChat:O}=x(s.stateMachine,B||void 0),[W,E]=n(null),[z,Q]=n(!1),[G,Y]=n(!1),{service:$,currentStateName:K}=s,[q,J]=n([]),[X,Z]=n([]),[ee,oe]=n(!1),[te,ne]=n(),[re,se]=u(s.context.selectedApp+"_prompts",[]),[ie,ae]=n(!1),{extractTemplateVariables:me,replaceTemplateVariables:pe,extractFilePlaceholders:ce,replaceFilePlaceholders:le,handleSelectFiles:de}=w($.uploadFile),he=t(!1),ge=t(null);r((()=>{const e=window.history.length>1,o=Boolean(document.referrer&&document.referrer!==window.location.href);Y(e||o)}),[]);r((()=>{f("SHOW_CHAT_PROMPTS")&&0===R.length&&s.service.getAppPrompts().then(se).catch((e=>{console.error("Failed to get prompts",e)}))}),[s.service,se,R.length]),r((()=>{setTimeout((()=>{M.current?.scrollIntoView({behavior:"smooth"})}),10)}),[R]),r((()=>{if(he.current)return;he.current=!0;const e=L.get("text"),o=L.get("id"),t=L.get("fid");if(V){console.log("Using temporary codicent from URL param:",V);const e=new URLSearchParams(L);e.delete("codicent"),H(e,{replace:!0})}if(e){(async()=>{const o=ce(e),t=me(e);D(),o.length>0||t.length>0?(Z(o),J(t),oe(!0),E(T(e))):E(T(e))})()}else o?O(o):t&&ne(t)}),[]),r((()=>{te&&"anonymous"===K&&ge.current!==te&&(ge.current=te,$.getFormById(te).then((async e=>{D();const o=_().language,t=e.prompt.replace("{{fid}}",te).replace("{{fname}}",e.name).replace("{{language}}",o);ae(!0);const n=await I(t);ae(!1),E(n),Y(!1)})))}),[te,D,$,E,K,I,_,ae]),r((()=>{if(W&&!ee){let e=W;X.length>0&&(e=le(e,X)),q.length>0&&(e=pe(e,q)),U(e),H({},{replace:!0}),E(null),J([]),Z([])}}),[W,ee,U,H,le,pe,X,q]);const ue=e=>{const o=L.get("append");o&&(e+="\n---\n"+o),U(e)};return e(b,{hideHeader:!0,hideFooter:!!te||v,children:[e("div",{id:"chat-container",className:F.chatContainer,style:{backgroundImage:`url(${f("CHAT_BACKGROUND_IMAGE_URL")})`},children:[G&&o("button",{onClick:()=>{G&&A(-1)},"aria-label":T("Tillbaka"),style:{position:"absolute",top:12,left:12,zIndex:100,background:"var(--colorNeutralBackground1)",border:"none",cursor:"pointer",padding:8,borderRadius:8,boxShadow:"0 2px 8px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",justifyContent:"center"},children:o(m,{style:{transform:"rotate(180deg)"}})}),o("div",{style:{marginLeft:G?40:0},children:o(p,{title:k||T(f("APP_CHAT_TITLE")||"Chatt"),onNewChat:te?void 0:()=>Q(!0)})}),e("div",{className:F.chatMessages,children:[P&&o(g,{sender:"bot",content:P}),f("SHOW_CHAT_PROMPTS")&&re.length>0&&0===R.length&&o(g,{sender:"bot",content:T(f("CHAT_WELCOME")||T("Välkommen!")),children:re.map(((t,n)=>e("div",{children:["> ",o("a",{href:"./#/chat",onClick:()=>{ue(t.title+"\n---\n"+t.prompt)},children:T(t.title)}),o("br",{})]},`prompt-${n}`)))}),R.map(((t,n)=>e("div",{children:[(N&&n===R.length-1||!N&&n===R.length-2)&&o("div",{ref:M}),o(g,{sender:t.sender,content:t.content,isNew:t.isNew,showSuggestions:n===R.length-1,onSuggestionClicked:U},t.id)]},t.id))),ie&&o(g,{sender:"user",content:T("Översätter...")}),N&&o(c,{})]}),o(d,{codicent:B||s.context.selectedApp,disableSend:N,onSend:ue,onSelectFiles:de,getImageUrl:j.getImageUrl,getFileInfo:e=>$.getFileInfo(e)})]}),o(l,{open:z,title:T("Vill du rensa chatten?"),content:T("En ny startas, men chatten kommer först sparas."),onYes:()=>{Q(!1),D()},onNo:()=>Q(!1)}),o(h,{open:ee,templateVariables:q,filePlaceholders:X,onTemplateVariablesChange:J,onFilePlaceholdersChange:Z,onConfirm:()=>oe(!1),onCancel:()=>{oe(!1),E(null),J([]),Z([])},uploadFile:$.uploadFile})]})};export{v as default};
1
+ import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useRef as t,useState as n,useEffect as r}from"react";import{makeStyles as s}from"@fluentui/react-components";import{useNavigate as i,useSearchParams as a}from"react-router-dom";import{CalendarWeekStart24Regular as m}from"@fluentui/react-icons";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/CompoundButton.js";import"../components/Spinner.js";import p from"../components/TextHeader.js";import c from"../components/TypingIndicator.js";import l from"../components/Prompt.js";import d from"../components/ChatInput.js";import{CombinedPlaceholderDialog as h}from"../components/CombinedPlaceholderDialog.js";import g from"../components/ChatMessage.js";import"../components/Header.js";import u from"../hooks/useStateWithLocalStorage.js";import{CodicentService as j}from"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as f}from"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"./AppFrame.js";import"./Compose.js";import"./Snap.js";import"./Search.js";import"./Login.js";import"./CrmPage.js";import"./CrmPagePersistent.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"./Purchase.js";import"../components/Content.js";import{Page as b}from"../components/Page.js";import"./QrScan.js";import C from"../hooks/useLocalization.js";import"../components/FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import{useChat as x}from"../hooks/useChat.js";import{useTemplateVariables as w}from"../hooks/useTemplateVariables.js";import"../hooks/useAppStyles.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/DataMessagePicker.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/QrCodeDialog.js";import"../components/QrScanner.js";import"../components/OfflineMessage.js";import"../components/LanguageSelector.js";import"../components/ListView.js";import"../components/RecordModal.js";import"../components/BulkUploadDialog.js";import"../components/CookieBanner.js";const S=s({chatContainer:{width:"100%",flex:1,maxWidth:"1600px",height:"100%",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden","@media (max-width: 768px)":{maxWidth:"100%",borderRadius:"0"},"@media (max-width: 480px)":{},backgroundPosition:"calc(50%) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",touchAction:"pan-y"},chatMessages:{display:"flex",flexDirection:"column",flex:1,padding:"16px",overflowY:"auto",touchAction:"pan-y"}}),v=({state:s,hideFooter:v,codicent:y,title:k,welcomeMessage:P})=>{const F=S(),{t:T,tAsync:I,getLanguageInfo:_}=C(),A=i(),M=t(null),[L,H]=a(),[V]=n((()=>L.get("codicent"))),B=V||y,{messages:R,isBotTyping:N,handleSend:U,newChat:D,openChat:O}=x(s.stateMachine,B||void 0),[W,E]=n(null),[z,Q]=n(!1),[G,Y]=n(!1),{service:$,currentStateName:K}=s,[q,J]=n([]),[X,Z]=n([]),[ee,oe]=n(!1),[te,ne]=n(),[re,se]=u(s.context.selectedApp+"_prompts",[]),[ie,ae]=n(!1),{extractTemplateVariables:me,replaceTemplateVariables:pe,extractFilePlaceholders:ce,replaceFilePlaceholders:le,handleSelectFiles:de}=w($.uploadFile),he=t(!1),ge=t(null);r((()=>{const e=window.history.length>1,o=Boolean(document.referrer&&document.referrer!==window.location.href);Y(e||o)}),[]);r((()=>{f("SHOW_CHAT_PROMPTS")&&0===R.length&&s.service.getAppPrompts().then(se).catch((e=>{console.error("Failed to get prompts",e)}))}),[s.service,se,R.length]),r((()=>{setTimeout((()=>{M.current?.scrollIntoView({behavior:"smooth"})}),10)}),[R]),r((()=>{if(he.current)return;he.current=!0;const e=L.get("text"),o=L.get("id"),t=L.get("fid");if(V){console.log("Using temporary codicent from URL param:",V);const e=new URLSearchParams(L);e.delete("codicent"),H(e,{replace:!0})}if(e){(async()=>{const o=ce(e),t=me(e);D(),o.length>0||t.length>0?(Z(o),J(t),oe(!0),E(T(e))):E(T(e))})()}else o?O(o):t&&ne(t)}),[]),r((()=>{te&&"anonymous"===K&&ge.current!==te&&(ge.current=te,$.getFormById(te).then((async e=>{D();const o=_().language,t=e.prompt.replace("{{fid}}",te).replace("{{fname}}",e.name).replace("{{language}}",o);ae(!0);const n=await I(t);ae(!1),E(n),Y(!1)})))}),[te,D,$,E,K,I,_,ae]),r((()=>{if(W&&!ee){let e=W;X.length>0&&(e=le(e,X)),q.length>0&&(e=pe(e,q)),U(e),H({},{replace:!0}),E(null),J([]),Z([])}}),[W,ee,U,H,le,pe,X,q]);const ue=e=>{const o=L.get("append");o&&(e+="\n---\n"+o),U(e)};return e(b,{hideHeader:!0,hideFooter:!!te||v,children:[e("div",{id:"chat-container",className:F.chatContainer,style:{backgroundImage:`url(${f("CHAT_BACKGROUND_IMAGE_URL")})`},children:[G&&o("button",{onClick:()=>{G&&A(-1)},"aria-label":T("Tillbaka"),style:{position:"absolute",top:12,left:12,zIndex:100,background:"var(--colorNeutralBackground1)",border:"none",cursor:"pointer",padding:8,borderRadius:8,boxShadow:"0 2px 8px rgba(0,0,0,0.08)",display:"flex",alignItems:"center",justifyContent:"center"},children:o(m,{style:{transform:"rotate(180deg)"}})}),o("div",{style:{marginLeft:G?40:0},children:o(p,{title:k||T(f("APP_CHAT_TITLE")||"Chatt"),onNewChat:te?void 0:()=>Q(!0)})}),e("div",{className:F.chatMessages,children:[P&&o(g,{sender:"bot",content:P}),f("SHOW_CHAT_PROMPTS")&&re.length>0&&0===R.length&&o(g,{sender:"bot",content:T(f("CHAT_WELCOME")||T("Välkommen!")),children:re.map(((t,n)=>e("div",{children:["> ",o("a",{href:"./#/chat",onClick:()=>{ue(t.title+"\n---\n"+t.prompt)},children:T(t.title)}),o("br",{})]},`prompt-${n}`)))}),R.map(((t,n)=>e("div",{children:[(N&&n===R.length-1||!N&&n===R.length-2)&&o("div",{ref:M}),o(g,{sender:t.sender,content:t.content,isNew:t.isNew,showSuggestions:n===R.length-1,onSuggestionClicked:U},t.id)]},t.id))),ie&&o(g,{sender:"user",content:T("Översätter...")}),N&&o(c,{})]}),o(d,{codicent:B||s.context.selectedApp,disableSend:N,onSend:ue,onSelectFiles:de,getImageUrl:j.getImageUrl,getFileInfo:e=>$.getFileInfo(e)})]}),o(l,{open:z,title:T("Vill du rensa chatten?"),content:T("En ny startas, men chatten kommer först sparas."),onYes:()=>{Q(!1),D()},onNo:()=>Q(!1)}),o(h,{open:ee,templateVariables:q,filePlaceholders:X,onTemplateVariablesChange:J,onFilePlaceholdersChange:Z,onConfirm:()=>oe(!1),onCancel:()=>{oe(!1),E(null),J([]),Z([])},uploadFile:$.uploadFile})]})};export{v as default};
@@ -1 +1 @@
1
- {"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,UAAU,QAAS,MAAM,SAgBrC,CAAC;AAEF,eAAO,MAAM,cAAc,SAAU,MAAM,SAU1C,CAAC;AA+BF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACp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,CAAC;IAoBpE;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,SACd,MAAM,kBACI,MAAM,YACb,MAAM,KACd,OAAO,CAAC,mBAAmB,CAAC,CA0B7B;CACH"}
@@ -1 +1 @@
1
- import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";var o;let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-";const i=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,r=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},c=t=>{t&&"string"==typeof t&&(a=t,i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a}))},h=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:n,signalRHost:a}),!0);let d=h();if(!d){const t=setInterval((()=>{d=h(),d&&clearInterval(t)}),100)}class l{constructor(o){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,n,a,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const o=await e.text();return JSON.parse(o)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const o=new e(t.content).content.split("\n"),n=o[0],a=o.slice(1).join("\n");return{id:t.id,title:n,content:a}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const o=await fetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0,s,i=0)=>{const r=await this.request(`${n}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,o,s)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,o,a)=>{const s=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,i=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const a=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const s=await fetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const o=await fetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})},this.getToken=()=>s,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),o&&o>0&&(a.trialPeriodDays=o);const s=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.request(`${n}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=o,r(o.API_BASE_URL),o.PUBSUB_URL&&c(o.PUBSUB_URL)}async request(t,e,o={}){const n={};o.headers&&o.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...o,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${n}realtime/session?voice=${t}&provider=${e}`,a=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}o=l,l.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,l.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,l.downloadFile=async t=>{fetch(o.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const o=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=o,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},l.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let a={project:e,message:t};o&&(a.messageId=o);const i=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(a)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},l.getMiniChatReply=async(t,e="codicent-mini",o,a=3e5,i=2e3,r)=>{const c={project:e,message:t};let h;o&&(c.messageId=o),r&&(c.previousResponseId=r);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(c)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(h=(await t.json()).promptMessageId,!h)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const d=Date.now();for(;Date.now()-d<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json(),a=o.content??o.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:o.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},l.getTranslations=async(t,e,o="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${s}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()};export{l as CodicentService,r as setBaseUrl,c as setSignalRHost};
1
+ import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";var o;let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-";const i=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,r=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},c=t=>{t&&"string"==typeof t&&(a=t,i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a}))},h=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:n,signalRHost:a}),!0);let d=h();if(!d){const t=setInterval((()=>{d=h(),d&&clearInterval(t)}),100)}class l{constructor(o){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,n,a,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const o=await e.text();return JSON.parse(o)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>[...(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const o=new e(t.content).content.split("\n"),n=o[0],a=o.slice(1).join("\n");return{id:t.id,title:n,content:a}})),...(await window.Codicent.getDataMessages({tags:["skill"],codicent:this.codicent})).map((t=>t.data)).filter((t=>t.name&&t.title)).map((t=>({id:t.name,title:t.title,content:t.content||t.description||""})))],this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const o=await fetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0,s,i=0)=>{const r=await this.request(`${n}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,o,s)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,o,a)=>{const s=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,i=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const a=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const s=await fetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const o=await fetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})},this.getToken=()=>s,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),o&&o>0&&(a.trialPeriodDays=o);const s=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.request(`${n}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=o,r(o.API_BASE_URL),o.PUBSUB_URL&&c(o.PUBSUB_URL)}async request(t,e,o={}){const n={};o.headers&&o.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...o,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${n}realtime/session?voice=${t}&provider=${e}`,a=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}o=l,l.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,l.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,l.downloadFile=async t=>{fetch(o.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const o=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=o,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},l.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let a={project:e,message:t};o&&(a.messageId=o);const i=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(a)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},l.getMiniChatReply=async(t,e="codicent-mini",o,a=3e5,i=2e3,r)=>{const c={project:e,message:t};let h;o&&(c.messageId=o),r&&(c.previousResponseId=r);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(c)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(h=(await t.json()).promptMessageId,!h)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const d=Date.now();for(;Date.now()-d<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json(),a=o.content??o.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:o.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},l.getTranslations=async(t,e,o="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${s}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()};export{l as CodicentService,r as setBaseUrl,c as setSignalRHost};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codicent-app-sdk",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "SDK for building AI-powered applications with Codicent",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",