@e-llm-studio/instant-learning 1.3.0-alpha.158 → 1.3.0-alpha.159

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.
Files changed (112) hide show
  1. package/dist/ContinueWithTemplateModal.js +1 -1
  2. package/dist/cjs/ContinueWithTemplateModal.js +1 -1
  3. package/dist/cjs/features/DocumentLearning/DocumentLearning.js +1 -1
  4. package/dist/cjs/features/DocumentLearning/_components/BookLearningForm.js +1 -1
  5. package/dist/cjs/features/DocumentLearning/_components/ChatComponent.js +1 -1
  6. package/dist/cjs/features/IL-OTJ/ILOTJTest.js +1 -1
  7. package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
  8. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +1 -1
  9. package/dist/cjs/features/IL-OTJ/_components/ChatComponents/NormalChat.js +1 -1
  10. package/dist/cjs/features/IL-marketplace/services/guideline.core.api.js +1 -1
  11. package/dist/cjs/features/IL-marketplace/services/instant-learning.api.js +1 -1
  12. package/dist/cjs/features/InstantLearning/_components/ChatComponent.js +1 -1
  13. package/dist/cjs/features/InstantLearning/_components/ContextualChatComponent.js +1 -1
  14. package/dist/cjs/features/InstantLearning/_components/ContextualLearningForm.js +1 -1
  15. package/dist/cjs/features/InstantLearning/_components/LearningDetailsForm.js +1 -1
  16. package/dist/cjs/features/LearningManagement/AuditLog/AuditLog.js +1 -1
  17. package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -1
  18. package/dist/cjs/features/LearningManagement/LearningManagementTest.js +1 -1
  19. package/dist/cjs/features/LearningManagement/LearningTemplateLayout.js +1 -1
  20. package/dist/cjs/features/LearningManagement/RBAC/AccessPanel.js +1 -1
  21. package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  22. package/dist/cjs/features/LearningManagement/apis/scopeApis.js +1 -1
  23. package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
  24. package/dist/cjs/features/LearningManagement/components/InstantLearningModalDynamic.js +1 -1
  25. package/dist/cjs/hooks/useAgentFix.js +1 -1
  26. package/dist/cjs/hooks/useAgentSuggestions.js +1 -1
  27. package/dist/cjs/hooks/useAgentValidation.js +1 -1
  28. package/dist/cjs/hooks/useExistingAgentCheck.js +1 -1
  29. package/dist/cjs/hooks/useExistingPromptCheck.js +1 -1
  30. package/dist/cjs/hooks/usePromptFix.js +1 -1
  31. package/dist/cjs/hooks/usePromptSuggestions.js +1 -1
  32. package/dist/cjs/hooks/usePromptValidation.js +1 -1
  33. package/dist/cjs/index.js +1 -1
  34. package/dist/cjs/service/InstantLearningService.js +1 -1
  35. package/dist/cjs/utils/agentGenieAPI.js +1 -1
  36. package/dist/cjs/utils/bookGenieAPI.js +1 -1
  37. package/dist/cjs/utils/instantLearningAPI.js +1 -1
  38. package/dist/features/DocumentLearning/DocumentLearning.js +1 -1
  39. package/dist/features/DocumentLearning/_components/BookLearningForm.js +1 -1
  40. package/dist/features/DocumentLearning/_components/ChatComponent.js +1 -1
  41. package/dist/features/IL-OTJ/ILOTJTest.js +1 -1
  42. package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
  43. package/dist/features/IL-OTJ/_components/ChatComponents/ChatComponent.js +1 -1
  44. package/dist/features/IL-OTJ/_components/ChatComponents/NormalChat.js +1 -1
  45. package/dist/features/IL-marketplace/services/guideline.core.api.js +1 -1
  46. package/dist/features/IL-marketplace/services/instant-learning.api.js +1 -1
  47. package/dist/features/InstantLearning/_components/ChatComponent.js +1 -1
  48. package/dist/features/InstantLearning/_components/ContextualChatComponent.js +1 -1
  49. package/dist/features/InstantLearning/_components/ContextualLearningForm.js +1 -1
  50. package/dist/features/InstantLearning/_components/LearningDetailsForm.js +1 -1
  51. package/dist/features/LearningManagement/AuditLog/AuditLog.js +1 -1
  52. package/dist/features/LearningManagement/LearningManagement.js +1 -1
  53. package/dist/features/LearningManagement/LearningManagementTest.js +1 -1
  54. package/dist/features/LearningManagement/LearningTemplateLayout.js +1 -1
  55. package/dist/features/LearningManagement/RBAC/AccessPanel.js +1 -1
  56. package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
  57. package/dist/features/LearningManagement/apis/scopeApis.js +1 -1
  58. package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
  59. package/dist/features/LearningManagement/components/InstantLearningModalDynamic.js +1 -1
  60. package/dist/hooks/useAgentFix.js +1 -1
  61. package/dist/hooks/useAgentSuggestions.js +1 -1
  62. package/dist/hooks/useAgentValidation.js +1 -1
  63. package/dist/hooks/useExistingAgentCheck.js +1 -1
  64. package/dist/hooks/useExistingPromptCheck.js +1 -1
  65. package/dist/hooks/usePromptFix.js +1 -1
  66. package/dist/hooks/usePromptSuggestions.js +1 -1
  67. package/dist/hooks/usePromptValidation.js +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/service/InstantLearningService.js +1 -1
  70. package/dist/types/src/features/DocumentLearning/DocumentLearning.d.ts.map +1 -1
  71. package/dist/types/src/features/DocumentLearning/_components/BookLearningForm.d.ts.map +1 -1
  72. package/dist/types/src/features/DocumentLearning/_components/LearningDetailsForm.d.ts.map +1 -1
  73. package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts.map +1 -1
  74. package/dist/types/src/features/IL-marketplace/services/guideline.core.api.d.ts.map +1 -1
  75. package/dist/types/src/features/IL-marketplace/services/instant-learning.api.d.ts.map +1 -1
  76. package/dist/types/src/features/InstantLearning/_components/ContextualLearningForm.d.ts.map +1 -1
  77. package/dist/types/src/features/InstantLearning/_components/LearningDetailsForm.d.ts.map +1 -1
  78. package/dist/types/src/features/LearningManagement/AuditLog/AuditLog.d.ts.map +1 -1
  79. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts +1 -9
  80. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  81. package/dist/types/src/features/LearningManagement/RBAC/AccessPanel.d.ts.map +1 -1
  82. package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts.map +1 -1
  83. package/dist/types/src/features/LearningManagement/components/InstantLearningModalDynamic.d.ts.map +1 -1
  84. package/dist/types/src/features/LearningManagement/queries/useApprovalQueries.d.ts +8 -11
  85. package/dist/types/src/features/LearningManagement/queries/useApprovalQueries.d.ts.map +1 -1
  86. package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts +1 -3
  87. package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts.map +1 -1
  88. package/dist/types/src/features/LearningManagement/store/useExternalWorkflowStore.d.ts +4 -4
  89. package/dist/types/src/features/LearningManagement/store/useExternalWorkflowStore.d.ts.map +1 -1
  90. package/dist/types/src/hooks/useAgentFix.d.ts.map +1 -1
  91. package/dist/types/src/hooks/useAgentSuggestions.d.ts.map +1 -1
  92. package/dist/types/src/hooks/useAgentValidation.d.ts.map +1 -1
  93. package/dist/types/src/hooks/useExistingAgentCheck.d.ts.map +1 -1
  94. package/dist/types/src/hooks/useExistingPromptCheck.d.ts.map +1 -1
  95. package/dist/types/src/hooks/usePromptFix.d.ts.map +1 -1
  96. package/dist/types/src/hooks/usePromptSuggestions.d.ts.map +1 -1
  97. package/dist/types/src/hooks/usePromptValidation.d.ts.map +1 -1
  98. package/dist/types/src/index.d.ts +0 -1
  99. package/dist/types/src/index.d.ts.map +1 -1
  100. package/dist/types/src/service/API.d.ts.map +1 -1
  101. package/dist/types/src/service/GoogleFilePickerService.d.ts.map +1 -1
  102. package/dist/types/src/service/InstantLearningService.d.ts +1 -12
  103. package/dist/types/src/service/InstantLearningService.d.ts.map +1 -1
  104. package/dist/types/src/service/ModelService.d.ts.map +1 -1
  105. package/dist/types/src/service/SavedDataSetService.d.ts.map +1 -1
  106. package/dist/types/src/utils/bookGenieAPI.d.ts.map +1 -1
  107. package/dist/types/src/utils/date.d.ts.map +1 -1
  108. package/dist/types/src/utils/instantLearningAPI.d.ts.map +1 -1
  109. package/dist/utils/agentGenieAPI.js +1 -1
  110. package/dist/utils/bookGenieAPI.js +1 -1
  111. package/dist/utils/instantLearningAPI.js +1 -1
  112. package/package.json +9 -10
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("../api/transport.js");exports.default=function(r){var o=t.useState(!1),a=o[0],s=o[1],i=t.useState([]),u=i[0],c=i[1],l=t.useState(null),p=l[0],d=l[1];return{fixAgentRules:function(t,o,a,i,u){return e.__awaiter(void 0,void 0,void 0,function(){var l,p,f,_,w,h,x;return e.__generator(this,function(g){switch(g.label){case 0:s(!0),c([]),d(null),l=e.__assign(e.__assign({},t),{wta:o.wta.map(function(e){return e.text}),wnta:o.wnta.map(function(e){return e.text}),mode:"AgentGenie",agent_description:i,agent_context:a,llm:u,n:1}),g.label=1;case 1:return g.trys.push([1,3,4,5]),[4,n.http.post("".concat(r,"/instant_learning/mode-wta-validation-fix"),l)];case 2:return p=g.sent(),f=p.data,_=[],null===(h=f.response.conditions_whentoapply)||void 0===h||h.forEach(function(e){_.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(x=f.response.conditions_whennottoapply)||void 0===x||x.forEach(function(e){_.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),c(_),[3,5];case 3:return w=g.sent(),console.error("Failed to fix rules:",w),d(w),[3,5];case 4:return s(!1),[7];case 5:return[2]}})})},isFixing:a,fixedSuggestions:u,error:p}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n){var r=t.useState(!1),o=r[0],s=r[1],a=t.useState([]),i=a[0],c=a[1],u=t.useState(null),l=u[0],p=u[1];return{fixAgentRules:function(t,r,o,a,i){return e.__awaiter(void 0,void 0,void 0,function(){var u,l,d,f,_,h,w;return e.__generator(this,function(x){switch(x.label){case 0:s(!0),c([]),p(null),u=e.__assign(e.__assign({},t),{wta:r.wta.map(function(e){return e.text}),wnta:r.wnta.map(function(e){return e.text}),mode:"AgentGenie",agent_description:a,agent_context:o,llm:i,n:1}),x.label=1;case 1:return x.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})];case 2:if(!(l=x.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return d=x.sent(),f=[],null===(h=d.response.conditions_whentoapply)||void 0===h||h.forEach(function(e){f.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(w=d.response.conditions_whennottoapply)||void 0===w||w.forEach(function(e){f.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),c(f),[3,6];case 4:return _=x.sent(),console.error("Failed to fix rules:",_),p(_),[3,6];case 5:return s(!1),[7];case 6:return[2]}})})},isFixing:o,fixedSuggestions:i,error:l}};
2
2
  //# sourceMappingURL=useAgentFix.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("./useDebounce.js"),o=require("../api/transport.js");exports.default=function(s,r,a,i,c,u){void 0===c&&(c=!0);var l=t.useState([]),p=l[0],d=l[1],f=t.useState(!1),g=f[0],h=f[1],_=t.useState(null),v=_[0],w=_[1],y=n.default(s,500),b=n.default(r,500);return t.useEffect(function(){if(b&&c){e.__awaiter(void 0,void 0,void 0,function(){var t,n,s,r,a,c,l;return e.__generator(this,function(e){switch(e.label){case 0:console.log("[".concat((new Date).toLocaleTimeString(),"] Attempting to fetch suggestions...")),h(!0),w(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),t={agent_context:y,agent_description:b,mode:"AgentGenie",llm:i,n:1},console.log("API Payload:",t),[4,o.http.post("".concat(u,"/instant_learning/mode-wta-suggestion"),t)];case 2:return n=e.sent(),s=n.data,r=[],null===(c=s.response.conditions_whentoapply)||void 0===c||c.forEach(function(e){r.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(l=s.response.conditions_whennottoapply)||void 0===l||l.forEach(function(e){r.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),d(r),[3,5];case 3:return a=e.sent(),console.error("Failed to fetch suggestions:",a),w(a),[3,5];case 4:return h(!1),[7];case 5:return[2]}})})}else d([])},[y,b,a,c]),{suggestions:p,isLoading:g,error:v}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("./useDebounce.js");exports.default=function(o,s,r,a,i,c){void 0===i&&(i=!0);var u=t.useState([]),l=u[0],d=u[1],p=t.useState(!1),f=p[0],g=p[1],h=t.useState(null),_=h[0],w=h[1],y=n.default(o,500),v=n.default(s,500);return t.useEffect(function(){if(v&&i){e.__awaiter(void 0,void 0,void 0,function(){var t,n,o,s,r,i,u;return e.__generator(this,function(e){switch(e.label){case 0:console.log("[".concat((new Date).toLocaleTimeString(),"] Attempting to fetch suggestions...")),g(!0),w(null),e.label=1;case 1:return e.trys.push([1,4,5,6]),t={agent_context:y,agent_description:v,mode:"AgentGenie",llm:a,n:1},console.log("API Payload:",t),[4,fetch("".concat(c,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})];case 2:if(!(n=e.sent()).ok)throw new Error("API Error: ".concat(n.statusText));return[4,n.json()];case 3:return o=e.sent(),s=[],null===(i=o.response.conditions_whentoapply)||void 0===i||i.forEach(function(e){s.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(u=o.response.conditions_whennottoapply)||void 0===u||u.forEach(function(e){s.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),d(s),[3,6];case 4:return r=e.sent(),console.error("Failed to fetch suggestions:",r),w(r),[3,6];case 5:return g(!1),[7];case 6:return[2]}})})}else d([])},[y,v,r,i]),{suggestions:l,isLoading:f,error:_}};
2
2
  //# sourceMappingURL=useAgentSuggestions.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("../api/transport.js");exports.default=function(a,r,l){var o=t.useState(!1),i=o[0],s=o[1],u=t.useState(null),c=u[0],d=u[1],p=t.useState(null),f=p[0],v=p[1],_=t.useCallback(function(t,o){return e.__awaiter(void 0,void 0,void 0,function(){var i,u,c,p;return e.__generator(this,function(e){switch(e.label){case 0:if(s(!0),d(null),v(null),0===(i={agent_context:a,agent_description:r,mode:"AgentGenie",llm:o,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text})}).wta.length)return console.error("WTA conditions cannot be empty."),s(!1),[2,null];e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,n.http.post("".concat(l,"/instant_learning/mode-wta-validation"),i)];case 2:return u=e.sent(),(c=u.data).response.is_valid?(console.log("Validation Successful!"),d(null)):(console.warn("Validation failed, conflicts found."),d(c.response)),[2,c.response];case 3:return p=e.sent(),console.error("Failed to validate rules:",p),v(p),[2,null];case 4:return s(!1),[7];case 5:return[2]}})})},[a,r,l]);return{validateAgentRules:_,clearValidation:function(){d(null)},isSaving:i,validationResponse:c,error:f}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n,r,a){var o=t.useState(!1),s=o[0],l=o[1],i=t.useState(null),u=i[0],c=i[1],d=t.useState(null),f=d[0],p=d[1],v=t.useCallback(function(t,o){return e.__awaiter(void 0,void 0,void 0,function(){var s,i,u,d;return e.__generator(this,function(e){switch(e.label){case 0:if(l(!0),c(null),p(null),0===(s={agent_context:n,agent_description:r,mode:"AgentGenie",llm:o,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text})}).wta.length)return console.error("WTA conditions cannot be empty."),l(!1),[2,null];e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(a,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})];case 2:if(!(i=e.sent()).ok)throw new Error("API Error: ".concat(i.statusText));return[4,i.json()];case 3:return(u=e.sent()).response.is_valid?(console.log("Validation Successful!"),c(null)):(console.warn("Validation failed, conflicts found."),c(u.response)),[2,u.response];case 4:return d=e.sent(),console.error("Failed to validate rules:",d),p(d),[2,null];case 5:return l(!1),[7];case 6:return[2]}})})},[n,r,a]);return{validateAgentRules:v,clearValidation:function(){c(null)},isSaving:s,validationResponse:u,error:f}};
2
2
  //# sourceMappingURL=useAgentValidation.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("../api/transport.js");exports.default=function(r){var s=t.useState(!1),i=s[0],a=s[1],o=t.useState(null),c=o[0],u=o[1],l=t.useState(null),g=l[0],f=l[1];return{checkExistingRules:function(t,s,i,o){return e.__awaiter(void 0,void 0,void 0,function(){var c,l,g,p;return e.__generator(this,function(e){switch(e.label){case 0:a(!0),f(null),u(null),c={mode:"AgentGenie",assistantname:i,organizationname:o,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text}),agent_id:s},console.log("Checking for existing DB conflicts with payload:",c),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,n.http.post("".concat(r,"/instant_learning/mode-wta-existing"),c)];case 2:return l=e.sent(),(g=l.data).response?(console.log("DB check successful. Setting state with:",g.response),u(g.response)):(console.error("DB check: API response object was missing."),u(null)),[3,5];case 3:return p=e.sent(),console.error("Failed to check for existing rules:",p),f(p),[3,5];case 4:return a(!1),[7];case 5:return[2]}})})},isLoading:i,existingConflicts:c,error:g,clearExistingAgentConflicts:function(){u(null)}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n){var r=t.useState(!1),s=r[0],o=r[1],i=t.useState(null),a=i[0],c=i[1],u=t.useState(null),l=u[0],g=u[1];return{checkExistingRules:function(t,r,s,i){return e.__awaiter(void 0,void 0,void 0,function(){var a,u,l,f;return e.__generator(this,function(e){switch(e.label){case 0:o(!0),g(null),c(null),a={mode:"AgentGenie",assistantname:s,organizationname:i,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text}),agent_id:r},console.log("Checking for existing DB conflicts with payload:",a),e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:if(!(u=e.sent()).ok)throw new Error("API Error: ".concat(u.statusText));return[4,u.json()];case 3:return(l=e.sent()).response?(console.log("DB check successful. Setting state with:",l.response),c(l.response)):(console.error("DB check: API response object was missing."),c(null)),[3,6];case 4:return f=e.sent(),console.error("Failed to check for existing rules:",f),g(f),[3,6];case 5:return o(!1),[7];case 6:return[2]}})})},isLoading:s,existingConflicts:a,error:l,clearExistingAgentConflicts:function(){c(null)}}};
2
2
  //# sourceMappingURL=useExistingAgentCheck.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("../api/transport.js");exports.default=function(r){var o=t.useState(!1),s=o[0],i=o[1],a=t.useState(null),c=a[0],l=a[1],u=t.useState(null),p=u[0],m=u[1];return{checkExistingPromptRules:function(t,o,s,a){return e.__awaiter(void 0,void 0,void 0,function(){var c,u,p,f;return e.__generator(this,function(e){switch(e.label){case 0:i(!0),m(null),l(null),c={mode:"PromptGenie",template_title:o,template_description:s,wta:t.wta.map(function(e){return e.text}).join(" OR "),wnta:t.wnta.map(function(e){return e.text}).join(" OR "),llm:a},console.log("Checking for existing DB conflicts (PromptGenie) with payload:",c),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,n.http.post("".concat(r,"/instant_learning/mode-wta-existing"),c)];case 2:return u=e.sent(),(p=u.data).response?(console.log("DB check (PromptGenie) successful. Setting state with:",p.response),l(p.response)):(console.error("DB check (PromptGenie): API response object was missing."),l(null)),[3,5];case 3:return f=e.sent(),console.error("Failed to check for existing prompt rules:",f),m(f),[3,5];case 4:return i(!1),[7];case 5:return[2]}})})},isLoading:s,existingPromptConflicts:c,error:p,clearExistingPromptConflicts:function(){l(null)}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n){var r=t.useState(!1),o=r[0],s=r[1],i=t.useState(null),c=i[0],a=i[1],l=t.useState(null),u=l[0],p=l[1];return{checkExistingPromptRules:function(t,r,o,i){return e.__awaiter(void 0,void 0,void 0,function(){var c,l,u,f;return e.__generator(this,function(e){switch(e.label){case 0:s(!0),p(null),a(null),c={mode:"PromptGenie",template_title:r,template_description:o,wta:t.wta.map(function(e){return e.text}).join(" OR "),wnta:t.wnta.map(function(e){return e.text}).join(" OR "),llm:i},console.log("Checking for existing DB conflicts (PromptGenie) with payload:",c),e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(l=e.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(u=e.sent()).response?(console.log("DB check (PromptGenie) successful. Setting state with:",u.response),a(u.response)):(console.error("DB check (PromptGenie): API response object was missing."),a(null)),[3,6];case 4:return f=e.sent(),console.error("Failed to check for existing prompt rules:",f),p(f),[3,6];case 5:return s(!1),[7];case 6:return[2]}})})},isLoading:o,existingPromptConflicts:c,error:u,clearExistingPromptConflicts:function(){a(null)}}};
2
2
  //# sourceMappingURL=useExistingPromptCheck.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("../api/transport.js");exports.default=function(r){var o=t.useState(!1),a=o[0],s=o[1],i=t.useState([]),u=i[0],c=i[1],p=t.useState(null),l=p[0],d=p[1];return{fixPromptRules:function(t,o,a,i,u){return e.__awaiter(void 0,void 0,void 0,function(){var p,l,f,_,w,h,x;return e.__generator(this,function(m){switch(m.label){case 0:s(!0),c([]),d(null),p=e.__assign(e.__assign({},t),{wta:o.wta.map(function(e){return e.text}),wnta:o.wnta.map(function(e){return e.text}),mode:"PromptGenie",template_context:a,template_description:i,llm:u}),m.label=1;case 1:return m.trys.push([1,3,4,5]),[4,n.http.post("".concat(r,"/instant_learning/mode-wta-validation-fix"),p)];case 2:return l=m.sent(),f=l.data,_=[],null===(h=f.response.conditions_whentoapply)||void 0===h||h.forEach(function(e){_.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(x=f.response.conditions_whennottoapply)||void 0===x||x.forEach(function(e){_.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),c(_),[3,5];case 3:return w=m.sent(),console.error("Failed to fix prompt rules:",w),d(w),[3,5];case 4:return s(!1),[7];case 5:return[2]}})})},isFixing:a,fixedSuggestions:u,error:l}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n){var r=t.useState(!1),o=r[0],s=r[1],a=t.useState([]),i=a[0],c=a[1],u=t.useState(null),l=u[0],p=u[1];return{fixPromptRules:function(t,r,o,a,i){return e.__awaiter(void 0,void 0,void 0,function(){var u,l,d,f,_,h,w;return e.__generator(this,function(x){switch(x.label){case 0:s(!0),c([]),p(null),u=e.__assign(e.__assign({},t),{wta:r.wta.map(function(e){return e.text}),wnta:r.wnta.map(function(e){return e.text}),mode:"PromptGenie",template_context:o,template_description:a,llm:i}),x.label=1;case 1:return x.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)})];case 2:if(!(l=x.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return d=x.sent(),f=[],null===(h=d.response.conditions_whentoapply)||void 0===h||h.forEach(function(e){f.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(w=d.response.conditions_whennottoapply)||void 0===w||w.forEach(function(e){f.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),c(f),[3,6];case 4:return _=x.sent(),console.error("Failed to fix prompt rules:",_),p(_),[3,6];case 5:return s(!1),[7];case 6:return[2]}})})},isFixing:o,fixedSuggestions:i,error:l}};
2
2
  //# sourceMappingURL=usePromptFix.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("./useDebounce.js"),o=require("../api/transport.js");exports.default=function(r,s,a,i,u,c){void 0===u&&(u=!0);var l=t.useState([]),p=l[0],d=l[1],f=t.useState(!1),h=f[0],_=f[1],v=t.useState(null),g=v[0],w=v[1],y=n.default(r,500),m=n.default(s,500);return t.useEffect(function(){if(y&&m&&u){e.__awaiter(void 0,void 0,void 0,function(){var t,n,r,s,a,u,l;return e.__generator(this,function(e){switch(e.label){case 0:_(!0),w(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),t={template_context:y,template_description:m,mode:"PromptGenie",llm:i,n:1},[4,o.http.post("".concat(c,"/instant_learning/mode-wta-suggestion"),t)];case 2:return n=e.sent(),r=n.data,s=[],null===(u=r.response.conditions_whentoapply)||void 0===u||u.forEach(function(e){s.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(l=r.response.conditions_whennottoapply)||void 0===l||l.forEach(function(e){s.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),d(s),[3,5];case 3:return a=e.sent(),console.error("Failed to fetch prompt suggestions:",a),w(a),[3,5];case 4:return _(!1),[7];case 5:return[2]}})})}else d([])},[y,m,a,u]),{suggestions:p,isLoading:h,error:g}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("./useDebounce.js");exports.default=function(o,r,s,a,i,c){void 0===i&&(i=!0);var u=t.useState([]),l=u[0],p=u[1],d=t.useState(!1),f=d[0],h=d[1],_=t.useState(null),w=_[0],y=_[1],g=n.default(o,500),v=n.default(r,500);return t.useEffect(function(){if(g&&v&&i){e.__awaiter(void 0,void 0,void 0,function(){var t,n,o,r,s,i,u;return e.__generator(this,function(e){switch(e.label){case 0:h(!0),y(null),e.label=1;case 1:return e.trys.push([1,4,5,6]),t={template_context:g,template_description:v,mode:"PromptGenie",llm:a,n:1},[4,fetch("".concat(c,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})];case 2:if(!(n=e.sent()).ok)throw new Error("API Error: ".concat(n.statusText));return[4,n.json()];case 3:return o=e.sent(),r=[],null===(i=o.response.conditions_whentoapply)||void 0===i||i.forEach(function(e){r.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})}),null===(u=o.response.conditions_whennottoapply)||void 0===u||u.forEach(function(e){r.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})}),p(r),[3,6];case 4:return s=e.sent(),console.error("Failed to fetch prompt suggestions:",s),y(s),[3,6];case 5:return h(!1),[7];case 6:return[2]}})})}else p([])},[g,v,s,i]),{suggestions:l,isLoading:f,error:w}};
2
2
  //# sourceMappingURL=usePromptSuggestions.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),n=require("../api/transport.js");exports.default=function(r,o,a,l){void 0===a&&(a=!0);var i=t.useState(!1),s=i[0],u=i[1],c=t.useState(null),p=c[0],d=c[1],f=t.useState(null),m=f[0],v=f[1];return{validateRules:function(t,i){return e.__awaiter(void 0,void 0,void 0,function(){var s,c,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!a)return[2,null];if(u(!0),d(null),v(null),0===(s={template_context:r,template_description:o,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text}),mode:"PromptGenie",llm_model:i}).wta.length)return console.error("WTA conditions cannot be empty."),v(new Error("When to Apply conditions cannot be empty.")),u(!1),[2,null];e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,n.http.post("".concat(l,"/instant_learning/mode-wta-validation"),s)];case 2:return c=e.sent(),(p=c.data).response.is_valid?(console.log("Prompt Validation Successful!"),d(null)):(console.warn("Prompt Validation failed, conflicts found."),d(p.response)),[2,p.response];case 3:return f=e.sent(),console.error("Failed to validate prompt rules:",f),v(f),[2,null];case 4:return u(!1),[7];case 5:return[2]}})})},clearValidation:function(){d(null)},isSaving:s,validationResponse:p,error:m}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react");exports.default=function(n,r,o,a){void 0===o&&(o=!0);var l=t.useState(!1),i=l[0],s=l[1],u=t.useState(null),c=u[0],d=u[1],p=t.useState(null),f=p[0],m=p[1];return{validateRules:function(t,l){return e.__awaiter(void 0,void 0,void 0,function(){var i,u,c,p;return e.__generator(this,function(e){switch(e.label){case 0:if(!o)return[2,null];if(s(!0),d(null),m(null),0===(i={template_context:n,template_description:r,wta:t.wta.map(function(e){return e.text}),wnta:t.wnta.map(function(e){return e.text}),mode:"PromptGenie",llm_model:l}).wta.length)return console.error("WTA conditions cannot be empty."),m(new Error("When to Apply conditions cannot be empty.")),s(!1),[2,null];e.label=1;case 1:return e.trys.push([1,4,5,6]),[4,fetch("".concat(a,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})];case 2:if(!(u=e.sent()).ok)throw new Error("API Error: ".concat(u.statusText));return[4,u.json()];case 3:return(c=e.sent()).response.is_valid?(console.log("Prompt Validation Successful!"),d(null)):(console.warn("Prompt Validation failed, conflicts found."),d(c.response)),[2,c.response];case 4:return p=e.sent(),console.error("Failed to validate prompt rules:",p),m(p),[2,null];case 5:return s(!1),[7];case 6:return[2]}})})},clearValidation:function(){d(null)},isSaving:i,validationResponse:c,error:f}};
2
2
  //# sourceMappingURL=usePromptValidation.js.map
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./features/InstantLearning/InstantLearning.js"),t=require("./features/WtaWnta/WtaWnta.js"),r=require("./features/DocumentLearning/DocumentLearning.js"),i=require("./features/IL-OTJ/ILOTJ.js"),n=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),a=require("./features/IL-OTJ/_components/atoms/Dropdown/Dropdown.js"),s=require("./features/IL-OTJ/_components/atoms/Toggle/Toggle.js"),o=require("./features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),u=require("./features/IL-OTJ/_components/molecules/Condition/ConditionList.js"),p=require("./features/IL-OTJ/_components/molecules/Sections/SectionWrapper.js"),l=require("./features/IL-OTJ/_components/molecules/SeperationRow/SeparationRow.js"),d=require("./features/IL-OTJ/_components/organisms/ConfigSection/ConfigSection.js"),c=require("./features/IL-OTJ/_components/organisms/TextSection/TextSection.js"),m=require("./features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.js"),x=require("./features/IL-OTJ/_components/organisms/ConditionSection/ConditionSection.js"),L=require("./features/IL-OTJ/_components/templates/TrafficManager/TrafficManagerTemplate.js"),g=require("./features/IL-OTJ/_components/templates/Testing/Testing.js"),G=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),I=require("./features/IL-OTJ/helpers/utils.js"),T=require("./features/IL-OTJ/store/CitationsContext.js"),f=require("./features/IL-OTJ/ILOTJTest.js"),C=require("./features/LearningManagement/LearningManagement.js"),j=require("./ILMarketplaceWrapper.js"),q=require("./features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js");require("./features/LearningManagement/LearningManagementTest.js");var S=require("./api/transport.js"),k=require("./ContinueWithTemplateModal.js"),D=require("./features/IL-marketplace/components/GuidelineCart.js"),_=require("./features/IL-marketplace/components/GuidelineCartHeader.js"),A=require("./features/IL-marketplace/components/GuidelineCartItem.js"),W=require("./features/IL-marketplace/components/GuidelineEmptyState.js"),O=require("./features/IL-marketplace/components/GuidelineHeader.js"),M=require("./features/IL-marketplace/components/GuidelineIconButton.js"),E=require("./features/IL-marketplace/components/GuidelineLandingPage.js"),P=require("./features/IL-marketplace/components/GuidelineFilterPanel.js"),y=require("./features/IL-marketplace/components/GuidelineLibrary.js"),F=require("./features/IL-marketplace/components/GuidelineLibraryCard.js"),B=require("./features/IL-marketplace/components/LearningManagementWrapper.js"),J=require("./features/IL-marketplace/components/GuidelineProceedButton.js"),b=require("./features/IL-marketplace/components/GuidelineSelectButton.js"),h=require("./features/IL-marketplace/components/GuidelineCardMenu.js"),v=require("./features/IL-marketplace/components/GuidelineConfirmDialog.js"),R=require("./features/IL-marketplace/hooks/useGuidelineSelection.js"),w=require("./features/IL-marketplace/constants.js"),V=require("./features/IL-marketplace/utils.js"),H=require("./features/IL-marketplace/workspace/workspace.runtime.js"),U=require("./features/IL-marketplace/workspace/useGuidelineWorkspace.js"),N=require("./features/IL-marketplace/services/guideline.session.js"),K=require("./features/IL-marketplace/services/instant-learning.api.js"),Q=require("./features/IL-marketplace/utils/guidelineOverlay.js"),Y=require("./features/IL-marketplace/utils/guidelineFiles.js"),z=require("./features/IL-marketplace/services/guideline.cart.api.js"),X=require("./features/IL-marketplace/queryClient.js");exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=i.default,exports.Button=n.Button,exports.Dropdown=a.Dropdown,exports.Toggle=s.Toggle,exports.Textarea=o.Textarea,exports.ConditionList=u.ConditionList,exports.SectionWrapper=p.SectionWrapper,exports.SeparationRow=l.SeparationRow,exports.ConfigSection=d.ConfigSection,exports.TextSection=c.TextSection,exports.ScopeSection=m.ScopeSection,exports.ConditionSection=x.ConditionSection,exports.TrafficManagerTemplate=L.TrafficManagerTemplate,exports.Testing=g.Testing,Object.defineProperty(exports,"TemplateList",{enumerable:!0,get:function(){return G.TemplateList}}),exports.TemplateMap=G.TemplateMap,exports.extractAndParseResponse=I.extractAndParseResponse,exports.extractAndParseWithProperty=I.extractAndParseWithProperty,exports.extractTextFromChildren=I.extractTextFromChildren,exports.extractVariantIds=I.extractVariantIds,exports.parseValidationData=I.parseValidationData,exports.useHeaderObserver=I.useHeaderObserver,exports.CitationProvider=T.CitationProvider,exports.useCitations=T.useCitations,exports.dummyDat=f.dummyDat,exports.getVariantInfo=f.getVariantInfo,exports.LearningManagement=C.default,exports.ILMarketplaceWrapper=j.default,exports.IL_MARKETPLACE_TAB_ID=j.IL_MARKETPLACE_TAB_ID,exports.MY_KNOWLEDGE_BASES_TAB_ID=j.MY_KNOWLEDGE_BASES_TAB_ID,exports.SAVED_TAB_ID=j.SAVED_TAB_ID,exports.TeachMePlugin=q.default,exports.TemplateRegistry=q.TemplateRegistry,exports.setApiDebug=S.setApiDebug,exports.ContinueWithTemplateModal=k.default,exports.GuidelineCart=D.GuidelineCart,exports.GuidelineCartHeader=_.GuidelineCartHeader,exports.GuidelineCartItem=A.GuidelineCartItem,exports.GuidelineEmptyState=W.GuidelineEmptyState,exports.GuidelineHeader=O.GuidelineHeader,exports.GuidelineIconButton=M.GuidelineIconButton,exports.GuidelineLandingPage=E.GuidelineLandingPage,exports.GuidelineFilterPanel=P.GuidelineFilterPanel,exports.GuidelineLibrary=y.GuidelineLibrary,exports.GuidelineLibraryCard=F.GuidelineLibraryCard,exports.LearningManagementWrapper=B.LearningManagementWrapper,exports.GuidelineProceedButton=J.GuidelineProceedButton,exports.GuidelineSelectButton=b.GuidelineSelectButton,exports.GuidelineCardMenu=h.GuidelineCardMenu,exports.createGuidelineCardMenuItems=h.createGuidelineCardMenuItems,exports.GuidelineConfirmDialog=v.GuidelineConfirmDialog,exports.useGuidelineSelection=R.useGuidelineSelection,exports.DEFAULT_GUIDELINE_ARTIFACT_TEMPLATE=w.DEFAULT_GUIDELINE_ARTIFACT_TEMPLATE,exports.DEFAULT_GUIDELINE_LABELS=w.DEFAULT_GUIDELINE_LABELS,exports.createGuidelineId=V.createGuidelineId,exports.cx=V.cx,exports.defaultFormatAddedOnLabel=V.defaultFormatAddedOnLabel,exports.getAppIntegrationId=V.getAppIntegrationId,exports.getGuidelineDate=V.getGuidelineDate,exports.getGuidelineDescription=V.getGuidelineDescription,exports.getGuidelineDisplayDescription=V.getGuidelineDisplayDescription,exports.getGuidelineId=V.getGuidelineId,exports.getGuidelineTitle=V.getGuidelineTitle,exports.isInstantLearningGuideline=V.isInstantLearningGuideline,exports.mergeGuidelineLabels=V.mergeGuidelineLabels,exports.getGuidelineWorkspaceActions=H.getGuidelineWorkspaceActions,exports.getGuidelineWorkspaceSnapshot=H.getGuidelineWorkspaceSnapshot,exports.useGuidelineWorkspace=U.useGuidelineWorkspace,exports.useGuidelineWorkspaceActions=U.useGuidelineWorkspaceActions,exports.useOptionalGuidelineWorkspace=U.useOptionalGuidelineWorkspace,exports.useOptionalGuidelineWorkspaceActions=U.useOptionalGuidelineWorkspaceActions,exports.clearGuidelineCartClearPending=N.clearGuidelineCartClearPending,exports.clearInstantLearningGuidelineCartPresent=N.clearInstantLearningGuidelineCartPresent,exports.getGuidelineSessionId=N.getGuidelineSessionId,exports.markGuidelineCartClearPending=N.markGuidelineCartClearPending,exports.rotateGuidelineSessionId=N.rotateGuidelineSessionId,exports.removeInstantLearningGuidelinesFromCart=K.removeInstantLearningGuidelinesFromCart,exports.closeGuidelineOverlayWithSync=Q.closeGuidelineOverlayWithSync,exports.dataCartFileToGuidelineFileItem=Y.dataCartFileToGuidelineFileItem,exports.getDataCartFilesFromResponse=Y.getDataCartFilesFromResponse,exports.isGuidelineDataCartFile=Y.isGuidelineDataCartFile,exports.mergeGuidelineFiles=Y.mergeGuidelineFiles,exports.syncGuidelineCartWithMemstore=z.syncGuidelineCartWithMemstore,exports.guidelineQueryClient=X.guidelineQueryClient;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./features/InstantLearning/InstantLearning.js"),t=require("./features/WtaWnta/WtaWnta.js"),r=require("./features/DocumentLearning/DocumentLearning.js"),i=require("./features/IL-OTJ/ILOTJ.js"),n=require("./features/IL-OTJ/_components/atoms/Button/Button.js"),a=require("./features/IL-OTJ/_components/atoms/Dropdown/Dropdown.js"),s=require("./features/IL-OTJ/_components/atoms/Toggle/Toggle.js"),o=require("./features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),u=require("./features/IL-OTJ/_components/molecules/Condition/ConditionList.js"),p=require("./features/IL-OTJ/_components/molecules/Sections/SectionWrapper.js"),l=require("./features/IL-OTJ/_components/molecules/SeperationRow/SeparationRow.js"),d=require("./features/IL-OTJ/_components/organisms/ConfigSection/ConfigSection.js"),c=require("./features/IL-OTJ/_components/organisms/TextSection/TextSection.js"),m=require("./features/IL-OTJ/_components/organisms/ScopeSection/ScopeSection.js"),x=require("./features/IL-OTJ/_components/organisms/ConditionSection/ConditionSection.js"),L=require("./features/IL-OTJ/_components/templates/TrafficManager/TrafficManagerTemplate.js"),g=require("./features/IL-OTJ/_components/templates/Testing/Testing.js"),G=require("./features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js"),I=require("./features/IL-OTJ/helpers/utils.js"),T=require("./features/IL-OTJ/store/CitationsContext.js"),f=require("./features/IL-OTJ/ILOTJTest.js"),C=require("./features/LearningManagement/LearningManagement.js"),j=require("./ILMarketplaceWrapper.js"),q=require("./features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js");require("./features/LearningManagement/LearningManagementTest.js");var S=require("./ContinueWithTemplateModal.js"),k=require("./features/IL-marketplace/components/GuidelineCart.js"),_=require("./features/IL-marketplace/components/GuidelineCartHeader.js"),D=require("./features/IL-marketplace/components/GuidelineCartItem.js"),A=require("./features/IL-marketplace/components/GuidelineEmptyState.js"),W=require("./features/IL-marketplace/components/GuidelineHeader.js"),O=require("./features/IL-marketplace/components/GuidelineIconButton.js"),M=require("./features/IL-marketplace/components/GuidelineLandingPage.js"),E=require("./features/IL-marketplace/components/GuidelineFilterPanel.js"),P=require("./features/IL-marketplace/components/GuidelineLibrary.js"),y=require("./features/IL-marketplace/components/GuidelineLibraryCard.js"),F=require("./features/IL-marketplace/components/LearningManagementWrapper.js"),B=require("./features/IL-marketplace/components/GuidelineProceedButton.js"),J=require("./features/IL-marketplace/components/GuidelineSelectButton.js"),h=require("./features/IL-marketplace/components/GuidelineCardMenu.js"),b=require("./features/IL-marketplace/components/GuidelineConfirmDialog.js"),v=require("./features/IL-marketplace/hooks/useGuidelineSelection.js"),R=require("./features/IL-marketplace/constants.js"),w=require("./features/IL-marketplace/utils.js"),V=require("./features/IL-marketplace/workspace/workspace.runtime.js"),H=require("./features/IL-marketplace/workspace/useGuidelineWorkspace.js"),U=require("./features/IL-marketplace/services/guideline.session.js"),N=require("./features/IL-marketplace/services/instant-learning.api.js"),K=require("./features/IL-marketplace/utils/guidelineOverlay.js"),Q=require("./features/IL-marketplace/utils/guidelineFiles.js"),Y=require("./features/IL-marketplace/services/guideline.cart.api.js"),z=require("./features/IL-marketplace/queryClient.js");exports.InstantLearning=e.default,exports.WtaWnta=t.default,exports.BookLearning=r.default,exports.ILOTJ=i.default,exports.Button=n.Button,exports.Dropdown=a.Dropdown,exports.Toggle=s.Toggle,exports.Textarea=o.Textarea,exports.ConditionList=u.ConditionList,exports.SectionWrapper=p.SectionWrapper,exports.SeparationRow=l.SeparationRow,exports.ConfigSection=d.ConfigSection,exports.TextSection=c.TextSection,exports.ScopeSection=m.ScopeSection,exports.ConditionSection=x.ConditionSection,exports.TrafficManagerTemplate=L.TrafficManagerTemplate,exports.Testing=g.Testing,Object.defineProperty(exports,"TemplateList",{enumerable:!0,get:function(){return G.TemplateList}}),exports.TemplateMap=G.TemplateMap,exports.extractAndParseResponse=I.extractAndParseResponse,exports.extractAndParseWithProperty=I.extractAndParseWithProperty,exports.extractTextFromChildren=I.extractTextFromChildren,exports.extractVariantIds=I.extractVariantIds,exports.parseValidationData=I.parseValidationData,exports.useHeaderObserver=I.useHeaderObserver,exports.CitationProvider=T.CitationProvider,exports.useCitations=T.useCitations,exports.dummyDat=f.dummyDat,exports.getVariantInfo=f.getVariantInfo,exports.LearningManagement=C.default,exports.ILMarketplaceWrapper=j.default,exports.IL_MARKETPLACE_TAB_ID=j.IL_MARKETPLACE_TAB_ID,exports.MY_KNOWLEDGE_BASES_TAB_ID=j.MY_KNOWLEDGE_BASES_TAB_ID,exports.SAVED_TAB_ID=j.SAVED_TAB_ID,exports.TeachMePlugin=q.default,exports.TemplateRegistry=q.TemplateRegistry,exports.ContinueWithTemplateModal=S.default,exports.GuidelineCart=k.GuidelineCart,exports.GuidelineCartHeader=_.GuidelineCartHeader,exports.GuidelineCartItem=D.GuidelineCartItem,exports.GuidelineEmptyState=A.GuidelineEmptyState,exports.GuidelineHeader=W.GuidelineHeader,exports.GuidelineIconButton=O.GuidelineIconButton,exports.GuidelineLandingPage=M.GuidelineLandingPage,exports.GuidelineFilterPanel=E.GuidelineFilterPanel,exports.GuidelineLibrary=P.GuidelineLibrary,exports.GuidelineLibraryCard=y.GuidelineLibraryCard,exports.LearningManagementWrapper=F.LearningManagementWrapper,exports.GuidelineProceedButton=B.GuidelineProceedButton,exports.GuidelineSelectButton=J.GuidelineSelectButton,exports.GuidelineCardMenu=h.GuidelineCardMenu,exports.createGuidelineCardMenuItems=h.createGuidelineCardMenuItems,exports.GuidelineConfirmDialog=b.GuidelineConfirmDialog,exports.useGuidelineSelection=v.useGuidelineSelection,exports.DEFAULT_GUIDELINE_ARTIFACT_TEMPLATE=R.DEFAULT_GUIDELINE_ARTIFACT_TEMPLATE,exports.DEFAULT_GUIDELINE_LABELS=R.DEFAULT_GUIDELINE_LABELS,exports.createGuidelineId=w.createGuidelineId,exports.cx=w.cx,exports.defaultFormatAddedOnLabel=w.defaultFormatAddedOnLabel,exports.getAppIntegrationId=w.getAppIntegrationId,exports.getGuidelineDate=w.getGuidelineDate,exports.getGuidelineDescription=w.getGuidelineDescription,exports.getGuidelineDisplayDescription=w.getGuidelineDisplayDescription,exports.getGuidelineId=w.getGuidelineId,exports.getGuidelineTitle=w.getGuidelineTitle,exports.isInstantLearningGuideline=w.isInstantLearningGuideline,exports.mergeGuidelineLabels=w.mergeGuidelineLabels,exports.getGuidelineWorkspaceActions=V.getGuidelineWorkspaceActions,exports.getGuidelineWorkspaceSnapshot=V.getGuidelineWorkspaceSnapshot,exports.useGuidelineWorkspace=H.useGuidelineWorkspace,exports.useGuidelineWorkspaceActions=H.useGuidelineWorkspaceActions,exports.useOptionalGuidelineWorkspace=H.useOptionalGuidelineWorkspace,exports.useOptionalGuidelineWorkspaceActions=H.useOptionalGuidelineWorkspaceActions,exports.clearGuidelineCartClearPending=U.clearGuidelineCartClearPending,exports.clearInstantLearningGuidelineCartPresent=U.clearInstantLearningGuidelineCartPresent,exports.getGuidelineSessionId=U.getGuidelineSessionId,exports.markGuidelineCartClearPending=U.markGuidelineCartClearPending,exports.rotateGuidelineSessionId=U.rotateGuidelineSessionId,exports.removeInstantLearningGuidelinesFromCart=N.removeInstantLearningGuidelinesFromCart,exports.closeGuidelineOverlayWithSync=K.closeGuidelineOverlayWithSync,exports.dataCartFileToGuidelineFileItem=Q.dataCartFileToGuidelineFileItem,exports.getDataCartFilesFromResponse=Q.getDataCartFilesFromResponse,exports.isGuidelineDataCartFile=Q.isGuidelineDataCartFile,exports.mergeGuidelineFiles=Q.mergeGuidelineFiles,exports.syncGuidelineCartWithMemstore=Y.syncGuidelineCartWithMemstore,exports.guidelineQueryClient=z.guidelineQueryClient;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),e=require("../api/transport.js");exports.publishAgenticFeedbackForVariantIngestion=function(a){return t.__awaiter(this,void 0,void 0,function(){var n,s,r,i,o,u,c;return t.__generator(this,function(l){switch(l.label){case 0:n=a.baseUrl,s=a.organizationName,r=a.payload,i=a.additionalHeaders,o="".concat(n,"/api/chatbot/publishAgenticFeedbackForVariantIngestion?name=ilnewtest&organizationName=").concat(encodeURIComponent(s)),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,e.http.post(o,"string"==typeof r?r:JSON.stringify(r),{headers:t.__assign({"Content-Type":"application/json"},null!=i?i:{}),withCredentials:!0,validateStatus:function(){return!0}})];case 2:return[2,{ok:(u=l.sent()).status>=200&&u.status<300,status:u.status,statusText:u.statusText,data:u.data}];case 3:throw c=l.sent(),console.error("[InstantLearningService] Request error:",c),c;case 4:return[2]}})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");exports.publishAgenticFeedbackForVariantIngestion=function(n){var t=n.baseUrl,a=n.organizationName,o=n.payload,i=n.additionalHeaders,r="".concat(t,"/api/chatbot/publishAgenticFeedbackForVariantIngestion?name=ilnewtest&organizationName=").concat(encodeURIComponent(a));return fetch(r,{method:"POST",headers:e.__assign({"Content-Type":"application/json"},null!=i?i:{}),credentials:"include",body:"string"==typeof o?o:JSON.stringify(o)}).catch(function(e){throw console.error("[InstantLearningService] Fetch error:",e),e})};
2
2
  //# sourceMappingURL=InstantLearningService.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("../api/transport.js"),r="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",n="techolution-instantLearning-topics",a="techolution-instantLearning-variants";exports.fetchAllCustomScopes=function(n){return e.__awaiter(void 0,void 0,void 0,function(){var a,s,o,i,c;return e.__generator(this,function(e){switch(e.label){case 0:a="".concat(n,"/api/scopes/getAllScoper"),s={Authorization:"Bearer ".concat(r)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.get(a,{headers:s})];case 2:return o=e.sent(),[2,((null===(c=o.data)||void 0===c?void 0:c.data)||[]).map(function(e){return{scopeName:e.scopeName,scopeId:e.scopeId}})];case 3:return i=e.sent(),console.error("Error fetching all scopes:",i),[2,[]];case 4:return[2]}})})},exports.fetchExistingTopicsAPI=function(s){return e.__awaiter(void 0,void 0,void 0,function(){var o,i,c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:o={topic_table:n,variant_table:a},i="".concat(s,"/api/instant-learning/getExistingTopics"),c={Authorization:"Bearer ".concat(r)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.post(i,o,{headers:c})];case 2:return(u=e.sent()).data.response&&0!==Object.keys(u.data.response.response).length?[2,Object.entries(u.data.response.response).map(function(e){return{id:e[0],label:e[1].topic_name}})]:[2,[]];case 3:return l=e.sent(),console.error("Error fetching existing topics:",l),[2,[]];case 4:return[2]}})})},exports.fetchScopes=function(n,a,s){return e.__awaiter(void 0,void 0,void 0,function(){var o,i,c,u,l,h,p,d,g,v,f,I,b;return e.__generator(this,function(e){switch(e.label){case 0:o={Authorization:"Bearer ".concat(r)},i="".concat(s,"/api/chatbot/getChatbot?name=").concat(n,"&organizationName=").concat(a),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.get(i,{headers:o})];case 2:return p=e.sent(),c=p.data,[3,4];case 3:throw u=e.sent(),console.error("Error fetching chatbot details:",u),u;case 4:l="".concat(s,"/api/agent/getAgentSettings?agentSettingsId=").concat(c.agentSettingsId),e.label=5;case 5:return e.trys.push([5,7,,8]),[4,t.http.get(l,{headers:o})];case 6:return p=e.sent(),h=null===(b=p.data)||void 0===b?void 0:b.agentSettings,[3,8];case 7:throw d=e.sent(),console.error("Error fetching agent settings:",d),d;case 8:return g=(null==h?void 0:h.scopeMetrics)||[],v=g.filter(function(e){return e.isSelected}),f=v.find(function(e){return"Custom"===e.scope}),I=(null==f?void 0:f.id)&&Array.isArray(f.id)?f.id.map(function(e){return{scopeName:e.scopeName,scopeId:e.id}}):[],console.log("Scope options:",v),console.log("Custom scope options:",I),[2,{scopeOptions:v,customScopeOptions:I,assistantId:c.id}]}})})},exports.fetchUserByEmail=function(n,a){return e.__awaiter(void 0,void 0,void 0,function(){var s,o,i;return e.__generator(this,function(e){switch(e.label){case 0:s="".concat(a,"/api/users/getUserByEmail/").concat(n),o={Authorization:"Bearer ".concat(r)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.get(s,{headers:o})];case 2:return[2,e.sent().data];case 3:throw i=e.sent(),console.error("Error fetching user by email:",i),i;case 4:return[2]}})})},exports.searchAssistants=function(n,a){return e.__awaiter(void 0,void 0,void 0,function(){var s,o,i,c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:s="".concat(a,"/api/chatbot/search"),o={Authorization:"Bearer ".concat(r)},i={organizationName:"techolution",name:n,isArchived:"false"},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.get(s,{headers:o,params:i})];case 2:return c=e.sent(),u=c.data,Array.isArray(u)?[2,u]:[2,(null==u?void 0:u.response)||(null==u?void 0:u.data)||[]];case 3:return l=e.sent(),console.error("Error searching assistants:",l),[2,[]];case 4:return[2]}})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(require("axios")),n="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",a="techolution-instantLearning-topics",s="techolution-instantLearning-variants";exports.fetchAllCustomScopes=function(t){return e.__awaiter(void 0,void 0,void 0,function(){var a,s,o,i,c;return e.__generator(this,function(e){switch(e.label){case 0:a="".concat(t,"/api/scopes/getAllScoper"),s={Authorization:"Bearer ".concat(n)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(a,{headers:s})];case 2:return o=e.sent(),[2,((null===(c=o.data)||void 0===c?void 0:c.data)||[]).map(function(e){return{scopeName:e.scopeName,scopeId:e.scopeId}})];case 3:return i=e.sent(),console.error("Error fetching all scopes:",i),[2,[]];case 4:return[2]}})})},exports.fetchExistingTopicsAPI=function(t){return e.__awaiter(void 0,void 0,void 0,function(){var o,i,c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:o={topic_table:a,variant_table:s},i="".concat(t,"/api/instant-learning/getExistingTopics"),c={Authorization:"Bearer ".concat(n)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.post(i,o,{headers:c})];case 2:return(u=e.sent()).data.response&&0!==Object.keys(u.data.response.response).length?[2,Object.entries(u.data.response.response).map(function(e){return{id:e[0],label:e[1].topic_name}})]:[2,[]];case 3:return l=e.sent(),console.error("Error fetching existing topics:",l),[2,[]];case 4:return[2]}})})},exports.fetchScopes=function(t,a,s){return e.__awaiter(void 0,void 0,void 0,function(){var o,i,c,u,l,d,h,p,g,f,v,b,I;return e.__generator(this,function(e){switch(e.label){case 0:o={Authorization:"Bearer ".concat(n)},i="".concat(s,"/api/chatbot/getChatbot?name=").concat(t,"&organizationName=").concat(a),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(i,{headers:o})];case 2:return h=e.sent(),c=h.data,[3,4];case 3:throw u=e.sent(),console.error("Error fetching chatbot details:",u),u;case 4:l="".concat(s,"/api/agent/getAgentSettings?agentSettingsId=").concat(c.agentSettingsId),e.label=5;case 5:return e.trys.push([5,7,,8]),[4,r.default.get(l,{headers:o})];case 6:return h=e.sent(),d=null===(I=h.data)||void 0===I?void 0:I.agentSettings,[3,8];case 7:throw p=e.sent(),console.error("Error fetching agent settings:",p),p;case 8:return g=(null==d?void 0:d.scopeMetrics)||[],f=g.filter(function(e){return e.isSelected}),v=f.find(function(e){return"Custom"===e.scope}),b=(null==v?void 0:v.id)&&Array.isArray(v.id)?v.id.map(function(e){return{scopeName:e.scopeName,scopeId:e.id}}):[],console.log("Scope options:",f),console.log("Custom scope options:",b),[2,{scopeOptions:f,customScopeOptions:b,assistantId:c.id}]}})})},exports.fetchUserByEmail=function(t,a){return e.__awaiter(void 0,void 0,void 0,function(){var s,o,i;return e.__generator(this,function(e){switch(e.label){case 0:s="".concat(a,"/api/users/getUserByEmail/").concat(t),o={Authorization:"Bearer ".concat(n)},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(s,{headers:o})];case 2:return[2,e.sent().data];case 3:throw i=e.sent(),console.error("Error fetching user by email:",i),i;case 4:return[2]}})})},exports.searchAssistants=function(t,a){return e.__awaiter(void 0,void 0,void 0,function(){var s,o,i,c,u,l;return e.__generator(this,function(e){switch(e.label){case 0:s="".concat(a,"/api/chatbot/search"),o={Authorization:"Bearer ".concat(n)},i={organizationName:"techolution",name:t,isArchived:"false"},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.default.get(s,{headers:o,params:i})];case 2:return c=e.sent(),u=c.data,Array.isArray(u)?[2,u]:[2,(null==u?void 0:u.response)||(null==u?void 0:u.data)||[]];case 3:return l=e.sent(),console.error("Error searching assistants:",l),[2,[]];case 4:return[2]}})})};
2
2
  //# sourceMappingURL=agentGenieAPI.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("../api/transport.js");exports.fetchBookSuggestions=function(r){return e.__awaiter(void 0,void 0,void 0,function(){var r,o;return e.__generator(this,function(e){switch(e.label){case 0:r="https://dev-creative-workspace.techo.camp/backend/book-finder-mode/books/titles",e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.get(r)];case 2:return[2,e.sent().data];case 3:throw o=e.sent(),console.error("Failed to fetch book suggestions:",o),o;case 4:return[2]}})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");exports.fetchBookSuggestions=function(t){return e.__awaiter(void 0,void 0,void 0,function(){var t,r,o;return e.__generator(this,function(e){switch(e.label){case 0:t="https://dev-creative-workspace.techo.camp/backend/book-finder-mode/books/titles",e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(t)];case 2:if(!(r=e.sent()).ok)throw new Error("API Error: ".concat(r.status," ").concat(r.statusText));return[4,r.json()];case 3:return[2,e.sent()];case 4:throw o=e.sent(),console.error("Failed to fetch book suggestions:",o),o;case 5:return[2]}})})};
2
2
  //# sourceMappingURL=bookGenieAPI.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("../api/transport.js");exports.fetchInstantLearningTagsAPI=function(n,r){return e.__awaiter(void 0,void 0,void 0,function(){var i,a,s,o;return e.__generator(this,function(e){switch(e.label){case 0:if(!r||!n)return console.warn("fetchInstantLearningTagsAPI: Missing query or baseUrl"),[2,{}];i="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.post("".concat(n,"/api/instant-learning/getInstantLearningTags"),{query:r},{headers:{Authorization:"Bearer ".concat(i)}})];case 2:return a=e.sent(),[2,(null===(o=null==a?void 0:a.data)||void 0===o?void 0:o.tags)||{}];case 3:return s=e.sent(),console.error("Error fetching instant learning tags:",s),[2,{}];case 4:return[2]}})})},exports.fetchSuggestedCategories=function(n,r){return e.__awaiter(void 0,void 0,void 0,function(){var i,a,s,o,c,l,u,d,I,h;return e.__generator(this,function(e){switch(e.label){case 0:if(!n.trim())return[2,[]];i="".concat(r,"/api/instant-learning/getSuggestedCategories"),a="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",s={llm_model:"gpt-4o",topics_config:{dbIndexName:"techolution-instantLearning-categories",dbType:"alloydb",embeddingModel:"mxbai-embed-large-v1",embedding_column:"category_embedding",similarity_threshold:.6},question:"".concat(n),prompt:'You are an intelligent classifier. Analyze the following question or conversation and extract the most relevant **categories** that describe its content. \nInclude:\n1. **Specific topics** (e.g., lung cancer, diabetes, neural networks).\n2. **General domains** (e.g., healthcare, education, technology).\n3. **Intent or task types** (e.g., treatment guidance, diagnosis, troubleshooting).\n\nInput:\nchat_data: The original query from the user\n\nOnly return the categories in this exact format:\n[\n {\n "categories": ["<category1>", "<category2>", "..."]\n }\n]'},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,t.http.post(i,s,{headers:{"Content-Type":"application/json",accept:"application/json, text/plain, */*",Authorization:"Bearer ".concat(a)}})];case 2:return o=e.sent(),c=o.data,(l=null===(I=null==c?void 0:c.response)||void 0===I?void 0:I.response)&&Array.isArray(l)&&l.length>0&&(u=null===(h=l[0])||void 0===h?void 0:h.categories)&&Array.isArray(u)?[2,u.map(function(e){return{label:e,value:e,isCustom:!1}})]:(console.warn("Category API response was successful but did not match the expected structure.",c),[2,[]]);case 3:return d=e.sent(),console.error("Error fetching suggested categories:",d),[2,[]];case 4:return[2]}})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(require("axios"));exports.fetchInstantLearningTagsAPI=function(t,r){return e.__awaiter(void 0,void 0,void 0,function(){var i,a,s,o;return e.__generator(this,function(e){switch(e.label){case 0:if(!r||!t)return console.warn("fetchInstantLearningTagsAPI: Missing query or baseUrl"),[2,{}];i="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.default.post("".concat(t,"/api/instant-learning/getInstantLearningTags"),{query:r},{headers:{Authorization:"Bearer ".concat(i)}})];case 2:return a=e.sent(),[2,(null===(o=null==a?void 0:a.data)||void 0===o?void 0:o.tags)||{}];case 3:return s=e.sent(),console.error("Error fetching instant learning tags:",s),[2,{}];case 4:return[2]}})})},exports.fetchSuggestedCategories=function(t,n){return e.__awaiter(void 0,void 0,void 0,function(){var r,i,a,s,o,c,l,u,d,I;return e.__generator(this,function(e){switch(e.label){case 0:if(!t.trim())return[2,[]];r="".concat(n,"/api/instant-learning/getSuggestedCategories"),i="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4MDU5NjU4Yy1hNjVjLTRlMTQtODlhYS1hNTE5NWY1ZDA5ZjUiLCJ1c2VybmFtZSI6IkthdGh5YXlhbmlNIiwibmFtZSI6Ik0gS2F0aHlheWFuaSIsImVtYWlsIjoibWFkdW1idS5rYXRoeWF5YW5pQHRlY2hvbHV0aW9uLmNvbSIsInJvbGUiOiJzdXBlcl9hZG1pbiIsInN0YXR1cyI6ImFjdGl2ZSIsImlhdCI6MTc1MzM4Mzg4N30.iF2nGYpBedIfeGasUNc7lhjStb_B_u1uz6NFEh0u6qI",a={llm_model:"gpt-4o",topics_config:{dbIndexName:"techolution-instantLearning-categories",dbType:"alloydb",embeddingModel:"mxbai-embed-large-v1",embedding_column:"category_embedding",similarity_threshold:.6},question:"".concat(t),prompt:'You are an intelligent classifier. Analyze the following question or conversation and extract the most relevant **categories** that describe its content. \nInclude:\n1. **Specific topics** (e.g., lung cancer, diabetes, neural networks).\n2. **General domains** (e.g., healthcare, education, technology).\n3. **Intent or task types** (e.g., treatment guidance, diagnosis, troubleshooting).\n\nInput:\nchat_data: The original query from the user\n\nOnly return the categories in this exact format:\n[\n {\n "categories": ["<category1>", "<category2>", "..."]\n }\n]'},e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json, text/plain, */*",Authorization:"Bearer ".concat(i)},body:JSON.stringify(a)})];case 2:if(!(s=e.sent()).ok)throw new Error("API request failed with status ".concat(s.status));return[4,s.json()];case 3:return o=e.sent(),(c=null===(d=null==o?void 0:o.response)||void 0===d?void 0:d.response)&&Array.isArray(c)&&c.length>0&&(l=null===(I=c[0])||void 0===I?void 0:I.categories)&&Array.isArray(l)?[2,l.map(function(e){return{label:e,value:e,isCustom:!1}})]:(console.warn("Category API response was successful but did not match the expected structure.",o),[2,[]]);case 4:return u=e.sent(),console.error("Error fetching suggested categories:",u),[2,[]];case 5:return[2]}})})};
2
2
  //# sourceMappingURL=instantLearningAPI.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as n,__generator as t}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as a,useEffect as r}from"react";import{Dialog as s,IconButton as l,DialogContent as g,Box as c}from"@mui/material";import d from"./_components/ChatComponent.js";import u from"./_components/BookLearningForm.js";import{http as m}from"../../api/transport.js";var p=function(p){var f=p.open,v=p.selectedText,h=p.chatAssistantName,x=p.organizationName,b=p.baseUrl,L=p.baseWebsocketUrl,S=p.closeFunction,w=p.ThinkingBulbIconComponent,D=p.chatAssistantLogoUrl,I=p.ChatIconComponent,T=p.ggcAssistantName;p.mode;var y=p.rating,C=p.loggedInUserEmail,R=p.currentDocumentDetails,k=a(f),W=k[0],A=k[1],F=a(!1);F[0],F[1];var M=a(!1),N=M[0],U=M[1],_=a({}),E=_[0],B=_[1],j=a(null),V=j[0],z=j[1],O=a(!1);O[0];var P=O[1],q=a(!1),H=q[0];q[1];var J=a(null);J[0];var G=J[1],K=a("");K[0];var Q=K[1],X=a(!1),Y=X[0],Z=X[1],$=a(!1),ee=$[0],ne=$[1],te=a(!1),ie=te[0],oe=te[1],ae=a(!1),re=ae[0],se=ae[1],le=a(null),ge=le[0],ce=le[1],de=a(null),ue=de[0],me=de[1],pe=a(""),fe=pe[0],ve=pe[1],he=a(""),xe=he[0],be=he[1],Le=a(!1),Se=Le[0];Le[1];var we=a(null),De=we[0],Ie=we[1],Te=a(null),ye=Te[0],Ce=Te[1],Re=a(null);Re[0];var ke=Re[1],We=a(null);We[0];var Ae=We[1],Fe=a(null),Me=Fe[0],Ne=Fe[1],Ue=a(y),_e=Ue[0],Ee=Ue[1],Be=a([]),je=Be[0],Ve=Be[1];r(function(){A(f)},[f]),r(function(){var e,i,o,a,r;if(re){console.log("Ingestion trigger received. Preparing payload...");var s=new Map;je.forEach(function(e){e.title&&e.isbn&&s.set(e.title,e.isbn)});var l=(null!==(e=null==V?void 0:V.sourceDocuments)&&void 0!==e?e:[]).map(function(e){return s.get(e)}).filter(function(e){return!!e}),g=(null!==(i=null==V?void 0:V.whenToApply)&&void 0!==i?i:[]).filter(function(e){return""!==e.trim()}).join(" OR "),c=(null!==(o=null==V?void 0:V.whenNotToApply)&&void 0!==o?o:[]).filter(function(e){return""!==e.trim()}).join(" OR "),d={metadata:{user_query:v,ingestion_time:(new Date).toISOString(),ingested_by:C,rating:null!==(a=null==V?void 0:V.rating)&&void 0!==a?a:_e,whenToApply:g,whenNotToApply:c,mode:"bookgenie",current_document:null==R?void 0:R.id,associated_docs:l},user_query:v,rating:null!==(r=null==V?void 0:V.rating)&&void 0!==r?r:_e,current_document:null==R?void 0:R.id,associated_docs:l,whenToApply:g,whenNotToApply:c,mode:"bookgenie"};console.log("Sending ingestion payload:",JSON.stringify(d,null,2));n(void 0,void 0,void 0,function(){var e,n,i;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,m.post("".concat(b,"/instant_learning/ingest-document-il"),d,{headers:{"Content-Type":"application/json"},validateStatus:function(){return!0}})];case 1:return(e=t.sent()).status>=200&&e.status<300?(n=e.data,console.log("Ingestion successful:",n),se(!1),console.log("Ingestion trigger reset."),A(!1),setTimeout(function(){S()},100)):(console.error("Ingestion failed:",e.status,e.data),se(!1)),[3,3];case 2:return i=t.sent(),console.error("Error calling ingestion API:",i),se(!1),[3,3];case 3:return[2]}})})}},[re,V,b,v,C,_e,R,je]);var ze=function(){A(!1),S()};return i(s,e({open:W,onClose:ze,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"95vw",height:"100vh",display:"flex",flexDirection:"column",margin:0,maxWidth:"100vw"}}},{children:[o(l,e({"aria-label":"close",onClick:ze,sx:{position:"absolute",right:8,top:8,zIndex:1,color:function(e){return e.palette.grey[500]}},size:"large"},{children:o("svg",e({width:"28px",height:"28px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"#000000"},{children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.707.708L7.293 8l-3.646 3.646.707.708L8 8.707z"})}))})),i(g,e({sx:{flex:1,overflow:"auto",display:"flex",flexDirection:"row",gap:2}},{children:[o(c,e({sx:{minWidth:"350px",maxWidth:"35%",bgcolor:"#f5f5f5",p:0,borderRadius:1,display:"flex",flexDirection:"column"}},{children:o(d,{chatAssistantLogoUrl:D||"",chatAssistantName:h,organizationName:x,baseUrl:b,setInstantLearningSuggestions:B,formDataState:V,setFormDataState:z,hasUserFilledForm:N,setHasUserFilledForm:U,baseWebsocketUrl:L,setIsNewChatClicked:P,selectedText:v,ChatIconComponent:I,ggcAssistantName:T||"",ThinkingBulbIconComponent:w,hasUserWrittenModification:H,setExtractedModification:G,setSave:Z,setExtractedTooltip:Q,setIsSaveLoading:oe,isSaveLoading:ie,save:Y,instantLearningSuggestions:E,template:"",setShouldTriggerSave:se,validationWtaResponse:ge,setValidationWtaResponse:ce,learningWtaResponse:ue,setLearningWtaResponse:me,isFormSaveClicked:ee,setIsFormSavedClicked:ne,onDeleteLearning:function(e){Ce(e)},deleteLearningTrigger:ye,setDeleteLearningTrigger:Ce,onMergeLearning:function(e){Ne(e)},mergeLearningTrigger:Me,setMergeLearningTrigger:Ne,onResetLearningData:function(){},setEditConflictingLearningTrigger:ke,setEditSimilarLearningTrigger:Ae,sendMessageInChat:fe,setSendMessageInChat:ve,setIsMergeLoading:function(){},sendValidationMessage:xe,setSendValidationMessage:be,setValidationRecommendations:Ie,isFormValidating:Se,validationRecommendations:De,setExtractedRating:Ee,extractedRating:_e,currentDocumentDetails:R,availableBooks:je})})),o(c,e({sx:{minWidth:"65%",maxWidth:"65%",display:"flex",flexDirection:"column"}},{children:o(u,{question:v,onSubmit:function(e){console.log("Book Learning Form Data:",e)},rating:y,baseUrl:b,extractedRating:_e,setExtractedRating:Ee,currentDocumentDetails:R,formDataState:V,setFormDataState:z,instantLearningSuggestions:E,setSendMessageInChat:ve,setValidationWtaResponse:ce,availableBooks:je,setAvailableBooks:Ve,validationRecommendations:De})}))]}))]}))};export{p as default};
1
+ import{__assign as e,__awaiter as n,__generator as t}from"tslib";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as a,useEffect as r}from"react";import{Dialog as s,IconButton as l,DialogContent as c,Box as g}from"@mui/material";import d from"./_components/ChatComponent.js";import u from"./_components/BookLearningForm.js";var m=function(m){var p=m.open,f=m.selectedText,v=m.chatAssistantName,h=m.organizationName,x=m.baseUrl,b=m.baseWebsocketUrl,S=m.closeFunction,L=m.ThinkingBulbIconComponent,y=m.chatAssistantLogoUrl,w=m.ChatIconComponent,T=m.ggcAssistantName;m.mode;var D=m.rating,I=m.loggedInUserEmail,C=m.currentDocumentDetails,R=a(p),k=R[0],W=R[1],A=a(!1);A[0],A[1];var F=a(!1),M=F[0],N=F[1],U=a({}),_=U[0],E=U[1],B=a(null),j=B[0],O=B[1],V=a(!1);V[0];var z=V[1],P=a(!1),q=P[0];P[1];var J=a(null);J[0];var H=J[1],G=a("");G[0];var K=G[1],Q=a(!1),X=Q[0],Y=Q[1],Z=a(!1),$=Z[0],ee=Z[1],ne=a(!1),te=ne[0],ie=ne[1],oe=a(!1),ae=oe[0],re=oe[1],se=a(null),le=se[0],ce=se[1],ge=a(null),de=ge[0],ue=ge[1],me=a(""),pe=me[0],fe=me[1],ve=a(""),he=ve[0],xe=ve[1],be=a(!1),Se=be[0];be[1];var Le=a(null),ye=Le[0],we=Le[1],Te=a(null),De=Te[0],Ie=Te[1],Ce=a(null);Ce[0];var Re=Ce[1],ke=a(null);ke[0];var We=ke[1],Ae=a(null),Fe=Ae[0],Me=Ae[1],Ne=a(D),Ue=Ne[0],_e=Ne[1],Ee=a([]),Be=Ee[0],je=Ee[1];r(function(){W(p)},[p]),r(function(){var e,i,o,a,r;if(ae){console.log("Ingestion trigger received. Preparing payload...");var s=new Map;Be.forEach(function(e){e.title&&e.isbn&&s.set(e.title,e.isbn)});var l=(null!==(e=null==j?void 0:j.sourceDocuments)&&void 0!==e?e:[]).map(function(e){return s.get(e)}).filter(function(e){return!!e}),c=(null!==(i=null==j?void 0:j.whenToApply)&&void 0!==i?i:[]).filter(function(e){return""!==e.trim()}).join(" OR "),g=(null!==(o=null==j?void 0:j.whenNotToApply)&&void 0!==o?o:[]).filter(function(e){return""!==e.trim()}).join(" OR "),d={metadata:{user_query:f,ingestion_time:(new Date).toISOString(),ingested_by:I,rating:null!==(a=null==j?void 0:j.rating)&&void 0!==a?a:Ue,whenToApply:c,whenNotToApply:g,mode:"bookgenie",current_document:null==C?void 0:C.id,associated_docs:l},user_query:f,rating:null!==(r=null==j?void 0:j.rating)&&void 0!==r?r:Ue,current_document:null==C?void 0:C.id,associated_docs:l,whenToApply:c,whenNotToApply:g,mode:"bookgenie"};console.log("Sending ingestion payload:",JSON.stringify(d,null,2));n(void 0,void 0,void 0,function(){var e,n,i,o,a,r;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,6,,7]),[4,fetch("".concat(x,"/instant_learning/ingest-document-il"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})];case 1:return(e=t.sent()).ok?[4,e.json()]:[3,3];case 2:return n=t.sent(),console.log("Ingestion successful:",n),re(!1),console.log("Ingestion trigger reset."),W(!1),setTimeout(function(){S()},100),[3,5];case 3:return o=(i=console).error,a=["Ingestion failed:",e.status],[4,e.text()];case 4:o.apply(i,a.concat([t.sent()])),re(!1),t.label=5;case 5:return[3,7];case 6:return r=t.sent(),console.error("Error calling ingestion API:",r),re(!1),[3,7];case 7:return[2]}})})}},[ae,j,x,f,I,Ue,C,Be]);var Oe=function(){W(!1),S()};return i(s,e({open:k,onClose:Oe,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"95vw",height:"100vh",display:"flex",flexDirection:"column",margin:0,maxWidth:"100vw"}}},{children:[o(l,e({"aria-label":"close",onClick:Oe,sx:{position:"absolute",right:8,top:8,zIndex:1,color:function(e){return e.palette.grey[500]}},size:"large"},{children:o("svg",e({width:"28px",height:"28px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"#000000"},{children:o("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.707.708L7.293 8l-3.646 3.646.707.708L8 8.707z"})}))})),i(c,e({sx:{flex:1,overflow:"auto",display:"flex",flexDirection:"row",gap:2}},{children:[o(g,e({sx:{minWidth:"350px",maxWidth:"35%",bgcolor:"#f5f5f5",p:0,borderRadius:1,display:"flex",flexDirection:"column"}},{children:o(d,{chatAssistantLogoUrl:y||"",chatAssistantName:v,organizationName:h,baseUrl:x,setInstantLearningSuggestions:E,formDataState:j,setFormDataState:O,hasUserFilledForm:M,setHasUserFilledForm:N,baseWebsocketUrl:b,setIsNewChatClicked:z,selectedText:f,ChatIconComponent:w,ggcAssistantName:T||"",ThinkingBulbIconComponent:L,hasUserWrittenModification:q,setExtractedModification:H,setSave:Y,setExtractedTooltip:K,setIsSaveLoading:ie,isSaveLoading:te,save:X,instantLearningSuggestions:_,template:"",setShouldTriggerSave:re,validationWtaResponse:le,setValidationWtaResponse:ce,learningWtaResponse:de,setLearningWtaResponse:ue,isFormSaveClicked:$,setIsFormSavedClicked:ee,onDeleteLearning:function(e){Ie(e)},deleteLearningTrigger:De,setDeleteLearningTrigger:Ie,onMergeLearning:function(e){Me(e)},mergeLearningTrigger:Fe,setMergeLearningTrigger:Me,onResetLearningData:function(){},setEditConflictingLearningTrigger:Re,setEditSimilarLearningTrigger:We,sendMessageInChat:pe,setSendMessageInChat:fe,setIsMergeLoading:function(){},sendValidationMessage:he,setSendValidationMessage:xe,setValidationRecommendations:we,isFormValidating:Se,validationRecommendations:ye,setExtractedRating:_e,extractedRating:Ue,currentDocumentDetails:C,availableBooks:Be})})),o(g,e({sx:{minWidth:"65%",maxWidth:"65%",display:"flex",flexDirection:"column"}},{children:o(u,{question:f,onSubmit:function(e){console.log("Book Learning Form Data:",e)},rating:D,baseUrl:x,extractedRating:Ue,setExtractedRating:_e,currentDocumentDetails:C,formDataState:j,setFormDataState:O,instantLearningSuggestions:_,setSendMessageInChat:fe,setValidationWtaResponse:ce,availableBooks:Be,setAvailableBooks:je,validationRecommendations:ye})}))]}))]}))};export{m as default};
2
2
  //# sourceMappingURL=DocumentLearning.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n,__spreadArray as e,__awaiter as t,__generator as o}from"tslib";import{useState as i,useEffect as r,useMemo as l,useRef as a,useCallback as s,createElement as c}from"react";import{jsxs as d,jsx as u,Fragment as f}from"react/jsx-runtime";import p from"@mui/icons-material/Delete";import h from"@mui/icons-material/Add";import m from"@mui/icons-material/Save";import g from"@mui/icons-material/Edit";import{Box as x,Typography as y,TextField as v,Autocomplete as w,Checkbox as b,ListItemText as C,CircularProgress as k,Chip as S,Button as _,Tooltip as L,IconButton as F,InputAdornment as I,Accordion as P,AccordionSummary as A,AccordionDetails as T}from"@mui/material";import z from"@mui/icons-material/CheckCircleOutline";import R from"@mui/icons-material/Cancel";import{X as J,Info as j,ChevronDown as W,Lightbulb as D}from"lucide-react";import O from"../InstantLearning.module.css.js";import{fetchBookSuggestions as V}from"../../../utils/bookGenieAPI.js";import E from"../../../hooks/useDebounce.js";import M,{Toaster as B}from"react-hot-toast";import N from"./ConflictingLearningWarnCard.js";import{http as H}from"../../../api/transport.js";var q=function(r){var l=r.label,a=r.required,s=void 0!==a&&a,c=r.tooltipText,f=r.conditions,w=r.onConditionsChange,b=r.isLoading,C=void 0!==b&&b,S=r.isValidating,_=void 0!==S&&S,P=r.onLock,A=r.onValidationFailure,T=r.children,z=i(!1),R=z[0],J=z[1];return d(x,n({sx:{display:"flex",flexDirection:"column",height:"100%"}},{children:[d(y,n({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"}},{children:[l,s&&u(x,n({component:"span",sx:{color:"red"}},{children:"*"})),c&&u(L,n({title:c,placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:u(j,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),d(x,n({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 32px)",bgcolor:"white",boxShadow:C?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[u(x,n({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:d("div",n({style:{width:"100%",display:"flex",gap:"0.25rem",justifyContent:"space-between",alignItems:"center"}},{children:[d("div",n({style:{display:"flex",gap:"0.25rem",alignItems:"center"}},{children:[u("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:u("g",n({clipPath:"url(#clip0_6004_60631)"},{children:u("path",{d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021Z",fill:"#5928ed"})}))})),u(y,n({variant:"body1",sx:{fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),d(x,{children:[u(L,n({title:"Add New Condition",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:u(F,n({onClick:function(){w(e(e([],f,!0),[""],!1)),J(!0)},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:u(h,{fontSize:"small"})}))})),f.length>0&&u(L,n({title:R?"Save & Lock":"Edit",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:u("span",{children:u(F,n({onClick:function(){return t(void 0,void 0,void 0,function(){var n;return o(this,function(e){switch(e.label){case 0:return R&&P?(console.log("Calling onLock (validation)..."),[4,P()]):[3,2];case 1:return n=e.sent(),console.log("Validation finished. Result (isValid):",n),J(!1),!n&&A?(console.log("Validation failed. Calling onValidationFailure..."),A()):n&&console.log("Validation succeeded."),[3,3];case 2:console.log("Toggling isEditable state (Edit clicked or no onLock)."),J(!R),e.label=3;case 3:return[2]}})})},size:"small",disabled:R&&f.some(function(n){return""===n.trim()})||_,sx:{color:"gray","&:hover":{color:"black"},opacity:_?.5:1,cursor:_?"wait":"pointer"}},{children:_?u(k,{size:20,sx:{color:"#5928ed"}}):u(R?m:g,{fontSize:"small"})}))})}))]})]}))})),u(x,n({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:f.length>0?d(x,n({sx:{pt:"16px"}},{children:[u("ol",n({style:{paddingLeft:"0rem",margin:0,fontFamily:"Plus Jakarta Sans"}},{children:f.map(function(t,o){return d(x,n({component:"li",sx:{display:"flex",alignItems:"flex-start",gap:1,mb:o<f.length-1?2:0,fontFamily:"Plus Jakarta Sans"}},{children:[u(v,{variant:"outlined",disabled:!R,fullWidth:!0,multiline:!0,value:t,onChange:function(n){return function(n,t){var o=e([],f,!0);o[n]=t,w(o)}(o,n.target.value)},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"}},InputProps:{startAdornment:d(I,n({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[o+1,"."]}))}}),R&&u(F,n({onClick:function(){return function(n){w(f.filter(function(e,t){return t!==n}))}(o)},sx:{mt:1},size:"large"},{children:u(p,{})}))]}),o)})})),_&&u(x,n({sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",mt:3,mb:2,fontFamily:'"Plus Jakarta Sans", sans-serif',color:"#5a28ed"}},{children:u(y,n({variant:"body2",sx:{color:"#5a28ed"}},{children:"Validating your conditions"}))})),T]})):u("div",n({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:d("div",n({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},{children:[u("div",n({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),d("div",n({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[u("div",{children:"Tell us about your learning in "}),u("span",n({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",u("span",{children:"Chat"})]}))]}))}))}))]}))]}))},Z=function(e){var t=e.color,o=void 0===t?"#fff":t,i=e.size,r=void 0===i?12:i;return d("svg",n({width:r,height:r,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[u("path",{d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.3188 23.8989 12.0012 24.0019 11.7759 23.9658L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.37668 16.8492 4.37668 16.1502 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021Z",fill:o}),u("path",{d:"M5.69218 1.72171C5.8106 1.52009 6.19176 1.52009 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.4808 5.75512 10.4808 6.24724 10.2792 6.31018L8.53618 6.88921C7.75918 7.15018 7.15018 7.75918 6.89068 8.53618L6.31018 10.2777C6.19176 10.4793 5.8106 10.4793 5.69218 10.2777L5.11168 8.53471C4.85071 7.75918 4.24171 7.15018 3.46618 6.88921L1.72318 6.30871C1.52156 6.24576 1.52156 5.75512 1.72318 5.69071L3.46618 5.11021C4.24171 4.85071 4.85071 4.24171 5.11168 3.46471L5.69218 1.72171Z",fill:o}),u("path",{d:"M16.2957 0.148207C16.4119 0.016038 16.5905 0.016038 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.4848 2.83676 19.4848 3.16265 19.3527 3.20521L18.1917 3.59221C17.6727 3.76521 17.2662 4.17171 17.0937 4.69021L16.7067 5.85121C16.5905 5.98338 16.4119 5.98338 16.2957 5.85121L15.9087 4.69021C15.7377 4.17171 15.3312 3.76521 14.8122 3.59221L13.6512 3.20521C13.519 3.16265 13.519 2.83676 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:o})]}))},G=function(e){var t=e.score;return d(x,n({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.5,py:.5,borderRadius:"16px",backgroundColor:"#10B981",color:"white",fontSize:"0.8rem",fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:[u(Z,{}),d(y,n({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"inherit"}},{children:[t,"%"]}))]}))},U=function(e){var t=e.reason,o=e.title;return d(P,n({elevation:0,sx:{backgroundColor:"#f3f0ff",border:"1px solid #dcd6f7",borderRadius:2,mb:2,"&::before":{display:"none"}}},{children:[u(A,n({expandIcon:u(W,{style:{color:"#5928ed"}}),sx:{minHeight:"auto","& .MuiAccordionSummary-content":{margin:"12px 0"}}},{children:d(x,n({sx:{display:"flex",alignItems:"center",gap:1}},{children:[u(D,{size:16,color:"#5928ed"}),u(y,n({sx:{fontSize:"0.85rem",fontWeight:600,color:"#5928ed",fontFamily:"Plus Jakarta Sans"}},{children:o}))]}))})),u(T,n({sx:{pt:0,pb:1.5,backgroundColor:"#faf9ff"}},{children:u(y,n({sx:{fontSize:"0.9rem",color:"#4A4458",fontFamily:"Plus Jakarta Sans"}},{children:t}))}))]}))},X=function(e){var t=e.condition,o=e.onAccept,i=e.onReject;return d(x,n({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1,mb:1,backgroundColor:"#f0f4f8",border:"1px solid #d1d9e6",borderRadius:"4px"}},{children:[u(y,n({sx:{flex:1,fontFamily:"Plus Jakarta Sans",mr:1}},{children:t})),d(x,n({sx:{flexShrink:0}},{children:[u(F,n({onClick:o,size:"small",sx:{color:"green"}},{children:u(z,{})})),u(F,n({onClick:i,size:"small",sx:{color:"red"}},{children:u(R,{})}))]}))]}))},K=function(e){var t=e.rating,o=e.onRatingChange,r=i(0),l=r[0],a=r[1],s=function(n){var e=l||t;return e>=n?"100%":e>=n-.5?"50%":"0%"};return u(x,n({sx:{display:"flex",gap:.5},onMouseLeave:function(){return a(0)}},{children:[1,2,3,4,5].map(function(e){return d(x,n({onClick:function(n){return function(n,e){var t=n.currentTarget.getBoundingClientRect(),i=(n.clientX-t.left)/t.width<=.5;o(i?e-.5:e)}(n,e)},onMouseMove:function(n){return function(n,e){var t=n.currentTarget.getBoundingClientRect(),o=(n.clientX-t.left)/t.width<=.5;a(o?e-.5:e)}(n,e)},sx:{cursor:"pointer",fontSize:"1.5rem",color:"#E0E0E0",position:"relative",display:"inline-block",lineHeight:1}},{children:["★",u(x,n({sx:{position:"absolute",top:0,left:0,width:s(e),overflow:"hidden",color:"#FFD700"}},{children:"★"}))]}),e)})}))},Q=function(p){var h=p.question,m=p.onSubmit,g=p.rating,L=p.baseUrl,F=p.extractedRating;p.setExtractedRating;var I=p.currentDocumentDetails,P=p.formDataState,A=p.setFormDataState,T=p.instantLearningSuggestions,z=p.setSendMessageInChat,R=p.setValidationWtaResponse,j=p.availableBooks,W=p.setAvailableBooks,D=p.validationRecommendations,Z=P||{},Q=Z.whenToApply,Y=void 0===Q?[]:Q,$=Z.whenNotToApply,nn=void 0===$?[]:$,en=Z.rating,tn=void 0===en?g:en,on=Z.sourceDocuments,rn=void 0===on?[]:on,ln=i(!1),an=ln[0],sn=ln[1],cn=i(null),dn=cn[0],un=cn[1],fn=i(!1),pn=fn[0],hn=fn[1],mn=i(!1),gn=mn[0],xn=mn[1],yn=i(!1),vn=yn[0],wn=yn[1],bn=i(""),Cn=bn[0],kn=bn[1],Sn=i(50),_n=Sn[0],Ln=Sn[1],Fn=E(Cn,500),In=i(!1),Pn=In[0],An=In[1],Tn=i(null),zn=Tn[0],Rn=Tn[1],Jn={title:null==I?void 0:I.title,author:null==I?void 0:I.author},jn=i(null),Wn=jn[0],Dn=jn[1],On=i(null),Vn=On[0],En=On[1],Mn=i({wta:!1,wnta:!1}),Bn=Mn[0],Nn=Mn[1],Hn=i({wta:!1,wnta:!1}),qn=Hn[0],Zn=Hn[1];r(function(){D&&(console.log("BookLearningForm: Received new validationRecommendations:",D),Dn(D.wta),En(D.wnta),Nn({wta:!!D.wta,wnta:!!D.wnta}),Zn({wta:!1,wnta:!1}),An(!1),Rn(null))},[D]);var Gn=function(t,o,i){An(!1),Rn(null),"wta"===o?(A(function(o){var i=qn.wta?Array.from(new Set(e(e([],o.whenToApply||[],!0),[t],!1))):[t];return n(n({},o),{whenToApply:i})}),Zn(function(e){return n(n({},e),{wta:!0})}),Dn(function(e){if(!e||!e.when_to_apply)return e;var t=n({},e.when_to_apply);return delete t[i],0===Object.keys(t).length?null:n(n({},e),{when_to_apply:t})})):(A(function(o){var i=qn.wnta?Array.from(new Set(e(e([],o.whenNotToApply||[],!0),[t],!1))):[t];return n(n({},o),{whenNotToApply:i})}),Zn(function(e){return n(n({},e),{wnta:!0})}),En(function(e){if(!e||!e.when_not_to_apply)return e;var t=n({},e.when_not_to_apply);return delete t[i],0===Object.keys(t).length?null:n(n({},e),{when_not_to_apply:t})}))},Un=function(e,t,o){"wta"===t?Dn(function(e){if(!e||!e.when_to_apply)return e;var t=n({},e.when_to_apply);return delete t[o],0===Object.keys(t).length?null:n(n({},e),{when_to_apply:t})}):En(function(e){if(!e||!e.when_not_to_apply)return e;var t=n({},e.when_not_to_apply);return delete t[o],0===Object.keys(t).length?null:n(n({},e),{when_not_to_apply:t})})},Xn=function(){return t(void 0,void 0,void 0,function(){var n,e,t,i,r,l,a,s,c,d,u,f,p;return o(this,function(o){switch(o.label){case 0:if(console.log("handleLockValidation started."),An(!1),Rn(null),R(null),!L)return console.error("❌ ERROR: Missing baseUrl for validation."),[2,!1];if(vn)return console.log("❕ Validation already in progress. Aborting."),[2,!1];wn(!0),n=Y.filter(function(n){return""!==n.trim()}),e=nn.filter(function(n){return""!==n.trim()}),t="".concat(L,"/instant_learning/validate-wta"),i={whenToApply:n,whenNotToApply:e},o.label=1;case 1:return o.trys.push([1,3,,4]),console.log("📡 Firing fetch request to:",t),[4,H.post(t,i,{headers:{"Content-Type":"application/json"},validateStatus:function(){return!0}})];case 2:if(r=o.sent(),console.log("✅ Request initiated. Status Code:",r.status),r.status<200||r.status>=300){l="Could not read error body.";try{l="string"==typeof r.data?r.data:JSON.stringify(r.data)}catch(n){}throw console.error("❌ API Error Response (".concat(r.status,"):"),l),new Error("API Error: ".concat(r.status))}return a=r.data,console.log("✅ Validation API response data:",a),R(a.response),wn(!1),(s=!0===(null===(u=null==a?void 0:a.response)||void 0===u?void 0:u.is_valid))?(An(!1),Rn(null)):(console.log("Validation API reported failure."),Rn((null===(f=null==a?void 0:a.response)||void 0===f?void 0:f.conflictingConditions)||[{conflictType:"api_validation_error",reason:(null===(p=null==a?void 0:a.response)||void 0===p?void 0:p.reason)||"Validation failed for an unknown reason."}]),An(!0)),console.log("handleLockValidation returning:",s),[2,s];case 3:return c=o.sent(),console.error("❌ Validation API fetch FAILED:",c.message,c),d={is_valid:!1,reason:"Failed to connect to validation service: ".concat(c.message),conflictingConditions:[{conflictType:"api_error",reason:"Failed to connect to validation service: ".concat(c.message)}]},R(d),Rn(d.conflictingConditions),An(!0),wn(!1),console.log("handleLockValidation returning false due to error."),[2,!1];case 4:return[2]}})})},Kn=function(){console.log("handleValidationFailure triggered."),z("Validation Failed. Do you have any recommendations for me?")},Qn=function(n){return n?n.toLowerCase().replace(/[^a-z0-9]/g,""):""},Yn=l(function(){for(var n=new Map,e=0,t=j;e<t.length;e++){var o=t[e];n.set(Qn(o.title),o.title)}return n},[j]),$n=!!h&&Y.length>0&&tn>0,ne=l(function(){return Fn.length<3?j:j.filter(function(n){return n.title.toLowerCase().includes(Fn.toLowerCase())})},[j,Fn]);r(function(){var e,t;if(T){var o=null===(e=null==T?void 0:T.conditions_whentoapply)||void 0===e?void 0:e.map(function(n){return n.when_to_apply}).filter(Boolean),i=null===(t=null==T?void 0:T.conditions_whennottoapply)||void 0===t?void 0:t.map(function(n){return n.when_not_to_apply}).filter(Boolean);(null==o?void 0:o.length)>0&&(hn(!0),setTimeout(function(){return hn(!1)},400)),(null==i?void 0:i.length)>0&&(xn(!0),setTimeout(function(){return xn(!1)},400)),((null==o?void 0:o.length)>0||(null==i?void 0:i.length)>0)&&(Dn(null),En(null),Nn({wta:!1,wnta:!1}),An(!1),Rn(null),A(function(e){return n(n({},e),{whenToApply:(null==o?void 0:o.length)>0?o:e.whenToApply,whenNotToApply:(null==i?void 0:i.length)>0?i:e.whenNotToApply})}))}},[T,A]);var ee=a("");r(function(){if(0!==Yn.size){var t=JSON.stringify(e([],rn,!0).sort());if(ee.current!==t){ee.current=t;var o=[],i=[];if(rn.forEach(function(n){var e=Qn(n);Yn.has(e)?o.push(Yn.get(e)):i.push(n)}),i.length>0){console.warn("[BookLearningForm] Invalid books:",i);var r=i[i.length-1];M.error("The suggested book could not be found: ".concat(r),{duration:6e3,style:{fontFamily:"Plus Jakarta Sans"}})}JSON.stringify(o.sort())!==t&&(console.log("[BookLearningForm] Normalizing source documents. Found valid:",o),A(function(e){return n(n({},e),{sourceDocuments:o})}))}}},[rn,Yn,A]),r(function(){Ln(50)},[Fn]),r(function(){null!=F&&A(function(e){return n(n({},e),{rating:F})})},[F,A]),r(function(){if(L){t(void 0,void 0,void 0,function(){var n,e;return o(this,function(t){switch(t.label){case 0:sn(!0),un(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,V()];case 2:return n=t.sent(),W(n),[3,5];case 3:return e=t.sent(),console.error("Error loading book suggestions:",e),un("Failed to load book suggestions."),[3,5];case 4:return sn(!1),[7];case 5:return[2]}})})}},[L,W]);var te=l(function(){return ne.slice(0,_n).map(function(n){return n.title})},[ne,_n]),oe=s(function(n){var e=n.currentTarget;e.scrollTop+e.clientHeight+40>=e.scrollHeight&&Ln(function(n){return Math.min(n+50,ne.length)})},[ne.length]);return d(x,n({p:0,className:O.customFont,sx:{display:"flex",flexDirection:"column",height:"100%",width:"95%",ml:2}},{children:[d(x,n({sx:{fontFamily:"Plus Jakarta Sans",display:"flex",flexDirection:"column",gap:2,justifyContent:"space-between",flexGrow:1,paddingTop:"20px",height:"100%",overflow:"auto"}},{children:[d(x,n({sx:{display:"flex",flexDirection:"column",gap:"20px",height:"calc(100% - 70px)",overflow:"auto",position:"relative"}},{children:[u(y,n({sx:{fontSize:{sm:"1.1rem",md:"1.25rem"},fontWeight:600,fontFamily:"Plus Jakarta Sans",color:"#000"}},{children:"We noticed you didn't like the recommendation"})),u(x,n({sx:{border:"1px solid #e0e0e0",borderRadius:"12px",padding:{sm:2,md:3},backgroundColor:"white"}},{children:d(x,n({sx:{display:"flex",gap:{sm:2,md:3},alignItems:"flex-start",flexDirection:{sm:"column",md:"row"}}},{children:[u(x,n({sx:{width:{sm:"80px",md:"100px"},height:{sm:"120px",md:"150px"},flexShrink:0,borderRadius:"8px",overflow:"hidden",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",alignSelf:{sm:"center",md:"flex-start"}}},{children:u("img",{src:null==I?void 0:I.coverUrl,alt:"Book cover",style:{width:"100%",height:"100%",objectFit:"cover"}})})),d(x,n({sx:{flex:1,width:{sm:"100%",md:"auto"}}},{children:[u(y,n({sx:{fontSize:{sm:"0.7rem",md:"0.75rem"},color:"#666",fontFamily:"Plus Jakarta Sans",mb:.5,fontWeight:500}},{children:"Here's what you searched for"})),u(v,{fullWidth:!0,value:h,InputProps:{readOnly:!0,sx:{fontFamily:"Plus Jakarta Sans",fontSize:{sm:"0.85rem",md:"0.95rem"},bgcolor:"#fafafa"}},sx:{mb:2,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans"}}}),d(x,n({sx:{display:"flex",gap:2,flexDirection:{sm:"column",lg:"row"}}},{children:[d(x,n({sx:{flex:1,width:{sm:"100%",lg:"auto"}}},{children:[u(y,n({sx:{fontSize:{sm:"0.7rem",md:"0.75rem"},color:"#666",fontFamily:"Plus Jakarta Sans",mb:.5,fontWeight:500}},{children:"Recommendation"})),u(x,n({sx:{border:"1px solid #c4c4c4",borderRadius:"4px",padding:{sm:"12px 10px",md:"16px 14px"},bgcolor:"#fafafa",minHeight:{sm:"48px",md:"56px"},display:"flex",alignItems:"center",boxSizing:"border-box",overflow:"hidden"}},{children:d(y,n({sx:{fontFamily:"Plus Jakarta Sans",fontSize:{sm:"0.85rem",md:"0.95rem"},color:"#000",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",width:"100%",lineHeight:1.4}},{children:[Jn.title," by ",Jn.author]}))}))]})),d(x,n({sx:{minWidth:{sm:"100%",lg:"200px"},display:"flex",flexDirection:"column"}},{children:[d(y,n({sx:{fontSize:{sm:"0.7rem",md:"0.75rem"},color:"#666",fontFamily:"Plus Jakarta Sans",mb:.5,fontWeight:500}},{children:["Ratings ",u("span",n({style:{color:"red"}},{children:"*"}))]})),u(x,n({sx:{border:"1px solid #c4c4c4",borderRadius:"4px",padding:{sm:"12px 10px",md:"16px 14px"},bgcolor:"#fafafa",minHeight:{sm:"48px",md:"56px"},display:"flex",alignItems:"center",justifyContent:{sm:"center",lg:"flex-start"},boxSizing:"border-box"}},{children:u(K,{rating:tn,onRatingChange:function(e){A(function(t){return n(n({},t),{rating:e})})}})}))]}))]}))]}))]}))})),u(y,n({sx:{fontSize:{sm:"1rem",md:"1.1rem"},fontWeight:600,fontFamily:"Plus Jakarta Sans",color:"#000"}},{children:"Help us improve the recommendation"})),d(x,n({sx:{display:"flex",gap:2,minHeight:"300px",flexShrink:0}},{children:[u(x,n({sx:{flex:1,height:"100%"}},{children:u(q,n({label:"When to Apply",required:!0,tooltipText:"Specific situations or conditions where this learning should be applied.",conditions:Y,onConditionsChange:function(e){A(function(t){return n(n({},t),{whenToApply:e})})},isLoading:pn,isValidating:vn,onLock:Xn,onValidationFailure:Kn},{children:Wn&&Wn.when_to_apply&&Object.keys(Wn.when_to_apply).length>0&&d(x,n({mt:Y.length>0?3:0,sx:{borderTop:Y.length>0?"1px dashed #ccc":"none",pt:Y.length>0?2:0}},{children:[Bn.wta&&d(x,n({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5}},{children:[u(y,n({variant:"subtitle2",sx:{fontWeight:"bold",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Recommended Fix:"})),u(G,{score:Wn.confidence_score})]})),Bn.wta&&Wn.reason&&u(U,{reason:Wn.reason,title:"Why these suggestions?"}),Object.entries(Wn.when_to_apply).map(function(n){var e=n[0],t=n[1];return u(X,{condition:"".concat(e,". ").concat(t),onAccept:function(){return Gn(t,"wta",e)},onReject:function(){return Un(0,"wta",e)}},"rec-wta-".concat(e))})]}))}))})),u(x,n({sx:{flex:1,height:"100%"}},{children:u(q,n({label:"When NOT to Apply",tooltipText:"Cases where this learning should not be applied to avoid incorrect responses.",conditions:nn,onConditionsChange:function(e){A(function(t){return n(n({},t),{whenNotToApply:e})})},isLoading:gn,isValidating:vn,onLock:Xn,onValidationFailure:Kn},{children:Vn&&Vn.when_not_to_apply&&Object.keys(Vn.when_not_to_apply).length>0&&d(x,n({mt:nn.length>0?3:0,sx:{borderTop:nn.length>0?"1px dashed #ccc":"none",pt:nn.length>0?2:0}},{children:[Bn.wnta&&d(x,n({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5}},{children:[u(y,n({variant:"subtitle2",sx:{fontWeight:"bold",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Recommended Fix:"})),u(G,{score:Vn.confidence_score})]})),Bn.wnta&&Vn.reason&&u(U,{reason:Vn.reason,title:"Why these suggestions?"}),Object.entries(Vn.when_not_to_apply).map(function(n){var e=n[0],t=n[1];return u(X,{condition:"".concat(e,". ").concat(t),onAccept:function(){return Gn(t,"wnta",e)},onReject:function(){return Un(0,"wnta",e)}},"rec-wnta-".concat(e))})]}))}))}))]})),Pn&&zn&&u(N,{conflictingConditions:zn}),d(x,{children:[u(y,n({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",mb:1.5}},{children:"Add Recommendations"})),u(w,{multiple:!0,id:"book-recommendation-autocomplete",options:te,onChange:function(e,t){A(function(e){return n(n({},e),{sourceDocuments:t})})},value:rn,isOptionEqualToValue:function(n,e){return Qn(n)===Qn(e)},disabled:an,disableCloseOnSelect:!0,inputValue:Cn,renderTags:function(){return null},onInputChange:function(n,e,t){"input"===t&&kn(e)},onOpen:function(){Ln(50)},filterOptions:function(n){return n},ListboxProps:{onScroll:oe},getOptionLabel:function(n){return n},renderOption:function(e,t,o){var i=o.selected;return c("li",n({},e,{key:t}),u(b,{checked:i}),u(C,{primary:t,sx:{fontFamily:"Plus Jakarta Sans"}}))},fullWidth:!0,loading:an,noOptionsText:dn?"Failed to load book suggestions.":Fn.length<3&&ne.length>0?"Type at least 3 characters to search":"No books found.",renderInput:function(e){return u(v,n({},e,{placeholder:"Search books which fit your description...",InputProps:n(n({},e.InputProps),{endAdornment:d(f,{children:[an?u(k,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"white","& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"#e0e0e0"}}}))}}),rn.length>0&&u(x,n({sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2}},{children:rn.map(function(e){return u(S,{label:u(x,n({sx:{display:"flex",flexDirection:"column",py:.5}},{children:u(y,n({sx:{fontSize:"0.875rem",fontFamily:"Plus Jakarta Sans",fontWeight:600,lineHeight:1.4}},{children:e}))})),onDelete:function(){return t=e,void A(function(e){return n(n({},e),{sourceDocuments:(e.sourceDocuments||[]).filter(function(n){return n!==t})})});var t},deleteIcon:u(x,n({sx:{display:"flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"50%",backgroundColor:"#d0d0d0",marginRight:"4px","&:hover":{backgroundColor:"#b0b0b0"}}},{children:u(J,{size:12,color:"#666"})})),sx:{height:"auto",padding:"6px 8px 6px 12px",backgroundColor:"#f5f5f5",border:"1px solid #e0e0e0",borderRadius:"8px","& .MuiChip-label":{padding:0,paddingRight:"8px"},"& .MuiChip-deleteIcon":{margin:0}}},e)})}))]})]})),u(x,n({sx:{display:"flex",gap:2,pt:2}},{children:u(x,n({sx:{flex:1,display:"flex",alignItems:"flex-end",justifyContent:"flex-end"}},{children:u(_,n({variant:"contained",onClick:function(){var n={question:h,whenToApply:Y.filter(function(n){return""!==n.trim()}),whenNotToApply:nn.filter(function(n){return""!==n.trim()}),rating:tn,sourceDocuments:rn};console.log("Form Data:",n),z("Save it"),m&&m(n)},disabled:!$n,sx:{width:"120px",height:"48px",fontFamily:"Plus Jakarta Sans",backgroundColor:"#5928ED",textTransform:"capitalize",fontSize:"1rem",fontWeight:600,borderRadius:"8px","&:hover":{backgroundColor:"#4820C9"},"&.Mui-disabled":{backgroundColor:"#E0E0E0",color:"#999"}}},{children:"Save"}))}))}))]})),u(B,{position:"bottom-center",containerStyle:{bottom:60,left:60},toastOptions:{style:{fontFamily:"Plus Jakarta Sans",fontSize:"0.95rem"}}})]}))};export{Q as default};
1
+ import{__assign as n,__spreadArray as e,__awaiter as t,__generator as o}from"tslib";import{useState as i,useEffect as r,useMemo as l,useRef as a,useCallback as s,createElement as c}from"react";import{jsxs as d,jsx as u,Fragment as f}from"react/jsx-runtime";import p from"@mui/icons-material/Delete";import h from"@mui/icons-material/Add";import m from"@mui/icons-material/Save";import g from"@mui/icons-material/Edit";import{Box as x,Typography as y,TextField as v,Autocomplete as b,Checkbox as w,ListItemText as C,CircularProgress as k,Chip as S,Button as _,Tooltip as L,IconButton as F,InputAdornment as I,Accordion as P,AccordionSummary as A,AccordionDetails as T}from"@mui/material";import z from"@mui/icons-material/CheckCircleOutline";import R from"@mui/icons-material/Cancel";import{X as J,Info as j,ChevronDown as W,Lightbulb as D}from"lucide-react";import O from"../InstantLearning.module.css.js";import{fetchBookSuggestions as V}from"../../../utils/bookGenieAPI.js";import E from"../../../hooks/useDebounce.js";import M,{Toaster as B}from"react-hot-toast";import N from"./ConflictingLearningWarnCard.js";var H=function(r){var l=r.label,a=r.required,s=void 0!==a&&a,c=r.tooltipText,f=r.conditions,b=r.onConditionsChange,w=r.isLoading,C=void 0!==w&&w,S=r.isValidating,_=void 0!==S&&S,P=r.onLock,A=r.onValidationFailure,T=r.children,z=i(!1),R=z[0],J=z[1];return d(x,n({sx:{display:"flex",flexDirection:"column",height:"100%"}},{children:[d(y,n({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"}},{children:[l,s&&u(x,n({component:"span",sx:{color:"red"}},{children:"*"})),c&&u(L,n({title:c,placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:u(j,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),d(x,n({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 32px)",bgcolor:"white",boxShadow:C?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[u(x,n({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:d("div",n({style:{width:"100%",display:"flex",gap:"0.25rem",justifyContent:"space-between",alignItems:"center"}},{children:[d("div",n({style:{display:"flex",gap:"0.25rem",alignItems:"center"}},{children:[u("svg",n({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:u("g",n({clipPath:"url(#clip0_6004_60631)"},{children:u("path",{d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021Z",fill:"#5928ed"})}))})),u(y,n({variant:"body1",sx:{fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),d(x,{children:[u(L,n({title:"Add New Condition",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:u(F,n({onClick:function(){b(e(e([],f,!0),[""],!1)),J(!0)},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:u(h,{fontSize:"small"})}))})),f.length>0&&u(L,n({title:R?"Save & Lock":"Edit",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:u("span",{children:u(F,n({onClick:function(){return t(void 0,void 0,void 0,function(){var n;return o(this,function(e){switch(e.label){case 0:return R&&P?(console.log("Calling onLock (validation)..."),[4,P()]):[3,2];case 1:return n=e.sent(),console.log("Validation finished. Result (isValid):",n),J(!1),!n&&A?(console.log("Validation failed. Calling onValidationFailure..."),A()):n&&console.log("Validation succeeded."),[3,3];case 2:console.log("Toggling isEditable state (Edit clicked or no onLock)."),J(!R),e.label=3;case 3:return[2]}})})},size:"small",disabled:R&&f.some(function(n){return""===n.trim()})||_,sx:{color:"gray","&:hover":{color:"black"},opacity:_?.5:1,cursor:_?"wait":"pointer"}},{children:_?u(k,{size:20,sx:{color:"#5928ed"}}):u(R?m:g,{fontSize:"small"})}))})}))]})]}))})),u(x,n({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:f.length>0?d(x,n({sx:{pt:"16px"}},{children:[u("ol",n({style:{paddingLeft:"0rem",margin:0,fontFamily:"Plus Jakarta Sans"}},{children:f.map(function(t,o){return d(x,n({component:"li",sx:{display:"flex",alignItems:"flex-start",gap:1,mb:o<f.length-1?2:0,fontFamily:"Plus Jakarta Sans"}},{children:[u(v,{variant:"outlined",disabled:!R,fullWidth:!0,multiline:!0,value:t,onChange:function(n){return function(n,t){var o=e([],f,!0);o[n]=t,b(o)}(o,n.target.value)},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"}},InputProps:{startAdornment:d(I,n({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[o+1,"."]}))}}),R&&u(F,n({onClick:function(){return function(n){b(f.filter(function(e,t){return t!==n}))}(o)},sx:{mt:1},size:"large"},{children:u(p,{})}))]}),o)})})),_&&u(x,n({sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",mt:3,mb:2,fontFamily:'"Plus Jakarta Sans", sans-serif',color:"#5a28ed"}},{children:u(y,n({variant:"body2",sx:{color:"#5a28ed"}},{children:"Validating your conditions"}))})),T]})):u("div",n({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:d("div",n({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},{children:[u("div",n({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),d("div",n({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[u("div",{children:"Tell us about your learning in "}),u("span",n({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",u("span",{children:"Chat"})]}))]}))}))}))]}))]}))},q=function(e){var t=e.color,o=void 0===t?"#fff":t,i=e.size,r=void 0===i?12:i;return d("svg",n({width:r,height:r,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[u("path",{d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.3188 23.8989 12.0012 24.0019 11.7759 23.9658L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.37668 16.8492 4.37668 16.1502 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021Z",fill:o}),u("path",{d:"M5.69218 1.72171C5.8106 1.52009 6.19176 1.52009 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.4808 5.75512 10.4808 6.24724 10.2792 6.31018L8.53618 6.88921C7.75918 7.15018 7.15018 7.75918 6.89068 8.53618L6.31018 10.2777C6.19176 10.4793 5.8106 10.4793 5.69218 10.2777L5.11168 8.53471C4.85071 7.75918 4.24171 7.15018 3.46618 6.88921L1.72318 6.30871C1.52156 6.24576 1.52156 5.75512 1.72318 5.69071L3.46618 5.11021C4.24171 4.85071 4.85071 4.24171 5.11168 3.46471L5.69218 1.72171Z",fill:o}),u("path",{d:"M16.2957 0.148207C16.4119 0.016038 16.5905 0.016038 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.4848 2.83676 19.4848 3.16265 19.3527 3.20521L18.1917 3.59221C17.6727 3.76521 17.2662 4.17171 17.0937 4.69021L16.7067 5.85121C16.5905 5.98338 16.4119 5.98338 16.2957 5.85121L15.9087 4.69021C15.7377 4.17171 15.3312 3.76521 14.8122 3.59221L13.6512 3.20521C13.519 3.16265 13.519 2.83676 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:o})]}))},Z=function(e){var t=e.score;return d(x,n({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.5,py:.5,borderRadius:"16px",backgroundColor:"#10B981",color:"white",fontSize:"0.8rem",fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:[u(q,{}),d(y,n({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"inherit"}},{children:[t,"%"]}))]}))},G=function(e){var t=e.reason,o=e.title;return d(P,n({elevation:0,sx:{backgroundColor:"#f3f0ff",border:"1px solid #dcd6f7",borderRadius:2,mb:2,"&::before":{display:"none"}}},{children:[u(A,n({expandIcon:u(W,{style:{color:"#5928ed"}}),sx:{minHeight:"auto","& .MuiAccordionSummary-content":{margin:"12px 0"}}},{children:d(x,n({sx:{display:"flex",alignItems:"center",gap:1}},{children:[u(D,{size:16,color:"#5928ed"}),u(y,n({sx:{fontSize:"0.85rem",fontWeight:600,color:"#5928ed",fontFamily:"Plus Jakarta Sans"}},{children:o}))]}))})),u(T,n({sx:{pt:0,pb:1.5,backgroundColor:"#faf9ff"}},{children:u(y,n({sx:{fontSize:"0.9rem",color:"#4A4458",fontFamily:"Plus Jakarta Sans"}},{children:t}))}))]}))},U=function(e){var t=e.condition,o=e.onAccept,i=e.onReject;return d(x,n({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1,mb:1,backgroundColor:"#f0f4f8",border:"1px solid #d1d9e6",borderRadius:"4px"}},{children:[u(y,n({sx:{flex:1,fontFamily:"Plus Jakarta Sans",mr:1}},{children:t})),d(x,n({sx:{flexShrink:0}},{children:[u(F,n({onClick:o,size:"small",sx:{color:"green"}},{children:u(z,{})})),u(F,n({onClick:i,size:"small",sx:{color:"red"}},{children:u(R,{})}))]}))]}))},X=function(e){var t=e.rating,o=e.onRatingChange,r=i(0),l=r[0],a=r[1],s=function(n){var e=l||t;return e>=n?"100%":e>=n-.5?"50%":"0%"};return u(x,n({sx:{display:"flex",gap:.5},onMouseLeave:function(){return a(0)}},{children:[1,2,3,4,5].map(function(e){return d(x,n({onClick:function(n){return function(n,e){var t=n.currentTarget.getBoundingClientRect(),i=(n.clientX-t.left)/t.width<=.5;o(i?e-.5:e)}(n,e)},onMouseMove:function(n){return function(n,e){var t=n.currentTarget.getBoundingClientRect(),o=(n.clientX-t.left)/t.width<=.5;a(o?e-.5:e)}(n,e)},sx:{cursor:"pointer",fontSize:"1.5rem",color:"#E0E0E0",position:"relative",display:"inline-block",lineHeight:1}},{children:["★",u(x,n({sx:{position:"absolute",top:0,left:0,width:s(e),overflow:"hidden",color:"#FFD700"}},{children:"★"}))]}),e)})}))},K=function(p){var h=p.question,m=p.onSubmit,g=p.rating,L=p.baseUrl,F=p.extractedRating;p.setExtractedRating;var I=p.currentDocumentDetails,P=p.formDataState,A=p.setFormDataState,T=p.instantLearningSuggestions,z=p.setSendMessageInChat,R=p.setValidationWtaResponse,j=p.availableBooks,W=p.setAvailableBooks,D=p.validationRecommendations,q=P||{},K=q.whenToApply,Q=void 0===K?[]:K,Y=q.whenNotToApply,$=void 0===Y?[]:Y,nn=q.rating,en=void 0===nn?g:nn,tn=q.sourceDocuments,on=void 0===tn?[]:tn,rn=i(!1),ln=rn[0],an=rn[1],sn=i(null),cn=sn[0],dn=sn[1],un=i(!1),fn=un[0],pn=un[1],hn=i(!1),mn=hn[0],gn=hn[1],xn=i(!1),yn=xn[0],vn=xn[1],bn=i(""),wn=bn[0],Cn=bn[1],kn=i(50),Sn=kn[0],_n=kn[1],Ln=E(wn,500),Fn=i(!1),In=Fn[0],Pn=Fn[1],An=i(null),Tn=An[0],zn=An[1],Rn={title:null==I?void 0:I.title,author:null==I?void 0:I.author},Jn=i(null),jn=Jn[0],Wn=Jn[1],Dn=i(null),On=Dn[0],Vn=Dn[1],En=i({wta:!1,wnta:!1}),Mn=En[0],Bn=En[1],Nn=i({wta:!1,wnta:!1}),Hn=Nn[0],qn=Nn[1];r(function(){D&&(console.log("BookLearningForm: Received new validationRecommendations:",D),Wn(D.wta),Vn(D.wnta),Bn({wta:!!D.wta,wnta:!!D.wnta}),qn({wta:!1,wnta:!1}),Pn(!1),zn(null))},[D]);var Zn=function(t,o,i){Pn(!1),zn(null),"wta"===o?(A(function(o){var i=Hn.wta?Array.from(new Set(e(e([],o.whenToApply||[],!0),[t],!1))):[t];return n(n({},o),{whenToApply:i})}),qn(function(e){return n(n({},e),{wta:!0})}),Wn(function(e){if(!e||!e.when_to_apply)return e;var t=n({},e.when_to_apply);return delete t[i],0===Object.keys(t).length?null:n(n({},e),{when_to_apply:t})})):(A(function(o){var i=Hn.wnta?Array.from(new Set(e(e([],o.whenNotToApply||[],!0),[t],!1))):[t];return n(n({},o),{whenNotToApply:i})}),qn(function(e){return n(n({},e),{wnta:!0})}),Vn(function(e){if(!e||!e.when_not_to_apply)return e;var t=n({},e.when_not_to_apply);return delete t[i],0===Object.keys(t).length?null:n(n({},e),{when_not_to_apply:t})}))},Gn=function(e,t,o){"wta"===t?Wn(function(e){if(!e||!e.when_to_apply)return e;var t=n({},e.when_to_apply);return delete t[o],0===Object.keys(t).length?null:n(n({},e),{when_to_apply:t})}):Vn(function(e){if(!e||!e.when_not_to_apply)return e;var t=n({},e.when_not_to_apply);return delete t[o],0===Object.keys(t).length?null:n(n({},e),{when_not_to_apply:t})})},Un=function(){return t(void 0,void 0,void 0,function(){var n,e,t,i,r,l,a,s,c,d,u,f,p;return o(this,function(o){switch(o.label){case 0:if(console.log("handleLockValidation started."),Pn(!1),zn(null),R(null),!L)return console.error("❌ ERROR: Missing baseUrl for validation."),[2,!1];if(yn)return console.log("❕ Validation already in progress. Aborting."),[2,!1];vn(!0),n=Q.filter(function(n){return""!==n.trim()}),e=$.filter(function(n){return""!==n.trim()}),t="".concat(L,"/instant_learning/validate-wta"),i={whenToApply:n,whenNotToApply:e},o.label=1;case 1:return o.trys.push([1,9,,10]),console.log("📡 Firing fetch request to:",t),[4,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})];case 2:if(r=o.sent(),console.log("✅ Fetch request initiated. Status Code:",r.status),r.ok)return[3,7];l="Could not read error body.",o.label=3;case 3:return o.trys.push([3,5,,6]),[4,r.text()];case 4:return l=o.sent(),[3,6];case 5:return o.sent(),[3,6];case 6:throw console.error("❌ API Error Response (".concat(r.status,"):"),l),new Error("API Error: ".concat(r.status));case 7:return[4,r.json()];case 8:return a=o.sent(),console.log("✅ Validation API response data:",a),R(a.response),vn(!1),(s=!0===(null===(u=null==a?void 0:a.response)||void 0===u?void 0:u.is_valid))?(Pn(!1),zn(null)):(console.log("Validation API reported failure."),zn((null===(f=null==a?void 0:a.response)||void 0===f?void 0:f.conflictingConditions)||[{conflictType:"api_validation_error",reason:(null===(p=null==a?void 0:a.response)||void 0===p?void 0:p.reason)||"Validation failed for an unknown reason."}]),Pn(!0)),console.log("handleLockValidation returning:",s),[2,s];case 9:return c=o.sent(),console.error("❌ Validation API fetch FAILED:",c.message,c),d={is_valid:!1,reason:"Failed to connect to validation service: ".concat(c.message),conflictingConditions:[{conflictType:"api_error",reason:"Failed to connect to validation service: ".concat(c.message)}]},R(d),zn(d.conflictingConditions),Pn(!0),vn(!1),console.log("handleLockValidation returning false due to error."),[2,!1];case 10:return[2]}})})},Xn=function(){console.log("handleValidationFailure triggered."),z("Validation Failed. Do you have any recommendations for me?")},Kn=function(n){return n?n.toLowerCase().replace(/[^a-z0-9]/g,""):""},Qn=l(function(){for(var n=new Map,e=0,t=j;e<t.length;e++){var o=t[e];n.set(Kn(o.title),o.title)}return n},[j]),Yn=!!h&&Q.length>0&&en>0,$n=l(function(){return Ln.length<3?j:j.filter(function(n){return n.title.toLowerCase().includes(Ln.toLowerCase())})},[j,Ln]);r(function(){var e,t;if(T){var o=null===(e=null==T?void 0:T.conditions_whentoapply)||void 0===e?void 0:e.map(function(n){return n.when_to_apply}).filter(Boolean),i=null===(t=null==T?void 0:T.conditions_whennottoapply)||void 0===t?void 0:t.map(function(n){return n.when_not_to_apply}).filter(Boolean);(null==o?void 0:o.length)>0&&(pn(!0),setTimeout(function(){return pn(!1)},400)),(null==i?void 0:i.length)>0&&(gn(!0),setTimeout(function(){return gn(!1)},400)),((null==o?void 0:o.length)>0||(null==i?void 0:i.length)>0)&&(Wn(null),Vn(null),Bn({wta:!1,wnta:!1}),Pn(!1),zn(null),A(function(e){return n(n({},e),{whenToApply:(null==o?void 0:o.length)>0?o:e.whenToApply,whenNotToApply:(null==i?void 0:i.length)>0?i:e.whenNotToApply})}))}},[T,A]);var ne=a("");r(function(){if(0!==Qn.size){var t=JSON.stringify(e([],on,!0).sort());if(ne.current!==t){ne.current=t;var o=[],i=[];if(on.forEach(function(n){var e=Kn(n);Qn.has(e)?o.push(Qn.get(e)):i.push(n)}),i.length>0){console.warn("[BookLearningForm] Invalid books:",i);var r=i[i.length-1];M.error("The suggested book could not be found: ".concat(r),{duration:6e3,style:{fontFamily:"Plus Jakarta Sans"}})}JSON.stringify(o.sort())!==t&&(console.log("[BookLearningForm] Normalizing source documents. Found valid:",o),A(function(e){return n(n({},e),{sourceDocuments:o})}))}}},[on,Qn,A]),r(function(){_n(50)},[Ln]),r(function(){null!=F&&A(function(e){return n(n({},e),{rating:F})})},[F,A]),r(function(){if(L){t(void 0,void 0,void 0,function(){var n,e;return o(this,function(t){switch(t.label){case 0:an(!0),dn(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,V()];case 2:return n=t.sent(),W(n),[3,5];case 3:return e=t.sent(),console.error("Error loading book suggestions:",e),dn("Failed to load book suggestions."),[3,5];case 4:return an(!1),[7];case 5:return[2]}})})}},[L,W]);var ee=l(function(){return $n.slice(0,Sn).map(function(n){return n.title})},[$n,Sn]),te=s(function(n){var e=n.currentTarget;e.scrollTop+e.clientHeight+40>=e.scrollHeight&&_n(function(n){return Math.min(n+50,$n.length)})},[$n.length]);return d(x,n({p:0,className:O.customFont,sx:{display:"flex",flexDirection:"column",height:"100%",width:"95%",ml:2}},{children:[d(x,n({sx:{fontFamily:"Plus Jakarta Sans",display:"flex",flexDirection:"column",gap:2,justifyContent:"space-between",flexGrow:1,paddingTop:"20px",height:"100%",overflow:"auto"}},{children:[d(x,n({sx:{display:"flex",flexDirection:"column",gap:"20px",height:"calc(100% - 70px)",overflow:"auto",position:"relative"}},{children:[u(y,n({sx:{fontSize:{sm:"1.1rem",md:"1.25rem"},fontWeight:600,fontFamily:"Plus Jakarta Sans",color:"#000"}},{children:"We noticed you didn't like the recommendation"})),u(x,n({sx:{border:"1px solid #e0e0e0",borderRadius:"12px",padding:{sm:2,md:3},backgroundColor:"white"}},{children:d(x,n({sx:{display:"flex",gap:{sm:2,md:3},alignItems:"flex-start",flexDirection:{sm:"column",md:"row"}}},{children:[u(x,n({sx:{width:{sm:"80px",md:"100px"},height:{sm:"120px",md:"150px"},flexShrink:0,borderRadius:"8px",overflow:"hidden",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",alignSelf:{sm:"center",md:"flex-start"}}},{children:u("img",{src:null==I?void 0:I.coverUrl,alt:"Book cover",style:{width:"100%",height:"100%",objectFit:"cover"}})})),d(x,n({sx:{flex:1,width:{sm:"100%",md:"auto"}}},{children:[u(y,n({sx:{fontSize:{sm:"0.7rem",md:"0.75rem"},color:"#666",fontFamily:"Plus Jakarta Sans",mb:.5,fontWeight:500}},{children:"Here's what you searched for"})),u(v,{fullWidth:!0,value:h,InputProps:{readOnly:!0,sx:{fontFamily:"Plus Jakarta Sans",fontSize:{sm:"0.85rem",md:"0.95rem"},bgcolor:"#fafafa"}},sx:{mb:2,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans"}}}),d(x,n({sx:{display:"flex",gap:2,flexDirection:{sm:"column",lg:"row"}}},{children:[d(x,n({sx:{flex:1,width:{sm:"100%",lg:"auto"}}},{children:[u(y,n({sx:{fontSize:{sm:"0.7rem",md:"0.75rem"},color:"#666",fontFamily:"Plus Jakarta Sans",mb:.5,fontWeight:500}},{children:"Recommendation"})),u(x,n({sx:{border:"1px solid #c4c4c4",borderRadius:"4px",padding:{sm:"12px 10px",md:"16px 14px"},bgcolor:"#fafafa",minHeight:{sm:"48px",md:"56px"},display:"flex",alignItems:"center",boxSizing:"border-box",overflow:"hidden"}},{children:d(y,n({sx:{fontFamily:"Plus Jakarta Sans",fontSize:{sm:"0.85rem",md:"0.95rem"},color:"#000",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",width:"100%",lineHeight:1.4}},{children:[Rn.title," by ",Rn.author]}))}))]})),d(x,n({sx:{minWidth:{sm:"100%",lg:"200px"},display:"flex",flexDirection:"column"}},{children:[d(y,n({sx:{fontSize:{sm:"0.7rem",md:"0.75rem"},color:"#666",fontFamily:"Plus Jakarta Sans",mb:.5,fontWeight:500}},{children:["Ratings ",u("span",n({style:{color:"red"}},{children:"*"}))]})),u(x,n({sx:{border:"1px solid #c4c4c4",borderRadius:"4px",padding:{sm:"12px 10px",md:"16px 14px"},bgcolor:"#fafafa",minHeight:{sm:"48px",md:"56px"},display:"flex",alignItems:"center",justifyContent:{sm:"center",lg:"flex-start"},boxSizing:"border-box"}},{children:u(X,{rating:en,onRatingChange:function(e){A(function(t){return n(n({},t),{rating:e})})}})}))]}))]}))]}))]}))})),u(y,n({sx:{fontSize:{sm:"1rem",md:"1.1rem"},fontWeight:600,fontFamily:"Plus Jakarta Sans",color:"#000"}},{children:"Help us improve the recommendation"})),d(x,n({sx:{display:"flex",gap:2,minHeight:"300px",flexShrink:0}},{children:[u(x,n({sx:{flex:1,height:"100%"}},{children:u(H,n({label:"When to Apply",required:!0,tooltipText:"Specific situations or conditions where this learning should be applied.",conditions:Q,onConditionsChange:function(e){A(function(t){return n(n({},t),{whenToApply:e})})},isLoading:fn,isValidating:yn,onLock:Un,onValidationFailure:Xn},{children:jn&&jn.when_to_apply&&Object.keys(jn.when_to_apply).length>0&&d(x,n({mt:Q.length>0?3:0,sx:{borderTop:Q.length>0?"1px dashed #ccc":"none",pt:Q.length>0?2:0}},{children:[Mn.wta&&d(x,n({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5}},{children:[u(y,n({variant:"subtitle2",sx:{fontWeight:"bold",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Recommended Fix:"})),u(Z,{score:jn.confidence_score})]})),Mn.wta&&jn.reason&&u(G,{reason:jn.reason,title:"Why these suggestions?"}),Object.entries(jn.when_to_apply).map(function(n){var e=n[0],t=n[1];return u(U,{condition:"".concat(e,". ").concat(t),onAccept:function(){return Zn(t,"wta",e)},onReject:function(){return Gn(0,"wta",e)}},"rec-wta-".concat(e))})]}))}))})),u(x,n({sx:{flex:1,height:"100%"}},{children:u(H,n({label:"When NOT to Apply",tooltipText:"Cases where this learning should not be applied to avoid incorrect responses.",conditions:$,onConditionsChange:function(e){A(function(t){return n(n({},t),{whenNotToApply:e})})},isLoading:mn,isValidating:yn,onLock:Un,onValidationFailure:Xn},{children:On&&On.when_not_to_apply&&Object.keys(On.when_not_to_apply).length>0&&d(x,n({mt:$.length>0?3:0,sx:{borderTop:$.length>0?"1px dashed #ccc":"none",pt:$.length>0?2:0}},{children:[Mn.wnta&&d(x,n({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5}},{children:[u(y,n({variant:"subtitle2",sx:{fontWeight:"bold",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Recommended Fix:"})),u(Z,{score:On.confidence_score})]})),Mn.wnta&&On.reason&&u(G,{reason:On.reason,title:"Why these suggestions?"}),Object.entries(On.when_not_to_apply).map(function(n){var e=n[0],t=n[1];return u(U,{condition:"".concat(e,". ").concat(t),onAccept:function(){return Zn(t,"wnta",e)},onReject:function(){return Gn(0,"wnta",e)}},"rec-wnta-".concat(e))})]}))}))}))]})),In&&Tn&&u(N,{conflictingConditions:Tn}),d(x,{children:[u(y,n({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",mb:1.5}},{children:"Add Recommendations"})),u(b,{multiple:!0,id:"book-recommendation-autocomplete",options:ee,onChange:function(e,t){A(function(e){return n(n({},e),{sourceDocuments:t})})},value:on,isOptionEqualToValue:function(n,e){return Kn(n)===Kn(e)},disabled:ln,disableCloseOnSelect:!0,inputValue:wn,renderTags:function(){return null},onInputChange:function(n,e,t){"input"===t&&Cn(e)},onOpen:function(){_n(50)},filterOptions:function(n){return n},ListboxProps:{onScroll:te},getOptionLabel:function(n){return n},renderOption:function(e,t,o){var i=o.selected;return c("li",n({},e,{key:t}),u(w,{checked:i}),u(C,{primary:t,sx:{fontFamily:"Plus Jakarta Sans"}}))},fullWidth:!0,loading:ln,noOptionsText:cn?"Failed to load book suggestions.":Ln.length<3&&$n.length>0?"Type at least 3 characters to search":"No books found.",renderInput:function(e){return u(v,n({},e,{placeholder:"Search books which fit your description...",InputProps:n(n({},e.InputProps),{endAdornment:d(f,{children:[ln?u(k,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"white","& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"#e0e0e0"}}}))}}),on.length>0&&u(x,n({sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2}},{children:on.map(function(e){return u(S,{label:u(x,n({sx:{display:"flex",flexDirection:"column",py:.5}},{children:u(y,n({sx:{fontSize:"0.875rem",fontFamily:"Plus Jakarta Sans",fontWeight:600,lineHeight:1.4}},{children:e}))})),onDelete:function(){return t=e,void A(function(e){return n(n({},e),{sourceDocuments:(e.sourceDocuments||[]).filter(function(n){return n!==t})})});var t},deleteIcon:u(x,n({sx:{display:"flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"50%",backgroundColor:"#d0d0d0",marginRight:"4px","&:hover":{backgroundColor:"#b0b0b0"}}},{children:u(J,{size:12,color:"#666"})})),sx:{height:"auto",padding:"6px 8px 6px 12px",backgroundColor:"#f5f5f5",border:"1px solid #e0e0e0",borderRadius:"8px","& .MuiChip-label":{padding:0,paddingRight:"8px"},"& .MuiChip-deleteIcon":{margin:0}}},e)})}))]})]})),u(x,n({sx:{display:"flex",gap:2,pt:2}},{children:u(x,n({sx:{flex:1,display:"flex",alignItems:"flex-end",justifyContent:"flex-end"}},{children:u(_,n({variant:"contained",onClick:function(){var n={question:h,whenToApply:Q.filter(function(n){return""!==n.trim()}),whenNotToApply:$.filter(function(n){return""!==n.trim()}),rating:en,sourceDocuments:on};console.log("Form Data:",n),z("Save it"),m&&m(n)},disabled:!Yn,sx:{width:"120px",height:"48px",fontFamily:"Plus Jakarta Sans",backgroundColor:"#5928ED",textTransform:"capitalize",fontSize:"1rem",fontWeight:600,borderRadius:"8px","&:hover":{backgroundColor:"#4820C9"},"&.Mui-disabled":{backgroundColor:"#E0E0E0",color:"#999"}}},{children:"Save"}))}))}))]})),u(B,{position:"bottom-center",containerStyle:{bottom:60,left:60},toastOptions:{style:{fontFamily:"Plus Jakarta Sans",fontSize:"0.95rem"}}})]}))};export{K as default};
2
2
  //# sourceMappingURL=BookLearningForm.js.map