"use strict";(self.webpackChunk_postman_app_scratchpad=self.webpackChunk_postman_app_scratchpad||[]).push([[8],{8286:function(e,t,a){a.r(t),a.d(t,{default:function(){return i}});var n=a(1);function i(e){return n.useMemo((()=>Object.assign({},e)),[...Object.values(e)])}},8288:function(e,t,a){a.r(t),a.d(t,{default:function(){return i}});var n=a(1);function i(){const e=n.useRef(!0);return n.useEffect((()=>()=>{e.current=!1}),[]),n.useCallback((()=>e.current),[])}},8284:function(e,t,a){a.r(t),a.d(t,{default:function(){return S}});var n=a(12),i=a.n(n),r=a(1),l=a(3663),o=a(1019),s=a(2893),d=a(4961),u=a(3842),c=a(4766),f=a(6623),m=a(4720),p=a(2730),E=a(8285),v=a(5372),y=a(5373),b=a(5374),g=a(8286),I=a(8287),h=a(8289);a(5386);function S(e,t){const a=(0,s.observer)((({controller:a,editorId:n})=>{const s=(0,o.toJS)(a.itemState.get("item")),{error:S,isLoading:C,isActive:R}=a.tabState,T=!1,[O,_]=r.useState({}),A=(0,r.useMemo)((()=>{return(e=a.update.bind(a)).path=(t,a)=>{e((e=>{void 0===a?i().unset(e,t):i().set(e,t,a)}))},e;var e}),[a]),D=(0,r.useCallback)((()=>{a.cacheUpdatesBuffer()}),[a]),L=Object.freeze((0,g.default)({type:pm.runtime.agent.stat.type,version:pm.runtime.version,isReady:pm.runtime.agent.isReady})),N=Object.freeze((0,g.default)({isActive:R,isOffline:a.isOffline,isReadOnly:a.isReadOnly})),k=(0,m.resolveStoreInstance)(f.default).get("editor.requestEditorLayoutName");if(S===E.default.DeletedEntity)return r.createElement(u.default,{userFriendlyEntityName:e.config.title,type:"deleted",hasToCapitalize:!1});if(S===E.default.NoHistoryPermission)return r.createElement(u.default,{userFriendlyEntityName:e.config.title,icon:e.config.icon,title:"You don't have view permission",message:`Only team members can view this ${e.config.title} from history of this workspace.`,hasToCapitalize:!1});if(S)return r.createElement(u.default,{userFriendlyEntityName:e.config.title,hasToCapitalize:!1});if(C)return r.createElement(d.default,null);return r.createElement(v.AgentContext.Provider,{value:L,key:s.id},r.createElement(c.default,{collectionId:null},r.createElement(y.TabContext.Provider,{value:N},r.createElement(b.LayoutContext.Provider,{value:k},function(){var i;return r.createElement(l.default,{direction:"column",height:"100%"},r.createElement(I.default,{state:s,isSaved:T,historyId:a instanceof h.default&&a.historyId||null,feedbackURL:e.config.feedbackURL,docsURL:e.config.docsURL,saveDisabledReason:a.saveDisabledReason,saveAsDisabledReason:a.saveAsDisabledReason,renameOnMount:null===(i=a.context)||void 0===i?void 0:i.rename,tabId:a.getTabId(),cacheUpdatesBuffer:D}),r.createElement(t,{state:s,update:A,agent:L,tab:N,historyEvents:a instanceof h.default?a.historyEvents:[],setContextData:e=>_(Object.assign(Object.assign({},O),e)),collectionId:null,promoteTab:()=>p.default.promoteEditor({id:n}),controller:a}))}()))))}));return class extends r.Component{render(){return r.createElement(a,{controller:this.props.controller,editorId:this.props.id})}}}},8287:function(e,t,a){a.r(t),a.d(t,{default:function(){return O}});var n=a(1),i=a(2921),r=a(3852),l=a(5188),o=a(3663),s=a(3016),d=a(3676),u=a(3836),c=a(6424),f=a(6426),m=a(5850),p=a(5860),E=a(5857),v=a(2595),y=a(5384),b=a(5371),g=a(5385),I=a(5386),h=a(8288),S=a(5373),C=a(2886),R=a(7008);(0,i.default)(d.Dropdown)`
  & .btn-group > .btn {
    min-width: var(--size-s);
    height: var(--size-m);
    padding: var(--spacing-s) var(--spacing-xs);
    margin-left: var(--border-width-default);
  }
`;const T=(0,i.default)(u.default)`
  &.entity-tab-header {
    border-bottom: 0;
  }
`;function O({state:e,isSaved:t,historyId:a,saveDisabledReason:i,saveAsDisabledReason:d,renameOnMount:u,tabId:O,cacheUpdatesBuffer:_}){var A;const D=(null===(A=pm.ECItemRegistry.getConfig(e.type))||void 0===A?void 0:A.title)||"item",L=i||`Save ${D}`,N=d||`Save ${D} to a collection`,{isOffline:k,isReadOnly:U}=(0,S.default)(),[w,x]=n.useState(!1),B=(0,h.default)(),M=n.useRef(null),P=Boolean(null!==a);n.useEffect((()=>{var e;u&&(null===(e=M.current)||void 0===e||e.handleEditName())}),[]);const z=n.useMemo((()=>{var a;const n=[];if(t){n.push({type:e.type,id:e.id,name:e.title});let t=null===(a=I.default.cacheAPI.get(e.id))||void 0===a?void 0:a.parent;for(;t;){const{parent:e}=I.default.getParent(t);n.unshift({type:e.type,id:e.id,name:e.title||""}),t=e.parent}}return n}),[e]),F=n.useCallback((()=>pm.mediator.trigger("showSignInModal",{userFlow:R.USER_FLOW.REQUEST_SAVE,subtitle:p.SAVE_REQUEST_SIGNIN_MODAL_SUBTITLE})),[]),j=(n.useCallback((()=>pm.mediator.trigger("showSignInModal",{userFlow:R.USER_FLOW.REQUEST_SAVE,subtitle:p.SAVE_REQUEST_SIGNIN_MODAL_SUBTITLE})),[]),n.useCallback((({id:e,type:t})=>{var a;t===y.COLLECTION?g.default.openInTab(e):null===(a=pm.ECItemRegistry.getSDK(t))||void 0===a||a.openInTab(e)}),[])),G=n.useCallback((({id:e,type:t})=>t===y.COLLECTION?{routeIdentifier:"build.collection",routeParams:{cid:e},queryParams:null}:pm.ECItemRegistry.getSDK(t)?{routeIdentifier:pm.ECItemRegistry.getSDK(t).openSavedIdentifier,routeParams:{ecid:e},queryParams:{}}:null),[]),K=n.useCallback((t=>{if(w)return;x(!0);pm.ECItemRegistry.getSDK(e.type).menuActionHandler(e.id,b.ItemAction.RENAME,{name:t}).then((()=>{B()&&x(!1)}))}),[w,e.type,e.id]);n.useCallback((()=>{pm.ECItemRegistry.getSDK(e.type).menuActionHandler(e.id,b.ItemAction.DELETE)}),[e.type,e.id]),t?n.createElement(r.default,{text:"Save",type:"secondary",icon:n.createElement(s.default,null),onClick:F,isDisabled:Boolean(i),tooltip:L}):n.createElement(r.default,{text:"Save",type:"secondary",icon:n.createElement(s.default,null),onClick:F,isDisabled:Boolean(d),tooltip:N});return n.createElement(T,{name:e.title,ref:M,path:z.length?z:null,entityType:a?`ech:${e.type}`:`ec:${e.type}`,entityUID:a||e.id,isEntityEditable:t&&!k&&!U&&!w,onBreadCrumbItemClick:j,onSubmit:K,leftMetaComponent:()=>n.createElement(m.default,{activeValue:e.type,tabId:O,canSwitch:!t&&!P,beforeSwitch:()=>_()}),renderActions:()=>n.createElement(o.default,{alignItems:"center",gap:"spacing-s"},(()=>{const e=n.createElement(r.default,{icon:n.createElement(s.default,null),text:"Save",type:"tertiary"});return v.default.isEnabled?n.createElement(l.default,{placement:"bottom-end",padding:"spacing-xs",maxWidth:"350px",trigger:e,pointer:"true"},n.createElement(E.default,{title:p.GENERIC_SIGNIN_MODAL_TITLE,subtitle:p.GENERIC_SIGNIN_MODAL_SUBTITLE})):n.createElement(r.default,{icon:n.createElement(s.default,null),text:"Save",type:"tertiary",onClick:F})})(),C.default.isUseBrowserTabsActive()&&n.createElement("div",{className:"environment-container"},n.createElement(c.default,{selectorWidth:130,useBrowserTabs:!0}),n.createElement("div",{className:"environment-splitter"}),n.createElement(f.default,{useBrowserTabs:!0}))),breadCrumbRouteConfig:G})}}}]);