@e-llm-studio/instant-learning 1.3.0-alpha.3 → 1.3.0-alpha.6
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.
- package/dist/cjs/features/LearningManagement/AuditLog/AuditLog.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/features/LearningManagement/AuditLog/AuditLog.js +1 -1
- package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/types/src/features/LearningManagement/AuditLog/AuditLog.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useMemo as o,useEffect as n}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,FileText as a,ExternalLink as d}from"lucide-react";var c=function(c){var s=c.configId,h=c.ruleData,p=c.scopeId,g=c.scopeName,u=(null==g?void 0:g.trim())||"Selected",m=o(function(){var e=[];return p&&e.push(p),e},[h,p]);return n(function(){console.log("Flattened External Resource IDs:",m)},[m]),t("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[t("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:[u," - Audit Log"]})),t("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:["Track all learning updates and modifications with the ",u," scope."]}))]})),i(r,{configId:s,getData:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/distinct-values"},query:{externalResourceId:m.length>0?m:[""],paginationLimit:10},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(o){return t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i(l,{size:16,color:"#64748b",style:{flexShrink:0}}),i("span",e({style:{fontWeight:500}},{children:o.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(t){var o,n,r=(o=t.changeTitle,(n=(o||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),l=t.changeTitle?t.changeTitle.replace(/_/g," "):"—";return i("span",e({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:l}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(o){var n;return t("div",e({style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"4px 0"}},{children:[i(a,{size:16,color:"#94a3b8",style:{flexShrink:0,marginTop:"2px"}}),i("span",e({style:{color:"#334155",fontSize:"13px",lineHeight:1.5}},{children:null!==(n=o.actionText)&&void 0!==n?n:"—"}))]}))},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(o){var n,r=(null===(n=o.metadata)||void 0===n?void 0:n.redirect_url)||o.redirect_url;return r?i("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t("a",e({href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",i(d,{size:14})]}))})):i("span",e({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(o){if(!o.actionDate)return i("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(o.actionDate),r=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),l=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[i("span",e({style:{fontWeight:500}},{children:r})),i("span",{children:l})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}})]}))};export{c as default};
|
|
2
2
|
//# sourceMappingURL=AuditLog.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as n,__spreadArray as t,__assign as r}from"tslib";import{jsxs as o,Fragment as i,jsx as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as y}from"primereact/toast";import T from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import b from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as S}from"../utils/treeUtils.js";import I from"../styles/LearningContent.module.css.js";import R from"../components/ConfirmationModal.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as _}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import"../LearningManagement.js";import j from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";var k=function(k){var L,O=k.noRulesTitle,D=void 0===O?"No rules have been added !":O,M=k.noRulesDesc,x=void 0===M?"Start by adding rules that should apply across all stations.":M,N=k.noRulesButtonText,A=void 0===N?"Create New Rule":N,E=k.deleteRuleSuccessMessage,F=void 0===E?"Rule deleted successfully!":E,V=k.deleteVariantSuccessMessage,P=void 0===V?"Variant deleted successfully!":V,J=k.deleteRuleErrorMessage,U=void 0===J?"Failed to delete rule. Please try again.":J,B=k.deleteVariantErrorMessage,W=void 0===B?"Failed to delete variant. Please try again.":B,G=k.deleteModalTitle,q=void 0===G?"Delete":G,H=k.deleteRuleModalWarning,$=void 0===H?"This will permanently delete the rule configuration.":H,z=k.deleteVariantModalWarning,K=void 0===z?"This will permanently delete the variant configuration.":z,Q=k.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=k.onRefreshRuleSets,Z=k.app_integration_id,ee=k.token,ne=c(function(e){return e.selectedRuleSetId}),te=c(function(e){return e.scopeTreeData}),re=c(function(e){return e.sidebarTab}),oe=c(function(e){return e.setInitialRules}),ie=c(function(e){return e.currentRules}),le=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var ae=c(function(e){return e.resetCreatedVariantInfo}),se=c(function(e){return e.isILModalTriggered}),ue=c(function(e){return e.setIsILModalTriggered}),ce=a(null),de=s(!1),pe=de[0],me=de[1],fe=s(null),ve=fe[0],ge=fe[1],he=s(null),ye=he[0],Te=he[1],we=s(null),be=we[0],Ce=we[1],Se=s(null),Ie=Se[0],Re=Se[1],_e=s(!1),je=_e[0],ke=_e[1],Le=s(null),Oe=Le[0],De=Le[1],Me=s(!1),xe=Me[0],Ne=Me[1],Ae=s(""),Ee=Ae[0],Fe=Ae[1],Ve=s(null),Pe=Ve[0],Je=Ve[1],Ue=s(!1),Be=Ue[0],We=Ue[1],Ge=s(!1),qe=Ge[0],He=Ge[1],$e=s("ruleDeletion"),ze=$e[0],Ke=$e[1],Qe=s(null),Xe=Qe[0],Ye=Qe[1],Ze=s(!1),en=Ze[0],nn=Ze[1],tn=s(!1),rn=tn[0],on=tn[1],ln=c.getState().tiers,an=s(null),sn=an[0],un=an[1],cn=s(null),dn=cn[0],pn=cn[1],mn=s(null),fn=mn[0],vn=mn[1],gn=function(){ge(null),Te(null),me(!0),Re(0)},hn=function(){me(!1),ue(!1),ge(null),Te(null),Ce(null),Re(null),He(!1),on(!1),yn(),un(null),pn(null),vn(null),Y&&Y(!1,ne||void 0)};u(function(){yn()},[ne,oe]),u(function(){se&&me(!0)},[se]);var yn=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,y,T,w,b,C,S,I;return n(this,function(n){switch(n.label){case 0:if(!ne)return oe([]),[2];o||ke(!0),De(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,p(ne,ee)];case 2:return e=n.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(le(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?t([],i.tiers,!0).sort(function(e,n){var t,r;return(null!==(t=e.tier_priority)&&void 0!==t?t:0)-(null!==(r=n.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var n=e[0],t=e[1];return!l.has(n)&&Array.isArray(t)}),s=a.map(function(e){var n=e[1];return new Set(n.flatMap(function(e){var n,t;return null!==(t=null===(n=e.variants)||void 0===n?void 0:n.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==t?t:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,n){var t;return e[n]=(null!==(t=e[n])&&void 0!==t?t:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var n;return r(r({},e),{variants:null===(n=e.variants)||void 0===n?void 0:n.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,n){var t,r=e[0],o=e[1],i=ln.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(t=null==i?void 0:i.tier_id)&&void 0!==t?t:String(n+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===n?"These are the system-wide learnings applied across all stations.":"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===n,rules:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,n){return[e[0],String(n+1)]})),y=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),T=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||y.has(e.id)})}),oe(T),(w=null===(I=null===(S=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===S?void 0:S[0])||void 0===I?void 0:I.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ae()},1e4)},500):ae()):oe(v),[3,5]):(oe([]),[2]);case 3:return b=n.sent(),console.error("Failed to fetch rule details",b),404!==(null==b?void 0:b.status)&&De((null==b?void 0:b.message)||"Failed to load rules. Please try again."),oe([]),[3,5];case 4:return o||ke(!1),[7];case 5:return[2]}})})},Tn=ne?S((null==te?void 0:te.data)||null,ne):null,wn=Tn?{ruleSetId:Tn.id,ruleSetName:Tn.name,ruleSetDesc:"",ruleCount:null===(L=null==Tn?void 0:Tn.metrics)||void 0===L?void 0:L.learningsCount}:void 0,bn=function(){if("stations"===re)return"custom";if(!Tn)return"global";switch(Tn.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Cn=function(e){if(!e)return l("p",{children:"Are you sure you want to delete this rule? This action cannot be undone."});var n=null==ie?void 0:ie.flatMap(function(e){var n;return null!==(n=e.rules)&&void 0!==n?n:[]}).find(function(n){return n.ruleId===e});return o("p",{children:["Are you sure you want to delete"," ",l("span",r({className:I.semibold},{children:null==n?void 0:n.ruleTitle}))," rule? This action cannot be undone."]})},Sn={editingRule:ve,editingTier:ye,editingVariants:be,focusedVariantIndex:Ie,setFocusedVariantIndex:Re,triggerAddVariant:qe,triggerFixGaps:rn,copiedRule:sn,copiedSourceTier:dn,copiedTargetTier:fn,initialDraftMessage:Ee,app_integration_id:Z,modeId:"019dde79-0494-78d7-ba5b-54a35d20f0fc"};return o(i,wn?{children:[l(y,{ref:ce}),l("div",r({className:I.container},{children:je?l(h,{}):Oe?l(w,{errorMessage:Oe,onRetry:yn}):l(T,{onAddRule:gn,onDeleteRule:function(e){Je(e)},onEditRule:function(e,n){ge(e),Te(n||null),Ce(e.variants||null),Re(null),He(!0),me(!0)},onEditVariant:function(e,n,t,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ie?void 0:ie.find(function(e){return e.name===t}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===n}))&&void 0!==l?l:null==ie?void 0:ie.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===n});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(n){return n.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;ge(s),Te(t||null),Ce(s.variants||null),Re(c),me(!0),"resolve_gaps"===r&&on(!0)}},onDeleteVariant:function(e,n){Ye({variantId:e,ruleId:n})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,t,r,o,i,a,s;return n(this,function(n){switch(n.label){case 0:if(!ne)return[2];Ne(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,m(ne)];case 2:return e=n.sent(),t=window.URL.createObjectURL(e),(r=document.createElement("a")).href=t,o=(null==wn?void 0:wn.ruleSetName)?"".concat(wn.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ne,".csv"),r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(t),null===(a=ce.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:l(b,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return i=n.sent(),console.error("Export error:",i),null===(s=ce.current)||void 0===s||s.show({severity:"error",sticky:!1,className:I.errorToast,content:l(C,{message:i.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ne(!1),[7];case 5:return[2]}})})},isExporting:xe,onToggleSuccess:function(){return yn(!0)},onReorderRules:function(t,r,o,i,a){return e(void 0,void 0,void 0,function(){var e,s,u;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,g(t,r,o,i,a)];case 1:return n.sent(),yn(!0),null===(s=ce.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:l(b,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=n.sent(),console.error("Failed to reorder rules:",e),yn(!0),null===(u=ce.current)||void 0===u||u.show({severity:"error",sticky:!1,className:I.errorToast,content:l(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:Y,setDeleteConfirmationUsedFor:Ke,onCopyToTier:function(e,n,t,r,o){var i,l,a=null===(l=null===(i=null==ie?void 0:ie.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===n});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(t),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");Fe(s),un(a),pn(r),vn(o),ge(null),Te(null),Ce(null),Re(null),me(!0)}}})})),pe&&l(_,{children:l(j,{isOpen:pe,onClose:hn,app_integration_id:Z,token:ee,mode:"ADD",pluginPayload:r(r({},Sn),{initialScope:bn(),ruleSet:wn})})}),l(R,{isOpen:!!Pe,title:q,description:Cn(Pe),warning:$,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,t,r,o,i;return n(this,function(n){switch(n.label){case 0:if(!Pe)return[2];We(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,f(Pe)];case 2:return n.sent(),Je(null),null===(t=ce.current)||void 0===t||t.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:l(b,{message:F})}),yn(),Y&&Y(!1,ne||void 0),[3,5];case 3:return e=n.sent(),console.error("Failed to delete rule",e),null===(r=ce.current)||void 0===r||r.show({severity:"error",sticky:!1,className:I.errorToast,content:l(C,{message:(null===(i=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===i?void 0:i.detail)||U})}),[3,5];case 4:return We(!1),[7];case 5:return[2]}})})},onCancel:function(){return Je(null)},isLoading:Be}),l(R,{isOpen:!!Xe,title:q,description:"variantDeletion"===ze?l("span",{children:"Are you sure you want to delete this variant? This action cannot be undone."}):Cn((null==Xe?void 0:Xe.ruleId)||null),warning:"ruleDeletion"===ze?$:K,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,t,r,o,i;return n(this,function(n){switch(n.label){case 0:if(!Xe)return[2];nn(!0),n.label=1;case 1:return n.trys.push([1,6,7,8]),"ruleDeletion"!==ze?[3,3]:[4,v(Xe.ruleId)];case 2:return n.sent(),[3,5];case 3:return[4,f(Xe.variantId)];case 4:n.sent(),n.label=5;case 5:return Ye(null),null===(t=ce.current)||void 0===t||t.show({severity:"success",sticky:!1,life:3e3,className:I.successToast,content:l(b,{message:"ruleDeletion"===ze?F:P})}),yn(),Y&&Y(!1,ne||void 0),[3,8];case 6:return e=n.sent(),console.error("Failed to delete variant",e),null===(r=ce.current)||void 0===r||r.show({severity:"error",sticky:!1,className:I.errorToast,content:l(C,{message:(null===(i=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===i?void 0:i.detail)||("ruleDeletion"===ze?U:W)})}),[3,8];case 7:return nn(!1),[7];case 8:return[2]}})})},onCancel:function(){return Ye(null)},isLoading:en})]}:{children:[l(d,{onCreate:gn,title:D,desc:x,button:A}),pe&&l(_,{children:l(j,{isOpen:pe,onClose:hn,app_integration_id:Z,token:ee,mode:"ADD",pluginPayload:r(r({},Sn),{initialScope:bn(),ruleSet:wn})})})]})};export{k as default};
|
|
1
|
+
import{__awaiter as e,__generator as n,__spreadArray as t,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as y}from"primereact/toast";import T from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import b from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as R}from"../utils/treeUtils.js";import S from"../styles/LearningContent.module.css.js";import I from"../components/ConfirmationModal.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as _}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import"../LearningManagement.js";import j from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";var k=function(k){var L,O=k.noRulesTitle,D=void 0===O?"No rules have been added !":O,M=k.noRulesDesc,x=void 0===M?"Start by adding rules that should apply across all stations.":M,N=k.noRulesButtonText,A=void 0===N?"Create New Rule":N,E=k.deleteRuleSuccessMessage,F=void 0===E?"Rule deleted successfully!":E,V=k.deleteVariantSuccessMessage,P=void 0===V?"Variant deleted successfully!":V,B=k.deleteRuleErrorMessage,J=void 0===B?"Failed to delete rule. Please try again.":B,U=k.deleteVariantErrorMessage,W=void 0===U?"Failed to delete variant. Please try again.":U,G=k.deleteModalTitle,q=void 0===G?"Delete":G,H=k.deleteRuleModalWarning,$=void 0===H?"This will permanently delete the rule configuration.":H,z=k.deleteVariantModalWarning,K=void 0===z?"This will permanently delete the variant configuration.":z,Q=k.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=k.onRefreshRuleSets,Z=k.app_integration_id,ee=k.token,ne=c(function(e){return e.selectedRuleSetId}),te=c(function(e){return e.scopeTreeData}),re=c(function(e){return e.sidebarTab}),oe=c(function(e){return e.setInitialRules}),ie=c(function(e){return e.currentRules}),le=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var ae=c(function(e){return e.resetCreatedVariantInfo}),se=c(function(e){return e.isILModalTriggered}),ue=c(function(e){return e.setIsILModalTriggered}),ce=a(null),de=s(!1),pe=de[0],me=de[1],fe=s(null),ve=fe[0],ge=fe[1],he=s(null),ye=he[0],Te=he[1],we=s(null),be=we[0],Ce=we[1],Re=s(null),Se=Re[0],Ie=Re[1],_e=s(!1),je=_e[0],ke=_e[1],Le=s(null),Oe=Le[0],De=Le[1],Me=s(!1),xe=Me[0],Ne=Me[1],Ae=s(""),Ee=Ae[0],Fe=Ae[1],Ve=s(null),Pe=Ve[0],Be=Ve[1],Je=s(!1),Ue=Je[0],We=Je[1],Ge=s(!1),qe=Ge[0],He=Ge[1],$e=s("ruleDeletion"),ze=$e[0],Ke=$e[1],Qe=s(null),Xe=Qe[0],Ye=Qe[1],Ze=s(!1),en=Ze[0],nn=Ze[1],tn=s(!1),rn=tn[0],on=tn[1],ln=c.getState().tiers,an=s(null),sn=an[0],un=an[1],cn=s(null),dn=cn[0],pn=cn[1],mn=s(null),fn=mn[0],vn=mn[1],gn=function(){ge(null),Te(null),me(!0),Ie(0)},hn=function(){me(!1),ue(!1),ge(null),Te(null),Ce(null),Ie(null),He(!1),on(!1),yn(),un(null),pn(null),vn(null),Y&&Y(!1,ne||void 0)};u(function(){yn()},[ne,oe]),u(function(){se&&me(!0)},[se]);var yn=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,y,T,w,b,C,R,S;return n(this,function(n){switch(n.label){case 0:if(!ne)return oe([]),[2];o||ke(!0),De(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,p(ne,ee)];case 2:return e=n.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(le(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?t([],i.tiers,!0).sort(function(e,n){var t,r;return(null!==(t=e.tier_priority)&&void 0!==t?t:0)-(null!==(r=n.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var n=e[0],t=e[1];return!l.has(n)&&Array.isArray(t)}),s=a.map(function(e){var n=e[1];return new Set(n.flatMap(function(e){var n,t;return null!==(t=null===(n=e.variants)||void 0===n?void 0:n.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==t?t:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,n){var t;return e[n]=(null!==(t=e[n])&&void 0!==t?t:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var n;return r(r({},e),{variants:null===(n=e.variants)||void 0===n?void 0:n.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,n){var t,r=e[0],o=e[1],i=ln.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(t=null==i?void 0:i.tier_id)&&void 0!==t?t:String(n+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===n?"These are the system-wide learnings applied across all stations.":"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===n,rules:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,n){return[e[0],String(n+1)]})),y=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),T=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||y.has(e.id)})}),oe(T),(w=null===(S=null===(R=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===R?void 0:R[0])||void 0===S?void 0:S.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ae()},1e4)},500):ae()):oe(v),[3,5]):(oe([]),[2]);case 3:return b=n.sent(),console.error("Failed to fetch rule details",b),404!==(null==b?void 0:b.status)&&De((null==b?void 0:b.message)||"Failed to load rules. Please try again."),oe([]),[3,5];case 4:return o||ke(!1),[7];case 5:return[2]}})})},Tn=ne?R((null==te?void 0:te.data)||null,ne):null,wn=Tn?{ruleSetId:Tn.id,ruleSetName:Tn.name,ruleSetDesc:"",ruleCount:null===(L=null==Tn?void 0:Tn.metrics)||void 0===L?void 0:L.learningsCount}:void 0,bn=Boolean(null==te?void 0:te.data),Cn=Boolean(ne&&!Tn&&bn),Rn=function(){if("stations"===re)return"custom";if(!Tn)return"global";switch(Tn.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Sn=function(e){if(!e)return o("p",{children:"Are you sure you want to delete this rule? This action cannot be undone."});var n=null==ie?void 0:ie.flatMap(function(e){var n;return null!==(n=e.rules)&&void 0!==n?n:[]}).find(function(n){return n.ruleId===e});return i("p",{children:["Are you sure you want to delete"," ",o("span",r({className:S.semibold},{children:null==n?void 0:n.ruleTitle}))," rule? This action cannot be undone."]})},In={editingRule:ve,editingTier:ye,editingVariants:be,focusedVariantIndex:Se,setFocusedVariantIndex:Ie,triggerAddVariant:qe,triggerFixGaps:rn,copiedRule:sn,copiedSourceTier:dn,copiedTargetTier:fn,initialDraftMessage:Ee,app_integration_id:Z,modeId:"019dde79-0494-78d7-ba5b-54a35d20f0fc"};return wn?i(l,{children:[o(y,{ref:ce}),o("div",r({className:S.container},{children:je?o(h,{}):Oe?o(w,{errorMessage:Oe,onRetry:yn}):o(T,{onAddRule:gn,onDeleteRule:function(e){Be(e)},onEditRule:function(e,n){ge(e),Te(n||null),Ce(e.variants||null),Ie(null),He(!0),me(!0)},onEditVariant:function(e,n,t,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ie?void 0:ie.find(function(e){return e.name===t}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===n}))&&void 0!==l?l:null==ie?void 0:ie.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===n});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(n){return n.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;ge(s),Te(t||null),Ce(s.variants||null),Ie(c),me(!0),"resolve_gaps"===r&&on(!0)}},onDeleteVariant:function(e,n){Ye({variantId:e,ruleId:n})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,t,r,i,l,a,s;return n(this,function(n){switch(n.label){case 0:if(!ne)return[2];Ne(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,m(ne)];case 2:return e=n.sent(),t=window.URL.createObjectURL(e),(r=document.createElement("a")).href=t,i=(null==wn?void 0:wn.ruleSetName)?"".concat(wn.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ne,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(t),null===(a=ce.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:o(b,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=n.sent(),console.error("Export error:",l),null===(s=ce.current)||void 0===s||s.show({severity:"error",sticky:!1,className:S.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ne(!1),[7];case 5:return[2]}})})},isExporting:xe,onToggleSuccess:function(){return yn(!0)},onReorderRules:function(t,r,i,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,g(t,r,i,l,a)];case 1:return n.sent(),yn(!0),null===(s=ce.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:o(b,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=n.sent(),console.error("Failed to reorder rules:",e),yn(!0),null===(u=ce.current)||void 0===u||u.show({severity:"error",sticky:!1,className:S.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:Y,setDeleteConfirmationUsedFor:Ke,onCopyToTier:function(e,n,t,r,o){var i,l,a=null===(l=null===(i=null==ie?void 0:ie.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===n});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(t),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");Fe(s),un(a),pn(r),vn(o),ge(null),Te(null),Ce(null),Ie(null),me(!0)}}})})),pe&&o(_,{children:o(j,{isOpen:pe,onClose:hn,app_integration_id:Z,token:ee,mode:"ADD",pluginPayload:r(r({},In),{initialScope:Rn(),ruleSet:wn})})}),o(I,{isOpen:!!Pe,title:q,description:Sn(Pe),warning:$,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,t,r,i,l;return n(this,function(n){switch(n.label){case 0:if(!Pe)return[2];We(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,f(Pe)];case 2:return n.sent(),Be(null),null===(t=ce.current)||void 0===t||t.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:o(b,{message:F})}),yn(),Y&&Y(!1,ne||void 0),[3,5];case 3:return e=n.sent(),console.error("Failed to delete rule",e),null===(r=ce.current)||void 0===r||r.show({severity:"error",sticky:!1,className:S.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||J})}),[3,5];case 4:return We(!1),[7];case 5:return[2]}})})},onCancel:function(){return Be(null)},isLoading:Ue}),o(I,{isOpen:!!Xe,title:q,description:"variantDeletion"===ze?o("span",{children:"Are you sure you want to delete this variant? This action cannot be undone."}):Sn((null==Xe?void 0:Xe.ruleId)||null),warning:"ruleDeletion"===ze?$:K,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,t,r,i,l;return n(this,function(n){switch(n.label){case 0:if(!Xe)return[2];nn(!0),n.label=1;case 1:return n.trys.push([1,6,7,8]),"ruleDeletion"!==ze?[3,3]:[4,v(Xe.ruleId)];case 2:return n.sent(),[3,5];case 3:return[4,f(Xe.variantId)];case 4:n.sent(),n.label=5;case 5:return Ye(null),null===(t=ce.current)||void 0===t||t.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:o(b,{message:"ruleDeletion"===ze?F:P})}),yn(),Y&&Y(!1,ne||void 0),[3,8];case 6:return e=n.sent(),console.error("Failed to delete variant",e),null===(r=ce.current)||void 0===r||r.show({severity:"error",sticky:!1,className:S.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===ze?J:W)})}),[3,8];case 7:return nn(!1),[7];case 8:return[2]}})})},onCancel:function(){return Ye(null)},isLoading:en})]}):Cn?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==Y?void 0:Y(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:gn,title:D,desc:x,button:A}),pe&&o(_,{children:o(j,{isOpen:pe,onClose:hn,app_integration_id:Z,token:ee,mode:"ADD",pluginPayload:r(r({},In),{initialScope:Rn(),ruleSet:wn})})})]})};export{k as default};
|
|
2
2
|
//# sourceMappingURL=RuleContent.js.map
|