@e-llm-studio/instant-learning 1.3.0-alpha.46 → 1.3.0-alpha.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/LearningManagement/AuditLog/AuditLog.js +1 -1
- package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js +2 -0
- package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js.map +1 -0
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +2 -0
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +1 -0
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js +2 -0
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js.map +1 -0
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/StationOnboardModal.js +1 -1
- package/dist/features/LearningManagement/AuditLog/AuditLog.js +1 -1
- package/dist/features/LearningManagement/assets/Search-result(add new).svg.js +2 -0
- package/dist/features/LearningManagement/assets/Search-result(add new).svg.js.map +1 -0
- package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +2 -0
- package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +1 -0
- package/dist/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js +2 -0
- package/dist/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js.map +1 -0
- package/dist/features/LearningManagement/components/StationOnboarding/StationOnboardModal.js +1 -1
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts +12 -0
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts.map +1 -0
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/DayToggleSelector.d.ts +13 -0
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/DayToggleSelector.d.ts.map +1 -0
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/StationOnboardModal.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as e,__awaiter as r,__generator as n,__spreadArray as t}from"tslib";import{jsxs as o,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useMemo as u,useEffect as c}from"react";import{Dialog as d,Box as p,Typography as f,IconButton as m,DialogContent as h,CircularProgress as g}from"@mui/material";import{X as v,Search as b,ArrowRight as x}from"lucide-react";import{Toast as S}from"primereact/toast";import{v4 as y}from"uuid";import w from"../../assets/Search-result(add new).svg.js";import C from"../../store/useAuthStore.js";import{IL_CONFIG_CONSTANTS as _}from"../../config.js";import{retrieveGenreScopes as O,fetchStationsByKeyword as F,searchScopes as T,inheritScope as A,deleteRuleSet as N,updateStation as M,createRuleSet as E}from"../../apis/scopeApis.js";import k from"./InputField.js";import D from"./StationAutocomplete.js";import z from"../CardSkeleton.js";import P from"./OnboardingLoader.js";import B from"./TemplateCard.js";var j=[{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"},{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"}],I=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],L=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}],R=function(R){var W,U=R.isOpen,q=R.onClose,G=R.onBoardStation,Y=R.app_integration_id,H=R.token,K=R.stationNameParam,X=a(null),J=X[0],Q=X[1],V=a([]),Z=V[0],$=V[1],ee=a(0),re=ee[0],ne=ee[1],te=a(!0),oe=te[0],ie=te[1],le=a(!1),ae=le[0],se=le[1],ue=a([]),ce=ue[0],de=ue[1],pe=a(""),fe=pe[0],me=pe[1],he=a(""),ge=he[0],ve=he[1],be=a(!1),xe=be[0],Se=be[1],ye=a(!1),we=ye[0],Ce=ye[1],_e=a(null),Oe=_e[0],Fe=_e[1],Te=a(!1),Ae=Te[0],Ne=Te[1],Me=a(0),Ee=Me[0],ke=Me[1],De=a(""),ze=De[0],Pe=De[1],Be=C().user,je=s(null),Ie=s(null),Le=s(null),Re=s(null),We=a({region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:""}),Ue=We[0],qe=We[1],Ge=function(e,r){return e.find(function(e){return e.value===r})||null},Ye=u(function(){return Z.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[Z]),He=u(function(){var e,r,n;if(!Ue.genre)return null;var t=Z.find(function(e){return e.scope_name===Ue.genre});return t?{id:t.id,title:t.scope_name||"Unnamed Template",description:(null===(e=t.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(r=t.inheritance)||void 0===r?void 0:r[0])||void 0,rulesCount:t.rules_count||0,tiersCount:t.tier_count||0,isCopy:null!==(n=t.is_copy)&&void 0!==n&&n}:null},[Ue.genre,Z]);c(function(){return function(){Le.current&&clearTimeout(Le.current)}},[]);var Ke=function(e){return r(void 0,void 0,void 0,function(){var r,o,i;return n(this,function(n){switch(n.label){case 0:if(ae)return[2];se(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,O({limit:"20",offset:String(e)})];case 2:return"success"===(null==(r=n.sent())?void 0:r.status)&&Array.isArray(null==r?void 0:r.data)?(o=r.data,$(function(r){if(0===e)return o;var n=new Set(r.map(function(e){return e.id})),i=o.filter(function(e){return!n.has(e.id)});return t(t([],r,!0),i,!0)}),o.length<20?ie(!1):ie(!0),ne(e+20)):ie(!1),[3,5];case 3:return i=n.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",i),ie(!1),[3,5];case 4:return se(!1),[7];case 5:return[2]}})})};c(function(){if(U&&($([]),ne(0),ie(!0),Ke(0),K)){Pe(K);r(void 0,void 0,void 0,function(){var e,r,t;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,F(K,!0)];case 1:return!0===(null==(e=n.sent())?void 0:e.success)&&Array.isArray(null==e?void 0:e.data)&&(r=e.data.find(function(e){var r;return(null===(r=e.station_name)||void 0===r?void 0:r.toLowerCase())===K.toLowerCase()&&!e.ruleset_id}),r&&Q(r)),[3,3];case 2:return t=n.sent(),console.error("[StationOnboard] Error auto-selecting station:",t),[3,3];case 3:return[2]}})})}},[U,K]);c(function(){qe(J?function(r){var n;return e(e({},r),{region:null!==(n=J.market)&&void 0!==n?n:""})}:{region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:""})},[J]),c(function(){var e=setTimeout(function(){ve(fe)},500);return function(){return clearTimeout(e)}},[fe]),c(function(){r(void 0,void 0,void 0,function(){var e,r,t;return n(this,function(n){switch(n.label){case 0:if(!ge.trim())return de([]),[2];Se(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,T({search_string:ge})];case 2:return"success"===(null==(e=n.sent())?void 0:e.status)&&Array.isArray(null==e?void 0:e.data)?(r=e.data.map(function(e){var r,n,t;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(r=e.description)||void 0===r?void 0:r.trim())||"No description available.",inheritedText:(null===(n=e.inheritance)||void 0===n?void 0:n[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(t=e.is_copy)&&void 0!==t&&t}}),de(r)):de([]),[3,5];case 3:return t=n.sent(),console.error("[StationOnboard] Error searching scopes:",t),de([]),[3,5];case 4:return Se(!1),[7];case 5:return[2]}})})},[ge]),c(function(){!ge.trim()&&He&&Fe(He.id)},[ge,He]);var Xe=function(){setTimeout(function(){Re.current&&Re.current.scrollTo({top:Re.current.scrollHeight,behavior:"smooth"})},100)},Je=function(){Pe(""),Q(null),qe({region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:""}),de([]),me(""),Fe(null),q()},Qe=function(r,n){var t;if("primeTime"!==r){var o=null!==(t=null==n?void 0:n.value)&&void 0!==t?t:"";qe(function(n){var t;return e(e({},n),((t={})[r]=String(o),t))}),"genre"===r&&(Ce(!0),Le.current&&clearTimeout(Le.current),Le.current=setTimeout(function(){var e=Z.find(function(e){return e.scope_name===o});Fe(e?e.id:null),Ce(!1)},800))}else{var i=(null==n?void 0:n.value)?String(n.value):"";qe(function(r){return e(e({},r),{primeTime:i?[i]:[]})})}},Ve=Boolean(J&&Ue.region&&Ue.primeTime.length>0&&Ue.genre);return o(d,e({open:U,onClose:Je,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden"}}},{children:[i(S,{ref:je}),o(p,e({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[o(p,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[i(f,e({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),i(f,e({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),i(m,e({onClick:Je,disabled:Ae,sx:{color:"#19213D"}},{children:i(v,{size:24})}))]})),o(h,e({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[i(P,{isLoading:Ae,currentStep:Ee,onComplete:function(){Ne(!1);var e=Ie.current;Je(),G(e||void 0),Ie.current=null}}),o(p,e({sx:{display:"flex",flex:1,paddingY:"14px",paddingX:"20px",gap:3,overflowY:"hidden"}},{children:[o(p,e({ref:Re,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5",height:"100%",overflowY:"auto"}},{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),i(f,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),o(p,e({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[o(p,e({className:"space-y-1.5"},{children:[o("label",e({className:"text-sm font-medium text-[#19213D]"},{children:[i("span",e({className:"mr-0.5 text-xs font-semibold text-[#8F2C23]"},{children:"*"})),"Station Name/Call Letters"]})),i(D,{value:ze,onChange:Pe,onStationSelect:function(e){return Q(e)}})]})),i(k,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:Ue.region||void 0,isSearchable:!1}),i(k,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:j,value:Ge(j,(null===(W=Ue.primeTime)||void 0===W?void 0:W[0])||""),onOptionChange:function(e){return Qe("primeTime",e)},isSearchable:!1}),i(p,e({onClick:Xe,sx:{width:"100%"}},{children:i(k,{required:!0,label:"Genre",placeholder:"Select Genre",options:Ye,value:Ge(Ye,Ue.genre),onOptionChange:function(e){return Qe("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!ae&&oe&&Ke(re)},isLoadingOptions:ae,hasMoreOptions:oe})})),i(p,e({onClick:Xe,sx:{width:"100%"}},{children:i(k,{label:"Station Type",placeholder:"None",options:I,value:Ge(I,Ue.type),onOptionChange:function(r){Qe("type",r),"Low Sellout"!==(null==r?void 0:r.value)&&qe(function(r){return e(e({},r),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===Ue.type&&i(p,e({onClick:Xe,sx:{width:"100%"}},{children:i(k,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:L,value:Ge(L,Ue.lowSelloutConfig),onOptionChange:function(e){return Qe("lowSelloutConfig",e)},isSearchable:!1})}))]}))]})),i(p,e({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column",height:"100%",overflowY:"auto"}},{children:Ue.genre?o(l,{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:500,mb:1.5}},{children:"Matching scope for your station"})),i(p,e({sx:{display:"flex",flexDirection:"column",gap:2,mb:4}},{children:we?i(z,{}):He?i(B,e({},He,{isSelected:Oe===He.id,onSelect:Fe}),He.id):null})),i(f,e({sx:{fontSize:"1rem",fontWeight:500,mb:1.5}},{children:"Other available stations"})),o("div",e({className:"relative mb-4 w-full"},{children:[i("input",{type:"text",value:fe,onChange:function(e){return me(e.target.value)},placeholder:"Search for station...",className:"w-full rounded-lg border border-[#E2E8F0] px-10 py-[7px] text-[12px] outline-none transition-all placeholder:text-[#BAC0CC] focus:border-blue-500 focus:ring-1 focus:ring-blue-500"}),i(b,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:16})]})),o(p,e({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[xe&&i(z,{}),!xe&&0===ce.length&&ge.trim()&&o(f,e({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',ge,'".']})),!xe&&ce.map(function(r){return i(B,e({},r,{isSelected:Oe===r.id,onSelect:Fe}),r.id)})]}))]}):o(l,{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:500,mb:1.5}},{children:"Fill in the station details to load AI recommended scopes"})),i(f,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:3}},{children:"AI will recommend the most relevant scope for this station."})),i(p,e({sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.5,py:10}},{children:i("img",{src:w,alt:"Empty Result"})}))]})}))]}))]})),o(p,e({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[i("button",e({onClick:Je,disabled:Ae,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),i("button",e({onClick:function(){return r(void 0,void 0,void 0,function(){var r,o,i,l,a,s,u,c,d,p,f,m,h,g,v,b,x,S;return n(this,function(n){switch(n.label){case 0:if(!J||!Oe)return console.error("[StationOnboard] Missing required data for onboarding"),[2];r=He?t([He],ce,!0):ce,o=r.find(function(e){return e.id===Oe}),i=null!==(h=null==o?void 0:o.isCopy)&&void 0!==h&&h,Ne(!0),ke(0),l=null,n.label=1;case 1:return n.trys.push([1,3,,4]),a={topic:"customRuleSet",customScopeGroupName:(null==_?void 0:_.CUSTOM_SCOPE_GROUP_NAME)||"Audacy-Traffic-Manager",scopeDescription:J.station_name||"New Station",parentScopeId:null,customScopeName:J.station_name||"New Station",customScopeId:y(),createByName:(null==Be?void 0:Be.firstname)||"System",createdBy:(null==Be?void 0:Be.email)||"system@audacy.com",applicationMappingId:Y},console.log("[StationOnboard] Step 1: Creating rule set with payload:",a),[4,E(a,H)];case 2:if(s=n.sent(),!(l=null===(g=null==s?void 0:s.data)||void 0===g?void 0:g.scopeId))throw new Error("Failed to create scope - no scopeId returned");return ke(1),[3,4];case 3:return u=n.sent(),console.error("[StationOnboard] Error creating rule set:",u),null===(v=je.current)||void 0===v||v.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),Ne(!1),ke(0),[2];case 4:return n.trys.push([4,6,,11]),c={market:J.market,region:J.region,primetime_windows:Ue.primeTime,genre:Ue.genre,station_type:""===Ue.type?null:Ue.type,low_sellout_configurations:"Low Sellout"===Ue.type?Ue.lowSelloutConfig:null,ruleset_id:l,station_guid:J.station_guid,station_name:J.station_name||"New Station"},console.log("[StationOnboard] Step 2: Updating station with payload:",c),[4,M(c)];case 5:return n.sent(),ke(2),[3,11];case 6:d=n.sent(),console.error("[StationOnboard] Error updating station, rolling back rule set:",d),409===d.status?(null===(b=je.current)||void 0===b||b.show({severity:"error",life:2500,summary:"Error updating station",detail:"Station already Onboarded."}),Q(null),Fe(null),Pe(""),qe(function(r){return e(e({},r),{region:""})})):null===(x=je.current)||void 0===x||x.show({severity:"error",life:2500,summary:"Error updating station",detail:"Please try again."}),n.label=7;case 7:return n.trys.push([7,9,,10]),[4,N(l,H)];case 8:return n.sent(),[3,10];case 9:return p=n.sent(),console.error("[StationOnboard] Failed to rollback rule set deletion:",p),[3,10];case 10:return Ne(!1),ke(0),[2];case 11:return n.trys.push([11,13,,14]),f={source_scope_id:Oe,target_scope_id:l,is_copy_parent_variant_id:i},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",f),[4,A(f)];case 12:return n.sent(),ke(3),[3,14];case 13:return m=n.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",m),null===(S=je.current)||void 0===S||S.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),Ne(!1),ke(0),[2];case 14:return Ie.current=l,[2]}})})},disabled:!Ve||Ae,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:Ve?"#2563EB":"#BFDBFE",color:"#fff",cursor:Ve&&!Ae?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:o(l,Ae?{children:[i(g,{size:16,color:"inherit"}),i("span",{children:"Onboarding..."})]}:{children:[i("span",{children:"Onboard Station"}),i(x,{size:16})]})}))]}))]}))};export{R as default};
|
|
2
|
+
//# sourceMappingURL=BackwardStationOnboardModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackwardStationOnboardModal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as e,__spreadArray as i}from"tslib";import{jsxs as r,jsx as n}from"react/jsx-runtime";var o={display:"flex",gap:"8px",flexWrap:"nowrap",padding:"10px 12px",backgroundColor:"#FAFAFA",border:"1px solid #E2E8F0",borderRadius:"8px",marginTop:"4px",minHeight:"54px",alignItems:"center",width:"70%",boxSizing:"border-box"},t={display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",fontSize:"0.815rem",fontWeight:500,cursor:"pointer",userSelect:"none",transition:"all 0.15s ease-in-out",height:"34px",flex:"1 0 calc((100% - (6 * 8px)) / 7)",minWidth:"0",position:"relative",boxSizing:"border-box"},l=function(l){var a=l.label,d=l.subText,p=l.required,s=l.options,x=l.selectedValues,c=l.onChange;return r("div",e({style:{display:"flex",flexDirection:"column",width:"100%",marginBottom:"4px"}},{children:[r("label",e({style:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",marginBottom:"2px",display:"block"}},{children:[p&&n("span",e({style:{color:"#E53E3E",marginRight:"4px"}},{children:"*"})),a]})),d&&n("p",e({style:{margin:"0 0 6px 0",fontSize:"0.75rem",color:"#666F8D",lineHeight:"1.2"}},{children:d})),n("div",e({style:o},{children:s.map(function(r){var o=x.includes(String(r.value));return n("div",e({onClick:function(){return e=String(r.value),void(x.includes(e)?c(x.filter(function(i){return i!==e})):c(i(i([],x,!0),[e],!1)));var e},style:e(e({},t),{border:o?"1.5px solid #2563EB":"1px solid #E2E8F0",backgroundColor:o?"#EFF6FF":"#FFFFFF",color:o?"#2563EB":"#64748B",boxShadow:o?"0 1px 2px rgba(37, 99, 235, 0.05)":"0 1px 2px rgba(0, 0, 0, 0.02)"})},{children:n("span",{children:r.label})}),r.value)})}))]}))};export{l as default};
|
|
2
|
+
//# sourceMappingURL=DayToggleSelector.js.map
|
package/dist/features/LearningManagement/components/StationOnboarding/DayToggleSelector.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DayToggleSelector.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/features/LearningManagement/components/StationOnboarding/StationOnboardModal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as o,__generator as r,__spreadArray as n}from"tslib";import{jsxs as i,jsx as t,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useMemo as c,useEffect as u}from"react";import{Dialog as d,Box as p,Typography as f,IconButton as m,DialogContent as h,CircularProgress as g}from"@mui/material";import{X as x,Search as v,ArrowRight as b}from"lucide-react";import{Toast as y}from"primereact/toast";import{v4 as S}from"uuid";import{retrieveGenreScopes as C,fetchStationsByKeyword as w,searchScopes as _,inheritScopeBackwardCompatible as F,createRuleSet as k}from"../../apis/scopeApis.js";import E from"./StationAutocomplete.js";import D from"../CardSkeleton.js";import T from"./OnboardingLoader.js";import B from"./TemplateCard.js";import O from"../../styles/StationOnboardModal.module.css.js";import z from"./InputField.js";import A from"../../store/useAuthStore.js";import{useConfigStore as I}from"../../store/useConfigStore.js";import{useLearningTemplateStore as M}from"../../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as L}from"../../config.js";import{useAppSecRolesStore as R}from"../../store/useAppSecRolesStore.js";import j from"../../store/useEnvStore.js";import N from"../../RuleContent/AddScopeApprovalSearchComponent.js";var W=[{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"},{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"}],q=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],P=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}],G=function(G){var U,H=G.isOpen,K=G.onClose,Y=G.onBoardStation,V=G.app_integration_id,X=G.token,J=a(null),Q=J[0],Z=J[1],$=a([]),ee=$[0],oe=$[1],re=a(0),ne=re[0],ie=re[1],te=a(!0),le=te[0],ae=te[1],se=a(!1),ce=se[0],ue=se[1],de=a([]),pe=de[0],fe=de[1],me=a(""),he=me[0],ge=me[1],xe=a(""),ve=xe[0],be=xe[1],ye=a(!1),Se=ye[0],Ce=ye[1],we=a(!1),_e=we[0],Fe=we[1],ke=a(null),Ee=ke[0],De=ke[1],Te=a(null);Te[0],Te[1];var Be=a(!1),Oe=Be[0],ze=Be[1],Ae=a(0),Ie=Ae[0],Me=Ae[1],Le=a(""),Re=Le[0],je=Le[1],Ne=A().user,We=s(null),qe=s(null),Pe=s(null),Ge=s(null);I().configuration;var Ue=s(null),He=R(function(e){return e.roles}),Ke=j(function(e){return e.rbacConfig}),Ye=a("approval_required"),Ve=Ye[0],Xe=Ye[1],Je=a([]),Qe=Je[0],Ze=Je[1],$e=a([]),eo=$e[0],oo=$e[1],ro=a(""),no=ro[0],io=ro[1],to=M(function(e){return e.stationNameParam}),lo=a({region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:""}),ao=lo[0],so=lo[1],co=function(e,o){return e.find(function(e){return e.value===o})||null},uo=c(function(){return ee.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[ee]),po=c(function(){var e,o,r;if(!ao.genre)return null;var n=ee.find(function(e){return e.scope_name===ao.genre});return n?{id:n.id,title:n.scope_name||"Unnamed Template",description:(null===(e=n.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(o=n.inheritance)||void 0===o?void 0:o[0])||void 0,rulesCount:n.rules_count||0,tiersCount:n.tier_count||0,isCopy:null!==(r=n.is_copy)&&void 0!==r&&r}:null},[ao.genre,ee]);u(function(){return function(){Pe.current&&clearTimeout(Pe.current)}},[]);var fo=function(e){return o(void 0,void 0,void 0,function(){var o,i,t;return r(this,function(r){switch(r.label){case 0:if(ce)return[2];ue(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,C({limit:"20",offset:String(e)})];case 2:return"success"===(null==(o=r.sent())?void 0:o.status)&&Array.isArray(null==o?void 0:o.data)?(i=o.data,oe(function(o){if(0===e)return i;var r=new Set(o.map(function(e){return e.id})),t=i.filter(function(e){return!r.has(e.id)});return n(n([],o,!0),t,!0)}),i.length<20?ae(!1):ae(!0),ie(e+20)):ae(!1),[3,5];case 3:return t=r.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",t),ae(!1),[3,5];case 4:return ue(!1),[7];case 5:return[2]}})})};u(function(){if(H&&(oe([]),ie(0),ae(!0),fo(0),to)){je(to);o(void 0,void 0,void 0,function(){var e,o,n;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,w(to,!0)];case 1:return!0===(null==(e=r.sent())?void 0:e.success)&&Array.isArray(null==e?void 0:e.data)&&(o=e.data.find(function(e){var o;return(null===(o=e.station_name)||void 0===o?void 0:o.toLowerCase())===to.toLowerCase()&&!e.ruleset_id}),o&&Z(o)),[3,3];case 2:return n=r.sent(),console.error("[StationOnboard] Error auto-selecting station:",n),[3,3];case 3:return[2]}})})}},[H,to]);u(function(){so(Q?function(o){var r;return e(e({},o),{region:null!==(r=Q.market)&&void 0!==r?r:""})}:{region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:""})},[Q]),u(function(){var e=setTimeout(function(){be(he)},500);return function(){return clearTimeout(e)}},[he]),u(function(){o(void 0,void 0,void 0,function(){var e,o,n,i;return r(this,function(r){switch(r.label){case 0:if(!ve.trim())return fe([]),[2];Ce(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,_({search_string:ve.trim()})];case 2:return"success"===(null==(e=r.sent())?void 0:e.status)&&Array.isArray(null==e?void 0:e.data)?(o=e.data.filter(function(e){var o,r=null!==(o=e.inheritance)&&void 0!==o?o:[],n=r.indexOf(e.scope_name);return!(n<=0)&&r[n-1]===ao.genre}),n=o.map(function(e){var o,r,n;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(o=e.description)||void 0===o?void 0:o.trim())||"No description available.",inheritedText:(null===(r=e.inheritance)||void 0===r?void 0:r[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(n=e.is_copy)&&void 0!==n&&n}}),fe(n)):fe([]),[3,5];case 3:return i=r.sent(),console.error("[StationOnboard] Error searching scopes:",i),fe([]),[3,5];case 4:return Ce(!1),[7];case 5:return[2]}})})},[ve,ao.genre]),u(function(){!ve.trim()&&po&&De(po.id)},[ve,po]);var mo=function(){setTimeout(function(){Ge.current&&Ge.current.scrollTo({top:Ge.current.scrollHeight,behavior:"smooth"})},100)},ho=function(){je(""),Z(null),so({region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:""}),fe([]),ge(""),De(null),Xe("approval_required"),Ze([]),oo([]),io(""),K()},go=function(o,r){var n;if("primeTime"!==o){var i=null!==(n=null==r?void 0:r.value)&&void 0!==n?n:"";so(function(r){var n;return e(e({},r),((n={})[o]=String(i),n))}),"genre"===o&&(Fe(!0),Pe.current&&clearTimeout(Pe.current),Pe.current=setTimeout(function(){var e=ee.find(function(e){return e.scope_name===i});De(e?e.id:null),Fe(!1)},800))}else{var t=(null==r?void 0:r.value)?String(r.value):"";so(function(o){return e(e({},o),{primeTime:t?[t]:[]})})}},xo=Boolean(Q&&ao.region&&ao.primeTime.length>0&&ao.genre);return i(d,e({open:H,onClose:ho,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"sans-serif"}}},{children:[t(y,{ref:We}),i(p,e({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[i(p,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[t(f,e({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),t(f,e({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),t(m,e({onClick:ho,disabled:Oe,sx:{color:"#19213D"}},{children:t(x,{size:24})}))]})),i(h,e({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[t(T,{isLoading:Oe,currentStep:Ie,onComplete:function(){ze(!1);var e=qe.current;ho(),Y(e||void 0),qe.current=null}}),t(p,e({sx:{display:"flex",flex:1,flexDirection:"column",paddingY:"14px",paddingX:"20px",gap:2,overflowY:"auto"}},{children:i(p,e({sx:{display:"flex",gap:3}},{children:[i(p,e({ref:Ge,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5"}},{children:[t(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),t(f,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),i(p,e({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[i(p,e({className:O.formGroup},{children:[i("label",e({className:O.label},{children:[t("span",e({className:O.asterisk},{children:"*"})),"Station Name/Call Letters"]})),t(E,{value:Re,onChange:je,onStationSelect:function(e){return Z(e)}})]})),t(z,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:ao.region||void 0,isSearchable:!1}),t(z,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:W,value:co(W,(null===(U=ao.primeTime)||void 0===U?void 0:U[0])||""),onOptionChange:function(e){return go("primeTime",e)},isSearchable:!1}),t(p,e({onClick:mo,sx:{width:"100%"}},{children:t(z,{label:"Station Sellout Type",placeholder:"None",options:q,value:co(q,ao.type),onOptionChange:function(o){go("type",o),"Low Sellout"!==(null==o?void 0:o.value)&&so(function(o){return e(e({},o),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===ao.type&&t(p,e({onClick:mo,sx:{width:"100%"}},{children:t(z,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:P,value:co(P,ao.lowSelloutConfig),onOptionChange:function(e){return go("lowSelloutConfig",e)},isSearchable:!1})})),M.getState().backwardCompatibility&&i("div",e({ref:Ue,style:{display:"flex",flexDirection:"column",marginTop:"12px"}},{children:[t(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Approval Settings"})),t(f,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Configure who can approve learnings before they get published."})),i("div",e({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"16px"}},{children:[i("div",e({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"12px"}},{children:[i("div",e({role:"radio","aria-checked":"approval_required"===Ve,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px",marginBottom:"8px"},onClick:function(){return Xe("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Xe("approval_required")}},{children:[i("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t("div",e({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Ve?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Ve&&t("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Approval Required Before Publishing"}))]})),t("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings require approval before publishing."}))]})),i("div",e({style:{gap:"16px"}},{children:["approval_required"===Ve&&t(N,{selectedApprovers:Qe,selectedGroupOfApprovers:eo,onApproversChange:function(e){Ze(e),io("")},onGroupsChange:function(e){oo(e),io("")}}),no&&t("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#8F2C23"}},{children:no}))]}))]})),i("div",e({role:"radio","aria-checked":"publish_without"===Ve,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px"},onClick:function(){Xe("publish_without"),io("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(Xe("publish_without"),io(""))}},{children:[i("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t("div",e({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Ve?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Ve&&t("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Publish Without Approval"}))]})),t("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings can be published directly."}))]}))]}))]}))]}))]})),i(p,e({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column"}},{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:[t("span",e({style:{color:"#E53E3E",marginRight:"2px"}},{children:"*"})),"Select a scope for your station"]})),t(f,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"16px"}},{children:"Your station will inherit the rules from the selected scope."})),t(p,e({sx:{mb:2}},{children:t(z,{required:!0,label:"",placeholder:"Select Genre",options:uo,value:co(uo,ao.genre),onOptionChange:function(e){return go("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!ce&&le&&fo(ne)},isLoadingOptions:ce,hasMoreOptions:le})})),t(p,e({sx:{mb:3}},{children:_e?t(D,{}):po?i(p,e({sx:{border:"1.5px solid #2563EB",borderRadius:"10px",p:"14px 16px",bgcolor:"#EFF6FF",display:"flex",alignItems:"flex-start",gap:"12px"}},{children:[t(p,e({sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#DBEAFE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:i("svg",e({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#2563EB",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[t("circle",{cx:"12",cy:"12",r:"2"}),t("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]}))})),i(p,e({sx:{flex:1,minWidth:0}},{children:[t(f,e({sx:{fontSize:"0.875rem",fontWeight:600,color:"#1E3A5F",mb:"2px"}},{children:po.title})),t(f,e({sx:{fontSize:"0.75rem",color:"#2563EB",mb:"8px"}},{children:po.description})),i(p,e({sx:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[po.inheritedText&&i(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px",display:"inline-flex",alignItems:"center",gap:"4px"}},{children:[i("svg",e({width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[t("polyline",{points:"15 3 21 3 21 9"}),t("path",{d:"M21 3L9 15"}),t("path",{d:"M3 21l6-6"})]})),po.inheritedText]})),i(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[po.rulesCount," rules"]})),i(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[po.tiersCount," Tiers"]}))]}))]}))]})):ao.genre?null:t(p,e({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.4,py:6,gap:1}},{children:t(f,e({sx:{fontSize:"0.75rem",color:"#94A3B8"}},{children:"Select a genre to load the matching scope"}))}))})),ao.genre&&i(l,{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:["Select an Existing Station from the “",ao.genre,"” Scope"," ",t(f,e({component:"span",sx:{fontSize:"1rem",fontWeight:400,color:"#64748B"}},{children:"(Optional)"}))]})),i(f,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"12px"}},{children:["Please select an existing station under the “",ao.genre,"” category to copy its learnings."]})),i("div",e({className:O.searchWrapper,style:{marginBottom:"12px"}},{children:[t("input",{type:"text",value:he,onChange:function(e){return ge(e.target.value)},placeholder:"Search for station...",className:O.searchInput}),t(v,{className:O.searchIcon,size:16})]})),i(p,e({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[Se&&t(D,{}),!Se&&0===pe.length&&ve.trim()&&i(f,e({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',ve,'".']})),!Se&&pe.map(function(o){return t(B,e({},o,{isSelected:Ee===o.id,onSelect:function(e){var o;De(Ee===e?null!==(o=null==po?void 0:po.id)&&void 0!==o?o:null:e)}}),o.id)})]}))]})]}))]}))}))]})),i(p,e({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[t("button",e({onClick:ho,disabled:Oe,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),t("button",e({onClick:function(){return o(void 0,void 0,void 0,function(){var e,o,i,t,l,a,s,c,u,d,p,f,m,h,g,x,v,b,y;return r(this,function(r){switch(r.label){case 0:if(!Q||!Ee)return console.error("[StationOnboard] Missing required data for onboarding"),[2];if(M.getState().backwardCompatibility&&"approval_required"===Ve&&0===Qe.length&&0===eo.length)return io("Please select at least one approver or approver group."),setTimeout(function(){var e;null===(e=Ue.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},50),[2];io(""),e=po?n([po],pe,!0):pe,o=e.find(function(e){return e.id===Ee}),null==o?void 0:o.isCopy,ze(!0),Me(0),i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),t=M.getState().backwardCompatibility,l=t?{topic:"customRuleSet",customScopeGroupName:L.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:Q.station_name||"New Station",parentScopeId:null!==(p=null==po?void 0:po.id)&&void 0!==p?p:null,customScopeName:Q.station_name||"New Station",customScopeId:S(),createByName:(null==Ne?void 0:Ne.firstname)||"System",createdBy:(null==Ne?void 0:Ne.email)||"system@audacy.com",scopeType:"Station",approvalRequired:"approval_required"===Ve,audacyStationMetadata:{genre:ao.genre,low_sellout_configurations:"Low Sellout"===ao.type?ao.lowSelloutConfig:null,market:Q.market,primetime_windows:ao.primeTime,region:Q.region,station_guid:Q.station_guid,station_type:""===ao.type?null:ao.type},appsecData:{application:null==Ke?void 0:Ke.applicationId,module:null==Ke?void 0:Ke.moduleId,roles:n(n([],"approval_required"===Ve?[{users:Qe.map(function(e){return e.email}),groups:eo.map(function(e){return e._id}),role:null!==(m=null===(f=He.find(function(e){return"Learning Manager"===e.name}))||void 0===f?void 0:f._id)&&void 0!==m?m:""}]:[],!0),[{users:[null==Ne?void 0:Ne.email],groups:[],role:null!==(g=null===(h=He.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===h?void 0:h._id)&&void 0!==g?g:""}],!1)}}:{topic:"customRuleSet",scope_reference_id:null,scopeDescription:"demo",parentScopeId:null,scopeName:Q.station_name||"New Station",scopeReferenceMetadata:{},applicationMappingId:V},console.log("[StationOnboard] Step 1: Creating rule set with payload:",l),[4,k(l,X)];case 2:if(a=r.sent(),!(i=null===(x=null==a?void 0:a.data)||void 0===x?void 0:x.scopeId))throw new Error("Failed to create scope - no scopeId returned");return console.log("[StationOnboard] Step 1 Complete: Created scope with ID:",i),Me(1),[3,4];case 3:return s=r.sent(),console.error("[StationOnboard] Error creating rule set:",s),null===(v=We.current)||void 0===v||v.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),ze(!1),Me(0),[2];case 4:return r.trys.push([4,6,,7]),c=null!==Ee&&Ee!==(null==po?void 0:po.id),u={source_scope_id:c?Ee:null!==(b=null==po?void 0:po.id)&&void 0!==b?b:Ee,target_scope_id:i,is_copy_parent_variant_id:c},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",u),[4,F(u)];case 5:return r.sent(),console.log("[StationOnboard] Step 3 Complete: Scope inherited"),Me(3),[3,7];case 6:return d=r.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",d),null===(y=We.current)||void 0===y||y.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),ze(!1),Me(0),[2];case 7:return qe.current=i,console.log("[StationOnboard] Onboarding completed successfully!"),[2]}})})},disabled:!xo||Oe,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:xo?"#2563EB":"#BFDBFE",color:"#fff",cursor:xo&&!Oe?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:i(l,Oe?{children:[t(g,{size:16,color:"inherit"}),t("span",{children:"Onboarding..."})]}:{children:[t("span",{children:"Onboard Station"}),t(b,{size:16})]})}))]}))]}))};export{G as default};
|
|
1
|
+
import{__assign as e,__awaiter as r,__generator as o,__spreadArray as n}from"tslib";import{jsxs as t,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useMemo as c,useEffect as d}from"react";import{Dialog as u,Box as p,Typography as f,IconButton as m,DialogContent as h,CircularProgress as g}from"@mui/material";import{X as x,Search as v,ArrowRight as y}from"lucide-react";import{Toast as b}from"primereact/toast";import{v4 as S}from"uuid";import{retrieveGenreScopes as w,fetchStationsByKeyword as C,searchScopes as _,inheritScopeBackwardCompatible as F,createRuleSet as k}from"../../apis/scopeApis.js";import D from"./StationAutocomplete.js";import E from"../CardSkeleton.js";import T from"./OnboardingLoader.js";import B from"./TemplateCard.js";import z from"../../styles/StationOnboardModal.module.css.js";import O from"./InputField.js";import A from"../../store/useAuthStore.js";import{useConfigStore as I}from"../../store/useConfigStore.js";import{useLearningTemplateStore as M}from"../../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as L}from"../../config.js";import{useAppSecRolesStore as R}from"../../store/useAppSecRolesStore.js";import j from"../../store/useEnvStore.js";import N from"../../RuleContent/AddScopeApprovalSearchComponent.js";import W from"./DayToggleSelector.js";var q=[{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"},{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"}],P=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],G=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}],U=[{label:"Mon",value:"monday"},{label:"Tue",value:"tuesday"},{label:"Wed",value:"wednesday"},{label:"Thu",value:"thursday"},{label:"Fri",value:"friday"},{label:"Sat",value:"saturday"},{label:"Sun",value:"sunday"}],H=function(H){var K,V=H.isOpen,Y=H.onClose,X=H.onBoardStation,J=H.app_integration_id,Q=H.token,Z=a(null),$=Z[0],ee=Z[1],re=a([]),oe=re[0],ne=re[1],te=a(0),ie=te[0],le=te[1],ae=a(!0),se=ae[0],ce=ae[1],de=a(!1),ue=de[0],pe=de[1],fe=a([]),me=fe[0],he=fe[1],ge=a(""),xe=ge[0],ve=ge[1],ye=a(""),be=ye[0],Se=ye[1],we=a(!1),Ce=we[0],_e=we[1],Fe=a(!1),ke=Fe[0],De=Fe[1],Ee=a(null),Te=Ee[0],Be=Ee[1],ze=a(null);ze[0],ze[1];var Oe=a(!1),Ae=Oe[0],Ie=Oe[1],Me=a(0),Le=Me[0],Re=Me[1],je=a(""),Ne=je[0],We=je[1],qe=A().user,Pe=s(null),Ge=s(null),Ue=s(null),He=s(null);I().configuration;var Ke=s(null),Ve=R(function(e){return e.roles}),Ye=j(function(e){return e.rbacConfig}),Xe=a("approval_required"),Je=Xe[0],Qe=Xe[1],Ze=a([]),$e=Ze[0],er=Ze[1],rr=a([]),or=rr[0],nr=rr[1],tr=a(""),ir=tr[0],lr=tr[1],ar=M(function(e){return e.stationNameParam}),sr=a({region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:"",source_days:["wednesday","thursday","friday","saturday"],target_days:["monday","tuesday","wednesday"]}),cr=sr[0],dr=sr[1],ur=function(e,r){return e.find(function(e){return e.value===r})||null},pr=c(function(){return oe.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[oe]),fr=c(function(){var e,r,o;if(!cr.genre)return null;var n=oe.find(function(e){return e.scope_name===cr.genre});return n?{id:n.id,title:n.scope_name||"Unnamed Template",description:(null===(e=n.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(r=n.inheritance)||void 0===r?void 0:r[0])||void 0,rulesCount:n.rules_count||0,tiersCount:n.tier_count||0,isCopy:null!==(o=n.is_copy)&&void 0!==o&&o}:null},[cr.genre,oe]);d(function(){return function(){Ue.current&&clearTimeout(Ue.current)}},[]);var mr=function(e){return r(void 0,void 0,void 0,function(){var r,t,i;return o(this,function(o){switch(o.label){case 0:if(ue)return[2];pe(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,w({limit:"20",offset:String(e)})];case 2:return"success"===(null==(r=o.sent())?void 0:r.status)&&Array.isArray(null==r?void 0:r.data)?(t=r.data,ne(function(r){if(0===e)return t;var o=new Set(r.map(function(e){return e.id})),i=t.filter(function(e){return!o.has(e.id)});return n(n([],r,!0),i,!0)}),t.length<20?ce(!1):ce(!0),le(e+20)):ce(!1),[3,5];case 3:return i=o.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",i),ce(!1),[3,5];case 4:return pe(!1),[7];case 5:return[2]}})})};d(function(){if(V&&(ne([]),le(0),ce(!0),mr(0),ar)){We(ar);r(void 0,void 0,void 0,function(){var e,r,n;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,C(ar,!0)];case 1:return!0===(null==(e=o.sent())?void 0:e.success)&&Array.isArray(null==e?void 0:e.data)&&(r=e.data.find(function(e){var r;return(null===(r=e.station_name)||void 0===r?void 0:r.toLowerCase())===ar.toLowerCase()&&!e.ruleset_id}),r&&ee(r)),[3,3];case 2:return n=o.sent(),console.error("[StationOnboard] Error auto-selecting station:",n),[3,3];case 3:return[2]}})})}},[V,ar]);d(function(){dr($?function(r){var o;return e(e({},r),{region:null!==(o=$.market)&&void 0!==o?o:""})}:{region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:"",source_days:["wednesday","thursday","friday","saturday"],target_days:["monday","tuesday","wednesday"]})},[$]),d(function(){var e=setTimeout(function(){Se(xe)},500);return function(){return clearTimeout(e)}},[xe]),d(function(){r(void 0,void 0,void 0,function(){var e,r,n,t;return o(this,function(o){switch(o.label){case 0:if(!be.trim())return he([]),[2];_e(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,_({search_string:be.trim()})];case 2:return"success"===(null==(e=o.sent())?void 0:e.status)&&Array.isArray(null==e?void 0:e.data)?(r=e.data.filter(function(e){var r,o=null!==(r=e.inheritance)&&void 0!==r?r:[],n=o.indexOf(e.scope_name);return!(n<=0)&&o[n-1]===cr.genre}),n=r.map(function(e){var r,o,n;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(r=e.description)||void 0===r?void 0:r.trim())||"No description available.",inheritedText:(null===(o=e.inheritance)||void 0===o?void 0:o[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(n=e.is_copy)&&void 0!==n&&n}}),he(n)):he([]),[3,5];case 3:return t=o.sent(),console.error("[StationOnboard] Error searching scopes:",t),he([]),[3,5];case 4:return _e(!1),[7];case 5:return[2]}})})},[be,cr.genre]),d(function(){!be.trim()&&fr&&Be(fr.id)},[be,fr]);var hr=function(){setTimeout(function(){He.current&&He.current.scrollTo({top:He.current.scrollHeight,behavior:"smooth"})},100)},gr=function(){We(""),ee(null),dr({region:"",primeTime:["06:00 AM - 7:00 PM"],genre:"Music",type:"",lowSelloutConfig:"",source_days:["wednesday","thursday","friday","saturday"],target_days:["monday","tuesday","wednesday"]}),he([]),ve(""),Be(null),Qe("approval_required"),er([]),nr([]),lr(""),Y()},xr=function(r,o){var n;if("primeTime"!==r)if("source_days"!==r&&"target_days"!==r){var t=null!==(n=null==o?void 0:o.value)&&void 0!==n?n:"";dr(function(o){var n;return e(e({},o),((n={})[r]=String(t),n))}),"genre"===r&&(De(!0),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(function(){var e=oe.find(function(e){return e.scope_name===t});Be(e?e.id:null),De(!1)},800))}else dr(function(n){var t;return e(e({},n),((t={})[r]=o,t))});else{var i=(null==o?void 0:o.value)?String(o.value):"";dr(function(r){return e(e({},r),{primeTime:i?[i]:[]})})}},vr=Boolean($&&cr.region&&cr.primeTime.length>0&&cr.genre);return t(u,e({open:V,onClose:gr,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"sans-serif"}}},{children:[i(b,{ref:Pe}),t(p,e({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[t(p,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[i(f,e({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),i(f,e({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),i(m,e({onClick:gr,disabled:Ae,sx:{color:"#19213D"}},{children:i(x,{size:24})}))]})),t(h,e({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[i(T,{isLoading:Ae,currentStep:Le,onComplete:function(){Ie(!1);var e=Ge.current;gr(),X(e||void 0),Ge.current=null}}),i(p,e({sx:{display:"flex",flex:1,flexDirection:"column",paddingY:"14px",paddingX:"20px",gap:2,overflowY:"auto"}},{children:t(p,e({sx:{display:"flex",gap:3}},{children:[t(p,e({ref:He,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5"}},{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),i(f,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),t(p,e({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[t(p,e({className:z.formGroup},{children:[t("label",e({className:z.label},{children:[i("span",e({className:z.asterisk},{children:"*"})),"Station Name/Call Letters"]})),i(D,{value:Ne,onChange:We,onStationSelect:function(e){return ee(e)}})]})),i(O,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:cr.region||void 0,isSearchable:!1}),i(O,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:q,value:ur(q,(null===(K=cr.primeTime)||void 0===K?void 0:K[0])||""),onOptionChange:function(e){return xr("primeTime",e)},isSearchable:!1}),i(p,e({onClick:hr,sx:{width:"100%"}},{children:i(O,{label:"Station Sellout Type",placeholder:"None",options:P,value:ur(P,cr.type),onOptionChange:function(r){xr("type",r),"Low Sellout"!==(null==r?void 0:r.value)&&dr(function(r){return e(e({},r),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===cr.type&&i(p,e({onClick:hr,sx:{width:"100%"}},{children:i(O,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:G,value:ur(G,cr.lowSelloutConfig),onOptionChange:function(e){return xr("lowSelloutConfig",e)},isSearchable:!1})})),t(p,e({onClick:hr,sx:{width:"100%",display:"flex",flexDirection:"column",gap:"20px"}},{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:600,color:"#19213D"}},{children:"Front-Loading Configuration"})),i(W,{label:"Source Days",subText:"Days from which spots can be front loaded.",options:U,selectedValues:cr.source_days,onChange:function(e){return xr("source_days",e)}}),i(W,{label:"Target Days",subText:"Days where front loaded spots can be placed.",options:U,selectedValues:cr.target_days,onChange:function(e){return xr("target_days",e)}})]})),M.getState().backwardCompatibility&&t("div",e({ref:Ke,style:{display:"flex",flexDirection:"column",marginTop:"12px"}},{children:[i(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Approval Settings"})),i(f,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Configure who can approve learnings before they get published."})),t("div",e({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"16px"}},{children:[t("div",e({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"12px"}},{children:[t("div",e({role:"radio","aria-checked":"approval_required"===Je,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px",marginBottom:"8px"},onClick:function(){return Qe("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Qe("approval_required")}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i("div",e({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Je?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Je&&i("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),i("span",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Approval Required Before Publishing"}))]})),i("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings require approval before publishing."}))]})),t("div",e({style:{gap:"16px"}},{children:["approval_required"===Je&&i(N,{selectedApprovers:$e,selectedGroupOfApprovers:or,onApproversChange:function(e){er(e),lr("")},onGroupsChange:function(e){nr(e),lr("")}}),ir&&i("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#8F2C23"}},{children:ir}))]}))]})),t("div",e({role:"radio","aria-checked":"publish_without"===Je,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px"},onClick:function(){Qe("publish_without"),lr("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(Qe("publish_without"),lr(""))}},{children:[t("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[i("div",e({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Je?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Je&&i("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),i("span",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Publish Without Approval"}))]})),i("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings can be published directly."}))]}))]}))]}))]}))]})),t(p,e({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column"}},{children:[t(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:[i("span",e({style:{color:"#E53E3E",marginRight:"2px"}},{children:"*"})),"Select a scope for your station"]})),i(f,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"16px"}},{children:"Your station will inherit the rules from the selected scope."})),i(p,e({sx:{mb:2}},{children:i(O,{required:!0,label:"",placeholder:"Select Genre",options:pr,value:ur(pr,cr.genre),onOptionChange:function(e){return xr("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!ue&&se&&mr(ie)},isLoadingOptions:ue,hasMoreOptions:se})})),i(p,e({sx:{mb:3}},{children:ke?i(E,{}):fr?t(p,e({sx:{border:"1.5px solid #2563EB",borderRadius:"10px",p:"14px 16px",bgcolor:"#EFF6FF",display:"flex",alignItems:"flex-start",gap:"12px"}},{children:[i(p,e({sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#DBEAFE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:t("svg",e({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#2563EB",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[i("circle",{cx:"12",cy:"12",r:"2"}),i("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]}))})),t(p,e({sx:{flex:1,minWidth:0}},{children:[i(f,e({sx:{fontSize:"0.875rem",fontWeight:600,color:"#1E3A5F",mb:"2px"}},{children:fr.title})),i(f,e({sx:{fontSize:"0.75rem",color:"#2563EB",mb:"8px"}},{children:fr.description})),t(p,e({sx:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[fr.inheritedText&&t(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px",display:"inline-flex",alignItems:"center",gap:"4px"}},{children:[t("svg",e({width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[i("polyline",{points:"15 3 21 3 21 9"}),i("path",{d:"M21 3L9 15"}),i("path",{d:"M3 21l6-6"})]})),fr.inheritedText]})),t(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[fr.rulesCount," rules"]})),t(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[fr.tiersCount," Tiers"]}))]}))]}))]})):cr.genre?null:i(p,e({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.4,py:6,gap:1}},{children:i(f,e({sx:{fontSize:"0.75rem",color:"#94A3B8"}},{children:"Select a genre to load the matching scope"}))}))})),cr.genre&&t(l,{children:[t(f,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:["Select an Existing Station from the “",cr.genre,"” Scope"," ",i(f,e({component:"span",sx:{fontSize:"1rem",fontWeight:400,color:"#64748B"}},{children:"(Optional)"}))]})),t(f,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"12px"}},{children:["Please select an existing station under the “",cr.genre,"” category to copy its learnings."]})),t("div",e({className:z.searchWrapper,style:{marginBottom:"12px"}},{children:[i("input",{type:"text",value:xe,onChange:function(e){return ve(e.target.value)},placeholder:"Search for station...",className:z.searchInput}),i(v,{className:z.searchIcon,size:16})]})),t(p,e({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[Ce&&i(E,{}),!Ce&&0===me.length&&be.trim()&&t(f,e({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',be,'".']})),!Ce&&me.map(function(r){return i(B,e({},r,{isSelected:Te===r.id,onSelect:function(e){var r;Be(Te===e?null!==(r=null==fr?void 0:fr.id)&&void 0!==r?r:null:e)}}),r.id)})]}))]})]}))]}))}))]})),t(p,e({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[i("button",e({onClick:gr,disabled:Ae,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),i("button",e({onClick:function(){return r(void 0,void 0,void 0,function(){var e,r,t,i,l,a,s,c,d,u,p,f,m,h,g,x,v,y,b;return o(this,function(o){switch(o.label){case 0:if(!$||!Te)return console.error("[StationOnboard] Missing required data for onboarding"),[2];if(M.getState().backwardCompatibility&&"approval_required"===Je&&0===$e.length&&0===or.length)return lr("Please select at least one approver or approver group."),setTimeout(function(){var e;null===(e=Ke.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},50),[2];lr(""),e=fr?n([fr],me,!0):me,r=e.find(function(e){return e.id===Te}),null==r?void 0:r.isCopy,Ie(!0),Re(0),t=null,o.label=1;case 1:return o.trys.push([1,3,,4]),i=M.getState().backwardCompatibility,l=i?{topic:"customRuleSet",customScopeGroupName:L.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:$.station_name||"New Station",parentScopeId:null!==(p=null==fr?void 0:fr.id)&&void 0!==p?p:null,customScopeName:$.station_name||"New Station",customScopeId:S(),createByName:(null==qe?void 0:qe.firstname)||"System",createdBy:(null==qe?void 0:qe.email)||"system@audacy.com",scopeType:"Station",approvalRequired:"approval_required"===Je,audacyStationMetadata:{genre:cr.genre,low_sellout_configurations:"Low Sellout"===cr.type?cr.lowSelloutConfig:null,market:$.market,primetime_windows:cr.primeTime,region:$.region,station_guid:$.station_guid,station_type:""===cr.type?null:cr.type,source_days:cr.source_days,target_days:cr.target_days},appsecData:{application:null==Ye?void 0:Ye.applicationId,module:null==Ye?void 0:Ye.moduleId,roles:n(n([],"approval_required"===Je?[{users:$e.map(function(e){return e.email}),groups:or.map(function(e){return e._id}),role:null!==(m=null===(f=Ve.find(function(e){return"Learning Manager"===e.name}))||void 0===f?void 0:f._id)&&void 0!==m?m:""}]:[],!0),[{users:[null==qe?void 0:qe.email],groups:[],role:null!==(g=null===(h=Ve.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===h?void 0:h._id)&&void 0!==g?g:""}],!1)}}:{topic:"customRuleSet",scope_reference_id:null,scopeDescription:"demo",parentScopeId:null,scopeName:$.station_name||"New Station",scopeReferenceMetadata:{},applicationMappingId:J},console.log("[StationOnboard] Step 1: Creating rule set with payload:",l),[4,k(l,Q)];case 2:if(a=o.sent(),!(t=null===(x=null==a?void 0:a.data)||void 0===x?void 0:x.scopeId))throw new Error("Failed to create scope - no scopeId returned");return console.log("[StationOnboard] Step 1 Complete: Created scope with ID:",t),Re(1),[3,4];case 3:return s=o.sent(),console.error("[StationOnboard] Error creating rule set:",s),null===(v=Pe.current)||void 0===v||v.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),Ie(!1),Re(0),[2];case 4:return o.trys.push([4,6,,7]),c=null!==Te&&Te!==(null==fr?void 0:fr.id),d={source_scope_id:c?Te:null!==(y=null==fr?void 0:fr.id)&&void 0!==y?y:Te,target_scope_id:t,is_copy_parent_variant_id:c},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",d),[4,F(d)];case 5:return o.sent(),console.log("[StationOnboard] Step 3 Complete: Scope inherited"),Re(3),[3,7];case 6:return u=o.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",u),null===(b=Pe.current)||void 0===b||b.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),Ie(!1),Re(0),[2];case 7:return Ge.current=t,console.log("[StationOnboard] Onboarding completed successfully!"),[2]}})})},disabled:!vr||Ae,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:vr?"#2563EB":"#BFDBFE",color:"#fff",cursor:vr&&!Ae?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:t(l,Ae?{children:[i(g,{size:16,color:"inherit"}),i("span",{children:"Onboarding..."})]}:{children:[i("span",{children:"Onboard Station"}),i(y,{size:16})]})}))]}))]}))};export{H as default};
|
|
2
2
|
//# sourceMappingURL=StationOnboardModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstantLearningModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/components/InstantLearningModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAoCjF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA2BpE,UAAU,yBAAyB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qEAAqE;IACrE,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IACvC,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,sBAAsB,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7E,6FAA6F;IAC7F,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAC,GAAG,CAAC;CACpB;AAoBD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAS,MAAM,GAAG,GAAG,WAMhD,CAAC;AAwIF,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,
|
|
1
|
+
{"version":3,"file":"InstantLearningModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/components/InstantLearningModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAoCjF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA2BpE,UAAU,yBAAyB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qEAAqE;IACrE,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IACvC,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,sBAAsB,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7E,6FAA6F;IAC7F,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAC,GAAG,CAAC;CACpB;AAoBD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAS,MAAM,GAAG,GAAG,WAMhD,CAAC;AAwIF,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAm2N7D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface StationOnboardModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onBoardStation: (scopeId?: string) => void;
|
|
6
|
+
app_integration_id?: string;
|
|
7
|
+
token: string;
|
|
8
|
+
stationNameParam?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const BackwardStationOnboardModal: React.FC<StationOnboardModalProps>;
|
|
11
|
+
export default BackwardStationOnboardModal;
|
|
12
|
+
//# sourceMappingURL=BackwardStationOnboardModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackwardStationOnboardModal.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AA+DpE,UAAU,wBAAwB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,QAAA,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAitBnE,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectOption } from "./InputField";
|
|
3
|
+
interface DayToggleSelectorProps {
|
|
4
|
+
label: string;
|
|
5
|
+
subText?: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
options: SelectOption[];
|
|
8
|
+
selectedValues: string[];
|
|
9
|
+
onChange: (updatedValues: string[]) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const DayToggleSelector: React.FC<DayToggleSelectorProps>;
|
|
12
|
+
export default DayToggleSelector;
|
|
13
|
+
//# sourceMappingURL=DayToggleSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DayToggleSelector.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/LearningManagement/components/StationOnboarding/DayToggleSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAkC5C,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC7C;AAED,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA4EvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StationOnboardModal.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/LearningManagement/components/StationOnboarding/StationOnboardModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StationOnboardModal.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/LearningManagement/components/StationOnboarding/StationOnboardModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAiFpE,UAAU,wBAAwB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qEAAqE;IACrE,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAuiC3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|