mockforme 8.1.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var e={133:(e,t,n)=>{n.r(t),n.d(t,{default:()=>Y}),function(){try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.mfm-token-form{padding:24px;text-align:center;max-width:400px;margin:0 auto;width:100%;box-sizing:border-box}.mfm-token-link-container{margin-top:15px;font-size:.8rem}.mfm-token-link-container a{color:var(--mfm-primary)}.mfm-token-container{display:flex;flex-direction:column;align-items:center;padding:16px}.mfm-token-header{position:absolute;right:0;top:0}.mfm-token-logo{margin-bottom:16px;height:30px}.mfm-token-title{margin:0 0 8px;font-size:1.25rem;font-weight:600;color:var(--mfm-text)}.mfm-token-desc{color:var(--mfm-text-dim);font-size:.9rem;margin-bottom:24px;line-height:1.5}.mfm-token-input{text-align:center;height:44px;font-size:1rem;width:100%;border:1px solid var(--mfm-border);border-radius:6px;background:var(--mfm-input-bg);color:var(--mfm-text);padding:0 12px;outline:none;transition:all .2s}.mfm-token-input:focus{border-color:var(--mfm-primary);box-shadow:0 0 0 2px #3b82f633}.mfm-token-error{color:var(--mfm-error);font-size:.8rem;margin-top:8px;display:none;min-height:20px}.mfm-token-submit{margin-top:16px;width:100%;height:44px;background:var(--mfm-primary);color:#fff;border:none;border-radius:6px;font-size:.95rem;font-weight:500;cursor:pointer;transition:all .2s;display:flex;align-items:center;justify-content:center}.mfm-token-submit:hover{background:var(--mfm-primary-hover)}.mfm-token-submit:disabled{opacity:.7;cursor:not-allowed}.json-viewer{font-family:Consolas,Monaco,monospace;font-size:13px;line-height:1.6;padding:12px;border-radius:6px;overflow:auto}.json-viewer-light{background:#fff;color:#1f1f1f}.json-viewer-dark{background:#1e1e1e;color:#d4d4d4}.json-node{position:relative;padding-left:18px;white-space:nowrap;-webkit-user-select:text;user-select:text}.json-children{margin-left:18px;padding-left:8px;border-left:1px dotted rgba(128,128,128,.25)}.json-toggle{position:absolute;left:0;cursor:pointer;-webkit-user-select:none;user-select:none;width:14px;height:14px;display:flex;align-items:center;justify-content:center;color:#888;font-weight:700;font-size:14px;border:1px solid rgba(128,128,128,.3);border-radius:2px;line-height:1;background:#8080800d;top:4px}.json-toggle:hover{color:#007acc;border-color:#007acc;background:#007acc0d}.json-bracket,.json-closing-bracket{display:inline-block}.json-closing-bracket{margin-left:18px}.json-key{color:#922}.json-viewer-dark .json-key{color:#9cdcfe}.json-value.string{color:#0b7500}.json-value.number{color:#1a01cc}.json-value.boolean{color:#aa0d91}.json-value.null{color:#777}.json-viewer-dark .json-value.string{color:#ce9178}.json-viewer-dark .json-value.number{color:#b5cea8}.json-viewer-dark .json-value.boolean{color:#569cd6}.json-viewer-dark .json-value.null{color:gray}.json-node:hover{background:#0000000a;border-radius:4px}.json-viewer-dark .json-node:hover{background:#ffffff0f}.json-match{background-color:#ffff0059;border-radius:3px}.json-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;padding-bottom:8px;border-bottom:1px solid rgba(128,128,128,.15)}.json-toolbar-group,.json-search-group{display:flex;align-items:center;gap:4px}.json-toolbar .json-toolbar-group button{height:20px;width:20px}.json-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border-radius:4px;border:1px solid var(--mfm-primary);cursor:pointer;background:var(--mfm-bg);color:#555;transition:all .2s}.json-toolbar button:hover{background:#eee;border-color:#ccc;color:#000}.json-viewer-dark .json-toolbar button{background:#333;color:#bbb;border:1px solid #444}.json-viewer-dark .json-toolbar button:hover{background:#444;border-color:#555;color:#fff}.json-search-group{flex:1;max-width:200px}.json-toolbar input{flex:1;font-size:12px;height:28px;padding:0 8px;border-radius:4px;border:1px solid var(--mfm-primary);outline:none}.json-viewer-dark .json-toolbar input{background:#252525;color:#ddd;border:1px solid #444}.json-viewer::-webkit-scrollbar{width:8px;height:8px}.json-viewer::-webkit-scrollbar-thumb{background:#80808066;border-radius:4px}.json-viewer::-webkit-scrollbar-thumb:hover{background:#80808099}.json-viewer-fullscreen{position:fixed!important;top:0!important;left:1%!important;width:98%;height:100vh!important;z-index:1000000!important;display:flex!important;flex-direction:column!important;box-sizing:border-box!important;max-height:99%!important}body.json-viewer-body-fullscreen{overflow:hidden!important;height:100vh!important}.json-viewer-fullscreen .json-tree-container{flex:1!important;overflow:auto!important;max-height:500px!important}.json-viewer.json-is-searching .json-node{display:none!important}.json-viewer.json-is-searching .json-node.json-item-visible{display:block!important}.json-tree-container{overflow:auto;max-height:315px}pre{user-select:text;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text}.mfm-status.rule{color:var(--mfm-info)}.mfm-mod-pill{font-size:.7rem;color:var(--mfm-primary);background:#3b82f61a;padding:2px 6px;border-radius:10px;font-weight:500}.mfm-rule-info .mfm-rule-action{font-weight:700;color:var(--mfm-primary)}.mfm-rule-info .mfm-rule-value{color:var(--mfm-value)}.mfm-mapping-list-activity{padding:0;max-height:468px;overflow-y:scroll}.mfm-mapping-list-activity .mfm-spinner{display:flex;justify-content:center;margin:10px auto}.mfm-mapping-list-activity .mfm-request-item{padding:16px}.mfm-empty{padding:32px;text-align:center;color:var(--mfm-text-dim);font-size:.9rem}.mfm-spinner{width:24px;height:24px;border:2px solid var(--mfm-border);border-top-color:var(--mfm-primary);border-radius:50%;animation:mfm-spin .8s linear infinite}@keyframes mfm-spin{to{transform:rotate(360deg)}}.mfm-rule-info{font-size:.7rem;color:var(--mfm-text-dim);margin-top:4px;padding-left:4px}.mfm-mocked-apis-activity{padding:0;height:468px;overflow-y:scroll}.mfm-other-apis-activity{padding:0;max-height:468px}.mfm-request-item{display:flex;flex-direction:column;padding:12px 16px;border-bottom:1px solid var(--mfm-border);cursor:pointer;background:var(--mfm-bg);transition:background-color .2s ease}.mfm-request-item:hover{background:var(--mfm-hover)}.mfm-request-item.active{background:var(--mfm-active-bg)}.mfm-request-header{display:flex;justify-content:space-between;align-items:center}.mfm-flex-row{display:flex;align-items:center;gap:8px}.mfm-method{font-size:.75rem;font-weight:700;min-width:40px}.mfm-status{font-size:.8rem;margin-left:8px}.mfm-status.success{color:var(--mfm-success)}.mfm-status.error{color:var(--mfm-error)}.mfm-status.pending{color:var(--mfm-text-dim)}.mfm-url{font-size:.85rem;color:var(--mfm-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.4}.mfm-dropdown{position:relative;display:inline-block}.mfm-dropdown-content{display:none;position:absolute;right:0;top:100%;background-color:var(--mfm-bg);min-width:160px;box-shadow:0 4px 12px #00000026;z-index:1000;border:1px solid var(--mfm-border);border-radius:6px;overflow:hidden;margin-top:4px}.mfm-dropdown-content button{color:var(--mfm-text);padding:10px 16px;text-decoration:none;display:block;width:100%;text-align:left;background:none;border:none;cursor:pointer;font-size:.85rem;transition:background .1s}.mfm-dropdown-content button:hover{background-color:var(--mfm-hover)}.mfm-btn-icon{background:none;border:none;padding:4px;cursor:pointer;color:var(--mfm-text-dim);border-radius:4px;display:flex;align-items:center;justify-content:center}.mfm-btn-icon:hover{background:var(--mfm-hover);color:var(--mfm-text)}:root{--mfm-primary: #2563eb;--mfm-primary-hover: #1d4ed8;--mfm-bg: #ffffff;--mfm-surface: #f8fafc;--mfm-surface-bright: #f1f5f9;--mfm-text: #0f172a;--mfm-text-dim: #64748b;--mfm-border: #e2e8f0;--mfm-success: #10b981;--mfm-error: #ef4444;--mfm-warning: #f59e0b;--mfm-radius: 8px;--mfm-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--mfm-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px 1px rgb(0 0 0 / .1);--mfm-transition: all .15s ease-in-out;--mfm-value: #9b2418}#mfm-root{all:initial;display:block;position:fixed;bottom:24px;right:24px;z-index:2147483647;font-family:Inter,-apple-system,system-ui,sans-serif;color:var(--mfm-text);-webkit-user-select:none;user-select:none;box-sizing:border-box;font-size:12px}#mfm-root svg{fill:transparent}#mfm-root *{box-sizing:border-box;font-family:inherit;font-size:inherit}.mfm-widget-toggle{display:flex;align-items:center;background:#fff;padding:6px;border-radius:9999px;box-shadow:var(--mfm-shadow-lg);border:1px solid var(--mfm-border);gap:2px;cursor:pointer;transition:var(--mfm-transition)}.mfm-widget-toggle.hidden{display:none!important}.mfm-toggle-section{padding:6px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:var(--mfm-transition)}.mfm-toggle-section:hover{background:var(--mfm-surface-bright)}.mfm-toggle-logo img{width:32px;height:32px}.mfm-toggle-divider{width:1px;height:24px;background:var(--mfm-border);margin:0 4px}.mfm-main-container{position:fixed;bottom:24px;right:24px;width:370px;height:650px;background:var(--mfm-bg);border:1px solid var(--mfm-border);border-radius:var(--mfm-radius);box-shadow:var(--mfm-shadow-lg);display:flex;flex-direction:column;overflow:hidden;transition:var(--mfm-transition);transform-origin:bottom right}.mfm-main-container.hidden{opacity:0;transform:scale(.95) translateY(20px);pointer-events:none}.mfm-header{padding:12px 16px;margin-bottom:5px;background:#fff;display:flex;align-items:center;justify-content:space-between}.mfm-logo img{height:25px;width:auto}.mfm-tabs-container{flex:1;display:flex;flex-direction:column;overflow:hidden}.mfm-tabs-nav{display:flex;padding:0 16px;background:#fff;border-bottom:1px solid var(--mfm-border);gap:4px}.mfm-tab-btn{padding:10px 16px;background:transparent;border:1px solid transparent;border-bottom:none;color:var(--mfm-text-dim);cursor:pointer;font-size:15px!important;font-weight:500;margin-bottom:-1px;border-top-left-radius:4px;border-top-right-radius:4px;transition:var(--mfm-transition)}.mfm-tab-btn:hover{color:var(--mfm-text);background:var(--mfm-surface)}.mfm-tab-btn.active{color:var(--mfm-primary);background:#fff;border-color:var(--mfm-border);border-bottom:1px solid white;font-weight:700}.mfm-tab-toolbar{padding:12px 16px;border-bottom:1px solid var(--mfm-border);display:flex;flex-direction:column;gap:8px}.mfm-toolbar-row{display:flex;gap:8px;align-items:center}.mfm-input{height:36px;width:100%;padding:0 12px;border:1px solid var(--mfm-border);border-radius:6px;font-size:.875rem;outline:none}.mfm-input:focus{border-color:var(--mfm-primary);box-shadow:0 0 0 2px #2563eb1a}.mfm-btn-outline,.mfm-btn-icon{height:26px;padding:0 12px;background:transparent!important;border:none!important;border-radius:6px;font-size:.875rem;font-weight:500;cursor:pointer;color:var(--mfm-text-dim);transition:var(--mfm-transition);display:flex;align-items:center;justify-content:center}.back-btn{padding:0}.mfm-btn-outline:hover,.mfm-btn-icon:hover{background:var(--mfm-surface-bright)!important;color:var(--mfm-text)}.mfm-preserve-logs{display:flex;align-items:center;gap:1px;font-size:.75rem;color:var(--mfm-text-dim);cursor:pointer}.mfm-preserve-logs input{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.mfm-tab-content{flex:1;background:#fff;height:468px;overflow-y:scroll}.mfm-list{display:flex;flex-direction:column;max-height:460px;overflow-y:scroll}.mfm-empty{padding:60px 20px;text-align:center;color:var(--mfm-text-dim);font-size:.875rem}.mfm-request-item{padding:6px 16px;border-bottom:1px solid var(--mfm-border);cursor:pointer;transition:var(--mfm-transition)}.mfm-request-item.active{background:#eff6ff;border-left:3px solid var(--mfm-primary)}.mfm-request-item:hover{background:var(--mfm-surface)}.mfm-request-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}.mfm-method{font-size:.7rem;font-weight:700;padding:2px 6px;border-radius:4px;text-transform:uppercase}.mfm-method.get{color:#2563eb;background:#eff6ff}.mfm-method.post{color:#16a34a;background:#f0fdf4}.mfm-method.put{color:#d97706;background:#fffbeb}.mfm-method.delete{color:#dc2626;background:#fef2f2}.mfm-method.rule{color:#7c3aed;background:#f5f3ff}.mfm-status{font-size:.75rem;font-weight:600}.mfm-status.rule{color:#8b5cf6;background:#8b5cf61a}.mfm-status.success{color:#16a34a}.mfm-status.error{color:#dc2626}.mfm-status.pending{color:#64748b}.mfm-url{font-size:.8125rem;color:var(--mfm-text);white-space:nowrap;overflow-x:scroll;width:290px;max-width:290px;scrollbar-width:thin}.mfm-url .mfm-rule-condition{display:inline-block;margin-right:4px;border-radius:20px;font-size:inherit;background:#eee;padding:2px 5px}.mfm-url .mfm-rule-condition .mfm-rule-condition-type{font-weight:600;color:var(--mfm-primary)}.mfm-url .mfm-rule-condition .mfm-rule-condition-operator{font-weight:600;border-bottom:1px solid var(--mfm-primary);text-transform:capitalize}.mfm-url .mfm-rule-condition .mfm-rule-condition-key-value{color:var(--mfm-value)}.mfm-rule-list .mfm-url{white-space:auto!important;overflow-x:scroll!important;text-overflow:inherit!important;scrollbar-width:thin}.mfm-bottomsheet{position:absolute;top:60px;left:0;right:0;bottom:0;background:#fff;z-index:1100;display:flex;flex-direction:column;transform:translate(100%);transition:transform .25s ease-in-out}.mfm-bottomsheet.active{transform:translate(0)}.mfm-bottomsheet-header{padding:12px 16px;border-bottom:1px solid var(--mfm-border);display:flex;align-items:center;gap:5px}.mfm-bottomsheet-content{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column}.mfm-detail-tabs{display:flex;border-bottom:1px solid var(--mfm-border);margin:16px -16px;padding:0 16px;gap:8px}.mfm-detail-tab-btn{padding:8px 12px;background:transparent;border:none;border-bottom:2px solid transparent;color:var(--mfm-text-dim);font-size:.8rem;font-weight:600;cursor:pointer;transition:var(--mfm-transition)}.mfm-detail-tab-btn:hover{color:var(--mfm-text)}.mfm-detail-tab-btn.active{color:var(--mfm-primary);border-bottom-color:var(--mfm-primary)}.mfm-detail-body{flex:1}.mfm-tab-content::-webkit-scrollbar,.mfm-bottomsheet-content::-webkit-scrollbar{width:8px}.mfm-tab-content::-webkit-scrollbar-track,.mfm-bottomsheet-content::-webkit-scrollbar-track{background:transparent}.mfm-tab-content::-webkit-scrollbar-thumb,.mfm-bottomsheet-content::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px;border:2px solid white}.mfm-tab-content::-webkit-scrollbar-thumb:hover,.mfm-bottomsheet-content::-webkit-scrollbar-thumb:hover{background:#94a3b8}.mfm-detail-section{margin-bottom:24px}.mfm-detail-title{font-size:.75rem;font-weight:600;text-transform:uppercase;color:var(--mfm-text-dim);margin-bottom:8px;display:flex;justify-content:space-between}.mfm-detail-content{background:var(--mfm-bg);padding:12px;border-radius:6px;font-family:JetBrains Mono,Menlo,monospace;font-size:.8rem;border:1px solid var(--mfm-primary);word-break:break-all;max-height:500px;overflow-y:auto}.mfm-copy-btn{background:var(--mfm-primary);border:none;color:#fff;padding:4px 8px;border-radius:4px;font-size:.7rem;cursor:pointer;font-weight:600}.mfm-dropdown{position:relative}.mfm-dropdown-content{display:none;position:absolute;top:100%;right:0;background:#fff;min-width:140px;box-shadow:var(--mfm-shadow-lg);border:1px solid var(--mfm-border);border-radius:8px;z-index:1000;overflow:hidden}.mfm-dropdown-content.show{display:block}.mfm-dropdown-content button{width:100%;padding:10px 16px;text-align:left;background:transparent;border:none;font-size:.8125rem;color:var(--mfm-text);cursor:pointer}.mfm-dropdown-content button:hover{background:var(--mfm-surface)}.mfm-btn-primary{background:var(--mfm-primary);color:#fff;border:none;border-radius:8px;padding:12px 24px;font-weight:600;cursor:pointer;transition:var(--mfm-transition)}.mfm-btn-primary:hover{background:var(--mfm-primary-hover)}.mfm-header-actions{display:flex;align-items:center}.mfm-switch{position:relative;display:inline-block;width:32px;height:20px;margin-right:12px}.mfm-switch input{opacity:0;width:0;height:0}.mfm-slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#cbd5e1;transition:.4s;border-radius:34px}.mfm-slider:before{position:absolute;content:"";height:16px;width:16px;left:2px;bottom:2px;background-color:#fff;transition:.4s;border-radius:50%}input:checked+.mfm-slider{background-color:var(--mfm-primary)}input:checked+.mfm-slider:before{transform:translate(12px)}.mfm-spinner{width:14px;height:14px;border:2px solid #cbd5e1;border-bottom-color:var(--mfm-primary);border-radius:50%;display:inline-block;box-sizing:border-box;animation:mfm-rotation 1s linear infinite}@keyframes mfm-rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.mfm-request-item.pending-item{cursor:default;opacity:.8}.mfm-snackbar{visibility:hidden;min-width:250px;background-color:#333;color:#fff;text-align:center;border-radius:8px;padding:12px;position:fixed;z-index:2000;left:50%;bottom:30px;transform:translate(-50%);font-size:.9rem;box-shadow:0 4px 6px #0000001a;opacity:0;transition:opacity .3s,bottom .3s}.mfm-snackbar.show{visibility:visible;opacity:1;bottom:50px}.clear-btn svg{color:var(--mfm-text-dim)}')),document.head.appendChild(e)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();var o=(e=>(e[e.NONE=0]="NONE",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(o||{}),r=(e=>(e.MFM_REQ_MAPPINGS="MFM_REQ_MAPPINGS",e.MFM_REQ_SAVED_MAPPINGS="MFM_REQ_SAVED_MAPPINGS",e.MFM_DEL_CLIENT_TOKEN="MFM_DEL_CLIENT_TOKEN",e.MFM_SUBMIT_TOKEN="MFM_SUBMIT_TOKEN",e.MFM_TOGGLE_INTERCEPTION="MFM_TOGGLE_INTERCEPTION",e.MFM_RES_MAPPINGS="MFM_RES_MAPPINGS",e.MFM_REQ="MFM_REQ",e.MFM_RES="MFM_RES",e.MFM_TOKEN_ERROR="MFM_TOKEN_ERROR",e.MFM_TOKEN_API_FAILED="MFM_TOKEN_API_FAILED",e.MFM_LOG_INFO="MFM_LOG_INFO",e.MFM_LOG_WARN="MFM_LOG_WARN",e.MFM_LOG_ERROR="MFM_LOG_ERROR",e))(r||{});function s(e,t,n="*",o){window.postMessage(function(e,t,n){const o={type:e};return n&&(o.source=n),void 0!==t&&(o.payload=t),o}(e,t,o),n)}const i=new class{constructor(){this.level=o.NONE}setLevel(e){this.level=e}normalizeArgs(e){return e.map((e=>{try{return void 0===e?"undefined":"string"==typeof e||"object"==typeof e?e:String(e)}catch{return"[Unserializable]"}}))}postLog(e,t){s(e,this.normalizeArgs(t),"*","mfm-widget-logger")}info(...e){this.level<o.INFO||(console.log("[MFM Info]",...e),this.postLog(r.MFM_LOG_INFO,e))}warn(...e){this.level<o.WARN||(console.warn("[MFM Warn]",...e),this.postLog(r.MFM_LOG_WARN,e))}error(...e){this.level<o.ERROR||(console.error("[MFM Error]",...e),this.postLog(r.MFM_LOG_ERROR,e))}},a=new Map,l=new Set;let d=!1;function c(e){return e!==r.MFM_LOG_INFO&&e!==r.MFM_LOG_WARN&&e!==r.MFM_LOG_ERROR}function m(){d||"undefined"==typeof window||(window.addEventListener("message",p),d=!0)}function u(e,t){c(e)&&i.info(`[postMessage] ${e}`,t),s(e,t)}function p(e){if(!function(e){if(!e||"object"!=typeof e)return!1;if(!("type"in e))return!1;const t=e.type;return"string"==typeof t&&t.startsWith("MFM_")}(e.data))return;const t=e.data;c(t.type)&&i.info(`[onMessage] ${t.type}`,t.payload),l.forEach((e=>e(t)));const n=a.get(t.type);n&&n.forEach((e=>{e(t.payload)}))}function f(e,t){if(!e)return t;try{return JSON.parse(e)}catch{return t}}const h={state:function(){var e,t,n,o,r,s,i,a,l,d,c,m;const u=f(sessionStorage.getItem("MFM_SAVED_REQUESTS"),[]).filter((e=>{var t;return!((null==(t=e.request)?void 0:t.url)||"").includes("/3f4eae522b")})).map((e=>e.response?e:{...e,response:{statusCode:0,statusText:"Disconnected",body:"[Request terminated due to page refresh or network interruption]",headers:{},endTime:new Date(e.timestamp||Date.now()).toISOString()}})),p=f(localStorage.getItem("MFM_CONFIG"),{}),h={enabled:!0,isInterceptEnabled:"false"!==sessionStorage.getItem("MFM_IS_INTERCEPT_ENABLED"),isOpen:p.isOpen||!1,token:localStorage.getItem("MFM_TOKEN")||null,isTokenValidating:!1,isTokenLoading:!1,mappings:{apis:[],rules:[]},isMappingsLoading:!1,requests:u,ui:{selectedTab:p.selectedTab||"MOCKED",tokenError:null,activeDropdownId:null,detailTab:p.detailTab||"HEADERS",tabConfigs:{MAPPINGS:{searchText:"",selectedRule:(null==(t=null==(e=p.tabConfigs)?void 0:e.MAPPINGS)?void 0:t.selectedRule)||null,isDetailOpen:Boolean(null==(o=null==(n=p.tabConfigs)?void 0:n.MAPPINGS)?void 0:o.isDetailOpen)},MOCKED:{searchText:"",selectedRequestId:(null==(s=null==(r=p.tabConfigs)?void 0:r.MOCKED)?void 0:s.selectedRequestId)||null,isPreserveLogs:"true"===localStorage.getItem("MFM_PRESERVE_LOGS_MOCKED"),isDetailOpen:Boolean(null==(a=null==(i=p.tabConfigs)?void 0:i.MOCKED)?void 0:a.isDetailOpen)},OTHER:{searchText:"",selectedRequestId:(null==(d=null==(l=p.tabConfigs)?void 0:l.OTHER)?void 0:d.selectedRequestId)||null,isPreserveLogs:"true"===localStorage.getItem("MFM_PRESERVE_LOGS_OTHER"),isDetailOpen:Boolean(null==(m=null==(c=p.tabConfigs)?void 0:c.OTHER)?void 0:m.isDetailOpen)}}}};return function(e){const t=e.ui.selectedTab;if("MAPPINGS"===t)return;const n=e.ui.tabConfigs[t];if(!n.isDetailOpen||!n.selectedRequestId)return;e.requests.some((e=>String(e.requestId)===String(n.selectedRequestId)))||(n.isDetailOpen=!1,n.selectedRequestId=null,e.ui.selectedTab="MOCKED")}(h),h}(),listeners:[],_notifyTimer:null,subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}},notify(){this._notifyTimer||(this._notifyTimer=requestAnimationFrame((()=>{var e;this._notifyTimer=null,this.listeners.forEach((e=>e(this.state))),document.dispatchEvent(new CustomEvent("MFM_STATE_CHANGE",{detail:this.state})),e=this.state,localStorage.setItem("MFM_CONFIG",JSON.stringify({isOpen:e.isOpen,selectedTab:e.ui.selectedTab,detailTab:e.ui.detailTab,activeDropdownId:e.ui.activeDropdownId,tabConfigs:{MAPPINGS:{selectedRule:e.ui.tabConfigs.MAPPINGS.selectedRule,isDetailOpen:e.ui.tabConfigs.MAPPINGS.isDetailOpen},MOCKED:{selectedRequestId:e.ui.tabConfigs.MOCKED.selectedRequestId,isDetailOpen:e.ui.tabConfigs.MOCKED.isDetailOpen},OTHER:{selectedRequestId:e.ui.tabConfigs.OTHER.selectedRequestId,isDetailOpen:e.ui.tabConfigs.OTHER.isDetailOpen}}}))})))},update(e,t){const n=e.split(".");let o=this.state;for(let e=0;e<n.length-1;e+=1){const t=o[n[e]];if(!t||"object"!=typeof t)return;o=t}o[n[n.length-1]]=t,this.notify()},set(e,t){this.state[e]=t,this.notify()}};let g=[];function b(e){var t,n;const o=null==(t=h.state.ui.tabConfigs.MOCKED)?void 0:t.isPreserveLogs,r=null==(n=h.state.ui.tabConfigs.OTHER)?void 0:n.isPreserveLogs,s=e.filter((e=>{const t="MOCKED"===e.interceptionType;return t&&o||!t&&r}));s.length>0?sessionStorage.setItem("MFM_SAVED_REQUESTS",JSON.stringify(s)):sessionStorage.removeItem("MFM_SAVED_REQUESTS")}function y(e){var t;if(((null==(t=e.request)?void 0:t.url)||"").includes("/3f4eae522b"))return;if(h.state.isTokenValidating)return i.info("Queuing request during token validation",e.requestId),void g.push(e);const n=function(e){const t=[...h.state.requests],n=t.findIndex((t=>t.requestId===e.requestId));if(n>-1){const o=t[n];t[n]={...o,...e,rule:e.rule||o.rule}}else t.push(e);return t.length>100?t.slice(t.length-100):t}(e);h.set("requests",n),b(n)}const v={toggleWidget(){h.update("isOpen",!h.state.isOpen)},setTab(e){h.update("ui.selectedTab",e)},deleteToken(){i.warn("Deleting Client Token"),h.update("token",null),h.update("isTokenValidating",!1),h.update("isTokenLoading",!1),h.update("ui.tokenError",null),this.closeDetails(),h.set("requests",[]),this.clearQueue(),sessionStorage.removeItem("MFM_SAVED_REQUESTS"),localStorage.removeItem("MFM_TOKEN"),u(r.MFM_DEL_CLIENT_TOKEN)},submitToken(e){e?(h.update("ui.tokenError",null),h.update("isTokenValidating",!0),h.update("isTokenLoading",!0),localStorage.setItem("MFM_TOKEN_TEMP",e),(e=>{u(r.MFM_SUBMIT_TOKEN,{token:e})})(e)):h.update("ui.tokenError","Token is required")},reloadMappings(){i.info("Reloading Mappings"),h.update("ui.tokenError",null),h.update("isMappingsLoading",!0),u(r.MFM_REQ_MAPPINGS)},fetchSavedMappings(){i.info("Fetching Saved Mappings"),u(r.MFM_REQ_SAVED_MAPPINGS)},toggleInterception(e){const t=void 0!==e?e:!h.state.isInterceptEnabled;t!==h.state.isInterceptEnabled&&(i.info("Toggling Interception:",t),h.update("isInterceptEnabled",t),sessionStorage.setItem("MFM_IS_INTERCEPT_ENABLED",String(t)),(e=>{u(r.MFM_TOGGLE_INTERCEPTION,{enabled:e})})(t))},addRequest(e){y(e)},clearRequests(){const e=h.state.ui.selectedTab,t=h.state.requests.filter((t=>("MOCKED"===t.interceptionType?"MOCKED":"OTHER")!==e));h.set("requests",t),sessionStorage.setItem("MFM_SAVED_REQUESTS",JSON.stringify(t))},setPreserveLogs(e){const t=h.state.ui.selectedTab;"MAPPINGS"!==t&&(h.update(`ui.tabConfigs.${t}.isPreserveLogs`,e),localStorage.setItem(`MFM_PRESERVE_LOGS_${t}`,String(e)),b(h.state.requests))},setSearchText(e){const t=h.state.ui.selectedTab;h.update(`ui.tabConfigs.${t}.searchText`,e)},selectRequest(e){const t=h.state.ui.selectedTab;"MAPPINGS"!==t&&(h.update(`ui.tabConfigs.${t}.selectedRequestId`,e),h.update(`ui.tabConfigs.${t}.isDetailOpen`,!0),h.update("ui.detailTab","HEADERS"))},selectRule(e){h.update("ui.tabConfigs.MAPPINGS.selectedRule",e),h.update("ui.tabConfigs.MAPPINGS.isDetailOpen",!0),h.update("ui.detailTab","HEADERS")},minimizeDetails(){const e=h.state.ui.selectedTab;h.update(`ui.tabConfigs.${e}.isDetailOpen`,!1)},closeDetails(){const e=h.state.ui.selectedTab;h.update(`ui.tabConfigs.${e}.isDetailOpen`,!1),"MAPPINGS"!==e?h.update(`ui.tabConfigs.${e}.selectedRequestId`,null):h.update("ui.tabConfigs.MAPPINGS.selectedRule",null)},resetUnavailableRequestDetails(e){h.update(`ui.tabConfigs.${e}.isDetailOpen`,!1),h.update(`ui.tabConfigs.${e}.selectedRequestId`,null),h.update("ui.selectedTab","MOCKED"),h.update("ui.detailTab","HEADERS")},setDetailTab(e){h.update("ui.detailTab",e)},setOpenDropdown(e){const t=h.state.ui.activeDropdownId;h.update("ui.activeDropdownId",t===e?null:e)},clearOpenDropdown(){h.state.ui.activeDropdownId&&h.update("ui.activeDropdownId",null)},flushQueue(){!function(){i.info("Flushing request queue",g.length);const e=[...g];g=[],e.forEach((e=>y(e)))}()},clearQueue(){i.warn("Clearing request queue"),g=[]}};function x(e,t="default",n=3e3){if(!document.body)return;let o=document.getElementById("mfm-snackbar");o||(o=document.createElement("div"),o.id="mfm-snackbar",o.className="mfm-snackbar",document.body.appendChild(o)),o.textContent=e,o.className=("mfm-snackbar show "+("error"===t?"mfm-snackbar-error":"")).trim(),setTimeout((()=>{o&&(o.className=o.className.replace("show","").trim())}),n)}function w(){const e=document.querySelector("#mfm-reload-header");e&&(e.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><polyline points="21 3 21 8 16 8"></polyline></svg>',e.style.pointerEvents="auto")}function E(e,t){i.error(`Token Error (${e})`,t),h.update("ui.tokenError",(null==t?void 0:t.message)||"Something went wrong"),h.update("isTokenLoading",!1),h.update("isMappingsLoading",!1),h.update("isTokenValidating",!1),e===r.MFM_TOKEN_ERROR&&(h.update("token",null),v.clearQueue(),localStorage.removeItem("MFM_TOKEN"),localStorage.removeItem("MFM_TOKEN_TEMP")),w(),x((null==t?void 0:t.message)||"Request failed","error")}const k="https://www.mockforme.com/assets/images/logo.png",M='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:block;"><circle cx="12" cy="12" r="10"></circle><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"></line></svg>',_='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',R='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>';class q{constructor(e){this.input=null,this.submitBtn=null,this.errorDisplay=null,this.closeBtn=null,this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-token-form",this.unsubscribe=h.subscribe(this.render.bind(this)),this.init()}init(){this.renderStructure(),this.bindEvents(),this.render(h.state),this.parent.appendChild(this.element)}closeTokenForm(){v.toggleWidget()}renderStructure(){this.element.innerHTML=`\n <div class="mfm-token-header">\n <button class="mfm-btn-icon" id="mfm-close-token-form" title="Close Widget">\n ${_}\n </button>\n </div>\n <div class="mfm-token-container">\n <img src="${k}" alt="MockForMe Logo" class="mfm-token-logo">\n <h3 class="mfm-token-title">Welcome to MockForMe</h3>\n <p class="mfm-token-desc">\n Paste your token below to start mocking and intercepting API requests.\n </p>\n <input type="text" class="mfm-input mfm-token-input" placeholder="Enter Client Token...">\n <div class="mfm-token-error"></div>\n <button class="mfm-token-submit">Continue</button>\n <div class="mfm-token-link-container">\n <a href="https://dashboard.mockforme.com/user/token" target="_blank" class="mfm-token-link">Get your access token</a>\n </div>\n </div>\n `,this.input=this.element.querySelector(".mfm-token-input"),this.submitBtn=this.element.querySelector(".mfm-token-submit"),this.errorDisplay=this.element.querySelector(".mfm-token-error"),this.closeBtn=this.element.querySelector("#mfm-close-token-form")}bindEvents(){this.input&&(this.input.oninput=()=>{h.state.ui.tokenError&&h.update("ui.tokenError",null)}),this.submitBtn&&(this.submitBtn.onclick=()=>{var e;const t=null==(e=this.input)?void 0:e.value.trim();t&&v.submitToken(t)}),this.closeBtn&&(this.closeBtn.onclick=()=>{this.closeTokenForm()})}render(e){if(!this.input||!this.submitBtn||!this.errorDisplay)return;const{tokenError:t}=e.ui,{isTokenLoading:n}=e;t?(this.errorDisplay.textContent=t,this.errorDisplay.style.display="block",this.input.style.borderColor="var(--mfm-error)"):(this.errorDisplay.style.display="none",this.input.style.borderColor=""),n?(this.input.disabled=!0,this.submitBtn.disabled=!0,this.submitBtn.innerHTML='<div class="mfm-spinner"></div>'):(this.input.disabled=!1,this.submitBtn.disabled=!1,this.submitBtn.innerHTML="Continue")}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}function T(e,t){if(!document.body)return;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy")&&t()}finally{n.remove()}}function S(e,t){if(C(e),!t)return;e.container.classList.add("json-is-searching");const n=new RegExp(t,"i");Array.from(e.treeContainer.querySelectorAll(".json-node")).forEach((t=>{const o=t.dataset.searchKey||"",r=t.dataset.searchValue||"";(n.test(o)||n.test(r))&&(t.classList.add("json-item-visible","json-match"),function(e){const t=e.querySelector(":scope > .json-children");if(!t)return;t.querySelectorAll(".json-node").forEach((e=>{e.classList.add("json-item-visible")})),t.style.display="block";const n=e.querySelector(":scope > .json-toggle");n&&(n.textContent="-")}(t),function(e,t){let n=t.parentElement;for(;n&&n!==e.treeContainer;){if(n.classList.contains("json-node")&&n.classList.add("json-item-visible"),n.classList.contains("json-children")){n.style.display="block";const e=n.parentElement.querySelector(":scope > .json-toggle");e&&(e.textContent="-")}n=n.parentElement}}(e,t))}))}function C(e){e.container.classList.remove("json-is-searching"),e.treeContainer.querySelectorAll(".json-match").forEach((e=>{e.classList.remove("json-match")})),e.treeContainer.querySelectorAll(".json-item-visible").forEach((e=>{e.classList.remove("json-item-visible")}))}function I(e,t,n=null,o=0){const r=document.createElement("div");if(r.className="json-node",null!==n){const e=document.createElement("span");e.className="json-key",e.textContent=`"${n}": `,r.appendChild(e),r.dataset.searchKey=String(n).toLowerCase()}if("object"==typeof t&&null!==t)return function(e,t,n,o){const r=Array.isArray(n),s=o<e.options.expandLevel,i=document.createElement("span");i.className="json-toggle",i.textContent=s?"-":"+";const a=document.createElement("span");a.className="json-bracket",a.textContent=r?"[":"{";const l=document.createElement("div");l.className="json-children",l.style.display=s?"block":"none",i.addEventListener("click",(()=>{const e="none"===l.style.display;l.style.display=e?"block":"none",i.textContent=e?"-":"+"})),t.appendChild(i),t.appendChild(a),Object.entries(n).forEach((([t,n])=>{const r=I(e,n,t,o+1);l.appendChild(r)})),t.appendChild(l);const d=document.createElement("div");d.className="json-closing-bracket",d.textContent=r?"]":"}",t.appendChild(d)}(e,r,t,o),r;const s=document.createElement("span");s.className="json-value "+typeof t;const i="string"==typeof t?`"${t}"`:String(t);return s.textContent=i,r.appendChild(s),r.dataset.searchValue=i.toLowerCase(),r}function O(e,t,n){const o=document.createElement("button");return o.innerHTML=e,o.title=t,o.onclick=n,o}class L{constructor(e,t={}){if(!e)throw new Error("Container element required");this.container=e,this.options={expandLevel:t.expandLevel??1,theme:t.theme??"light",toolbar:t.toolbar??!0,searchable:t.searchable??!0,debounceTime:t.debounceTime??300},this.data=null,this.searchTimer=null,this.container.classList.add("json-viewer",`json-viewer-${this.options.theme}`),this.options.toolbar&&function(e,t){e.toolbar=document.createElement("div"),e.toolbar.className="json-toolbar";const n=document.createElement("div");n.className="json-toolbar-group",n.appendChild(O(t.expand,"Expand All",(()=>e.expandAll()))),n.appendChild(O(t.collapse,"Collapse All",(()=>e.collapseAll()))),e.fullscreenBtn=O(t.fullscreen,"Fullscreen",(()=>e.toggleFullscreen())),e.copyBtn=O(t.copy,"Copy JSON",(()=>e.copy())),n.appendChild(e.fullscreenBtn),n.appendChild(e.copyBtn),e.toolbar.appendChild(n),e.options.searchable&&e.toolbar.appendChild(function(e,t){const n=document.createElement("div");n.className="json-search-group";const o=document.createElement("input");o.placeholder="Search...",o.oninput=t=>{clearTimeout(e.searchTimer),e.searchTimer=setTimeout((()=>{const n=t.target;S(e,n.value)}),e.options.debounceTime)};const r=O(t,"Clear Search",(()=>{o.value="",C(e)}));return n.appendChild(o),n.appendChild(r),n}(e,t.clear)),e.container.appendChild(e.toolbar)}(this,{expand:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>',collapse:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>',fullscreen:R,copy:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',clear:M}),this.treeContainer=document.createElement("div"),this.treeContainer.className="json-tree-container",this.container.appendChild(this.treeContainer)}toggleFullscreen(){const e=this.container.classList.toggle("json-viewer-fullscreen");document.body.classList.toggle("json-viewer-body-fullscreen",e),this.fullscreenBtn&&(this.fullscreenBtn.innerHTML=e?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"></path></svg>':R,this.fullscreenBtn.title=e?"Minimize":"Fullscreen")}render(e){this.data=e,this.treeContainer.innerHTML="",this.root=I(this,e,null,0),this.treeContainer.appendChild(this.root)}copy(){!function(e){if(!e.data)return;const t=JSON.stringify(e.data,null,2),n=()=>{if(!e.copyBtn)return;const t=e.copyBtn.innerHTML;e.copyBtn.innerHTML="&#10003;",setTimeout((()=>{e.copyBtn.innerHTML=t}),2e3)};navigator.clipboard&&"function"==typeof navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(n).catch((()=>{T(t,n)})):T(t,n)}(this)}expandAll(){var e;(e=this).treeContainer.querySelectorAll(".json-children").forEach((e=>{e.style.display="block"})),e.treeContainer.querySelectorAll(".json-toggle").forEach((e=>{e.textContent="-"}))}collapseAll(){var e;(e=this).treeContainer.querySelectorAll(".json-children").forEach((e=>{e.style.display="none"})),e.treeContainer.querySelectorAll(".json-toggle").forEach((e=>{e.textContent="+"}))}search(e){S(this,e)}clearSearch(){C(this)}}function A(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function N(e,t,n){const o=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}(n);if(!o||"object"!=typeof o)return;const r=e.querySelector(t);r&&(r.innerHTML="",new L(r,{expandLevel:1,theme:"light",toolbar:!0,searchable:!0}).render(o))}function j(e){const t={},n=e.modificationActions;return n&&Object.entries(n).forEach((([e,n])=>{(null==n?void 0:n.enabled)&&(t[e]=n)})),{requestId:`rule_${String(e.ruleName||e.condition||"unknown")}`,interceptionType:"RULE",request:{method:"RULE",url:String(e.condition||e.ruleName||""),headers:n||{},body:t},response:{statusCode:0,body:e}}}function P(e){var t,n,o,r;const{selectedTab:s,detailTab:i,tabConfigs:a}=h.state.ui,l=a[s];if(!l||!l.isDetailOpen)return e.sheet.classList.remove("active"),e.isUrlExpanded=!1,e.responseBodyMode="TEXT",e.prevState={},e;const{req:d,isRule:c}=function(){const{selectedTab:e,tabConfigs:t}=h.state.ui,n=t[e],o=n.selectedRequestId||null,r=n.selectedRule||null;return"MAPPINGS"===e&&r?{req:j(r),isRule:!0}:"MAPPINGS"!==e&&o?{req:h.state.requests.find((e=>String(e.requestId)===String(o)))||null,isRule:!1}:{req:null,isRule:!1}}();if(!d)return"MOCKED"!==s&&"OTHER"!==s||v.resetUnavailableRequestDetails(s),e.sheet.classList.remove("active"),e;if(function(e,t){const{selectedTab:n,detailTab:o,tabConfigs:r}=h.state.ui,s=r[n];return e.prevState.selectedTab===n&&e.prevState.selectedRule===s.selectedRule&&e.prevState.selectedRequestId===s.selectedRequestId&&e.prevState.reqObj===t&&e.prevState.detailTab===o&&e.prevState.isUrlExpanded===e.isUrlExpanded&&e.prevState.responseBodyMode===e.responseBodyMode}(e,d))return e;!function(e,t){const{selectedTab:n,detailTab:o,tabConfigs:r}=h.state.ui,s=r[n];e.prevState={selectedTab:n,selectedRule:s.selectedRule,selectedRequestId:s.selectedRequestId,reqObj:t,detailTab:o,isUrlExpanded:e.isUrlExpanded,responseBodyMode:e.responseBodyMode}}(e,d),function(e,t,n){var o;const r=t.request.method||"REQ",s=n?"RULE":(null==(o=t.response)?void 0:o.statusCode)??"Pending",i=function(e,t,n,o){return e?"pending":t?"success":n?"error":o?"rule":""}("Pending"===s,"number"==typeof s&&s>=200&&s<300,"number"==typeof s&&(0===s||s>=400),n),a=0===s?"Error":s,l=n?"":`<span class="mfm-method ${String(r).toLowerCase()}" style="flex-shrink: 0;">${r}</span>`,d=e.isUrlExpanded?"normal":"nowrap",c=e.isUrlExpanded?"break-all":"normal",m=e.isUrlExpanded?"60px":"2em",u=e.isUrlExpanded?"auto":"hidden";e.infoContainer.innerHTML=`\n ${l}\n <span class="mfm-status ${i}" style="flex-shrink: 0;">${a}</span>\n <span class="mfm-url-small" title="Click to toggle full URL" style="font-family: monospace; color: var(--mfm-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: ${d}; word-break: ${c}; max-height: ${m}; overflow-y: ${u}; flex: 1;">${t.request.url||""}</span>\n `}(e,d,c);const m=e.sheet.querySelector(".mfm-bottomsheet-content");if(!m)return e;const u={first:"Headers",second:"Request",third:"Response"};c&&(u.first="Configs",u.second="Modifications",u.third="Full Rule");const p=null==(t=d.response)?void 0:t.body,f="string"==typeof p?p:JSON.stringify(p||{},null,2),g=function(e){if(!e||"object"!=typeof e)return"";const t=e,n=t["content-type"]||t["Content-Type"]||t["CONTENT-TYPE"];return"string"==typeof n?n.toLowerCase():""}(null==(n=d.response)?void 0:n.headers),b=!c&&"string"==typeof p&&!function(e){try{return JSON.parse(e),!0}catch{return!1}}(p)&&(g.includes("text/html")||/<!doctype html|<html[\s>]|<body[\s>]|<\/?[a-z][\s\S]*>/i.test(p));b||(e.responseBodyMode="TEXT");let y="";if("HEADERS"===i&&(y=function(e,t,n){const o=n?"":`\n <div class="mfm-detail-section" style="margin-top:16px">\n <div class="mfm-detail-title">Response Headers</div>\n <div class="mfm-detail-content"><pre style="margin:0">${JSON.stringify(t||{},null,2)}</pre></div>\n </div>\n `;return`\n <div class="mfm-detail-section">\n <div class="mfm-detail-title">${n?"Rule Configuration":"Request Headers"}</div>\n <div class="mfm-detail-content"><pre style="margin:0">${JSON.stringify(e||{},null,2)}</pre></div>\n </div>\n ${o}\n `}(d.request.headers,null==(o=d.response)?void 0:o.headers,c)),"REQ_BODY"===i&&(y=function(e,t){return`\n <div class="mfm-detail-section">\n <div class="mfm-detail-title">${t?"Enabled Modifications":"Request Body"}</div>\n <div class="mfm-detail-content" id="mfm-req-viewer"><pre style="margin:0">${"string"==typeof e?A(e):JSON.stringify(e,null,2)}</pre></div>\n </div>\n `}(d.request.body,c)),"RES_BODY"===i&&(y=function(e){const t=e.isRule?"Complete Rule Object":"Response Body";let n="";e.isHtmlNonJsonResponse&&(n=`\n <div style="display:flex; gap:8px; margin-bottom:8px;">\n <button class="mfm-btn-outline mfm-res-mode-btn ${"TEXT"===e.responseBodyMode?"active":""}" data-mode="TEXT">Text</button>\n <button class="mfm-btn-outline mfm-res-mode-btn ${"PREVIEW"===e.responseBodyMode?"active":""}" data-mode="PREVIEW">Preview</button>\n </div>\n `);let o=`<pre style="margin:0">${A(e.responseText)}</pre>`;return e.isHtmlNonJsonResponse&&"PREVIEW"===e.responseBodyMode&&(o='<iframe id="mfm-res-preview" sandbox="" style="width:100%; min-height:280px; border:1px solid var(--mfm-border); border-radius:8px; background:#fff;"></iframe>'),`\n <div class="mfm-detail-section">\n <div class="mfm-detail-title">${t}</div>\n ${n}\n <div class="mfm-detail-content" id="mfm-res-viewer">${o}</div>\n </div>\n `}({isRule:c,isHtmlNonJsonResponse:b,responseBodyMode:e.responseBodyMode,responseText:f})),m.innerHTML=`${function(e,t){return`\n <div class="mfm-detail-tabs" style="margin-top: 0;">\n <button class="mfm-detail-tab-btn ${"HEADERS"===e?"active":""}" data-tab="HEADERS">${t.first}</button>\n <button class="mfm-detail-tab-btn ${"REQ_BODY"===e?"active":""}" data-tab="REQ_BODY">${t.second}</button>\n <button class="mfm-detail-tab-btn ${"RES_BODY"===e?"active":""}" data-tab="RES_BODY">${t.third}</button>\n </div>\n `}(i,u)}<div class="mfm-detail-body">${y}</div>`,"REQ_BODY"===i&&d.request.body&&N(e.sheet,"#mfm-req-viewer",d.request.body),"RES_BODY"===i&&(null==(r=d.response)?void 0:r.body)&&!b&&N(e.sheet,"#mfm-res-viewer",d.response.body),"RES_BODY"===i&&b&&"PREVIEW"===e.responseBodyMode){const t=e.sheet.querySelector("#mfm-res-preview");t&&(t.srcdoc=f)}return e.sheet.querySelectorAll(".mfm-detail-tab-btn").forEach((e=>{e.onclick=()=>{const t=e.dataset.tab;t&&v.setDetailTab(t)}})),e.sheet.querySelectorAll(".mfm-res-mode-btn").forEach((t=>{t.onclick=()=>{const n=t.dataset.mode;n&&n!==e.responseBodyMode&&(e.responseBodyMode=n,P(e))}})),e.sheet.classList.add("active"),e}class ${constructor(e){this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-apis-list",this.init()}init(){this.parent.appendChild(this.element)}render(e){(null==e?void 0:e.length)?this.element.innerHTML=e.map((e=>`\n <div class="mfm-request-item" data-id="${e.url}" data-type="api">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.method||"").toLowerCase()}">${e.method||"REQ"}</span>\n <span class="mfm-url" title="${e.url}">${e.url}</span>\n </div>\n </div>\n </div>\n `)).join(""):this.element.innerHTML=""}}function D(e,t){const n=e.ruleName||"",o=function(e){const t=F(e);if(t.length>0){const e=t[0];if("string"==typeof e.value)return e.value}return String(e.condition||e.ruleName||"")}(e);return`${t}::${n}::${o}`}function F(e){const t=e,n=function(e){const t=e,n=t.rule;if(n&&"object"==typeof n)return n;if("string"==typeof n)try{const e=JSON.parse(n);if(e&&"object"==typeof e)return e}catch{return t}return t}(e),o=Array.isArray(t.conditions)?t.conditions:[],r=Array.isArray(n.conditions)?n.conditions:[];return o.length>0?o:r}class H{constructor(e){this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-rule-list",this.init()}init(){this.parent.appendChild(this.element),this.attachEvents()}attachEvents(){this.element.onclick=e=>{var t;const n=e.target,o=n.closest(".mfm-dots-btn");if(o){e.stopPropagation();const t=o.closest(".mfm-request-item"),n=null==t?void 0:t.dataset.id;return void(n&&v.setOpenDropdown(n))}const r=n.closest("[data-action]");if(r){e.stopPropagation();const n=r.dataset.action,o=r.closest(".mfm-request-item"),s=this.readRuleIndex(o);return n&&null!==s&&this.handleAction(n,s),void(null==(t=r.parentElement)||t.classList.remove("show"))}const s=n.closest(".mfm-request-item");if(!s)return;e.stopPropagation();const i=this.readRuleIndex(s);if(null===i)return;const a=h.state.mappings.rules[i];a&&v.selectRule(a)}}readRuleIndex(e){if(!(null==e?void 0:e.dataset.ruleIndex))return null;const t=Number(e.dataset.ruleIndex);return Number.isNaN(t)?null:t}handleAction(e,t){if("view-rule-details"===e){const e=h.state.mappings.rules[t];e&&v.selectRule(e)}v.clearOpenDropdown()}render(e){if(!(null==e?void 0:e.length))return void(this.element.innerHTML="");const t=e.map(((e,t)=>D(e,t)));Array.from(this.element.querySelectorAll(".mfm-request-item")).forEach((e=>{t.includes(e.dataset.id||"")||e.remove()})),e.forEach(((e,t)=>{var n,o,r;const s=D(e,t),i=this.element.querySelector(`[data-id="${s}"]`),a=function(e){const t=F(e);let n=[];return t.length>0&&(n=t.map((e=>{const t=function(e){const t="string"==typeof e.type&&e.type.trim()?e.type:"RULE",n="string"==typeof e.operator&&e.operator.trim()?e.operator:"matches",o="string"==typeof e.key&&e.key.trim()?e.key:"",r="string"==typeof e.value&&e.value.trim()?e.value:"-";return o?`\n <span class="mfm-rule-condition-type">${t}</span>\n <span class="mfm-rule-condition-operator">${n}</span>\n <span class="mfm-rule-condition-key-value">${o}=${r}</span>\n `:`\n <span class="mfm-rule-condition-type">${t}</span>\n <span class="mfm-rule-condition-operator">${n}</span>\n <span class="mfm-rule-condition-key-value">${r}</span>\n `}(e);return t}))),n}(e),l=function(e){const{action:t,config:n}=function(e){const t=e.timingAction;if(!(null==t?void 0:t.actions)||"object"!=typeof t.actions)return{action:"",config:null};const n=Object.keys(t.actions);if(0===n.length)return{action:"",config:null};const o=t.activeAction||n[0],r=t.actions[o];return{action:o,config:r&&"object"==typeof r?r:null}}(e);if(!t||!n)return"";const o="number"!=typeof(r=n.value)||Number.isNaN(r)||r<0?0:r;var r;const s="string"==typeof n.redirectUrl&&n.redirectUrl.trim()?n.redirectUrl:"";return"delay_and_timeout"===t?`\n <span class="mfm-rule-action">Delay and Timeout</span>\n <span class="mfm-rule-value">${o}s</span>`:"delay_and_redirect"===t?s?`\n <span class="mfm-rule-action">Delay and Redirect ${o}s</span>\n <span class="mfm-rule-value">${s}</span>`:`\n <span class="mfm-rule-action">Delay and Redirect ${o}s</span>\n <span class="mfm-rule-value">${s}</span>`:"delay"===t?`\n <span class="mfm-rule-action">Delay ${o}s</span>`:`\n <span class="mfm-rule-action">${function(e){if(!e)return e;const t=e.toLowerCase().replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)}(t)} ${o}s</span>`}(e),d=null==(n=e.timingAction)?void 0:n.activeAction,c=null==(r=null==(o=e.timingAction)?void 0:o.actions)?void 0:r[d||""],m=c?`${c.value||0}s (${String(d).replace(/_/g," ")})`:String(e.type||"RULE");let u=0;e.modificationActions&&Object.values(e.modificationActions).forEach((e=>{e.enabled&&(u+=1)}));const p=h.state.ui.tabConfigs.MAPPINGS.selectedRule,f=Boolean(p)&&((null==p?void 0:p.ruleName)===(e.ruleName||e.condition)||(null==p?void 0:p.condition)===(e.condition||e.ruleName)),g=h.state.ui.activeDropdownId===s,b=`${f}_${m}_${u}_${g}`,y=`\n <div class="mfm-request-item ${f?"active":""}" data-id="${s}" data-rule-index="${t}" data-type="rule">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method rule">RULE</span>\n <span class="mfm-status rule">${String(e.type||"RULE")}</span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n ${u>0?`<span class="mfm-mod-pill">${u} Actions</span>`:""}\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${g?"show":""}">\n <button data-action="view-rule-details">View Modifications</button>\n </div>\n </div>\n </div>\n <div class="mfm-url">${a.map((e=>`<span class="mfm-rule-condition">${e}</span>`)).join("")}</div>\n ${l?`<div class="mfm-rule-info">${l}</div>`:""}\n </div>\n `;if(i){if(i.dataset.hash!==b){const e=document.createElement("div");e.innerHTML=y;const t=e.firstElementChild;t&&(t.dataset.hash=b,this.element.replaceChild(t,i))}}else{const e=document.createElement("div");e.innerHTML=y;const n=e.firstElementChild;if(!n)return;n.dataset.hash=b;const o=this.element.children[t];o?this.element.insertBefore(n,o):this.element.appendChild(n)}}))}}class B{constructor(e){this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-mapping-list-activity",this.ruleListView=new H(this.element),this.apisListView=new $(this.element),this.init()}init(){this.parent.appendChild(this.element),this.unsubscribe=h.subscribe((()=>{"MAPPINGS"===h.state.ui.selectedTab&&this.render()})),this.render()}render(){if(h.state.isMappingsLoading)return this.element.innerHTML='<div class="mfm-spinner"></div>',this.ruleListView.element.style.display="none",void(this.apisListView.element.style.display="none");const{apis:e,rules:t}=function(){const{apis:e,rules:t}=h.state.mappings,n=(h.state.ui.tabConfigs.MAPPINGS.searchText||"").toLowerCase();return{apis:e.filter((e=>(e.url||"").toLowerCase().includes(n))),rules:t.filter((e=>(e.ruleName||"").toLowerCase().includes(n)||(e.condition||"").toLowerCase().includes(n)))}}();if(0===e.length&&0===t.length)return this.element.innerHTML='<div class="mfm-empty">No mappings found</div>',this.ruleListView.element.style.display="none",void(this.apisListView.element.style.display="none");this.element.contains(this.ruleListView.element)||(this.element.innerHTML="",this.element.appendChild(this.ruleListView.element),this.element.appendChild(this.apisListView.element)),this.ruleListView.element.style.display="block",this.apisListView.element.style.display="block",this.ruleListView.render(t),this.apisListView.render(e)}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}async function U(e){if("undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return void await navigator.clipboard.writeText(e);if(!(null==document?void 0:document.body))throw new Error("Clipboard unavailable: document body not ready");const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",document.body.appendChild(t),t.focus(),t.select();try{if(!document.execCommand("copy"))throw new Error("Copy command failed")}finally{t.remove()}}function G(e,t){const n=e.request.method||"GET",o=e.request.url,r=e.request.headers||{},s=(i=e.request.body)?"string"==typeof i?i:JSON.stringify(i):null;var i;if("copy-curl"===t){let e=`curl '${o}' \\\n -X ${n}`;return Object.entries(r).forEach((([t,n])=>{e+=` \\\n -H '${t}: ${String(n)}'`})),s&&(e+=` \\\n --data-raw '${s.replace(/'/g,"'\\''")}'`),e}if("copy-fetch"===t){const e={method:n,headers:r};return s&&(e.body=s),`fetch('${o}', ${JSON.stringify(e,null,2)})`}let a="const xhr = new XMLHttpRequest();\n";return a+=`xhr.open('${n}', '${o}');\n`,Object.entries(r).forEach((([e,t])=>{a+=`xhr.setRequestHeader('${e}', '${String(t)}');\n`})),a+=s?`xhr.send('${s.replace(/'/g,"\\'")}');`:"xhr.send();",a}let K=class{static render(e){var t,n;const o=void 0===(null==(t=e.response)?void 0:t.statusCode),r=o?"Pending":null==(n=e.response)?void 0:n.statusCode,s=0===r?"Error":r,i=h.state.ui.tabConfigs.MOCKED.selectedRequestId===e.requestId,a=function(e,t,n){return e?"pending":t?"success":n?"error":""}(o,!o&&"number"==typeof r&&r>=200&&r<300,!o&&"number"==typeof r&&(0===r||r>=400));return`\n <div class="mfm-request-item ${i?"active":""} ${o?"pending-item":""}" data-id="${e.requestId}" data-type="request">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.request.method||"").toLowerCase()}">${e.request.method}</span>\n <span class="mfm-status ${a}">\n ${o?'<span class="mfm-spinner"></span>':s}\n </span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${h.state.ui.activeDropdownId===e.requestId?"show":""}">\n <button data-action="copy-curl">Copy as cURL</button>\n <button data-action="copy-fetch">Copy as Fetch</button>\n <button data-action="copy-xhr">Copy as XHR</button>\n </div>\n </div>\n </div>\n <span class="mfm-url" title="${e.request.url}">${e.request.url}</span>\n </div>\n `}};class z{static render(e){var t,n,o,r,s,i,a;const l=e.rule?{action:e.rule.action||(null==(t=e.rule.timingAction)?void 0:t.activeAction),config:e.rule.config||(null==(r=null==(n=e.rule.timingAction)?void 0:n.actions)?void 0:r[(null==(o=e.rule.timingAction)?void 0:o.activeAction)||""])}:null,d=void 0===(null==(s=e.response)?void 0:s.statusCode),c=d?"Pending":null==(i=e.response)?void 0:i.statusCode,m=0===c?"Error":c,u=h.state.ui.tabConfigs.MOCKED.selectedRequestId===e.requestId,p=function(e,t,n){return e?"pending":t?"success":n?"error":""}(d,!d&&"number"==typeof c&&c>=200&&c<300,!d&&"number"==typeof c&&(0===c||c>=400));return`\n <div class="mfm-request-item ${u?"active":""} ${d?"pending-item":""}" data-id="${e.requestId}" data-type="request">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.request.method||"").toLowerCase()}">${e.request.method}</span>\n <span class="mfm-status ${p}">\n ${d?'<span class="mfm-spinner"></span>':m}\n </span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${h.state.ui.activeDropdownId===e.requestId?"show":""}">\n <button data-action="copy-curl">Copy as cURL</button>\n <button data-action="copy-fetch">Copy as Fetch</button>\n <button data-action="copy-xhr">Copy as XHR</button>\n </div>\n </div>\n </div>\n <span class="mfm-url" title="${e.request.url}">${e.request.url}</span>\n ${(null==l?void 0:l.action)?`\n <div class="mfm-rule-info">\n <span class="mfm-rule-action">${String(l.action).replace(/_/g," ")}</span>\n <span class="mfm-rule-value">${(null==(a=l.config)?void 0:a.value)||0}s</span>\n </div>`:""}\n </div>\n `}}class V{constructor(e){this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-mocked-apis-activity",this.init()}init(){this.parent.appendChild(this.element),this.attachEvents(),this.unsubscribe=h.subscribe((()=>{"MOCKED"===h.state.ui.selectedTab&&this.render()})),this.render()}attachEvents(){this.element.onclick=e=>{var t;const n=e.target,o=n.closest(".mfm-dots-btn");if(o){e.stopPropagation();const t=o.closest(".mfm-request-item"),n=null==t?void 0:t.dataset.id;return void(n&&v.setOpenDropdown(n))}const r=n.closest("[data-action]");if(r){e.stopPropagation();const n=r.dataset.action,o=r.closest(".mfm-request-item"),s=null==o?void 0:o.dataset.id;return n&&s&&this.handleAction(n,s),void(null==(t=r.parentElement)||t.classList.remove("show"))}const s=n.closest(".mfm-request-item");if(s){if(s.classList.contains("pending-item"))return;e.stopPropagation();const t=s.dataset.id;t&&v.selectRequest(t)}}}handleAction(e,t){const n=h.state.requests.find((e=>e.requestId===t));n&&(U(G(n,e)),v.clearOpenDropdown())}render(){const e=function(){const e=(h.state.ui.tabConfigs.MOCKED.searchText||"").toLowerCase();return h.state.requests.filter((t=>{var n,o;return"MOCKED"===t.interceptionType&&(((null==(n=t.request)?void 0:n.url)||"").toLowerCase().includes(e)||((null==(o=t.rule)?void 0:o.ruleName)||"").toLowerCase().includes(e))}))}(),t=h.state.ui.tabConfigs.MOCKED.selectedRequestId,n=h.state.ui.activeDropdownId;if(!e||0===e.length)return void(this.element.querySelector(".mfm-empty")||(this.element.innerHTML='<div class="mfm-empty">No requests found</div>'));const o=this.element.querySelector(".mfm-empty");o&&o.remove();const r=e.map((e=>e.requestId));Array.from(this.element.querySelectorAll(".mfm-request-item")).forEach((e=>{r.includes(e.dataset.id||"")||e.remove()})),e.forEach(((e,o)=>{const r=this.element.querySelector(`[data-id="${e.requestId}"]`),s=e.rule?z.render(e):K.render(e),i=t===e.requestId,a=n===e.requestId,l=`${JSON.stringify(e).length}_${i}_${a}`;if(r){if(r.dataset.hash!==l){const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;t&&(t.dataset.hash=l,this.element.replaceChild(t,r))}}else{const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;if(!t)return;t.dataset.hash=l;const n=this.element.children[o];n?this.element.insertBefore(t,n):this.element.appendChild(t)}}))}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}class Q{static render(e){var t,n;const o=void 0===(null==(t=e.response)?void 0:t.statusCode),r=o?"Pending":null==(n=e.response)?void 0:n.statusCode,s=0===r?"Error":r,i=h.state.ui.tabConfigs.OTHER.selectedRequestId===e.requestId,a=function(e,t,n){return e?"pending":t?"success":n?"error":""}(o,!o&&"number"==typeof r&&r>=200&&r<300,!o&&"number"==typeof r&&(0===r||r>=400));return`\n <div class="mfm-request-item ${i?"active":""} ${o?"pending-item":""}" data-id="${e.requestId}" data-type="request">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.request.method||"").toLowerCase()}">${e.request.method}</span>\n <span class="mfm-status ${a}">\n ${o?'<span class="mfm-spinner"></span>':s}\n </span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${h.state.ui.activeDropdownId===e.requestId?"show":""}">\n <button data-action="copy-curl">Copy as cURL</button>\n <button data-action="copy-fetch">Copy as Fetch</button>\n <button data-action="copy-xhr">Copy as XHR</button>\n </div>\n </div>\n </div>\n <span class="mfm-url" title="${e.request.url}">${e.request.url}</span>\n </div>\n `}}class J{constructor(e){this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-other-apis-activity",this.init()}init(){this.parent.appendChild(this.element),this.attachEvents(),this.unsubscribe=h.subscribe((()=>{"OTHER"===h.state.ui.selectedTab&&this.render()})),this.render()}attachEvents(){this.element.onclick=e=>{var t;const n=e.target,o=n.closest(".mfm-dots-btn");if(o){e.stopPropagation();const t=o.closest(".mfm-request-item"),n=null==t?void 0:t.dataset.id;return void(n&&v.setOpenDropdown(n))}const r=n.closest("[data-action]");if(r){e.stopPropagation();const n=r.dataset.action,o=r.closest(".mfm-request-item"),s=null==o?void 0:o.dataset.id;return n&&s&&this.handleAction(n,s),void(null==(t=r.parentElement)||t.classList.remove("show"))}const s=n.closest(".mfm-request-item");if(s){if(s.classList.contains("pending-item"))return;e.stopPropagation();const t=s.dataset.id;t&&v.selectRequest(t)}}}handleAction(e,t){const n=h.state.requests.find((e=>e.requestId===t));n&&(U(G(n,e)),v.clearOpenDropdown())}render(){const e=function(){const e=(h.state.ui.tabConfigs.OTHER.searchText||"").toLowerCase();return h.state.requests.filter((t=>{var n;return"MOCKED"!==t.interceptionType&&((null==(n=t.request)?void 0:n.url)||"").toLowerCase().includes(e)}))}(),t=h.state.ui.tabConfigs.OTHER.selectedRequestId,n=h.state.ui.activeDropdownId;if(!e||0===e.length)return void(this.element.querySelector(".mfm-empty")||(this.element.innerHTML='<div class="mfm-empty">No requests found</div>'));const o=this.element.querySelector(".mfm-empty");o&&o.remove();const r=e.map((e=>e.requestId));Array.from(this.element.querySelectorAll(".mfm-request-item")).forEach((e=>{r.includes(e.dataset.id||"")||e.remove()})),e.forEach(((e,o)=>{const r=this.element.querySelector(`[data-id="${e.requestId}"]`),s=Q.render(e),i=t===e.requestId,a=n===e.requestId,l=`${JSON.stringify(e).length}_${i}_${a}`;if(r){if(r.dataset.hash!==l){const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;t&&(t.dataset.hash=l,this.element.replaceChild(t,r))}}else{const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;if(!t)return;t.dataset.hash=l;const n=this.element.children[o];n?this.element.insertBefore(t,n):this.element.appendChild(t)}}))}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}function W(e){const t=document.createElement("div");t.id="mfm-root";const n=document.createElement("div");n.className="mfm-widget-toggle",n.innerHTML='\n <div class="mfm-toggle-section mfm-toggle-reload" title="Reload Mappings"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><polyline points="21 3 21 8 16 8"></polyline></svg></div>\n <div class="mfm-toggle-divider"></div>\n <div class="mfm-toggle-section mfm-toggle-logo" title="MockForMe"><img src="https://ik.imagekit.io/mfm/static-collection/mfm-48x48.png" alt="Logo"></div>\n ';const o=document.createElement("div");o.className="mfm-main-container hidden",t.appendChild(n),t.appendChild(o),e.appendChild(t),function(e,t){const n=(t,n)=>{const o=e.getBoundingClientRect(),r=o.width||60,s=o.height||60,i=window.innerWidth-r,a=window.innerHeight-s,l=Math.max(0,Math.min(t,i)),d=Math.max(0,Math.min(n,a));e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.bottom="auto",e.style.right="auto"},o=()=>{const e=localStorage.getItem("MFM_POSITION");if(e)try{const t=JSON.parse(e);"number"==typeof t.xPercent&&"number"==typeof t.yPercent&&n(t.xPercent*window.innerWidth,t.yPercent*window.innerHeight)}catch{}};o();let r=!1,s=0,i=0,a=0,l=0;const d=n=>{const o="touchstart"===n.type,d=o?n.touches[0].clientX:n.clientX,u=o?n.touches[0].clientY:n.clientY;r=!0,s=d,i=u;const p=e.getBoundingClientRect();a=p.left,l=p.top,t.dataset.moved="false",document.addEventListener("mousemove",c),document.addEventListener("mouseup",m),document.addEventListener("touchmove",c,{passive:!1}),document.addEventListener("touchend",m),e.style.transition="none"},c=e=>{if(!r)return;const o="touchmove"===e.type;o&&e.cancelable&&e.preventDefault();const d=o?e.touches[0].clientX:e.clientX,c=o?e.touches[0].clientY:e.clientY,m=d-s,u=c-i;(Math.abs(m)>5||Math.abs(u)>5)&&(t.dataset.moved="true"),n(a+m,l+u)},m=()=>{if(!r)return;r=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",c),document.removeEventListener("touchend",m),e.style.transition="";const t=e.getBoundingClientRect();((e,t)=>{const n=e/window.innerWidth,o=t/window.innerHeight;localStorage.setItem("MFM_POSITION",JSON.stringify({xPercent:n,yPercent:o}))})(t.left,t.top)};t.addEventListener("mousedown",d),t.addEventListener("touchstart",d,{passive:!1}),window.addEventListener("resize",o),window.addEventListener("orientationchange",o)}(t,n),function(e){const t=document.createElement("div");t.className="mfm-header",t.innerHTML=`\n <div class="mfm-logo">\n <img src="${k}" height="32" alt="MockForMe Logo">\n </div>\n <div class="mfm-header-actions">\n <label class="mfm-switch" title="Toggle Mock Interception">\n <input type="checkbox" id="mfm-intercept-toggle" ${h.state.isInterceptEnabled?"checked":""}>\n <span class="mfm-slider"></span>\n </label>\n <button class="mfm-btn-icon" id="mfm-reload-header" title="Reload Mappings">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-cw"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><polyline points="21 3 21 8 16 8"></polyline></svg>\n </button>\n <button class="mfm-btn-icon" id="mfm-delete-token" title="Delete Token">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>\n </button>\n <button class="mfm-btn-icon" id="mfm-close-widget" title="Close Widget">\n ${_}\n </button>\n </div>\n `,e.appendChild(t);const n=t.querySelector("#mfm-intercept-toggle"),o=t.querySelector("#mfm-reload-header"),r=t.querySelector("#mfm-delete-token"),s=t.querySelector("#mfm-close-widget");n&&(n.onchange=()=>{v.toggleInterception()}),o&&(o.onclick=()=>{o.innerHTML='<div class="mfm-spinner"></div>',o.style.pointerEvents="none",v.reloadMappings()}),r&&(r.onclick=()=>{v.deleteToken()}),s&&(s.onclick=()=>{v.toggleWidget()}),h.subscribe((e=>{n&&(n.checked=e.isInterceptEnabled)}))}(o),new q(o),function(e){var t,n;const o=document.createElement("div");o.className="mfm-tabs-container";const r=document.createElement("div");r.className="mfm-tabs-nav",[{id:"MAPPINGS",label:"Mappings"},{id:"MOCKED",label:"Mocked"},{id:"OTHER",label:"Others"}].forEach((e=>{const t=document.createElement("button");t.className="mfm-tab-btn "+(h.state.ui.selectedTab===e.id?"active":""),t.innerText=e.label,t.onclick=()=>{v.setTab(e.id)},t.dataset.tabId=e.id,r.appendChild(t)}));const s=document.createElement("div");s.className="mfm-tab-toolbar",s.innerHTML=`\n <div class="mfm-toolbar-row">\n <input type="text" class="mfm-input" id="mfm-search" placeholder="Search requests..." value="${(null==(t=h.state.ui.tabConfigs[h.state.ui.selectedTab])?void 0:t.searchText)||""}">\n <label class="mfm-preserve-logs">\n <input type="checkbox" id="mfm-preserve-check" ${(null==(n=h.state.ui.tabConfigs[h.state.ui.selectedTab])?void 0:n.isPreserveLogs)?"checked":""}>\n Preserve\n </label>\n <button class="mfm-btn-outline clear-btn" id="mfm-clear-btn" title="Clear requests">\n ${M}\n </button>\n </div>\n `;const i=document.createElement("div");i.className="mfm-tab-content",o.appendChild(r),o.appendChild(s),o.appendChild(i),e.appendChild(o);const a=new B(i),l=new V(i),d=new J(i),c=s.querySelector("#mfm-search"),m=s.querySelector("#mfm-clear-btn"),u=s.querySelector("#mfm-preserve-check"),p=s.querySelector(".mfm-preserve-logs");c&&(c.oninput=e=>{const t=e.target;v.setSearchText(t.value)}),m&&(m.onclick=()=>{v.clearRequests()}),u&&(u.onchange=e=>{const t=e.target;v.setPreserveLogs(Boolean(t.checked))});const f=()=>{const e=h.state.ui.selectedTab,t=h.state.ui.tabConfigs[e];if(r.querySelectorAll(".mfm-tab-btn").forEach((t=>{t.classList.toggle("active",t.dataset.tabId===e)})),c){const e=(null==t?void 0:t.searchText)||"";c.value!==e&&(c.value=e)}const n="MAPPINGS"===e;m&&(m.style.display=n?"none":"block"),p&&(p.style.display=n?"none":"flex"),!n&&u&&(u.checked=Boolean(null==t?void 0:t.isPreserveLogs)),a.element&&(a.element.style.display="MAPPINGS"===e?"block":"none"),l.element&&(l.element.style.display="MOCKED"===e?"block":"none"),d.element&&(d.element.style.display="OTHER"===e?"block":"none")};f(),h.subscribe((()=>f()))}(o),function(e){const t=document.createElement("div");t.className="mfm-bottomsheet",t.id="mfm-details-sheet",t.innerHTML='\n <div class="mfm-bottomsheet-header" style="justify-content: flex-start; gap: 8px; padding-right: 12px;">\n <button class="mfm-btn-icon back-btn" id="mfm-close-sheet" title="Back"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg></button>\n <div id="mfm-header-info" style="display: flex; align-items: baseline; gap: 6px; overflow: hidden; flex: 1; cursor: pointer;"></div>\n </div>\n <div class="mfm-bottomsheet-content"></div>\n ',e.appendChild(t);const n=t.querySelector("#mfm-close-sheet"),o=t.querySelector("#mfm-header-info");if(!n||!o)return;n.onclick=e=>{e.stopPropagation(),v.closeDetails()};let r=!1,s="TEXT",i={};const a=()=>{const e=P({sheet:t,infoContainer:o,isUrlExpanded:r,responseBodyMode:s,prevState:i});r=e.isUrlExpanded,s=e.responseBodyMode,i=e.prevState};o.onclick=()=>{r=!r,a()},h.subscribe(a),a()}(o);const r=e=>{const t=Boolean(e.token),r=o.querySelector(".mfm-header"),s=o.querySelector(".mfm-tabs-container"),i=o.querySelector(".mfm-token-form");r&&(r.style.display=t?"flex":"none"),s&&(s.style.display=t?"block":"none"),i&&(i.style.display=t?"none":"block"),o.classList.toggle("hidden",!e.isOpen),n.classList.toggle("hidden",e.isOpen)};h.subscribe(r),r(h.state);const s=n.querySelector(".mfm-toggle-reload"),i=n.querySelector(".mfm-toggle-logo");return s&&(s.onclick=e=>{e.stopPropagation(),"true"!==n.dataset.moved&&(h.state.token?v.reloadMappings():h.update("isOpen",!0))}),i&&(i.onclick=e=>{e.stopPropagation(),"true"!==n.dataset.moved&&(h.state.token?v.toggleWidget():h.update("isOpen",!0))}),window.addEventListener("click",(e=>{const t=e.target;(null==t?void 0:t.closest(".mfm-dropdown"))||v.clearOpenDropdown()})),t}function X(e){i.info("Initializing MockForMe Widget");let t=null;const n=e=>{e&&(t=W(e))},o=()=>e||document.body;o()?n(o()):"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>n(o()))):document.body&&n(document.body),m();const s={[r.MFM_RES_MAPPINGS]:e=>{if(!e)return;const t=h.state.isMappingsLoading;if(e.token&&!h.state.token&&(i.info("Setting token from incoming MFM_RES_MAPPINGS"),h.update("token",e.token),localStorage.setItem("MFM_TOKEN",e.token)),h.set("mappings",e),h.update("isMappingsLoading",!1),h.state.isTokenValidating){const e=localStorage.getItem("MFM_TOKEN_TEMP")||h.state.token;e&&(h.update("token",e),localStorage.setItem("MFM_TOKEN",e),localStorage.removeItem("MFM_TOKEN_TEMP")),h.update("isTokenValidating",!1),h.update("isTokenLoading",!1),v.flushQueue()}w(),t&&!h.state.ui.tokenError&&x("Mappings reloaded successfully")},[r.MFM_REQ]:e=>{e&&(i.info("Captured Request",e),v.addRequest(e))},[r.MFM_RES]:e=>{e&&(i.info("Captured Response",e),v.addRequest(e))},[r.MFM_TOKEN_ERROR]:e=>{E(r.MFM_TOKEN_ERROR,e)},[r.MFM_TOKEN_API_FAILED]:e=>{E(r.MFM_TOKEN_API_FAILED,e)},[r.MFM_TOGGLE_INTERCEPTION]:e=>{e&&"boolean"==typeof e.enabled&&v.toggleInterception(e.enabled)}},l=Object.keys(s).map((e=>function(e,t){m(),a.has(e)||a.set(e,new Set);const n=a.get(e);return n.add(t),()=>{n.delete(t)}}(e,(t=>{(0,s[e])(t)}))));return h.state.token&&v.fetchSavedMappings(),{destroy(){l.forEach((e=>e())),t&&t.remove()},actions:v}}const Y={run:X,initMFM:X,actions:v};window.MFM=Y}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};const o=()=>"undefined"!=typeof process&&null!=process.versions?.node,r=e=>{try{return e?e.toLowerCase():e}catch(e){return console.log(e),null}},s=(e,t)=>{const n=e.split("/"),o=t.split("/");if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++){const t=n[e];if(t!==o[e]&&":any"!==t)return!1}return!0};let i=[];function a(e){i=e}function l(){return i}function d(e,t="get"){const n=e=>e.startsWith("/")?e:`/${e}`,o=n(e);for(const a of i)if(r(a.apiMethod)===r(t)){const r=n(a.apiEndpoint);if(r===o||s(r,o)){console.log(`[MockForMe] Match Found: ${t} ${e} -> ${a.apiEndpoint}`);const n={url:e,method:a.apiMethod,_ack:a._ack||null};return a._ri_&&(n._ri_=a._ri_),n}}return null}const c="JAVASCRIPT",m="CHROME_EXTENSION",u="mfmver",p="mockforme",f="8.1.0",h="https://api.mockforme.com",g=`${h}/mockforme`,b=`${h}/gateway/3f4eae522b`;let y=null,v=null,x=null,w=[];function E({_o:e,mk:t,_mck:n,_rules:o}){y=e,v=t,x=n,w=o}function k(){return w}function M(){return`${g}/${y}/${v}`}function _(){return x}const R=e=>{try{return new URL(e,window.location.origin).toString()}catch{return e}},q=function(e,t,n){const r=o();var s;function i(){if(4==s.readyState)if(s.status.toString().match(/^20[0-9]$/)){var e=function(){var e=s.getResponseHeader("Content-Type"),t=s.responseText;if(e){var n=e.split(";");try{return"application/json"===n[0]?JSON.parse(t):t}catch(e){throw"Unable to convert response header"}}}();t.call(this,e,s)}else n.call(this,s.responseText,s)}function a(e,t){var n=[];for(var o in e)if(e.hasOwnProperty(o)){var r=t?t+"["+o+"]":o,s=e[o];n.push("object"==typeof s?a(s,r):encodeURIComponent(r)+"="+encodeURIComponent(s))}return n.join("&")}return r||(window.XMLHttpRequest?s=new XMLHttpRequest:window.ActiveXObject&&(s=new ActiveXObject("Microsoft.XMLHTTP"))),{request:function(){if(!r){if(window.XMLHttpRequest)s.onload=i;else{if(!window.ActiveXObject)throw"unable to process ajax";s.onreadystatechange=i}var t=a(e.params);if("get"==e.method.toLowerCase()&&"object"==typeof e.params){if(-1==e.url.indexOf("?"))e.url+="?";else{var n=e.url.split("?");n[1]&&n[1].split("=")[1]&&(e.url+="&")}e.url+=t}e.hasOwnProperty("async")||(e.async=!0),s.open(e.method,e.url,e.async),e.headers&&function(e){for(let t in e)s.setRequestHeader(t,e[t])}(e.headers),s.send(t)}}}};function T({di:e,iv:t},n){var o;const r=function(e,t){const n=t.length;return e.split("").map(((e,o)=>String.fromCharCode(e.charCodeAt(0)^t.charCodeAt(o%n)))).join("")}((o=e,"undefined"!=typeof Buffer?Buffer.from(o,"base64").toString("utf8"):decodeURIComponent(escape(atob(o)))),n+t);return JSON.parse(r)}function S(e,t,n,o){fetch(b,{method:"GET",headers:{[p]:e,[u]:f,"x-mfm-adaptor":t}}).then((e=>{if(!e.ok)throw e;return e.json()})).then((e=>{if(e){const{di:t,iv:o,_o:r,_mck:s,mk:i,r:l}=e,d=T({di:t,iv:o},r);E({_o:r,mk:i,_mck:s,_rules:l}),d&&(a(d),n(d,{_o:r,mk:i,_mck:s,_rules:l}))}})).catch((e=>{console.error("Error in loading mocked APIs:",e),o(e)}))}const C="MFM_TOKEN_ERROR",I=new class{constructor(e={}){o()||(this.token=e.token||("undefined"!=typeof localStorage?localStorage.getItem("MFM_TOKEN"):null),this.isAuthenticated=!!this.token,this.onAuthSuccess=e.onAuthSuccess||(()=>{}),this.mappings=e.mappings||[],this.rules=e.rules||[],this.widgetKey=e.widgetKey||null,this.interceptionEnabled="undefined"==typeof localStorage||"false"!==localStorage.getItem("MFM_INTERCEPTION_ENABLED"),this.setupMessageListeners())}setupMessageListeners(){"undefined"!=typeof window&&window.addEventListener("message",(e=>{const{type:t,payload:n}=e.data||{};if(t&&"string"==typeof t&&t.startsWith("MFM_"))switch(t){case"MFM_REQ_MAPPINGS":this.refreshMappings();break;case"MFM_REQ_SAVED_MAPPINGS":this.handleReqSavedMappings();break;case"MFM_SUBMIT_TOKEN":this.handleTokenSubmission(n?.token);break;case"MFM_DEL_CLIENT_TOKEN":this.handleTokenDeletion();break;case"MFM_TOGGLE_INTERCEPTION":this.interceptionEnabled=!!n?.enabled,"undefined"!=typeof localStorage&&localStorage.setItem("MFM_INTERCEPTION_ENABLED",this.interceptionEnabled)}}))}init(){if("undefined"!=typeof document&&this.checkVisibility()&&("undefined"!=typeof window&&Promise.resolve().then(n.bind(n,133)).then((()=>{window.MFM&&"function"==typeof window.MFM.run&&window.MFM.run()})).catch((e=>{console.error("[MockForMe] Failed to load mfm-widget",e)})),console.log("[MockForMe] Widget initialized"),this.token)){const e=this.getSavedMappings();e&&(this.mappings=e.mappings||[],this.rules=e.meta?._rules||[],this.onAuthSuccess(this.token,this.mappings,e.meta),this.updateMappings(this.mappings,e.meta))}}setWidgetKey(e){this.widgetKey=e,this.init()}checkVisibility(){return!this.widgetKey||"undefined"!=typeof localStorage&&localStorage.getItem("widgetKey")===this.widgetKey}handleTokenSubmission(e){e&&(this.token=e,this.isAuthenticated=!0,"undefined"!=typeof localStorage&&localStorage.setItem("MFM_TOKEN",e),this.refreshMappings())}handleTokenDeletion(){this.token=null,this.isAuthenticated=!1,"undefined"!=typeof localStorage&&(localStorage.removeItem("MFM_TOKEN"),localStorage.removeItem("MFM_CACHED_MAPPINGS")),this.mappings=[],this.rules=[],this.onAuthSuccess(null,[],{_rules:[]}),this.updateMappings([],{_rules:[]})}refreshMappings(){this.token&&S(this.token,"JAVASCRIPT",((e,t)=>{this.mappings=e||[],this.rules=t?._rules||[],this.saveMappings(e,t),this.onAuthSuccess(this.token,this.mappings,t),this.updateMappings(this.mappings,t)}),(e=>{console.error("[MockForMe] Failed to fetch mappings",e),e instanceof Response&&e.headers&&"true"===e.headers.get("mfm-invalid-token")&&this.sendMessage(C,{message:"Unauthorized: Invalid token"}),this.updateMappings([],{_rules:[]})}))}saveMappings(e,t){if("undefined"!=typeof localStorage)try{localStorage.setItem("MFM_CACHED_MAPPINGS",JSON.stringify({mappings:e,meta:t}))}catch(e){console.error("[MockForMe] Failed to save mappings to storage",e)}}handleReqSavedMappings(){const e=this.getSavedMappings();e?(this.mappings=e.mappings||[],this.rules=e.meta?._rules||[],this.onAuthSuccess(this.token,this.mappings,e.meta),this.updateMappings(this.mappings,e.meta)):this.refreshMappings()}getSavedMappings(){if("undefined"==typeof localStorage)return null;try{const e=localStorage.getItem("MFM_CACHED_MAPPINGS");return e?JSON.parse(e):null}catch(e){return null}}updateMappings(e,t){this.sendMessage("MFM_RES_MAPPINGS",{apis:e.map((e=>({method:e.apiMethod,url:e.apiEndpoint}))),rules:(t?._rules||[]).map((e=>{const t="object"==typeof e.rule&&null!==e.rule?e.rule:{},n={...e,...t},o=n.timingAction||{},r=o.activeAction||"MODIFY";let s="MODIFY";"delay"===r?s="DELAY":"delay_and_timeout"===r?s="TIMEOUT":"delay_and_redirect"===r&&(s="REDIRECT");const i={ruleName:n.ruleName||n._id||"Unnamed Rule",type:s,conditions:n.conditions||[],modificationActions:n.modificationActions||{}};return("MODIFY"!==s||o.activeAction)&&(i.timingAction=o),i})),token:this.token})}addRequest(e,t){if(!this.interceptionEnabled)return;const n=e=>{if(!e)return{};let t={};return"string"==typeof e?e.split("\r\n").forEach((e=>{const n=e.split(": "),o=n.shift();o&&(t[o]=n.join(": "))})):t="function"==typeof e.entries?Object.fromEntries(e.entries()):e,Object.keys(t).reduce(((e,n)=>(e[n.toLowerCase()]=t[n],e)),{})},o={requestId:t.requestId||Math.random().toString(36).substring(7),interceptionType:"mocked"===e?"MOCKED":"OTHER",request:{method:t.method,url:t.url,headers:n(t.requestHeaders||t.headers),body:t.requestBody||t.body},response:t.pending&&void 0===t.status?null:{statusCode:t.status,headers:n(t.responseHeaders),body:t.responseBody,endTime:(new Date).toISOString()},rule:t.rule};if(t.pending)this.sendMessage("MFM_REQ",o);else if(this.sendMessage("MFM_RES",o),o.response&&o.response.headers){const e=o.response.headers["mfm-invalid-token"];if("true"===e||!0===e){const{message:e}=t.responseBody;console.warn("[MockForMe] Invalid token detected from response headers"),this.sendMessage(C,{message:e||"Unauthorized: Invalid token detected from response headers"}),this.handleTokenDeletion()}}}sendMessage(e,t){"undefined"!=typeof window&&window.postMessage({type:e,payload:t},"*")}};class O{static match(e,t){if(!Array.isArray(t)||0===t.length)return!1;const{url:n,headers:o,queryParams:r,body:s}=e,i="undefined"!=typeof window?window.location.origin:globalThis.location?.origin||"http://localhost";for(const e of t){let t="";const{type:a,key:l,operator:d,value:c}=e;switch(a){case"URL":try{t=new URL(n,i).pathname}catch{t=n}break;case"QUERY_PARAM":if(r&&void 0!==r[l])t=String(r[l]);else try{t=new URL(n,i).searchParams.get(l)||""}catch{t=""}break;case"REQUEST_BODY":if(l){if("object"==typeof s&&null!==s)t=void 0!==s[l]?String(s[l]):"";else if("string"==typeof s)try{const e=JSON.parse(s);t=void 0!==e[l]?String(e[l]):""}catch{t=""}}else t="object"==typeof s?JSON.stringify(s):String(s||"");break;case"REQUEST_HEADER":if(l){const e=l?.toLowerCase();if(t="",o){const n=Object.keys(o).find((t=>t.toLowerCase()===e));t=n?String(o[n]):""}}else t=JSON.stringify(o||{});break;default:return!1}if(!this.evaluate(t,d,c))return!1}return!0}static evaluate(e,t,n){const o=t?.toLowerCase(),r=String(e),s=String(n);switch(o){case"contains":return r.includes(s);case"equal":case"equals":return r===s;case"regexp":try{let e=s;if(e.startsWith("/")&&e.lastIndexOf("/")>0){const t=e.lastIndexOf("/"),n=e.slice(1,t),o=e.slice(t+1);return new RegExp(n,o).test(r)}return new RegExp(e).test(r)}catch{return!1}default:return!1}}}class L{static async apply(e){if(!e||!e.activeAction)return{type:"passThrough",delay:0};const{activeAction:t,actions:n}=e,o=n?.[t];if(!o)return{type:"passThrough",delay:0};const r={type:"passThrough",delay:0},s=Number(o.value||0);switch(t){case"delay":r.delay=s,r.delay>0&&await new Promise((e=>setTimeout(e,1e3*r.delay)));break;case"redirect":case"delay_and_redirect":r.type="redirect",r.delay=s,r.redirectUrl=o.redirectUrl,r.delay>0&&await new Promise((e=>setTimeout(e,1e3*r.delay)));break;case"delay_and_timeout":r.type="timeout",r.delay=s,r.delay>0&&await new Promise((e=>setTimeout(e,1e3*r.delay)))}return r}}class A{static applyRequestModifications(e,t){if(!t)return e;let{url:n,method:o,headers:r,queryParams:s,body:i}={...e};r&&(r={...r}),s&&(s={...s});const{modifyQueryParams:a,modifyRequestBody:l,modifyRequestHeaders:d}=t;if(a?.enabled)try{const e=new URL(n,"undefined"!=typeof window?window.location.href:"http://localhost");Array.isArray(a.remove)&&a.remove.forEach((t=>{e.searchParams.delete(t),s&&delete s[t]})),Array.isArray(a.add)&&a.add.forEach((({key:t,value:n})=>{e.searchParams.set(t,n),s&&(s[t]=n)})),n=e.toString()}catch(e){console.error("[MockForMe] Failed to modify query params",e)}d?.enabled&&(r={...r},Array.isArray(d.remove)&&d.remove.forEach((e=>{const t=e.toLowerCase(),n=Object.keys(r).find((e=>e.toLowerCase()===t));n&&delete r[n]})),Array.isArray(d.add)&&d.add.forEach((({key:e,value:t})=>{r[e]=t})));const c=String(o||"GET").toUpperCase(),m="GET"===c||"HEAD"===c;if(l?.enabled&&!m)try{let e=null;if("string"==typeof i)try{e=JSON.parse(i)}catch{e={}}else if("object"==typeof i&&null!==i)try{e=JSON.parse(JSON.stringify(i))}catch{e={...i}}else(Array.isArray(l.add)&&l.add.length>0||Array.isArray(l.update)&&l.update.length>0)&&(e={});e&&(Array.isArray(l.remove)&&l.remove.forEach((t=>delete e[t])),Array.isArray(l.add)&&l.add.forEach((({key:t,value:n})=>e[t]=n)),Array.isArray(l.update)&&l.update.forEach((({key:t,value:n})=>e[t]=n)),i=JSON.stringify(e))}catch(e){console.error("[MockForMe] Failed to modify request body",e)}return{...e,url:n,headers:r,queryParams:s,body:i}}static applyResponseModifications(e,t){if(!t?.modifyResponseHeaders?.enabled)return e;const{modifyResponseHeaders:n}=t,o={...e};return Array.isArray(n.remove)&&n.remove.forEach((e=>{const t=e.toLowerCase(),n=Object.keys(o).find((e=>e.toLowerCase()===t));n&&delete o[n]})),Array.isArray(n.add)&&n.add.forEach((({key:e,value:t})=>{o[e]=t})),o}}class N{static match(e,t){if(!Array.isArray(t)||0===t.length)return null;for(const n of t){const t=n.rule||n;if(t.conditions&&Array.isArray(t.conditions)&&O.match(e,t.conditions)){const e=t.timingAction?.activeAction||"";return{action:e,config:t.timingAction?.actions?.[e]||{},rule:t}}}return null}static async apply(e,t){if(!e)return null;const n=e.rule||e,o=A.applyRequestModifications(t,n.modificationActions);return{...await L.apply(n.timingAction),modifiedRequest:o,rule:n}}static applyResponseModifications(e,t){return A.applyResponseModifications(e,t)}}class j{static apply({target:e=("undefined"!=typeof window?window:globalThis),originalFetch:t=e.fetch,ruleProvider:n=()=>[],mappingProvider:o=e=>null,onBeforeRequest:r=e=>{},onRuleMatch:s=async(e,t,n,o,r)=>null,onMockMatch:i=async(e,t,n,o,r)=>null,onOtherRequest:a=async(e,t,n,o)=>null,isEnabled:l=()=>!0}){t&&(e.fetch=async function(e,d={}){if(!l())return t(e,d);let c;try{const t="string"==typeof e?e:e.url,n=String(d.method||(e instanceof Request?e.method:"GET")).toUpperCase().trim(),o=Math.random().toString(36).substring(7);c={url:t,method:n,headers:d.headers||(e instanceof Request?e.headers:{}),body:d.body||(e instanceof Request?"{binary/stream}":null),requestId:o,queryParams:j.getQueryParams(t)},r(c)}catch(n){return console.warn("[MockForMe] Fetch Interceptor Setup Error:",n),t(e,d)}try{const r=n(),l=N.match(c,r);if(l){const n=await s(l,c,e,d,t);if(n)return n}const m=o(c);if(m){const n=await i(m,c,e,d,t);if(n)return n}const u=await a(c,e,d,t);if(u)return u}catch(e){if(e.message.includes("timed out")||"AbortError"===e.name||e.message.includes("rules"))throw e;throw console.warn("[MockForMe] Interceptor Hook Error:",e),e}return t(e,d)})}static getQueryParams(e){try{const t="undefined"!=typeof window?window.location.origin:"http://localhost",n=new URL(e,t).searchParams;return Object.fromEntries(n.entries())}catch{return{}}}}class P{static apply({target:e=("undefined"!=typeof window?window:{}),OriginalXHR:t=e.XMLHttpRequest,ruleProvider:n=()=>[],mappingProvider:o=e=>null,onBeforeRequest:r=e=>{},onRuleMatch:s=(e,t,n,o)=>{o.call(n.proxy,t.body)},onMockMatch:i=(e,t,n,o)=>{o.call(n.proxy,t.body)},onOtherRequest:a=(e,t,n)=>{n.call(t.proxy,e.body)},isEnabled:l=()=>!0}){t&&(e.XMLHttpRequest=class{constructor(){return this._xhr=new t,this._headers={},this._method=null,this._url=null,this._body=null,this._requestId=null,this._startTime=null,this._captured=!1,this._isMocked=!1,this.proxy=new Proxy(this,{get:(e,t)=>{if(t in e)return e[t];const n=e._xhr[t];return"function"==typeof n?n.bind(e._xhr):n},set:(e,t,n)=>t in e?(e[t]=n,!0):(e._xhr[t]=n,!0)}),this.proxy}_capture(e,t,n,o={}){if(this._captured)return;this._captured=!0;const r=e=>{const t=`on${e}`;(this[t]||this._xhr[t])?.(),this._xhr.dispatchEvent(new Event(e))};if("Aborted"!==e)try{Object.defineProperty(this.proxy,"responseText",{value:t,configurable:!0}),Object.defineProperty(this.proxy,"response",{value:t,configurable:!0}),Object.defineProperty(this.proxy,"status",{value:Number(e)||0,configurable:!0}),Object.defineProperty(this.proxy,"statusText",{value:200==e?"OK":"",configurable:!0})}catch(e){console.warn("[MockForMe] Error setting XHR props",e)}Object.defineProperty(this.proxy,"readyState",{value:4,configurable:!0}),r("readystatechange"),"Aborted"===e||o.aborted?r("abort"):0===e||"Error"===e||o.error?r("error"):"Timeout"===e||o.timeout?r("timeout"):r("load")}open(e,t,n=!0,o=null,r=null){this._method=(e||"").toUpperCase().trim();try{this._url=new URL(t,"undefined"!=typeof window?window.location.href:"http://localhost").toString()}catch(e){this._url=t}return this._xhr.open(e,t,n,o,r)}setRequestHeader(e,t){return this._headers[e]=t,this._xhr.setRequestHeader(e,t)}send(e){if(!l())return this._xhr.send(e);this._body=e,this._requestId=Math.random().toString(36).substring(7),this._startTime=Date.now();const t={url:this._url,method:this._method,headers:this._headers,body:this._body,requestId:this._requestId,startTime:this._startTime,queryParams:P.getQueryParams(this._url)};r(t);const d=n(),c=N.match(t,d),m=e=>this._xhr.send(e);if(c)return this._isMocked=!0,s(c,t,this,m);const u=o(t);return u?(this._isMocked=!0,i(u,t,this,m)):(this._isMocked=!1,a(t,this,m))}})}static getQueryParams(e){try{const t="undefined"!=typeof window?window.location.origin:"http://localhost",n=new URL(e,t).searchParams;return Object.fromEntries(n.entries())}catch{return{}}}}const $=(e,t=null,n=c)=>{if(o())return;let r="string"==typeof e?e:e?.token,s="object"==typeof e?e?.widgetKey:null;if(s?I.setWidgetKey(s):I.init(),n===c)try{r&&("undefined"!=typeof localStorage&&(localStorage.removeItem("mockforme-token"),localStorage.setItem("MFM_TOKEN",r)),I.token=r,I.isAuthenticated=!0),!r&&I.token&&(r=I.token),I.onAuthSuccess=(e,t,n)=>{a(t),E(n),I.updateMappings(t,n)}}catch(e){console.log("Error in showing mockforme widget",e)}t||={mappings:[],_o:null,mk:null,_mck:null,_rules:[]};const{mappings:i=[],_o:h,mk:g,_mck:y,_rules:v=[]}=t;return a(i),E({_o:h,mk:g,_mck:y,_rules:v}),{run:(e,t=()=>{})=>{if(function(e,t){if("undefined"!=typeof window){if(window._mfm_intercepted)return;window._mfm_intercepted=!0}const n=()=>I.token||e;j.apply({isEnabled:()=>I.interceptionEnabled,ruleProvider:()=>k(),mappingProvider:e=>{try{return d(new URL(e.url,window.location.origin).pathname,e.method)}catch{return null}},onRuleMatch:async(e,t,n,o,r)=>{const s=t.requestId||Math.random().toString(36).substring(7),i=Date.now();I.addRequest("mocked",{...t,requestId:s,pending:!0,startTime:i,rule:e});const a=await N.apply(e,t),{modifiedRequest:l,type:d,delay:c,redirectUrl:m}=a;if("timeout"!==d&&I.addRequest("mocked",{...l,requestId:s,pending:!0,startTime:i,rule:e}),"timeout"===d){const t=Date.now()-i;throw I.addRequest("mocked",{...l,requestId:s,status:"Aborted",pending:!1,duration:t,aborted:!0,rule:e}),new Error("Fetch timed out by rules")}if("redirect"===d&&!m)throw new Error("rules: Redirect missing URL");let u="redirect"===d?m:l.url,p={...o};l.headers&&(p.headers=l.headers),l.body&&(p.body=l.body);let f=null;if("redirect"===d){f=Math.random().toString(36).substring(7);const e={url:m,method:l.method,headers:p.headers||{},body:p.body,requestId:f,queryParams:j.getQueryParams(m),requestHeaders:p.headers||{},requestBody:p.body,pending:!0,startTime:Date.now()};I.addRequest("mocked",e)}return r(u,p).then((async e=>{const t=Date.now()-i;let n=Object.fromEntries(e.headers.entries());if(a.rule.modificationActions?.modifyResponseHeaders?.enabled&&(n=N.applyResponseModifications(n,a.rule.modificationActions)),"redirect"===d&&f){const t=e.clone(),o=t.headers.get("content-type")||"",r=Date.now()-i;try{let s;s=o.includes("application/json")?await t.json():await t.text(),I.addRequest("mocked",{url:m,method:l.method,requestId:f,status:e.status,pending:!1,duration:r,responseHeaders:n,responseBody:s,requestHeaders:p.headers||{},requestBody:p.body})}catch(t){I.addRequest("mocked",{url:m,method:l.method,requestId:f,status:e.status,pending:!1,duration:r,responseHeaders:n,requestHeaders:p.headers||{},requestBody:p.body})}}return I.addRequest("mocked",{...l,requestId:s,status:e.status,pending:!1,duration:t,responseHeaders:n,rule:a.rule}),e})).catch((e=>{const t=Date.now()-i,n="AbortError"===e.name||e.message.includes("aborted");if(I.addRequest("mocked",{...l,requestId:s,status:n?"Aborted":0,pending:!1,duration:t,rule:a.rule}),"redirect"===d&&f&&I.addRequest("mocked",{url:m,method:l.method,requestId:f,status:n?"Aborted":0,pending:!1,duration:t,error:!n}),"redirect"===d){const t=e.message||"Redirect failed";if(!t.includes("rules"))throw new Error(`rules: Redirect failed - ${t}`)}throw e}))},onMockMatch:async(e,o,r,s,i)=>{const a=o.requestId||Math.random().toString(36).substring(7),l=Date.now();I.addRequest("mocked",{...o,requestId:a,pending:!0,startTime:l});const d=n(),c=new URL(o.url,window.location.origin).search;let h=`${M()}${e.url}${c}`,g={[p]:d,[u]:f,"x-mfm-adaptor":t};const b=_();b&&e._ack&&(g["x-mfm-key"]=`${b}-${e._ack}`),e?._ri_&&(g._ri_=e._ri_);const y=r instanceof Request?r.headers:s.headers,v=new Headers(y||{});Object.entries(g).forEach((([e,t])=>v.set(e,t))),v.set("x-mfm-internal","true");let x=s.body;if(!x&&r instanceof Request){const e=r.clone();"GET"!==e.method&&"HEAD"!==e.method&&(x=await e.text())}const w={method:o.method,headers:v,credentials:r instanceof Request&&r.credentials||s.credentials||"include",mode:r instanceof Request&&r.mode||s.mode||"cors"};return t===m?(({actualUrl:e,url:t,method:n,headers:o,body:r,credentials:s,mode:i,rule:a})=>{const l=`${Date.now()}-${Math.random()}`,d=R(t);return new Promise(((t,c)=>{window.addEventListener("message",(function e(n){if(n.source!==window)return;const o=n.data;if("INTERCEPTED_RESPONSE"===o?.type&&o?.requestId===l){if(window.removeEventListener("message",e),o?.response?.error)return c(new Error(o.response.message));const{status:n,headers:r,body:s}=o.response,i=new Response(s,{status:n,headers:r});i._rawHeaders=r,t(i)}})),window.postMessage({type:"REQUEST_INTERCEPTED",requestId:l,payload:{actualUrl:e,url:d,method:n,headers:o,body:r,credentials:s,mode:i,rule:a}},"*")}))})({actualUrl:o.url,url:h,method:o.method,headers:Object.fromEntries(v.entries()),body:x,credentials:w.credentials,mode:w.mode}).then((e=>(e.clone().text().then((t=>{const n=Date.now()-l,r=e._rawHeaders||Object.fromEntries(e.headers.entries());I.addRequest("mocked",{...o,requestId:a,status:e.status,responseHeaders:r,responseBody:t,pending:!1,duration:n})})),e))):(x&&(w.body=x),i(h,w).then((async e=>{const t=e.clone(),n=t.headers.get("content-type")||"",r=Date.now()-l,s=n=>(I.addRequest("mocked",{...o,requestId:a,status:e.status,responseHeaders:Object.fromEntries(t.headers.entries()),responseBody:n,pending:!1,duration:r}),new Response("string"==typeof n?n:JSON.stringify(n),{status:e.status,headers:t.headers}));return n.includes("application/json")?t.json().then(s):t.text().then(s)})).catch((e=>{const t=Date.now()-l;return I.addRequest("mocked",{...o,requestId:a,status:0,pending:!1,duration:t}),i(r,s)})))},onOtherRequest:async(e,t,n,o)=>{const r=n?.headers||(t instanceof Request?t.headers:{});let s=!1;r instanceof Headers?s="true"===r.get("x-mfm-internal"):"object"==typeof r&&(s="true"===r["x-mfm-internal"]);const i=M();if(e.url.startsWith(i)&&(s=!0),"OPTIONS"===e.method||s)return o(t,n);const a=e.requestId,l=Date.now();return I.addRequest("other",{...e,requestId:a,pending:!0,startTime:l}),o(t,n).then((async t=>{const n=t.clone(),o=Date.now()-l,r=Object.fromEntries(t.headers.entries());I.addRequest("other",{...e,requestId:a,status:t.status,responseHeaders:r,pending:!0,duration:o});try{const s=await n.text();I.addRequest("other",{...e,requestId:a,status:t.status,responseHeaders:r,responseBody:s,pending:!1,duration:o})}catch(n){I.addRequest("other",{...e,requestId:a,status:t.status,responseHeaders:r,pending:!1,duration:o})}return t})).catch((t=>{const n=Date.now()-l,o="AbortError"===t.name||t.message.includes("aborted"),r="TimeoutError"===t.name||t.message.includes("timed out");throw I.addRequest("other",{...e,requestId:a,status:o?"Aborted":r?"Timeout":"Error",pending:!1,duration:n,aborted:o,timeout:r,error:!o&&!r}),t}))}}),P.apply({isEnabled:()=>I.interceptionEnabled,ruleProvider:()=>k(),mappingProvider:e=>{try{return d(new URL(e.url,window.location.origin).pathname,e.method)}catch{return null}},onRuleMatch:async(e,t,n,o)=>{const r=t.requestId,s=Date.now();I.addRequest("mocked",{...t,requestId:r,pending:!0,startTime:s,rule:e});const i=await N.apply(e,t),{modifiedRequest:a,type:l,redirectUrl:d}=i;"timeout"!==l&&I.addRequest("mocked",{...a,requestId:r,pending:!0,startTime:s,rule:e});let c=null;if("redirect"===l){c=Math.random().toString(36).substring(7);const e={url:d,method:a.method,headers:a.headers||{},body:a.body,requestId:c,queryParams:(()=>{try{const e="undefined"!=typeof window?window.location.origin:"http://localhost",t=new URL(d,e).searchParams;return Object.fromEntries(t.entries())}catch{return{}}})(),requestHeaders:a.headers||{},requestBody:a.body,pending:!0,startTime:Date.now()};I.addRequest("mocked",e)}const m=(e,t,o,m={})=>{const u=Date.now()-s;if(i.rule.modificationActions?.modifyResponseHeaders?.enabled){let e="string"==typeof o?Object.fromEntries(o.split("\r\n").filter((e=>e)).map((e=>e.split(": ")))):o;e=N.applyResponseModifications(e,i.rule.modificationActions),o=e}I.addRequest("mocked",{...a,requestId:r,status:e,responseBody:t,responseHeaders:o,pending:!1,duration:u,rule:i.rule,...m}),"redirect"===l&&c&&I.addRequest("mocked",{url:d,method:a.method,requestId:c,status:e,responseBody:t,responseHeaders:o,pending:!1,duration:u,requestHeaders:a.headers||{},requestBody:a.body,...m}),n._capture(e,t,o,m)};if("timeout"===l)return m("Aborted","Timed out by rule",{},{aborted:!0}),void n._xhr.abort();if("redirect"===l){if(!d)return void m(0,"Redirect missing URL",{},{error:!0});n._xhr.open(a.method,d,!0)}else a.url!==t.url&&n._xhr.open(a.method,a.url,!0);a.headers&&Object.entries(a.headers).forEach((([e,t])=>{try{n._xhr.setRequestHeader(e,t)}catch(e){}})),n._xhr.addEventListener("abort",(()=>m("Aborted","Aborted",{},{aborted:!0})),{once:!0}),n._xhr.addEventListener("error",(()=>m(0,"Error",{},{error:!0})),{once:!0}),n._xhr.addEventListener("timeout",(()=>m("Timeout","Timeout",{},{timeout:!0})),{once:!0}),n._xhr.addEventListener("load",(()=>m(n._xhr.status,n._xhr.responseText,n._xhr.getAllResponseHeaders())),{once:!0}),o(a.body)},onMockMatch:(e,o,r,s)=>{const i=o.requestId,a=Date.now(),l=n(),d=new URL(o.url,window.location.origin);let c=`${M()}${e.url}${d.search}`,h={[p]:l,[u]:f,"x-mfm-adaptor":t};const g=_();g&&e._ack&&(h["x-mfm-key"]=`${g}-${e._ack}`),e?._ri_&&(h._ri_=e._ri_),h["x-mfm-internal"]="true";const b={...o.headers,...h};I.addRequest("mocked",{...o,requestId:i,pending:!0,startTime:a});const y=(e,t,n,s={})=>{const l=Date.now()-a;I.addRequest("mocked",{...o,requestId:i,status:e,responseBody:t,responseHeaders:n,pending:!1,duration:l,...s}),r._capture(e,t,n,s)};if(r._xhr.addEventListener("abort",(()=>y("Aborted","Aborted",{},{aborted:!0})),{once:!0}),r._xhr.addEventListener("error",(()=>y(0,"Error",{},{error:!0})),{once:!0}),r._xhr.addEventListener("timeout",(()=>y("Timeout","Timeout",{},{timeout:!0})),{once:!0}),t===m)(({actualUrl:e,url:t,method:n,headers:o,body:r,onSuccess:s,onError:i,rule:a})=>{const l=`${Date.now()}-${Math.random()}`,d=R(t);window.addEventListener("message",(function e(t){if(t.source!==window)return;const n=t.data;if("INTERCEPTED_RESPONSE"===n.type&&n.requestId===l){if(window.removeEventListener("message",e),n.response?.error)return i?.(n.response.message);const{body:t,status:o,headers:r}=n.response;s?.({body:t,status:o,headers:r})}})),window.postMessage({type:"REQUEST_INTERCEPTED",requestId:l,payload:{actualUrl:e,url:d,method:n,headers:o,body:r,credentials:"same-origin",mode:"cors",rule:a}},"*")})({actualUrl:o.url,url:c,method:o.method,headers:b,body:o.body,onSuccess:({body:e,status:t,headers:n})=>y(t,e,n||{}),onError:e=>y(0,e.message||"XHR Error",{},{error:!0})});else{const e=new window.XMLHttpRequest;e.open(o.method,c,!0);for(const t in b)e.setRequestHeader(t,b[t]);e.withCredentials=r.proxy.withCredentials,e.onload=()=>y(e.status,e.responseText,e.getAllResponseHeaders()),e.onerror=()=>y(0,"Network Error",{},{error:!0}),e.ontimeout=()=>y("Timeout","Request timed out",{},{timeout:!0}),e.send(o.body)}},onOtherRequest:(e,t,n)=>{const o="true"===e.headers?.["x-mfm-internal"],r=M(),s=e.url.startsWith(r);if("OPTIONS"===e.method||o||s)return n(e.body);const i=Date.now();I.addRequest("other",{...e,pending:!0,startTime:i});const a=(n,o,r,s={})=>{const a=Date.now()-i;I.addRequest("other",{...e,status:n,responseBody:o,responseHeaders:r,pending:!1,duration:a,...s}),t._capture(n,o,r,s)};t._xhr.addEventListener("abort",(()=>a("Aborted","Aborted",{},{aborted:!0})),{once:!0}),t._xhr.addEventListener("error",(()=>a(0,"Error",{},{error:!0})),{once:!0}),t._xhr.addEventListener("timeout",(()=>a("Timeout","Timeout",{},{timeout:!0})),{once:!0}),t._xhr.addEventListener("load",(()=>a(t._xhr.status,t._xhr.responseText,t._xhr.getAllResponseHeaders())),{once:!0}),t._xhr.addEventListener("readystatechange",(()=>{if(t._xhr.readyState>=2&&!t._captured){const n=t._xhr.status;if(n>0){const o=Date.now()-i;I.addRequest("other",{...e,status:n,responseHeaders:t._xhr.getAllResponseHeaders(),pending:t._xhr.readyState<4,duration:o})}}})),n(e.body)}})}(r,n),h&&g)I.mappings=i,I.rules=v,e?.(i,{_o:h,mk:g,_mck:y,_rules:v});else if(r){const o=I.getSavedMappings();if(o&&o.mappings&&o.mappings.length>0)return I.mappings=o.mappings,I.rules=o.meta?._rules||[],a(o.mappings),E(o.meta),I.updateMappings(o.mappings,o.meta),void e?.(o.mappings,o.meta);!function(t,n,o,r){q({method:"get",url:b,async:!1,headers:{[p]:t,[u]:f,"x-mfm-adaptor":n}},(t=>{if(t)try{const{di:r,iv:s,_o:i,_mck:l,mk:d,r:c}=t,m=T({di:r,iv:s},i);E({_o:i,mk:d,_mck:l,_rules:c}),m&&(a(m),n=m,o={_o:i,mk:d,_mck:l,_rules:c},I.saveMappings(n,o),I.updateMappings(n,o),e?.(n,o))}catch(e){return void r(new Error("Unable to fetch mocked apis"))}var n,o}),(e=>{console.log("Error in loading mocked apis"),r(e)})).request()}(r,n,0,t)}},checkIfApiToBeMocked:d,getMappings:l,doFetchMappings:(e,t)=>{S(r||I.token,n,((t,n)=>{I.updateMappings(t,n),e?.(t,n)}),t)},recheckWidgetVisibility:()=>{I.init()}}},D=o();D||(globalThis.mockforme=$);let F=$;D&&(F=e=>({run:()=>{}}));const H=F;export{H as mockforme};
1
+ var e={849:(e,t,n)=>{n.r(t),n.d(t,{default:()=>oe}),function(){try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.mfm-token-form{padding:24px;text-align:center;max-width:400px;margin:0 auto;width:100%;box-sizing:border-box}.mfm-token-link-container{margin-top:15px;font-size:.8rem}.mfm-token-link-container a{color:var(--mfm-primary)}.mfm-token-container{display:flex;flex-direction:column;align-items:center;padding:16px}.mfm-token-header{position:absolute;right:0;top:0}.mfm-token-logo{margin-bottom:16px;height:30px}.mfm-token-title{margin:0 0 8px;font-size:1.25rem;font-weight:600;color:var(--mfm-text)}.mfm-token-desc{color:var(--mfm-text-dim);font-size:.9rem;margin-bottom:24px;line-height:1.5}.mfm-token-input{text-align:center;height:44px;font-size:1rem;width:100%;border:1px solid var(--mfm-border);border-radius:6px;background:var(--mfm-input-bg);color:var(--mfm-text);padding:0 12px;outline:none;transition:all .2s}.mfm-token-input:focus{border-color:var(--mfm-primary);box-shadow:0 0 0 2px #3b82f633}.mfm-token-error{color:var(--mfm-error);font-size:.8rem;margin-top:8px;display:none;min-height:20px}.mfm-token-submit{margin-top:16px;width:100%;height:44px;background:var(--mfm-primary);color:#fff;border:none;border-radius:6px;font-size:.95rem;font-weight:500;cursor:pointer;transition:all .2s;display:flex;align-items:center;justify-content:center}.mfm-token-submit:hover{background:var(--mfm-primary-hover)}.mfm-token-submit:disabled{opacity:.7;cursor:not-allowed}.json-viewer{font-family:Consolas,Monaco,monospace;font-size:13px;line-height:1.6;padding:12px;border-radius:6px;overflow:auto}.json-viewer-light{background:#fff;color:#1f1f1f}.json-viewer-dark{background:#1e1e1e;color:#d4d4d4}.json-node{position:relative;padding-left:18px;white-space:nowrap;-webkit-user-select:text;user-select:text}.json-children{margin-left:18px;padding-left:8px;border-left:1px dotted rgba(128,128,128,.25)}.json-toggle{position:absolute;left:0;cursor:pointer;-webkit-user-select:none;user-select:none;width:14px;height:14px;display:flex;align-items:center;justify-content:center;color:#888;font-weight:700;font-size:14px;border:1px solid rgba(128,128,128,.3);border-radius:2px;line-height:1;background:#8080800d;top:4px}.json-toggle:hover{color:#007acc;border-color:#007acc;background:#007acc0d}.json-bracket,.json-closing-bracket{display:inline-block}.json-closing-bracket{margin-left:18px}.json-key{color:#922}.json-viewer-dark .json-key{color:#9cdcfe}.json-value.string{color:#0b7500}.json-value.number{color:#1a01cc}.json-value.boolean{color:#aa0d91}.json-value.null{color:#777}.json-viewer-dark .json-value.string{color:#ce9178}.json-viewer-dark .json-value.number{color:#b5cea8}.json-viewer-dark .json-value.boolean{color:#569cd6}.json-viewer-dark .json-value.null{color:gray}.json-node:hover{background:#0000000a;border-radius:4px}.json-viewer-dark .json-node:hover{background:#ffffff0f}.json-match{background-color:#ffff0059;border-radius:3px}.json-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;padding-bottom:8px;border-bottom:1px solid rgba(128,128,128,.15)}.json-toolbar-group,.json-search-group{display:flex;align-items:center;gap:4px}.json-toolbar .json-toolbar-group button{height:20px;width:20px}.json-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border-radius:4px;border:1px solid var(--mfm-primary);cursor:pointer;background:var(--mfm-bg);color:#555;transition:all .2s}.json-toolbar button:hover{background:#eee;border-color:#ccc;color:#000}.json-viewer-dark .json-toolbar button{background:#333;color:#bbb;border:1px solid #444}.json-viewer-dark .json-toolbar button:hover{background:#444;border-color:#555;color:#fff}.json-search-group{flex:1;max-width:200px}.json-toolbar input{flex:1;font-size:12px;height:28px;padding:0 8px;border-radius:4px;border:1px solid var(--mfm-primary);outline:none}.json-viewer-dark .json-toolbar input{background:#252525;color:#ddd;border:1px solid #444}.json-viewer::-webkit-scrollbar{width:8px;height:8px}.json-viewer::-webkit-scrollbar-thumb{background:#80808066;border-radius:4px}.json-viewer::-webkit-scrollbar-thumb:hover{background:#80808099}.json-viewer-fullscreen{position:fixed!important;top:0!important;left:1%!important;width:98%;height:100vh!important;z-index:1000000!important;display:flex!important;flex-direction:column!important;box-sizing:border-box!important;max-height:99%!important}body.json-viewer-body-fullscreen{overflow:hidden!important;height:100vh!important}.json-viewer-fullscreen .json-tree-container{flex:1!important;overflow:auto!important;max-height:500px!important}.json-viewer.json-is-searching .json-node{display:none!important}.json-viewer.json-is-searching .json-node.json-item-visible{display:block!important}.json-tree-container{overflow:auto;max-height:315px}pre{user-select:text;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text}.mfm-status.rule{color:var(--mfm-info)}.mfm-mod-pill{font-size:.7rem;color:var(--mfm-primary);background:#3b82f61a;padding:2px 6px;border-radius:10px;font-weight:500}.mfm-rule-info .mfm-rule-action{font-weight:700;color:var(--mfm-primary)}.mfm-rule-info .mfm-rule-value{color:var(--mfm-value)}.mfm-mapping-list-activity{padding:0;max-height:468px;overflow-y:scroll}.mfm-mapping-list-activity .mfm-spinner{display:flex;justify-content:center;margin:10px auto}.mfm-mapping-list-activity .mfm-request-item{padding:16px}.mfm-empty{padding:32px;text-align:center;color:var(--mfm-text-dim);font-size:.9rem}.mfm-spinner{width:24px;height:24px;border:2px solid var(--mfm-border);border-top-color:var(--mfm-primary);border-radius:50%;animation:mfm-spin .8s linear infinite}@keyframes mfm-spin{to{transform:rotate(360deg)}}.mfm-rule-info{font-size:.7rem;color:var(--mfm-text-dim);margin-top:4px;padding-left:4px}.mfm-mocked-apis-activity{padding:0;height:468px;overflow-y:scroll}.mfm-other-apis-activity{padding:0;max-height:468px}.mfm-request-item{display:flex;flex-direction:column;padding:12px 16px;border-bottom:1px solid var(--mfm-border);cursor:pointer;background:var(--mfm-bg);transition:background-color .2s ease}.mfm-request-item:hover{background:var(--mfm-hover)}.mfm-request-item.active{background:var(--mfm-active-bg)}.mfm-request-header{display:flex;justify-content:space-between;align-items:center}.mfm-flex-row{display:flex;align-items:center;gap:8px}.mfm-method{font-size:.75rem;font-weight:700;min-width:40px}.mfm-status{font-size:.8rem;margin-left:8px}.mfm-status.success{color:var(--mfm-success)}.mfm-status.error{color:var(--mfm-error)}.mfm-status.pending{color:var(--mfm-text-dim)}.mfm-url{font-size:.85rem;color:var(--mfm-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.4}.mfm-dropdown{position:relative;display:inline-block}.mfm-dropdown-content{display:none;position:absolute;right:0;top:100%;background-color:var(--mfm-bg);min-width:160px;box-shadow:0 4px 12px #00000026;z-index:1000;border:1px solid var(--mfm-border);border-radius:6px;overflow:hidden;margin-top:4px}.mfm-dropdown-content button{color:var(--mfm-text);padding:10px 16px;text-decoration:none;display:block;width:100%;text-align:left;background:none;border:none;cursor:pointer;font-size:.85rem;transition:background .1s}.mfm-dropdown-content button:hover{background-color:var(--mfm-hover)}.mfm-btn-icon{background:none;border:none;padding:4px;cursor:pointer;color:var(--mfm-text-dim);border-radius:4px;display:flex;align-items:center;justify-content:center}.mfm-btn-icon:hover{background:var(--mfm-hover);color:var(--mfm-text)}:root{--mfm-primary: #2563eb;--mfm-primary-hover: #1d4ed8;--mfm-bg: #ffffff;--mfm-surface: #f8fafc;--mfm-surface-bright: #f1f5f9;--mfm-text: #0f172a;--mfm-text-dim: #64748b;--mfm-border: #e2e8f0;--mfm-success: #10b981;--mfm-error: #ef4444;--mfm-warning: #f59e0b;--mfm-radius: 8px;--mfm-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--mfm-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px 1px rgb(0 0 0 / .1);--mfm-transition: all .15s ease-in-out;--mfm-value: #9b2418}#mfm-root{all:initial;display:block;position:fixed;bottom:24px;right:24px;z-index:2147483647;font-family:Inter,-apple-system,system-ui,sans-serif;color:var(--mfm-text);-webkit-user-select:none;user-select:none;box-sizing:border-box;font-size:12px}#mfm-root svg{fill:transparent}#mfm-root *{box-sizing:border-box;font-family:inherit;font-size:inherit}.mfm-widget-toggle{display:flex;align-items:center;background:#fff;padding:6px;border-radius:9999px;box-shadow:var(--mfm-shadow-lg);border:1px solid var(--mfm-border);gap:2px;cursor:pointer;transition:var(--mfm-transition)}.mfm-widget-toggle.hidden{display:none!important}.mfm-toggle-section{padding:6px;border-radius:50%;display:flex;align-items:center;justify-content:center;transition:var(--mfm-transition)}.mfm-toggle-section:hover{background:var(--mfm-surface-bright)}.mfm-toggle-logo img{width:32px;height:32px}.mfm-toggle-divider{width:1px;height:24px;background:var(--mfm-border);margin:0 4px}.mfm-main-container{position:fixed;bottom:24px;right:24px;width:370px;height:650px;background:var(--mfm-bg);border:1px solid var(--mfm-border);border-radius:var(--mfm-radius);box-shadow:var(--mfm-shadow-lg);display:flex;flex-direction:column;overflow:hidden;transition:var(--mfm-transition);transform-origin:bottom right}.mfm-main-container.hidden{opacity:0;transform:scale(.95) translateY(20px);pointer-events:none}.mfm-header{padding:12px 16px;margin-bottom:5px;background:#fff;display:flex;align-items:center;justify-content:space-between}.mfm-logo img{height:25px;width:auto}.mfm-tabs-container{flex:1;display:flex;flex-direction:column;overflow:hidden}.mfm-tabs-nav{display:flex;padding:0 16px;background:#fff;border-bottom:1px solid var(--mfm-border);gap:4px}.mfm-tab-btn{padding:10px 16px;background:transparent;border:1px solid transparent;border-bottom:none;color:var(--mfm-text-dim);cursor:pointer;font-size:15px!important;font-weight:500;margin-bottom:-1px;border-top-left-radius:4px;border-top-right-radius:4px;transition:var(--mfm-transition)}.mfm-tab-btn:hover{color:var(--mfm-text);background:var(--mfm-surface)}.mfm-tab-btn.active{color:var(--mfm-primary);background:#fff;border-color:var(--mfm-border);border-bottom:1px solid white;font-weight:700}.mfm-tab-toolbar{padding:12px 16px;border-bottom:1px solid var(--mfm-border);display:flex;flex-direction:column;gap:8px}.mfm-toolbar-row{display:flex;gap:8px;align-items:center}.mfm-input{height:36px;width:100%;padding:0 12px;border:1px solid var(--mfm-border);border-radius:6px;font-size:.875rem;outline:none}.mfm-input:focus{border-color:var(--mfm-primary);box-shadow:0 0 0 2px #2563eb1a}.mfm-btn-outline,.mfm-btn-icon{height:26px;padding:0 12px;background:transparent!important;border:none!important;border-radius:6px;font-size:.875rem;font-weight:500;cursor:pointer;color:var(--mfm-text-dim);transition:var(--mfm-transition);display:flex;align-items:center;justify-content:center}.back-btn{padding:0}.mfm-btn-outline:hover,.mfm-btn-icon:hover{background:var(--mfm-surface-bright)!important;color:var(--mfm-text)}.mfm-preserve-logs{display:flex;align-items:center;gap:1px;font-size:.75rem;color:var(--mfm-text-dim);cursor:pointer}.mfm-preserve-logs input{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.mfm-tab-content{flex:1;background:#fff;height:468px;overflow-y:scroll}.mfm-list{display:flex;flex-direction:column;max-height:460px;overflow-y:scroll}.mfm-empty{padding:60px 20px;text-align:center;color:var(--mfm-text-dim);font-size:.875rem}.mfm-request-item{padding:6px 16px;border-bottom:1px solid var(--mfm-border);cursor:pointer;transition:var(--mfm-transition)}.mfm-request-item.active{background:#eff6ff;border-left:3px solid var(--mfm-primary)}.mfm-request-item:hover{background:var(--mfm-surface)}.mfm-request-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}.mfm-method{font-size:.7rem;font-weight:700;padding:2px 6px;border-radius:4px;text-transform:uppercase}.mfm-method.get{color:#2563eb;background:#eff6ff}.mfm-method.post{color:#16a34a;background:#f0fdf4}.mfm-method.put{color:#d97706;background:#fffbeb}.mfm-method.delete{color:#dc2626;background:#fef2f2}.mfm-method.rule{color:#7c3aed;background:#f5f3ff}.mfm-status{font-size:.75rem;font-weight:600}.mfm-status.rule{color:#8b5cf6;background:#8b5cf61a}.mfm-status.success{color:#16a34a}.mfm-status.error{color:#dc2626}.mfm-status.pending{color:#64748b}.mfm-url{font-size:.8125rem;color:var(--mfm-text);white-space:nowrap;overflow-x:scroll;width:290px;max-width:290px;scrollbar-width:thin}.mfm-url .mfm-rule-condition{display:inline-block;margin-right:4px;border-radius:20px;font-size:inherit;background:#eee;padding:2px 5px}.mfm-url .mfm-rule-condition .mfm-rule-condition-type{font-weight:600;color:var(--mfm-primary)}.mfm-url .mfm-rule-condition .mfm-rule-condition-operator{font-weight:600;border-bottom:1px solid var(--mfm-primary);text-transform:capitalize}.mfm-url .mfm-rule-condition .mfm-rule-condition-key-value{color:var(--mfm-value)}.mfm-rule-list .mfm-url{white-space:auto!important;overflow-x:scroll!important;text-overflow:inherit!important;scrollbar-width:thin}.mfm-bottomsheet{position:absolute;top:60px;left:0;right:0;bottom:0;background:#fff;z-index:1100;display:flex;flex-direction:column;transform:translate(100%);transition:transform .25s ease-in-out}.mfm-bottomsheet.active{transform:translate(0)}.mfm-bottomsheet-header{padding:12px 16px;border-bottom:1px solid var(--mfm-border);display:flex;align-items:center;gap:5px}.mfm-bottomsheet-content{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column}.mfm-detail-tabs{display:flex;border-bottom:1px solid var(--mfm-border);margin:16px -16px;padding:0 16px;gap:8px}.mfm-detail-tab-btn{padding:8px 12px;background:transparent;border:none;border-bottom:2px solid transparent;color:var(--mfm-text-dim);font-size:.8rem;font-weight:600;cursor:pointer;transition:var(--mfm-transition)}.mfm-detail-tab-btn:hover{color:var(--mfm-text)}.mfm-detail-tab-btn.active{color:var(--mfm-primary);border-bottom-color:var(--mfm-primary)}.mfm-detail-body{flex:1}.mfm-tab-content::-webkit-scrollbar,.mfm-bottomsheet-content::-webkit-scrollbar{width:8px}.mfm-tab-content::-webkit-scrollbar-track,.mfm-bottomsheet-content::-webkit-scrollbar-track{background:transparent}.mfm-tab-content::-webkit-scrollbar-thumb,.mfm-bottomsheet-content::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px;border:2px solid white}.mfm-tab-content::-webkit-scrollbar-thumb:hover,.mfm-bottomsheet-content::-webkit-scrollbar-thumb:hover{background:#94a3b8}.mfm-detail-section{margin-bottom:24px}.mfm-detail-title{font-size:.75rem;font-weight:600;text-transform:uppercase;color:var(--mfm-text-dim);margin-bottom:8px;display:flex;justify-content:space-between}.mfm-detail-content{background:var(--mfm-bg);padding:12px;border-radius:6px;font-family:JetBrains Mono,Menlo,monospace;font-size:.8rem;border:1px solid var(--mfm-primary);word-break:break-all;max-height:500px;overflow-y:auto}.mfm-copy-btn{background:var(--mfm-primary);border:none;color:#fff;padding:4px 8px;border-radius:4px;font-size:.7rem;cursor:pointer;font-weight:600}.mfm-dropdown{position:relative}.mfm-dropdown-content{display:none;position:absolute;top:100%;right:0;background:#fff;min-width:140px;box-shadow:var(--mfm-shadow-lg);border:1px solid var(--mfm-border);border-radius:8px;z-index:1000;overflow:hidden}.mfm-dropdown-content.show{display:block}.mfm-dropdown-content button{width:100%;padding:10px 16px;text-align:left;background:transparent;border:none;font-size:.8125rem;color:var(--mfm-text);cursor:pointer}.mfm-dropdown-content button:hover{background:var(--mfm-surface)}.mfm-btn-primary{background:var(--mfm-primary);color:#fff;border:none;border-radius:8px;padding:12px 24px;font-weight:600;cursor:pointer;transition:var(--mfm-transition)}.mfm-btn-primary:hover{background:var(--mfm-primary-hover)}.mfm-header-actions{display:flex;align-items:center}.mfm-switch{position:relative;display:inline-block;width:32px;height:20px;margin-right:12px}.mfm-switch input{opacity:0;width:0;height:0}.mfm-slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#cbd5e1;transition:.4s;border-radius:34px}.mfm-slider:before{position:absolute;content:"";height:16px;width:16px;left:2px;bottom:2px;background-color:#fff;transition:.4s;border-radius:50%}input:checked+.mfm-slider{background-color:var(--mfm-primary)}input:checked+.mfm-slider:before{transform:translate(12px)}.mfm-spinner{width:14px;height:14px;border:2px solid #cbd5e1;border-bottom-color:var(--mfm-primary);border-radius:50%;display:inline-block;box-sizing:border-box;animation:mfm-rotation 1s linear infinite}@keyframes mfm-rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.mfm-request-item.pending-item{cursor:default;opacity:.8}.mfm-snackbar{visibility:hidden;min-width:250px;background-color:#333;color:#fff;text-align:center;border-radius:8px;padding:12px;position:fixed;z-index:2000;left:50%;bottom:30px;transform:translate(-50%);font-size:.9rem;box-shadow:0 4px 6px #0000001a;opacity:0;transition:opacity .3s,bottom .3s}.mfm-snackbar.show{visibility:visible;opacity:1;bottom:50px}.clear-btn svg{color:var(--mfm-text-dim)}#mfm-root .mfm-bulk-mock-popup{position:absolute;top:5px;left:5px;right:5px;bottom:5px;background:#fff;z-index:1200;border-radius:var(--mfm-radius);box-shadow:var(--mfm-shadow-lg);display:none;flex-direction:column;border:1px solid var(--mfm-border)}#mfm-root .mfm-bulk-mock-popup.active{display:flex}#mfm-root .mfm-bulk-mock-container{display:flex;flex-direction:column;height:100%;padding:16px;overflow:hidden}#mfm-root .mfm-bulk-mock-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;flex-shrink:0}#mfm-root .mfm-bulk-mock-header h3{margin:0;font-size:1.1rem;color:var(--mfm-text)}#mfm-root .mfm-bulk-mock-header-actions{display:flex;align-items:center;gap:8px}#mfm-root #mfm-bulk-save-btn{padding:6px 12px;font-size:.8rem;background:var(--mfm-primary);color:#fff;border:none;border-radius:4px;cursor:pointer}#mfm-root #mfm-bulk-save-btn:disabled{opacity:.5;background:var(--mfm-text-dim);cursor:not-allowed}#mfm-root .mfm-bulk-mock-filters{display:flex;flex-direction:column;gap:12px;margin-bottom:16px;padding-bottom:16px;border-bottom:1px solid var(--mfm-border);flex-shrink:0}#mfm-root .mfm-bulk-mock-list{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:4px}#mfm-root .mfm-bulk-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:6px;cursor:pointer;transition:var(--mfm-transition)}#mfm-root .mfm-bulk-item:hover{background:var(--mfm-surface)}#mfm-root .mfm-bulk-item .mfm-url{flex:1;font-size:.8rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:auto}#mfm-root .mfm-toolbar-dropdown{position:relative;display:flex;align-items:center}#mfm-root .mfm-toolbar-dropdown .mfm-dropdown-menu{display:none;position:absolute;top:100%;right:0;background:#fff;min-width:120px;box-shadow:var(--mfm-shadow-lg);border:1px solid var(--mfm-border);border-radius:8px;z-index:1001;margin-top:4px}#mfm-root .mfm-toolbar-dropdown.show .mfm-dropdown-menu{display:block}#mfm-root .mfm-dropdown-item{width:100%;padding:10px 16px;text-align:left;background:transparent;border:none;font-size:.85rem;color:var(--mfm-text);cursor:pointer}#mfm-root .mfm-dropdown-item:hover{background:var(--mfm-surface)}#mfm-root .mfm-bulk-mock-popup{background:#fffffff2;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.2)}#mfm-root .mfm-bulk-item.selected{background:#2563eb0d;border-color:#2563eb1a}#mfm-root .mfm-bulk-checkbox{width:16px;height:16px;accent-color:var(--mfm-primary)}#mfm-root .mfm-bulk-mock-header h3{font-weight:700;letter-spacing:-.01em}#mfm-root .mfm-bulk-size{font-size:.7rem;color:var(--mfm-text-dim);margin-left:auto;padding:0 8px;font-family:inherit}#mfm-root .mfm-url-container{display:flex;flex-direction:column;overflow:hidden;flex:1;gap:2px}#mfm-root .mfm-url-path{font-size:.8rem;font-weight:500;color:var(--mfm-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}#mfm-root .mfm-url-domain{font-size:.7rem;color:var(--mfm-text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.mfm-bulk-item-actions{display:flex;gap:8px;margin-left:auto}.mfm-btn-text{background:transparent;border:none;color:var(--mfm-primary);font-size:.75rem;cursor:pointer;padding:2px 6px;border-radius:4px}.mfm-btn-text:hover{background:#2563eb1a}.mfm-response-editor{position:absolute;top:0;left:0;right:0;bottom:0;background:#fff;z-index:1300;display:none;flex-direction:column;padding:16px}.mfm-response-editor.active{display:flex}.mfm-response-editor textarea{flex:1;width:100%;padding:12px;border:1px solid var(--mfm-border);border-radius:6px;font-family:JetBrains Mono,Menlo,monospace;font-size:.8rem;resize:none;margin:12px 0}.mfm-editor-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.mfm-editor-footer{display:flex;justify-content:flex-end;gap:12px}#mfm-root .mfm-bulk-mock-list::-webkit-scrollbar{width:6px}#mfm-root .mfm-bulk-mock-list::-webkit-scrollbar-track{background:transparent}#mfm-root .mfm-bulk-mock-list::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}.mfm-switch-with-label{display:flex;align-items:center;gap:4px;border:1px solid var(--mfm-border);border-radius:20px;padding:2px 2px 2px 5px}.mfm-switch-with-label .mfm-label{font-weight:700}')),document.head.appendChild(e)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();var o=(e=>(e[e.NONE=0]="NONE",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(o||{}),r=(e=>(e.MFM_REQ_MAPPINGS="MFM_REQ_MAPPINGS",e.MFM_REQ_SAVED_MAPPINGS="MFM_REQ_SAVED_MAPPINGS",e.MFM_DEL_CLIENT_TOKEN="MFM_DEL_CLIENT_TOKEN",e.MFM_SUBMIT_TOKEN="MFM_SUBMIT_TOKEN",e.MFM_TOGGLE_INTERCEPTION="MFM_TOGGLE_INTERCEPTION",e.MFM_RES_MAPPINGS="MFM_RES_MAPPINGS",e.MFM_REQ="MFM_REQ",e.MFM_RES="MFM_RES",e.MFM_TOKEN_ERROR="MFM_TOKEN_ERROR",e.MFM_TOKEN_API_FAILED="MFM_TOKEN_API_FAILED",e.MFM_LOG_INFO="MFM_LOG_INFO",e.MFM_LOG_WARN="MFM_LOG_WARN",e.MFM_LOG_ERROR="MFM_LOG_ERROR",e))(r||{});function s(e,t,n="*",o){window.postMessage(function(e,t,n){const o={type:e};return n&&(o.source=n),void 0!==t&&(o.payload=t),o}(e,t,o),n)}const i=new class{constructor(){this.level=o.NONE}setLevel(e){this.level=e}normalizeArgs(e){return e.map((e=>{try{return void 0===e?"undefined":"string"==typeof e||"object"==typeof e?e:String(e)}catch{return"[Unserializable]"}}))}postLog(e,t){s(e,this.normalizeArgs(t),"*","mfm-widget-logger")}info(...e){this.level<o.INFO||(console.log("[MFM Info]",...e),this.postLog(r.MFM_LOG_INFO,e))}warn(...e){this.level<o.WARN||(console.warn("[MFM Warn]",...e),this.postLog(r.MFM_LOG_WARN,e))}error(...e){this.level<o.ERROR||(console.error("[MFM Error]",...e),this.postLog(r.MFM_LOG_ERROR,e))}},a=new Map,l=new Set;let d=!1;function c(e){return e!==r.MFM_LOG_INFO&&e!==r.MFM_LOG_WARN&&e!==r.MFM_LOG_ERROR}function m(){d||"undefined"==typeof window||(window.addEventListener("message",p),d=!0)}function u(e,t){c(e)&&i.info(`[postMessage] ${e}`,t),s(e,t)}function p(e){if(!function(e){if(!e||"object"!=typeof e)return!1;if(!("type"in e))return!1;const t=e.type;return"string"==typeof t&&t.startsWith("MFM_")}(e.data))return;const t=e.data;c(t.type)&&i.info(`[onMessage] ${t.type}`,t.payload),l.forEach((e=>e(t)));const n=a.get(t.type);n&&n.forEach((e=>{e(t.payload)}))}function f(e,t){if(!e)return t;try{return JSON.parse(e)}catch{return t}}const h={state:function(){var e,t,n,o,r,s,i,a,l,d,c,m;const u=f(sessionStorage.getItem("MFM_SAVED_REQUESTS"),[]).filter((e=>{var t;return!((null==(t=e.request)?void 0:t.url)||"").includes("/3f4eae522b")})).map((e=>e.response?e:{...e,response:{statusCode:0,statusText:"Disconnected",body:"[Request terminated due to page refresh or network interruption]",headers:{},endTime:new Date(e.timestamp||Date.now()).toISOString()}})),p=f(localStorage.getItem("MFM_CONFIG"),{}),h={enabled:!0,isInterceptEnabled:"false"!==sessionStorage.getItem("MFM_IS_INTERCEPT_ENABLED"),isOpen:p.isOpen||!1,token:localStorage.getItem("MFM_TOKEN")||null,isTokenValidating:!1,isTokenLoading:!1,mappings:{apis:[],rules:[]},isMappingsLoading:!1,requests:u.filter((e=>!e.request.url.includes("mockforme.com"))),ui:{selectedTab:p.selectedTab||"MOCKED",tokenError:null,activeDropdownId:null,detailTab:p.detailTab||"HEADERS",tabConfigs:{MAPPINGS:{searchText:"",selectedRule:(null==(t=null==(e=p.tabConfigs)?void 0:e.MAPPINGS)?void 0:t.selectedRule)||null,isDetailOpen:Boolean(null==(o=null==(n=p.tabConfigs)?void 0:n.MAPPINGS)?void 0:o.isDetailOpen)},MOCKED:{searchText:"",selectedRequestId:(null==(s=null==(r=p.tabConfigs)?void 0:r.MOCKED)?void 0:s.selectedRequestId)||null,isPreserveLogs:"true"===localStorage.getItem("MFM_PRESERVE_LOGS_MOCKED"),isDetailOpen:Boolean(null==(a=null==(i=p.tabConfigs)?void 0:i.MOCKED)?void 0:a.isDetailOpen)},OTHER:{searchText:"",selectedRequestId:(null==(d=null==(l=p.tabConfigs)?void 0:l.OTHER)?void 0:d.selectedRequestId)||null,isPreserveLogs:"true"===localStorage.getItem("MFM_PRESERVE_LOGS_OTHER"),isDetailOpen:Boolean(null==(m=null==(c=p.tabConfigs)?void 0:c.OTHER)?void 0:m.isDetailOpen)}},isBulkMockOpen:!1}};return function(e){const t=e.ui.selectedTab;if("MAPPINGS"===t)return;const n=e.ui.tabConfigs[t];if(!n.isDetailOpen||!n.selectedRequestId)return;e.requests.some((e=>String(e.requestId)===String(n.selectedRequestId)))||(n.isDetailOpen=!1,n.selectedRequestId=null,e.ui.selectedTab="MOCKED")}(h),h}(),listeners:[],_notifyTimer:null,subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}},notify(){this._notifyTimer||(this._notifyTimer=requestAnimationFrame((()=>{var e;this._notifyTimer=null,this.listeners.forEach((e=>e(this.state))),document.dispatchEvent(new CustomEvent("MFM_STATE_CHANGE",{detail:this.state})),e=this.state,localStorage.setItem("MFM_CONFIG",JSON.stringify({isOpen:e.isOpen,selectedTab:e.ui.selectedTab,detailTab:e.ui.detailTab,activeDropdownId:e.ui.activeDropdownId,tabConfigs:{MAPPINGS:{selectedRule:e.ui.tabConfigs.MAPPINGS.selectedRule,isDetailOpen:e.ui.tabConfigs.MAPPINGS.isDetailOpen},MOCKED:{selectedRequestId:e.ui.tabConfigs.MOCKED.selectedRequestId,isDetailOpen:e.ui.tabConfigs.MOCKED.isDetailOpen},OTHER:{selectedRequestId:e.ui.tabConfigs.OTHER.selectedRequestId,isDetailOpen:e.ui.tabConfigs.OTHER.isDetailOpen}}}))})))},update(e,t){const n=e.split(".");let o=this.state;for(let e=0;e<n.length-1;e+=1){const t=o[n[e]];if(!t||"object"!=typeof t)return;o=t}o[n[n.length-1]]=t,this.notify()},set(e,t){this.state[e]=t,this.notify()}};let b=[];function g(e){var t,n;const o=null==(t=h.state.ui.tabConfigs.MOCKED)?void 0:t.isPreserveLogs,r=null==(n=h.state.ui.tabConfigs.OTHER)?void 0:n.isPreserveLogs,s=e.filter((e=>{const t="MOCKED"===e.interceptionType;return t&&o||!t&&r}));s.length>0?sessionStorage.setItem("MFM_SAVED_REQUESTS",JSON.stringify(s)):sessionStorage.removeItem("MFM_SAVED_REQUESTS")}function y(e){var t;const n=(null==(t=e.request)?void 0:t.url)||"";if(n.includes("/3f4eae522b")||n.includes("mockforme.com"))return;if(h.state.isTokenValidating)return i.info("Queuing request during token validation",e.requestId),void b.push(e);const o=function(e){const t=[...h.state.requests],n=t.findIndex((t=>t.requestId===e.requestId));if(n>-1){const o=t[n];t[n]={...o,...e,rule:e.rule||o.rule}}else t.push(e);return t.length>100?t.slice(t.length-100):t}(e);h.set("requests",o),g(o)}const v={toggleWidget(){h.update("isOpen",!h.state.isOpen)},setTab(e){h.update("ui.selectedTab",e)},deleteToken(){i.warn("Deleting Client Token"),h.update("token",null),h.update("isTokenValidating",!1),h.update("isTokenLoading",!1),h.update("ui.tokenError",null),this.closeDetails(),h.set("requests",[]),this.clearQueue(),sessionStorage.removeItem("MFM_SAVED_REQUESTS"),localStorage.removeItem("MFM_TOKEN"),u(r.MFM_DEL_CLIENT_TOKEN)},submitToken(e){e?(h.update("ui.tokenError",null),h.update("isTokenValidating",!0),h.update("isTokenLoading",!0),localStorage.setItem("MFM_TOKEN_TEMP",e),(e=>{u(r.MFM_SUBMIT_TOKEN,{token:e})})(e)):h.update("ui.tokenError","Token is required")},reloadMappings(){i.info("Reloading Mappings"),h.update("ui.tokenError",null),h.update("isMappingsLoading",!0),u(r.MFM_REQ_MAPPINGS)},fetchSavedMappings(){i.info("Fetching Saved Mappings"),u(r.MFM_REQ_SAVED_MAPPINGS)},toggleInterception(e){const t=void 0!==e?e:!h.state.isInterceptEnabled;t!==h.state.isInterceptEnabled&&(i.info("Toggling Interception:",t),h.update("isInterceptEnabled",t),sessionStorage.setItem("MFM_IS_INTERCEPT_ENABLED",String(t)),(e=>{u(r.MFM_TOGGLE_INTERCEPTION,{enabled:e})})(t))},addRequest(e){y(e)},clearRequests(){const e=h.state.ui.selectedTab,t=h.state.requests.filter((t=>("MOCKED"===t.interceptionType?"MOCKED":"OTHER")!==e));h.set("requests",t),sessionStorage.setItem("MFM_SAVED_REQUESTS",JSON.stringify(t))},setPreserveLogs(e){const t=h.state.ui.selectedTab;"MAPPINGS"!==t&&(h.update(`ui.tabConfigs.${t}.isPreserveLogs`,e),localStorage.setItem(`MFM_PRESERVE_LOGS_${t}`,String(e)),g(h.state.requests))},setSearchText(e){const t=h.state.ui.selectedTab;h.update(`ui.tabConfigs.${t}.searchText`,e)},selectRequest(e){const t=h.state.ui.selectedTab;"MAPPINGS"!==t&&(h.update(`ui.tabConfigs.${t}.selectedRequestId`,e),h.update(`ui.tabConfigs.${t}.isDetailOpen`,!0),h.update("ui.detailTab","HEADERS"))},selectRule(e){h.update("ui.tabConfigs.MAPPINGS.selectedRule",e),h.update("ui.tabConfigs.MAPPINGS.isDetailOpen",!0),h.update("ui.detailTab","HEADERS")},minimizeDetails(){const e=h.state.ui.selectedTab;h.update(`ui.tabConfigs.${e}.isDetailOpen`,!1)},closeDetails(){const e=h.state.ui.selectedTab;h.update(`ui.tabConfigs.${e}.isDetailOpen`,!1),"MAPPINGS"!==e?h.update(`ui.tabConfigs.${e}.selectedRequestId`,null):h.update("ui.tabConfigs.MAPPINGS.selectedRule",null)},resetUnavailableRequestDetails(e){h.update(`ui.tabConfigs.${e}.isDetailOpen`,!1),h.update(`ui.tabConfigs.${e}.selectedRequestId`,null),h.update("ui.selectedTab","MOCKED"),h.update("ui.detailTab","HEADERS")},setDetailTab(e){h.update("ui.detailTab",e)},setOpenDropdown(e){const t=h.state.ui.activeDropdownId;h.update("ui.activeDropdownId",t===e?null:e)},clearOpenDropdown(){h.state.ui.activeDropdownId&&h.update("ui.activeDropdownId",null)},setBulkMockOpen(e){h.update("ui.isBulkMockOpen",e)},flushQueue(){!function(){i.info("Flushing request queue",b.length);const e=[...b];b=[],e.forEach((e=>y(e)))}()},clearQueue(){i.warn("Clearing request queue"),b=[]}};function x(e,t="default",n=3e3){if(!document.body)return;let o=document.getElementById("mfm-snackbar");o||(o=document.createElement("div"),o.id="mfm-snackbar",o.className="mfm-snackbar",document.body.appendChild(o)),o.textContent=e,o.className=("mfm-snackbar show "+("error"===t?"mfm-snackbar-error":"")).trim(),setTimeout((()=>{o&&(o.className=o.className.replace("show","").trim())}),n)}function k(){const e=document.querySelector("#mfm-reload-header");e&&(e.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><polyline points="21 3 21 8 16 8"></polyline></svg>',e.style.pointerEvents="auto")}function w(e,t){i.error(`Token Error (${e})`,t),h.update("ui.tokenError",(null==t?void 0:t.message)||"Something went wrong"),h.update("isTokenLoading",!1),h.update("isMappingsLoading",!1),h.update("isTokenValidating",!1),e===r.MFM_TOKEN_ERROR&&(h.update("token",null),v.clearQueue(),localStorage.removeItem("MFM_TOKEN"),localStorage.removeItem("MFM_TOKEN_TEMP")),k(),x((null==t?void 0:t.message)||"Request failed","error")}const E="https://www.mockforme.com/assets/images/logo.png",M='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:block;"><circle cx="12" cy="12" r="10"></circle><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"></line></svg>',q='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',S='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>';class R{constructor(e){this.input=null,this.submitBtn=null,this.errorDisplay=null,this.closeBtn=null,this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-token-form",this.unsubscribe=h.subscribe(this.render.bind(this)),this.init()}init(){this.renderStructure(),this.bindEvents(),this.render(h.state),this.parent.appendChild(this.element)}closeTokenForm(){v.toggleWidget()}renderStructure(){this.element.innerHTML=`\n <div class="mfm-token-header">\n <button class="mfm-btn-icon" id="mfm-close-token-form" title="Close Widget">\n ${q}\n </button>\n </div>\n <div class="mfm-token-container">\n <img src="${E}" alt="MockForMe Logo" class="mfm-token-logo">\n <h3 class="mfm-token-title">Welcome to MockForMe</h3>\n <p class="mfm-token-desc">\n Paste your token below to start mocking and intercepting API requests.\n </p>\n <input type="text" class="mfm-input mfm-token-input" placeholder="Enter Client Token...">\n <div class="mfm-token-error"></div>\n <button class="mfm-token-submit">Continue</button>\n <div class="mfm-token-link-container">\n <a href="https://dashboard.mockforme.com/user/token" target="_blank" class="mfm-token-link">Get your access token</a>\n </div>\n </div>\n `,this.input=this.element.querySelector(".mfm-token-input"),this.submitBtn=this.element.querySelector(".mfm-token-submit"),this.errorDisplay=this.element.querySelector(".mfm-token-error"),this.closeBtn=this.element.querySelector("#mfm-close-token-form")}bindEvents(){this.input&&(this.input.oninput=()=>{h.state.ui.tokenError&&h.update("ui.tokenError",null)}),this.submitBtn&&(this.submitBtn.onclick=()=>{var e;const t=null==(e=this.input)?void 0:e.value.trim();t&&v.submitToken(t)}),this.closeBtn&&(this.closeBtn.onclick=()=>{this.closeTokenForm()})}render(e){if(!this.input||!this.submitBtn||!this.errorDisplay)return;const{tokenError:t}=e.ui,{isTokenLoading:n}=e;t?(this.errorDisplay.textContent=t,this.errorDisplay.style.display="block",this.input.style.borderColor="var(--mfm-error)"):(this.errorDisplay.style.display="none",this.input.style.borderColor=""),n?(this.input.disabled=!0,this.submitBtn.disabled=!0,this.submitBtn.innerHTML='<div class="mfm-spinner"></div>'):(this.input.disabled=!1,this.submitBtn.disabled=!1,this.submitBtn.innerHTML="Continue")}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}function _(e,t){if(!document.body)return;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy")&&t()}finally{n.remove()}}function T(e,t){if(C(e),!t)return;e.container.classList.add("json-is-searching");const n=new RegExp(t,"i");Array.from(e.treeContainer.querySelectorAll(".json-node")).forEach((t=>{const o=t.dataset.searchKey||"",r=t.dataset.searchValue||"";(n.test(o)||n.test(r))&&(t.classList.add("json-item-visible","json-match"),function(e){const t=e.querySelector(":scope > .json-children");if(!t)return;t.querySelectorAll(".json-node").forEach((e=>{e.classList.add("json-item-visible")})),t.style.display="block";const n=e.querySelector(":scope > .json-toggle");n&&(n.textContent="-")}(t),function(e,t){let n=t.parentElement;for(;n&&n!==e.treeContainer;){if(n.classList.contains("json-node")&&n.classList.add("json-item-visible"),n.classList.contains("json-children")){n.style.display="block";const e=n.parentElement.querySelector(":scope > .json-toggle");e&&(e.textContent="-")}n=n.parentElement}}(e,t))}))}function C(e){e.container.classList.remove("json-is-searching"),e.treeContainer.querySelectorAll(".json-match").forEach((e=>{e.classList.remove("json-match")})),e.treeContainer.querySelectorAll(".json-item-visible").forEach((e=>{e.classList.remove("json-item-visible")}))}function O(e,t,n=null,o=0){const r=document.createElement("div");if(r.className="json-node",null!==n){const e=document.createElement("span");e.className="json-key",e.textContent=`"${n}": `,r.appendChild(e),r.dataset.searchKey=String(n).toLowerCase()}if("object"==typeof t&&null!==t)return function(e,t,n,o){const r=Array.isArray(n),s=o<e.options.expandLevel,i=document.createElement("span");i.className="json-toggle",i.textContent=s?"-":"+";const a=document.createElement("span");a.className="json-bracket",a.textContent=r?"[":"{";const l=document.createElement("div");l.className="json-children",l.style.display=s?"block":"none",i.addEventListener("click",(()=>{const e="none"===l.style.display;l.style.display=e?"block":"none",i.textContent=e?"-":"+"})),t.appendChild(i),t.appendChild(a),Object.entries(n).forEach((([t,n])=>{const r=O(e,n,t,o+1);l.appendChild(r)})),t.appendChild(l);const d=document.createElement("div");d.className="json-closing-bracket",d.textContent=r?"]":"}",t.appendChild(d)}(e,r,t,o),r;const s=document.createElement("span");s.className="json-value "+typeof t;const i="string"==typeof t?`"${t}"`:String(t);return s.textContent=i,r.appendChild(s),r.dataset.searchValue=i.toLowerCase(),r}function I(e,t,n){const o=document.createElement("button");return o.innerHTML=e,o.title=t,o.onclick=n,o}class L{constructor(e,t={}){if(!e)throw new Error("Container element required");this.container=e,this.options={expandLevel:t.expandLevel??1,theme:t.theme??"light",toolbar:t.toolbar??!0,searchable:t.searchable??!0,debounceTime:t.debounceTime??300},this.data=null,this.searchTimer=null,this.container.classList.add("json-viewer",`json-viewer-${this.options.theme}`),this.options.toolbar&&function(e,t){e.toolbar=document.createElement("div"),e.toolbar.className="json-toolbar";const n=document.createElement("div");n.className="json-toolbar-group",n.appendChild(I(t.expand,"Expand All",(()=>e.expandAll()))),n.appendChild(I(t.collapse,"Collapse All",(()=>e.collapseAll()))),e.fullscreenBtn=I(t.fullscreen,"Fullscreen",(()=>e.toggleFullscreen())),e.copyBtn=I(t.copy,"Copy JSON",(()=>e.copy())),n.appendChild(e.fullscreenBtn),n.appendChild(e.copyBtn),e.toolbar.appendChild(n),e.options.searchable&&e.toolbar.appendChild(function(e,t){const n=document.createElement("div");n.className="json-search-group";const o=document.createElement("input");o.placeholder="Search...",o.oninput=t=>{clearTimeout(e.searchTimer),e.searchTimer=setTimeout((()=>{const n=t.target;T(e,n.value)}),e.options.debounceTime)};const r=I(t,"Clear Search",(()=>{o.value="",C(e)}));return n.appendChild(o),n.appendChild(r),n}(e,t.clear)),e.container.appendChild(e.toolbar)}(this,{expand:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>',collapse:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>',fullscreen:S,copy:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1-2-2h9a2 2 0 0 1 2 2v1"></path></svg>',clear:M}),this.treeContainer=document.createElement("div"),this.treeContainer.className="json-tree-container",this.container.appendChild(this.treeContainer)}toggleFullscreen(){const e=this.container.classList.toggle("json-viewer-fullscreen");document.body.classList.toggle("json-viewer-body-fullscreen",e),this.fullscreenBtn&&(this.fullscreenBtn.innerHTML=e?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"></path></svg>':S,this.fullscreenBtn.title=e?"Minimize":"Fullscreen")}render(e){this.data=e,this.treeContainer.innerHTML="",this.root=O(this,e,null,0),this.treeContainer.appendChild(this.root)}copy(){!function(e){if(!e.data)return;const t=JSON.stringify(e.data,null,2),n=()=>{if(!e.copyBtn)return;const t=e.copyBtn.innerHTML;e.copyBtn.innerHTML="&#10003;",setTimeout((()=>{e.copyBtn.innerHTML=t}),2e3)};navigator.clipboard&&"function"==typeof navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(n).catch((()=>{_(t,n)})):_(t,n)}(this)}expandAll(){var e;(e=this).treeContainer.querySelectorAll(".json-children").forEach((e=>{e.style.display="block"})),e.treeContainer.querySelectorAll(".json-toggle").forEach((e=>{e.textContent="-"}))}collapseAll(){var e;(e=this).treeContainer.querySelectorAll(".json-children").forEach((e=>{e.style.display="none"})),e.treeContainer.querySelectorAll(".json-toggle").forEach((e=>{e.textContent="+"}))}search(e){T(this,e)}clearSearch(){C(this)}}function N(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function A(e,t,n){const o=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}(n);if(!o||"object"!=typeof o)return;const r=e.querySelector(t);r&&(r.innerHTML="",new L(r,{expandLevel:1,theme:"light",toolbar:!0,searchable:!0}).render(o))}function $(e){const t={},n=e.modificationActions;return n&&Object.entries(n).forEach((([e,n])=>{(null==n?void 0:n.enabled)&&(t[e]=n)})),{requestId:`rule_${String(e.ruleName||e.condition||"unknown")}`,interceptionType:"RULE",request:{method:"RULE",url:String(e.condition||e.ruleName||""),headers:n||{},body:t},response:{statusCode:0,body:e}}}function j(e){var t,n,o,r;const{selectedTab:s,detailTab:i,tabConfigs:a}=h.state.ui,l=a[s];if(!l||!l.isDetailOpen)return e.sheet.classList.remove("active"),e.isUrlExpanded=!1,e.responseBodyMode="TEXT",e.prevState={},e;const{req:d,isRule:c}=function(){const{selectedTab:e,tabConfigs:t}=h.state.ui,n=t[e],o=n.selectedRequestId||null,r=n.selectedRule||null;return"MAPPINGS"===e&&r?{req:$(r),isRule:!0}:"MAPPINGS"!==e&&o?{req:h.state.requests.find((e=>String(e.requestId)===String(o)))||null,isRule:!1}:{req:null,isRule:!1}}();if(!d)return"MOCKED"!==s&&"OTHER"!==s||v.resetUnavailableRequestDetails(s),e.sheet.classList.remove("active"),e;if(function(e,t){const{selectedTab:n,detailTab:o,tabConfigs:r}=h.state.ui,s=r[n];return e.prevState.selectedTab===n&&e.prevState.selectedRule===s.selectedRule&&e.prevState.selectedRequestId===s.selectedRequestId&&e.prevState.reqObj===t&&e.prevState.detailTab===o&&e.prevState.isUrlExpanded===e.isUrlExpanded&&e.prevState.responseBodyMode===e.responseBodyMode}(e,d))return e;!function(e,t){const{selectedTab:n,detailTab:o,tabConfigs:r}=h.state.ui,s=r[n];e.prevState={selectedTab:n,selectedRule:s.selectedRule,selectedRequestId:s.selectedRequestId,reqObj:t,detailTab:o,isUrlExpanded:e.isUrlExpanded,responseBodyMode:e.responseBodyMode}}(e,d),function(e,t,n){var o;const r=t.request.method||"REQ",s=n?"RULE":(null==(o=t.response)?void 0:o.statusCode)??"Pending",i=function(e,t,n,o){return e?"pending":t?"success":n?"error":o?"rule":""}("Pending"===s,"number"==typeof s&&s>=200&&s<300,"number"==typeof s&&(0===s||s>=400),n),a=0===s?"Error":s,l=n?"":`<span class="mfm-method ${String(r).toLowerCase()}" style="flex-shrink: 0;">${r}</span>`,d=e.isUrlExpanded?"normal":"nowrap",c=e.isUrlExpanded?"break-all":"normal",m=e.isUrlExpanded?"60px":"2em",u=e.isUrlExpanded?"auto":"hidden";e.infoContainer.innerHTML=`\n ${l}\n <span class="mfm-status ${i}" style="flex-shrink: 0;">${a}</span>\n <span class="mfm-url-small" title="Click to toggle full URL" style="font-family: monospace; color: var(--mfm-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: ${d}; word-break: ${c}; max-height: ${m}; overflow-y: ${u}; flex: 1;">${t.request.url||""}</span>\n `}(e,d,c);const m=e.sheet.querySelector(".mfm-bottomsheet-content");if(!m)return e;const u={first:"Headers",second:"Request",third:"Response"};c&&(u.first="Configs",u.second="Modifications",u.third="Full Rule");const p=null==(t=d.response)?void 0:t.body,f="string"==typeof p?p:JSON.stringify(p||{},null,2),b=function(e){if(!e||"object"!=typeof e)return"";const t=e,n=t["content-type"]||t["Content-Type"]||t["CONTENT-TYPE"];return"string"==typeof n?n.toLowerCase():""}(null==(n=d.response)?void 0:n.headers),g=!c&&"string"==typeof p&&!function(e){try{return JSON.parse(e),!0}catch{return!1}}(p)&&(b.includes("text/html")||/<!doctype html|<html[\s>]|<body[\s>]|<\/?[a-z][\s\S]*>/i.test(p));g||(e.responseBodyMode="TEXT");let y="";if("HEADERS"===i&&(y=function(e,t,n){const o=n?"":`\n <div class="mfm-detail-section" style="margin-top:16px">\n <div class="mfm-detail-title">Response Headers</div>\n <div class="mfm-detail-content"><pre style="margin:0">${JSON.stringify(t||{},null,2)}</pre></div>\n </div>\n `;return`\n <div class="mfm-detail-section">\n <div class="mfm-detail-title">${n?"Rule Configuration":"Request Headers"}</div>\n <div class="mfm-detail-content"><pre style="margin:0">${JSON.stringify(e||{},null,2)}</pre></div>\n </div>\n ${o}\n `}(d.request.headers,null==(o=d.response)?void 0:o.headers,c)),"REQ_BODY"===i&&(y=function(e,t){return`\n <div class="mfm-detail-section">\n <div class="mfm-detail-title">${t?"Enabled Modifications":"Request Body"}</div>\n <div class="mfm-detail-content" id="mfm-req-viewer"><pre style="margin:0">${"string"==typeof e?N(e):JSON.stringify(e,null,2)}</pre></div>\n </div>\n `}(d.request.body,c)),"RES_BODY"===i&&(y=function(e){const t=e.isRule?"Complete Rule Object":"Response Body";let n="";e.isHtmlNonJsonResponse&&(n=`\n <div style="display:flex; gap:8px; margin-bottom:8px;">\n <button class="mfm-btn-outline mfm-res-mode-btn ${"TEXT"===e.responseBodyMode?"active":""}" data-mode="TEXT">Text</button>\n <button class="mfm-btn-outline mfm-res-mode-btn ${"PREVIEW"===e.responseBodyMode?"active":""}" data-mode="PREVIEW">Preview</button>\n </div>\n `);let o=`<pre style="margin:0">${N(e.responseText)}</pre>`;return e.isHtmlNonJsonResponse&&"PREVIEW"===e.responseBodyMode&&(o='<iframe id="mfm-res-preview" sandbox="" style="width:100%; min-height:280px; border:1px solid var(--mfm-border); border-radius:8px; background:#fff;"></iframe>'),`\n <div class="mfm-detail-section">\n <div class="mfm-detail-title">${t}</div>\n ${n}\n <div class="mfm-detail-content" id="mfm-res-viewer">${o}</div>\n </div>\n `}({isRule:c,isHtmlNonJsonResponse:g,responseBodyMode:e.responseBodyMode,responseText:f})),m.innerHTML=`${function(e,t){return`\n <div class="mfm-detail-tabs" style="margin-top: 0;">\n <button class="mfm-detail-tab-btn ${"HEADERS"===e?"active":""}" data-tab="HEADERS">${t.first}</button>\n <button class="mfm-detail-tab-btn ${"REQ_BODY"===e?"active":""}" data-tab="REQ_BODY">${t.second}</button>\n <button class="mfm-detail-tab-btn ${"RES_BODY"===e?"active":""}" data-tab="RES_BODY">${t.third}</button>\n </div>\n `}(i,u)}<div class="mfm-detail-body">${y}</div>`,"REQ_BODY"===i&&d.request.body&&A(e.sheet,"#mfm-req-viewer",d.request.body),"RES_BODY"===i&&(null==(r=d.response)?void 0:r.body)&&!g&&A(e.sheet,"#mfm-res-viewer",d.response.body),"RES_BODY"===i&&g&&"PREVIEW"===e.responseBodyMode){const t=e.sheet.querySelector("#mfm-res-preview");t&&(t.srcdoc=f)}return e.sheet.querySelectorAll(".mfm-detail-tab-btn").forEach((e=>{e.onclick=()=>{const t=e.dataset.tab;t&&v.setDetailTab(t)}})),e.sheet.querySelectorAll(".mfm-res-mode-btn").forEach((t=>{t.onclick=()=>{const n=t.dataset.mode;n&&n!==e.responseBodyMode&&(e.responseBodyMode=n,j(e))}})),e.sheet.classList.add("active"),e}function P(e){try{const t=new URL(e);return{path:t.pathname+(t.search||""),domain:t.hostname}}catch(t){return{path:e,domain:""}}}class D{constructor(e){this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-apis-list",this.init()}init(){this.parent.appendChild(this.element)}render(e){(null==e?void 0:e.length)?this.element.innerHTML=e.map((e=>{const{path:t,domain:n}=P(e.url);return`\n <div class="mfm-request-item" data-id="${e.url}" data-type="api">\n <div class="mfm-request-header">\n <div class="mfm-flex-row" style="width: 100%;">\n <span class="mfm-method ${(e.method||"").toLowerCase()}">${e.method||"REQ"}</span>\n <div class="mfm-url-container">\n <div class="mfm-url-path" title="${e.url}">${t}</div>\n <div class="mfm-url-domain" style="max-width: 250px;">${n}</div>\n </div>\n </div>\n </div>\n </div>\n `})).join(""):this.element.innerHTML=""}}function F(e,t){const n=e.ruleName||"",o=function(e){const t=B(e);if(t.length>0){const e=t[0];if("string"==typeof e.value)return e.value}return String(e.condition||e.ruleName||"")}(e);return`${t}::${n}::${o}`}function B(e){const t=e,n=function(e){const t=e,n=t.rule;if(n&&"object"==typeof n)return n;if("string"==typeof n)try{const e=JSON.parse(n);if(e&&"object"==typeof e)return e}catch{return t}return t}(e),o=Array.isArray(t.conditions)?t.conditions:[],r=Array.isArray(n.conditions)?n.conditions:[];return o.length>0?o:r}class H{constructor(e){this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-rule-list",this.init()}init(){this.parent.appendChild(this.element),this.attachEvents()}attachEvents(){this.element.onclick=e=>{var t;const n=e.target,o=n.closest(".mfm-dots-btn");if(o){e.stopPropagation();const t=o.closest(".mfm-request-item"),n=null==t?void 0:t.dataset.id;return void(n&&v.setOpenDropdown(n))}const r=n.closest("[data-action]");if(r){e.stopPropagation();const n=r.dataset.action,o=r.closest(".mfm-request-item"),s=this.readRuleIndex(o);return n&&null!==s&&this.handleAction(n,s),void(null==(t=r.parentElement)||t.classList.remove("show"))}const s=n.closest(".mfm-request-item");if(!s)return;e.stopPropagation();const i=this.readRuleIndex(s);if(null===i)return;const a=h.state.mappings.rules[i];a&&v.selectRule(a)}}readRuleIndex(e){if(!(null==e?void 0:e.dataset.ruleIndex))return null;const t=Number(e.dataset.ruleIndex);return Number.isNaN(t)?null:t}handleAction(e,t){if("view-rule-details"===e){const e=h.state.mappings.rules[t];e&&v.selectRule(e)}v.clearOpenDropdown()}render(e){if(!(null==e?void 0:e.length))return void(this.element.innerHTML="");const t=e.map(((e,t)=>F(e,t)));Array.from(this.element.querySelectorAll(".mfm-request-item")).forEach((e=>{t.includes(e.dataset.id||"")||e.remove()})),e.forEach(((e,t)=>{var n,o,r;const s=F(e,t),i=this.element.querySelector(`[data-id="${s}"]`),a=function(e){const t=B(e);let n=[];return t.length>0&&(n=t.map((e=>{const t=function(e){const t="string"==typeof e.type&&e.type.trim()?e.type:"RULE",n="string"==typeof e.operator&&e.operator.trim()?e.operator:"matches",o="string"==typeof e.key&&e.key.trim()?e.key:"",r="string"==typeof e.value&&e.value.trim()?e.value:"-";return o?`\n <span class="mfm-rule-condition-type">${t}</span>\n <span class="mfm-rule-condition-operator">${n}</span>\n <span class="mfm-rule-condition-key-value">${o}=${r}</span>\n `:`\n <span class="mfm-rule-condition-type">${t}</span>\n <span class="mfm-rule-condition-operator">${n}</span>\n <span class="mfm-rule-condition-key-value">${r}</span>\n `}(e);return t}))),n}(e),l=function(e){const{action:t,config:n}=function(e){const t=e.timingAction;if(!(null==t?void 0:t.actions)||"object"!=typeof t.actions)return{action:"",config:null};const n=Object.keys(t.actions);if(0===n.length)return{action:"",config:null};const o=t.activeAction||n[0],r=t.actions[o];return{action:o,config:r&&"object"==typeof r?r:null}}(e);if(!t||!n)return"";const o="number"!=typeof(r=n.value)||Number.isNaN(r)||r<0?0:r;var r;const s="string"==typeof n.redirectUrl&&n.redirectUrl.trim()?n.redirectUrl:"";return"delay_and_timeout"===t?`\n <span class="mfm-rule-action">Delay and Timeout</span>\n <span class="mfm-rule-value">${o}s</span>`:"delay_and_redirect"===t?s?`\n <span class="mfm-rule-action">Delay and Redirect ${o}s</span>\n <span class="mfm-rule-value">${s}</span>`:`\n <span class="mfm-rule-action">Delay and Redirect ${o}s</span>\n <span class="mfm-rule-value">${s}</span>`:"delay"===t?`\n <span class="mfm-rule-action">Delay ${o}s</span>`:`\n <span class="mfm-rule-action">${function(e){if(!e)return e;const t=e.toLowerCase().replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)}(t)} ${o}s</span>`}(e),d=null==(n=e.timingAction)?void 0:n.activeAction,c=null==(r=null==(o=e.timingAction)?void 0:o.actions)?void 0:r[d||""],m=c?`${c.value||0}s (${String(d).replace(/_/g," ")})`:String(e.type||"RULE");let u=0;e.modificationActions&&Object.values(e.modificationActions).forEach((e=>{e.enabled&&(u+=1)}));const p=h.state.ui.tabConfigs.MAPPINGS.selectedRule,f=Boolean(p)&&((null==p?void 0:p.ruleName)===(e.ruleName||e.condition)||(null==p?void 0:p.condition)===(e.condition||e.ruleName)),b=h.state.ui.activeDropdownId===s,g=`${f}_${m}_${u}_${b}`,y=`\n <div class="mfm-request-item ${f?"active":""}" data-id="${s}" data-rule-index="${t}" data-type="rule">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method rule">RULE</span>\n <span class="mfm-status rule">${String(e.type||"RULE")}</span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n ${u>0?`<span class="mfm-mod-pill">${u} Actions</span>`:""}\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${b?"show":""}">\n <button data-action="view-rule-details">View Details</button>\n </div>\n </div>\n </div>\n <div class="mfm-url">${a.map((e=>`<span class="mfm-rule-condition">${e}</span>`)).join("")}</div>\n ${l?`<div class="mfm-rule-info">${l}</div>`:""}\n </div>\n `;if(i){if(i.dataset.hash!==g){const e=document.createElement("div");e.innerHTML=y;const t=e.firstElementChild;t&&(t.dataset.hash=g,this.element.replaceChild(t,i))}}else{const e=document.createElement("div");e.innerHTML=y;const n=e.firstElementChild;if(!n)return;n.dataset.hash=g;const o=this.element.children[t];o?this.element.insertBefore(n,o):this.element.appendChild(n)}}))}}class z{constructor(e){this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-mapping-list-activity",this.ruleListView=new H(this.element),this.apisListView=new D(this.element),this.init()}init(){this.parent.appendChild(this.element),this.unsubscribe=h.subscribe((()=>{"MAPPINGS"===h.state.ui.selectedTab&&this.render()})),this.render()}render(){if(h.state.isMappingsLoading)return this.element.innerHTML='<div class="mfm-spinner"></div>',this.ruleListView.element.style.display="none",void(this.apisListView.element.style.display="none");const{apis:e,rules:t}=function(){const{apis:e,rules:t}=h.state.mappings,n=(h.state.ui.tabConfigs.MAPPINGS.searchText||"").toLowerCase();return{apis:e.filter((e=>(e.url||"").toLowerCase().includes(n))),rules:t.filter((e=>(e.ruleName||"").toLowerCase().includes(n)||(e.condition||"").toLowerCase().includes(n)))}}();if(0===e.length&&0===t.length)return this.element.innerHTML='<div class="mfm-empty">No mappings found</div>',this.ruleListView.element.style.display="none",void(this.apisListView.element.style.display="none");this.element.contains(this.ruleListView.element)||(this.element.innerHTML="",this.element.appendChild(this.ruleListView.element),this.element.appendChild(this.apisListView.element)),this.ruleListView.element.style.display="block",this.apisListView.element.style.display="block",this.ruleListView.render(t),this.apisListView.render(e)}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}async function U(e){if("undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return void await navigator.clipboard.writeText(e);if(!(null==document?void 0:document.body))throw new Error("Clipboard unavailable: document body not ready");const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",document.body.appendChild(t),t.focus(),t.select();try{if(!document.execCommand("copy"))throw new Error("Copy command failed")}finally{t.remove()}}function G(e,t){const n=e.request.method||"GET",o=e.request.url,r=e.request.headers||{},s=(i=e.request.body)?"string"==typeof i?i:JSON.stringify(i):null;var i;if("copy-curl"===t){let e=`curl '${o}' \\\n -X ${n}`;return Object.entries(r).forEach((([t,n])=>{e+=` \\\n -H '${t}: ${String(n)}'`})),s&&(e+=` \\\n --data-raw '${s.replace(/'/g,"'\\''")}'`),e}if("copy-fetch"===t){const e={method:n,headers:r};return s&&(e.body=s),`fetch('${o}', ${JSON.stringify(e,null,2)})`}let a="const xhr = new XMLHttpRequest();\n";return a+=`xhr.open('${n}', '${o}');\n`,Object.entries(r).forEach((([e,t])=>{a+=`xhr.setRequestHeader('${e}', '${String(t)}');\n`})),a+=s?`xhr.send('${s.replace(/'/g,"\\'")}');`:"xhr.send();",a}let K=class{static render(e){var t,n;const o=void 0===(null==(t=e.response)?void 0:t.statusCode),r=o?"Pending":null==(n=e.response)?void 0:n.statusCode,s=0===r?"Error":r,i=h.state.ui.tabConfigs.MOCKED.selectedRequestId===e.requestId,a=function(e,t,n){return e?"pending":t?"success":n?"error":""}(o,!o&&"number"==typeof r&&r>=200&&r<300,!o&&"number"==typeof r&&(0===r||r>=400)),{path:l,domain:d}=P(e.request.url);return`\n <div class="mfm-request-item ${i?"active":""} ${o?"pending-item":""}" data-id="${e.requestId}" data-type="request">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.request.method||"").toLowerCase()}">${e.request.method}</span>\n <span class="mfm-status ${a}">\n ${o?'<span class="mfm-spinner"></span>':s}\n </span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${h.state.ui.activeDropdownId===e.requestId?"show":""}">\n <button data-action="copy-curl">Copy as cURL</button>\n <button data-action="copy-fetch">Copy as Fetch</button>\n <button data-action="copy-xhr">Copy as XHR</button>\n </div>\n </div>\n </div>\n <div class="mfm-url-container">\n <div class="mfm-url-path" title="${e.request.url}">${l}</div>\n <div class="mfm-url-domain">${d}</div>\n </div>\n </div>\n `}};class J{static render(e){var t,n,o,r,s,i,a;const l=e.rule?{action:e.rule.action||(null==(t=e.rule.timingAction)?void 0:t.activeAction),config:e.rule.config||(null==(r=null==(n=e.rule.timingAction)?void 0:n.actions)?void 0:r[(null==(o=e.rule.timingAction)?void 0:o.activeAction)||""])}:null,d=void 0===(null==(s=e.response)?void 0:s.statusCode),c=d?"Pending":null==(i=e.response)?void 0:i.statusCode,m=0===c?"Error":c,u=h.state.ui.tabConfigs.MOCKED.selectedRequestId===e.requestId,p=function(e,t,n){return e?"pending":t?"success":n?"error":""}(d,!d&&"number"==typeof c&&c>=200&&c<300,!d&&"number"==typeof c&&(0===c||c>=400)),{path:f,domain:b}=P(e.request.url);return`\n <div class="mfm-request-item ${u?"active":""} ${d?"pending-item":""}" data-id="${e.requestId}" data-type="request">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.request.method||"").toLowerCase()}">${e.request.method}</span>\n <span class="mfm-status ${p}">\n ${d?'<span class="mfm-spinner"></span>':m}\n </span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${h.state.ui.activeDropdownId===e.requestId?"show":""}">\n <button data-action="copy-curl">Copy as cURL</button>\n <button data-action="copy-fetch">Copy as Fetch</button>\n <button data-action="copy-xhr">Copy as XHR</button>\n </div>\n </div>\n </div>\n <div class="mfm-url-container">\n <div class="mfm-url-path" title="${e.request.url}">${f}</div>\n <div class="mfm-url-domain">${b}</div>\n </div>\n ${(null==l?void 0:l.action)?`\n <div class="mfm-rule-info">\n <span class="mfm-rule-action">${String(l.action).replace(/_/g," ")}</span>\n <span class="mfm-rule-value">${(null==(a=l.config)?void 0:a.value)||0}s</span>\n </div>`:""}\n </div>\n `}}class V{constructor(e){this.unsubscribe=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-mocked-apis-activity",this.init()}init(){this.parent.appendChild(this.element),this.attachEvents(),this.unsubscribe=h.subscribe((()=>{"MOCKED"===h.state.ui.selectedTab&&this.render()})),this.render()}attachEvents(){this.element.onclick=e=>{var t;const n=e.target,o=n.closest(".mfm-dots-btn");if(o){e.stopPropagation();const t=o.closest(".mfm-request-item"),n=null==t?void 0:t.dataset.id;return void(n&&v.setOpenDropdown(n))}const r=n.closest("[data-action]");if(r){e.stopPropagation();const n=r.dataset.action,o=r.closest(".mfm-request-item"),s=null==o?void 0:o.dataset.id;return n&&s&&this.handleAction(n,s),void(null==(t=r.parentElement)||t.classList.remove("show"))}const s=n.closest(".mfm-request-item");if(s){if(s.classList.contains("pending-item"))return;e.stopPropagation();const t=s.dataset.id;t&&v.selectRequest(t)}}}handleAction(e,t){const n=h.state.requests.find((e=>e.requestId===t));n&&(U(G(n,e)),v.clearOpenDropdown())}render(){const e=function(){const e=(h.state.ui.tabConfigs.MOCKED.searchText||"").toLowerCase();return h.state.requests.filter((t=>{var n,o;return"MOCKED"===t.interceptionType&&(((null==(n=t.request)?void 0:n.url)||"").toLowerCase().includes(e)||((null==(o=t.rule)?void 0:o.ruleName)||"").toLowerCase().includes(e))}))}(),t=h.state.ui.tabConfigs.MOCKED.selectedRequestId,n=h.state.ui.activeDropdownId;if(!e||0===e.length)return void(this.element.querySelector(".mfm-empty")||(this.element.innerHTML='<div class="mfm-empty">No requests found</div>'));const o=this.element.querySelector(".mfm-empty");o&&o.remove();const r=e.map((e=>e.requestId));Array.from(this.element.querySelectorAll(".mfm-request-item")).forEach((e=>{r.includes(e.dataset.id||"")||e.remove()})),e.forEach(((e,o)=>{const r=this.element.querySelector(`[data-id="${e.requestId}"]`),s=e.rule?J.render(e):K.render(e),i=t===e.requestId,a=n===e.requestId,l=`${JSON.stringify(e).length}_${i}_${a}`;if(r){if(r.dataset.hash!==l){const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;t&&(t.dataset.hash=l,this.element.replaceChild(t,r))}}else{const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;if(!t)return;t.dataset.hash=l;const n=this.element.children[o];n?this.element.insertBefore(t,n):this.element.appendChild(t)}}))}destroy(){this.unsubscribe&&this.unsubscribe(),this.element.remove()}}class Q{static render(e){var t,n;const o=void 0===(null==(t=e.response)?void 0:t.statusCode),r=o?"Pending":null==(n=e.response)?void 0:n.statusCode,s=0===r?"Error":r,i=h.state.ui.tabConfigs.OTHER.selectedRequestId===e.requestId,a=function(e,t,n){return e?"pending":t?"success":n?"error":""}(o,!o&&"number"==typeof r&&r>=200&&r<300,!o&&"number"==typeof r&&(0===r||r>=400)),{path:l,domain:d}=P(e.request.url);return`\n <div class="mfm-request-item ${i?"active":""} ${o?"pending-item":""}" data-id="${e.requestId}" data-type="request">\n <div class="mfm-request-header">\n <div class="mfm-flex-row">\n <span class="mfm-method ${(e.request.method||"").toLowerCase()}">${e.request.method}</span>\n <span class="mfm-status ${a}">\n ${o?'<span class="mfm-spinner"></span>':s}\n </span>\n </div>\n <div class="mfm-dropdown" style="display: flex; align-items: center; gap: 8px;">\n <button class="mfm-btn-icon mfm-dots-btn">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>\n </button>\n <div class="mfm-dropdown-content ${h.state.ui.activeDropdownId===e.requestId?"show":""}">\n <button data-action="create-mock" style="color: var(--mfm-primary); font-weight: 600;">Create Mock</button>\n <button data-action="copy-curl">Copy as cURL</button>\n <button data-action="copy-fetch">Copy as Fetch</button>\n <button data-action="copy-xhr">Copy as XHR</button>\n </div>\n </div>\n </div>\n <div class="mfm-url-container">\n <div class="mfm-url-path" title="${e.request.url}">${l}</div>\n <div class="mfm-url-domain">${d}</div>\n </div>\n </div>\n `}}function W(e,t){const n=document.createElement("div");n.className="mfm-response-editor",n.id="mfm-shared-editor",n.innerHTML=`\n <div class="mfm-editor-header">\n <div style="display: flex; align-items: center; gap: 12px;">\n <h4 style="margin: 0; font-size: 1rem;">${t.title||"Edit Mock"}</h4>\n <div class="mfm-switch-with-label">\n <span class="mfm-label">Enable</span>\n <label class="mfm-switch" style="margin-right: 0; width: 32px; height: 18px;">\n <input type="checkbox" id="mfm-editor-enabled-switch">\n <span class="mfm-slider" style="border-radius: 34px;"></span>\n </label>\n </div>\n </div>\n <button class="mfm-btn-icon" id="mfm-editor-close" style="padding: 0; min-height: auto;">${q}</button>\n </div>\n\n <div class="mfm-url-preview" style="font-size: 0.75rem; color: var(--mfm-text-dim); margin-bottom: 8px; word-break: break-all;" id="mfm-editor-url"></div>\n\n <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 8px;">\n <label style="font-size: 0.75rem; color: var(--mfm-text-dim);">Status Code:</label>\n <input type="number" id="mfm-editor-status" class="mfm-input" style="width: 80px; height: 28px; font-size: 0.8rem;" value="200">\n </div>\n\n <textarea id="mfm-editor-textarea" spellcheck="false" placeholder="Enter response body..."></textarea>\n \n <div class="mfm-editor-footer">\n <button class="mfm-btn-text" id="mfm-editor-cancel">Cancel</button>\n <button class="mfm-btn mfm-btn-primary" style="padding: 6px 16px; border-radius: 4px; font-size: 0.8rem;" id="mfm-editor-save">Apply Changes</button>\n </div>\n `,e.appendChild(n);const o=n.querySelector("#mfm-editor-textarea"),r=n.querySelector("#mfm-editor-status"),s=n.querySelector("#mfm-editor-enabled-switch"),i=n.querySelector("#mfm-editor-url"),a=n.querySelector("#mfm-editor-close"),l=n.querySelector("#mfm-editor-cancel"),d=n.querySelector("#mfm-editor-save");return a.onclick=l.onclick=()=>t.onCancel(),d.onclick=()=>{t.onSave({body:o.value,status:parseInt(r.value)||200,enabled:s.checked})},{show:(e,t)=>{i.innerText=e.request.url,o.value=t.body,r.value=t.status.toString(),s.checked=t.enabled,n.classList.add("active")},hide:()=>{n.classList.remove("active")},destroy:()=>{n.remove()}}}const X="https://api.mockforme.com",Y="/mockforme",Z={async createBulkMocks(e){const t=h.state.token;if(!t)return x("Token not found","error"),!1;const n={apis:e};try{const e=await fetch(`${X}${Y}/httpRequestBulkMock/bulk_mock`,{method:"POST",headers:{"Content-Type":"application/json",mockforme:t},body:JSON.stringify(n)}),o=await e.json();return e.ok?(x(o.message||"Mocks created successfully"),!0):(x(o.message||"Mocks creation failed","error"),console.error("Mocks creation failed",o),!1)}catch(e){return x("Error during mocks creation","error"),console.error("Error during mocks creation:",e),!1}}};class ee{constructor(e){this.unsubscribe=null,this.editor=null,this.parent=e,this.element=document.createElement("div"),this.element.className="mfm-other-apis-activity",this.init()}init(){this.parent.appendChild(this.element),this.attachEvents(),this.unsubscribe=h.subscribe((()=>{"OTHER"===h.state.ui.selectedTab&&this.render()})),this.render()}attachEvents(){this.element.onclick=e=>{var t;const n=e.target,o=n.closest(".mfm-dots-btn");if(o){e.stopPropagation();const t=o.closest(".mfm-request-item"),n=null==t?void 0:t.dataset.id;return void(n&&v.setOpenDropdown(n))}const r=n.closest("[data-action]");if(r){e.stopPropagation();const n=r.dataset.action,o=r.closest(".mfm-request-item"),s=null==o?void 0:o.dataset.id;return"create-mock"===n&&s?this.openMockEditor(s):n&&s&&this.handleAction(n,s),void(null==(t=r.parentElement)||t.classList.remove("show"))}const s=n.closest(".mfm-request-item");if(s){if(s.classList.contains("pending-item"))return;e.stopPropagation();const t=s.dataset.id;t&&v.selectRequest(t)}}}handleAction(e,t){const n=h.state.requests.find((e=>e.requestId===t));n&&(U(G(n,e)),v.clearOpenDropdown())}openMockEditor(e){var t,n,o,r,s;const i=h.state.requests.find((t=>t.requestId===e));if(!i)return;this.editor||(this.editor=W(this.parent,{onSave:e=>this.handleSaveMock(i,e),onCancel:()=>this.editor.hide()}));const a={body:"string"==typeof(null==(t=i.response)?void 0:t.body)?i.response.body:JSON.stringify((null==(n=i.response)?void 0:n.body)||{},null,2),status:"Error"===(null==(o=i.response)?void 0:o.statusCode)||"error"===(null==(r=i.response)?void 0:r.statusCode)?504:Number(null==(s=i.response)?void 0:s.statusCode)||200,enabled:!0};this.editor.show(i,a),v.clearOpenDropdown()}async handleSaveMock(e,t){await Z.createBulkMocks([{url:e.request.url,method:e.request.method,body:e.request.body||{},status:t.status,response:t.body,headers:JSON.stringify(e.request.headers||{}),enabled:t.enabled}])&&(this.editor.hide(),setTimeout((()=>v.reloadMappings()),1e3))}render(){const e=function(){const e=(h.state.ui.tabConfigs.OTHER.searchText||"").toLowerCase();return h.state.requests.filter((t=>{var n;return"MOCKED"!==t.interceptionType&&((null==(n=t.request)?void 0:n.url)||"").toLowerCase().includes(e)}))}(),t=h.state.ui.tabConfigs.OTHER.selectedRequestId,n=h.state.ui.activeDropdownId;if(!e||0===e.length)return void(this.element.querySelector(".mfm-empty")||(this.element.innerHTML='<div class="mfm-empty">No requests found</div>'));const o=this.element.querySelector(".mfm-empty");o&&o.remove();const r=e.map((e=>e.requestId));Array.from(this.element.querySelectorAll(".mfm-request-item")).forEach((e=>{r.includes(e.dataset.id||"")||e.remove()})),e.forEach(((e,o)=>{const r=this.element.querySelector(`[data-id="${e.requestId}"]`),s=Q.render(e),i=t===e.requestId,a=n===e.requestId,l=`${JSON.stringify(e).length}_${i}_${a}`;if(r){if(r.dataset.hash!==l){const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;t&&(t.dataset.hash=l,this.element.replaceChild(t,r))}}else{const e=document.createElement("div");e.innerHTML=s;const t=e.firstElementChild;if(!t)return;t.dataset.hash=l;const n=this.element.children[o];n?this.element.insertBefore(t,n):this.element.appendChild(t)}}))}destroy(){this.unsubscribe&&this.unsubscribe(),this.editor&&this.editor.destroy(),this.element.remove()}}function te(e){const t=document.createElement("div");t.id="mfm-root";const n=document.createElement("div");n.className="mfm-widget-toggle",n.innerHTML='\n <div class="mfm-toggle-section mfm-toggle-reload" title="Reload Mappings"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><polyline points="21 3 21 8 16 8"></polyline></svg></div>\n <div class="mfm-toggle-divider"></div>\n <div class="mfm-toggle-section mfm-toggle-logo" title="MockForMe"><img src="https://ik.imagekit.io/mfm/static-collection/mfm-48x48.png" alt="Logo"></div>\n ';const o=document.createElement("div");o.className="mfm-main-container hidden",t.appendChild(n),t.appendChild(o),e.appendChild(t),function(e,t){const n=(t,n)=>{const o=e.getBoundingClientRect(),r=o.width||60,s=o.height||60,i=window.innerWidth-r,a=window.innerHeight-s,l=Math.max(0,Math.min(t,i)),d=Math.max(0,Math.min(n,a));e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.bottom="auto",e.style.right="auto"},o=()=>{const e=localStorage.getItem("MFM_POSITION");if(e)try{const t=JSON.parse(e);"number"==typeof t.xPercent&&"number"==typeof t.yPercent&&n(t.xPercent*window.innerWidth,t.yPercent*window.innerHeight)}catch{}};o();let r=!1,s=0,i=0,a=0,l=0;const d=n=>{const o="touchstart"===n.type,d=o?n.touches[0].clientX:n.clientX,u=o?n.touches[0].clientY:n.clientY;r=!0,s=d,i=u;const p=e.getBoundingClientRect();a=p.left,l=p.top,t.dataset.moved="false",document.addEventListener("mousemove",c),document.addEventListener("mouseup",m),document.addEventListener("touchmove",c,{passive:!1}),document.addEventListener("touchend",m),e.style.transition="none"},c=e=>{if(!r)return;const o="touchmove"===e.type;o&&e.cancelable&&e.preventDefault();const d=o?e.touches[0].clientX:e.clientX,c=o?e.touches[0].clientY:e.clientY,m=d-s,u=c-i;(Math.abs(m)>5||Math.abs(u)>5)&&(t.dataset.moved="true"),n(a+m,l+u)},m=()=>{if(!r)return;r=!1,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",m),document.removeEventListener("touchmove",c),document.removeEventListener("touchend",m),e.style.transition="";const t=e.getBoundingClientRect();((e,t)=>{const n=e/window.innerWidth,o=t/window.innerHeight;localStorage.setItem("MFM_POSITION",JSON.stringify({xPercent:n,yPercent:o}))})(t.left,t.top)};t.addEventListener("mousedown",d),t.addEventListener("touchstart",d,{passive:!1}),window.addEventListener("resize",o),window.addEventListener("orientationchange",o)}(t,n),function(e){const t=document.createElement("div");t.className="mfm-header",t.innerHTML=`\n <div class="mfm-logo">\n <img src="${E}" height="32" alt="MockForMe Logo">\n </div>\n <div class="mfm-header-actions">\n <label class="mfm-switch" title="Toggle Mock Interception">\n <input type="checkbox" id="mfm-intercept-toggle" ${h.state.isInterceptEnabled?"checked":""}>\n <span class="mfm-slider"></span>\n </label>\n <button class="mfm-btn-icon" id="mfm-reload-header" title="Reload Mappings">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-cw"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><polyline points="21 3 21 8 16 8"></polyline></svg>\n </button>\n <button class="mfm-btn-icon" id="mfm-delete-token" title="Delete Token">\n <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>\n </button>\n <button class="mfm-btn-icon" id="mfm-close-widget" title="Close Widget">\n ${q}\n </button>\n </div>\n `,e.appendChild(t);const n=t.querySelector("#mfm-intercept-toggle"),o=t.querySelector("#mfm-reload-header"),r=t.querySelector("#mfm-delete-token"),s=t.querySelector("#mfm-close-widget");n&&(n.onchange=()=>{v.toggleInterception()}),o&&(o.onclick=()=>{o.innerHTML='<div class="mfm-spinner"></div>',o.style.pointerEvents="none",v.reloadMappings()}),r&&(r.onclick=()=>{v.deleteToken()}),s&&(s.onclick=()=>{v.toggleWidget()}),h.subscribe((e=>{n&&(n.checked=e.isInterceptEnabled)}))}(o),new R(o),function(e){var t,n;const o=document.createElement("div");o.className="mfm-tabs-container";const r=document.createElement("div");r.className="mfm-tabs-nav",[{id:"MAPPINGS",label:"Mappings"},{id:"MOCKED",label:"Mocked"},{id:"OTHER",label:"Others"}].forEach((e=>{const t=document.createElement("button");t.className="mfm-tab-btn "+(h.state.ui.selectedTab===e.id?"active":""),t.innerText=e.label,t.onclick=()=>{v.setTab(e.id)},t.dataset.tabId=e.id,r.appendChild(t)}));const s=document.createElement("div");s.className="mfm-tab-toolbar",s.innerHTML=`\n <div class="mfm-toolbar-row">\n <input type="text" class="mfm-input" id="mfm-search" placeholder="Search requests..." value="${(null==(t=h.state.ui.tabConfigs[h.state.ui.selectedTab])?void 0:t.searchText)||""}">\n <label class="mfm-preserve-logs">\n <input type="checkbox" id="mfm-preserve-check" ${(null==(n=h.state.ui.tabConfigs[h.state.ui.selectedTab])?void 0:n.isPreserveLogs)?"checked":""}>\n Preserve\n </label>\n <button class="mfm-btn-outline clear-btn" id="mfm-clear-btn" title="Clear requests">\n ${M}\n </button>\n <div class="mfm-dropdown mfm-toolbar-dropdown" id="mfm-toolbar-dropdown">\n <button class="mfm-btn-outline dots-btn" id="mfm-dots-btn" title="More options">\n <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1.5"></circle><circle cx="12" cy="5" r="1.5"></circle><circle cx="12" cy="19" r="1.5"></circle></svg>\n </button>\n <div class="mfm-dropdown-menu">\n <button class="mfm-dropdown-item" id="mfm-bulk-mock-btn">Bulk Mock</button>\n </div>\n\n\n </div>\n </div>\n `;const i=document.createElement("div");i.className="mfm-tab-content",o.appendChild(r),o.appendChild(s),o.appendChild(i),e.appendChild(o);const a=new z(i),l=new V(i),d=new ee(i),c=s.querySelector("#mfm-search"),m=s.querySelector("#mfm-clear-btn"),u=s.querySelector("#mfm-preserve-check"),p=s.querySelector(".mfm-preserve-logs");c&&(c.oninput=e=>{const t=e.target;v.setSearchText(t.value)}),m&&(m.onclick=()=>{v.clearRequests()}),u&&(u.onchange=e=>{const t=e.target;v.setPreserveLogs(Boolean(t.checked))});const f=s.querySelector("#mfm-dots-btn"),b=s.querySelector("#mfm-bulk-mock-btn");f&&(f.onclick=e=>{e.stopPropagation(),v.setOpenDropdown("toolbar")}),b&&(b.onclick=()=>{v.setBulkMockOpen(!0),v.clearOpenDropdown()});const g=()=>{const e=h.state.ui.selectedTab,t=h.state.ui.tabConfigs[e];if(r.querySelectorAll(".mfm-tab-btn").forEach((t=>{t.classList.toggle("active",t.dataset.tabId===e)})),c){const e=(null==t?void 0:t.searchText)||"";c.value!==e&&(c.value=e)}const n="MAPPINGS"===e;m&&(m.style.display=n?"none":"block"),p&&(p.style.display=n?"none":"flex");const o=s.querySelector("#mfm-toolbar-dropdown");if(o){o.style.display="OTHER"===e?"block":"none",o.classList.toggle("show","toolbar"===h.state.ui.activeDropdownId);const t=o.querySelector("#mfm-bulk-mock-btn");t&&(t.style.display="block")}!n&&u&&(u.checked=Boolean(null==t?void 0:t.isPreserveLogs)),a.element&&(a.element.style.display="MAPPINGS"===e?"block":"none"),l.element&&(l.element.style.display="MOCKED"===e?"block":"none"),d.element&&(d.element.style.display="OTHER"===e?"block":"none")};g(),h.subscribe((()=>g()))}(o),function(e){const t=document.createElement("div");t.className="mfm-bottomsheet",t.id="mfm-details-sheet",t.innerHTML='\n <div class="mfm-bottomsheet-header" style="justify-content: flex-start; gap: 8px; padding-right: 12px;">\n <button class="mfm-btn-icon back-btn" id="mfm-close-sheet" title="Back"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg></button>\n <div id="mfm-header-info" style="display: flex; align-items: baseline; gap: 6px; overflow: hidden; flex: 1; cursor: pointer;"></div>\n </div>\n <div class="mfm-bottomsheet-content"></div>\n ',e.appendChild(t);const n=t.querySelector("#mfm-close-sheet"),o=t.querySelector("#mfm-header-info");if(!n||!o)return;n.onclick=e=>{e.stopPropagation(),v.closeDetails()};let r=!1,s="TEXT",i={};const a=()=>{const e=j({sheet:t,infoContainer:o,isUrlExpanded:r,responseBodyMode:s,prevState:i});r=e.isUrlExpanded,s=e.responseBodyMode,i=e.prevState};o.onclick=()=>{r=!r,a()},h.subscribe(a),a()}(o),function(e){const t=document.createElement("div");t.className="mfm-bulk-mock-popup",t.id="mfm-bulk-mock-popup";let n=new Set,o=!1,r="",s=!1,i=new Map,a=new Map,l=new Map,d=null,c=null;const m=()=>{const{isBulkMockOpen:e}=h.state.ui;if(!e)return s&&k(),void t.classList.remove("active");s||(u(),s=!0),f(),p()},u=()=>{t.innerHTML=`\n <div class="mfm-bulk-mock-container">\n <div class="mfm-bulk-mock-header">\n <h3>Bulk Mock APIs</h3>\n <div class="mfm-bulk-mock-header-actions">\n <button class="mfm-btn mfm-btn-primary" id="mfm-bulk-save-btn" disabled style="padding: 6px 12px; font-size: 0.8rem; border-radius: 4px;">\n Save Mock\n </button>\n <button class="mfm-btn-icon" id="mfm-bulk-close-btn">${q}</button>\n </div>\n </div>\n <div class="mfm-bulk-mock-filters">\n <input type="text" class="mfm-input" id="mfm-bulk-search" placeholder="Search APIs..." value="">\n <div style="display: flex; align-items: center; justify-content: space-between;">\n <label class="mfm-checkbox-label" style="display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--mfm-text-dim); cursor: pointer;">\n <input type="checkbox" id="mfm-bulk-domain-filter" style="margin: 0;">\n Current/Sub domain only\n </label>\n <span id="mfm-bulk-selection-stats" style="font-size: 0.75rem; color: var(--mfm-text-dim);">Selected: 0/10 - 0.0 KB</span>\n </div>\n </div>\n <div class="mfm-bulk-mock-list" id="mfm-bulk-list-container">\n </div>\n </div>\n\n <div class="mfm-bulk-mock-list" id="mfm-bulk-list-container">\n </div>\n </div>\n `,t.classList.add("active"),w()},p=()=>{const e=t.querySelector("#mfm-bulk-save-btn");e&&(e.disabled=0===n.size,e.innerText="Save Mock");const o=t.querySelector("#mfm-bulk-selection-stats");if(o){const e=(()=>{const e={apis:h.state.requests.filter((e=>n.has(e.requestId))).map((e=>{var t,n,o;const r=i.get(e.requestId)??("string"==typeof(null==(t=e.response)?void 0:t.body)?e.response.body:JSON.stringify((null==(n=e.response)?void 0:n.body)||{}));let s=a.get(e.requestId);if(void 0===s){const t=null==(o=e.response)?void 0:o.statusCode;"Error"===t||"error"===t?s=504:null!=t?(s=Number(t),isNaN(s)&&(s=504)):s=200}return{url:e.request.url,method:e.request.method,body:e.request.body||{},status:s,response:r,headers:JSON.stringify(e.request.headers||{}),enabled:l.get(e.requestId)||!1}}))};return new Blob([JSON.stringify(e)]).size})(),t=e>1048576?`${(e/1048576).toFixed(2)} MB`:`${(e/1024).toFixed(1)} KB`;o.innerText=`Selected: ${n.size}/10 - ${t}`,e>1048576?(o.style.color="var(--mfm-error, #ef4444)",o.style.fontWeight="600"):(o.style.color="var(--mfm-text-dim)",o.style.fontWeight="normal")}},f=()=>{const e=window.location.hostname,s=h.state.requests.filter((e=>"OTHER"===e.interceptionType)).filter((t=>{if(!t.request.url.toLowerCase().includes(r.toLowerCase()))return!1;if(o)try{const n=new URL(t.request.url);return n.hostname===e||n.hostname.endsWith("."+e)}catch(e){return!1}return!0})),a=t.querySelector("#mfm-bulk-list-container");a&&(a.innerHTML=`\n ${0===s.length?'<div class="mfm-empty">No APIs found</div>':""}\n ${s.map((e=>{var t,o;const r=n.has(e.requestId),s=e.request.method||"GET",a=i.has(e.requestId),l=i.get(e.requestId)??("string"==typeof(null==(t=e.response)?void 0:t.body)?e.response.body:JSON.stringify((null==(o=e.response)?void 0:o.body)||{})),d=new Blob([l]).size,c=d>1048576?`${(d/1048576).toFixed(2)} MB`:`${(d/1024).toFixed(1)} KB`,{path:m,domain:u}=P(e.request.url);return`\n <div class="mfm-bulk-item ${r?"selected":""}" data-id="${e.requestId}">\n <input type="checkbox" class="mfm-bulk-checkbox" ${r?"checked":""} ${!r&&n.size>=10?"disabled":""}>\n <span class="mfm-method ${String(s).toLowerCase()}">${s}</span>\n <div class="mfm-url-container">\n <div class="mfm-url-path" title="${e.request.url}">${m}</div>\n <div class="mfm-url-domain">${u}</div>\n </div>\n <span class="mfm-bulk-size">${c}</span>\n ${r?`\n <div class="mfm-bulk-item-actions">\n <button class="mfm-btn-text edit-response-btn" data-id="${e.requestId}">\n ${a?"Edited":"Edit Response"}\n </button>\n </div>\n `:""}\n </div>\n `})).join("")}\n `,a.querySelectorAll(".mfm-bulk-item").forEach((e=>{const t=e.dataset.id,n=e.querySelector(".mfm-bulk-checkbox"),o=e.querySelector(".edit-response-btn");n&&(n.onclick=e=>{e.stopPropagation(),b(t,n.checked)}),o&&(o.onclick=e=>{e.stopPropagation(),g(t)}),e.onclick=o=>{if((o.target===e||o.target.classList.contains("mfm-url")||o.target.classList.contains("mfm-method"))&&n&&!n.disabled){const e=!n.checked;n.checked=e,b(t,e)}}})))},b=(e,t)=>{t?n.size<10&&n.add(e):(n.delete(e),i.delete(e)),p(),f()},g=e=>{var n,o,r;const s=h.state.requests.find((t=>t.requestId===e));if(!s)return;d=e,c||(c=W(t,{onSave:e=>y(e),onCancel:()=>c.hide()}));let m=i.get(e);void 0===m&&(m="string"==typeof(null==(n=s.response)?void 0:n.body)?s.response.body:JSON.stringify((null==(o=s.response)?void 0:o.body)||{},null,2));let u=a.get(e);if(void 0===u){const e=null==(r=s.response)?void 0:r.statusCode;u="Error"===e||"error"===e?504:Number(e)||200}c.show(s,{body:m,status:u,enabled:l.get(e)||!1})},y=e=>{d&&(i.set(d,e.body),a.set(d,e.status),l.set(d,e.enabled),x("Changes updated locally"),f(),c.hide())},k=()=>{s=!1,r="",o=!1,n.clear(),i.clear(),a.clear(),l.clear(),d=null},w=()=>{const e=t.querySelector("#mfm-bulk-close-btn"),s=t.querySelector("#mfm-bulk-save-btn"),i=t.querySelector("#mfm-bulk-search"),a=t.querySelector("#mfm-bulk-domain-filter"),l=t.querySelector("#mfm-editor-close"),d=t.querySelector("#mfm-editor-cancel"),m=t.querySelector("#mfm-editor-save");e&&(e.onclick=()=>{v.setBulkMockOpen(!1)}),s&&(s.onclick=async()=>{const e=h.state.requests.filter((e=>n.has(e.requestId)));await E(e)}),i&&(i.oninput=e=>{r=e.target.value,f()}),a&&(a.onchange=e=>{o=e.target.checked,f()}),l&&(l.onclick=()=>null==c?void 0:c.hide()),d&&(d.onclick=()=>null==c?void 0:c.hide()),m&&(m.onclick=()=>y({body:t.querySelector("#mfm-editor-textarea").value,status:parseInt(t.querySelector("#mfm-editor-status").value)||200,enabled:t.querySelector("#mfm-editor-enabled-switch").checked}))},E=async e=>{const t=h.state.token;if(!t)return void x("Token not found","error");const n={apis:e.map((e=>{var t,n,o;let r=i.get(e.requestId);void 0===r&&(r="string"==typeof(null==(t=e.response)?void 0:t.body)?e.response.body:JSON.stringify((null==(n=e.response)?void 0:n.body)||{}));let s=a.get(e.requestId);if(void 0===s){let t=null==(o=e.response)?void 0:o.statusCode;s=200,"Error"===t||"error"===t?s=504:null!=t&&(s=Number(t),isNaN(s)&&(s=504))}return{url:e.request.url,method:e.request.method,body:e.request.body||{},status:s,response:r,headers:JSON.stringify(e.request.headers||{}),enabled:l.get(e.requestId)||!1}}))},o=JSON.stringify(n),r=new Blob([o]).size;if(r>1048576)x(`Payload size (${(r/1048576).toFixed(2)}MB) exceeds 1MB limit.`,"error");else try{const e=await fetch(`${X}${Y}/httpRequestBulkMock/bulk_mock`,{method:"POST",headers:{"Content-Type":"application/json",mockforme:t},body:o}),n=await e.json();e.ok?(v.setBulkMockOpen(!1),x(n.message||"Bulk mocks created successfully"),setTimeout((()=>{v.reloadMappings()}),2e3)):(x(n.message||"Bulk upload failed","error"),console.error("Bulk upload failed",n))}catch(e){x("Error during bulk upload","error"),console.error("Error during bulk upload:",e)}};e.appendChild(t),h.subscribe(m),m()}(o);const r=e=>{const t=Boolean(e.token),r=o.querySelector(".mfm-header"),s=o.querySelector(".mfm-tabs-container"),i=o.querySelector(".mfm-token-form");r&&(r.style.display=t?"flex":"none"),s&&(s.style.display=t?"block":"none"),i&&(i.style.display=t?"none":"block"),o.classList.toggle("hidden",!e.isOpen),n.classList.toggle("hidden",e.isOpen)};h.subscribe(r),r(h.state);const s=n.querySelector(".mfm-toggle-reload"),i=n.querySelector(".mfm-toggle-logo");return s&&(s.onclick=e=>{e.stopPropagation(),"true"!==n.dataset.moved&&(h.state.token?v.reloadMappings():h.update("isOpen",!0))}),i&&(i.onclick=e=>{e.stopPropagation(),"true"!==n.dataset.moved&&(h.state.token?v.toggleWidget():h.update("isOpen",!0))}),window.addEventListener("click",(e=>{const t=e.target;(null==t?void 0:t.closest(".mfm-dropdown"))||v.clearOpenDropdown()})),t}function ne(e){i.info("Initializing MockForMe Widget");let t=null;const n=e=>{e&&(t=te(e))},o=()=>e||document.body;o()?n(o()):"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>n(o()))):document.body&&n(document.body),m();const s={[r.MFM_RES_MAPPINGS]:e=>{if(!e)return;const t=h.state.isMappingsLoading;if(e.token&&!h.state.token&&(i.info("Setting token from incoming MFM_RES_MAPPINGS"),h.update("token",e.token),localStorage.setItem("MFM_TOKEN",e.token)),h.set("mappings",e),h.update("isMappingsLoading",!1),h.state.isTokenValidating){const e=localStorage.getItem("MFM_TOKEN_TEMP")||h.state.token;e&&(h.update("token",e),localStorage.setItem("MFM_TOKEN",e),localStorage.removeItem("MFM_TOKEN_TEMP")),h.update("isTokenValidating",!1),h.update("isTokenLoading",!1),v.flushQueue()}k(),t&&!h.state.ui.tokenError&&x("Mappings reloaded successfully")},[r.MFM_REQ]:e=>{e&&(i.info("Captured Request",e),v.addRequest(e))},[r.MFM_RES]:e=>{e&&(i.info("Captured Response",e),v.addRequest(e))},[r.MFM_TOKEN_ERROR]:e=>{w(r.MFM_TOKEN_ERROR,e)},[r.MFM_TOKEN_API_FAILED]:e=>{w(r.MFM_TOKEN_API_FAILED,e)},[r.MFM_TOGGLE_INTERCEPTION]:e=>{e&&"boolean"==typeof e.enabled&&v.toggleInterception(e.enabled)}},l=Object.keys(s).map((e=>function(e,t){m(),a.has(e)||a.set(e,new Set);const n=a.get(e);return n.add(t),()=>{n.delete(t)}}(e,(t=>{(0,s[e])(t)}))));return h.state.token&&v.fetchSavedMappings(),{destroy(){l.forEach((e=>e())),t&&t.remove()},actions:v}}const oe={run:ne,initMFM:ne,actions:v};window.MFM=oe}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};const o=()=>"undefined"!=typeof process&&null!=process.versions?.node,r=e=>{try{return e?e.toLowerCase():e}catch(e){return console.log(e),null}},s=(e,t)=>{const n=e.split("/"),o=t.split("/");if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++){const t=n[e];if(t!==o[e]&&":any"!==t)return!1}return!0};let i=[];function a(e){i=e}function l(){return i}function d(e,t="get"){const n=e=>e.startsWith("/")?e:`/${e}`,o=n(e);for(const a of i)if(r(a.apiMethod)===r(t)){const r=n(a.apiEndpoint);if(r===o||s(r,o)){console.log(`[MockForMe] Match Found: ${t} ${e} -> ${a.apiEndpoint}`);const n={url:e,method:a.apiMethod,_ack:a._ack||null};return a._ri_&&(n._ri_=a._ri_),n}}return null}const c="JAVASCRIPT",m="CHROME_EXTENSION",u="mfmver",p="mockforme",f="8.2.0",h="https://api.mockforme.com",b=`${h}/mockforme`,g=`${h}/gateway/3f4eae522b`;let y=null,v=null,x=null,k=[];function w({_o:e,mk:t,_mck:n,_rules:o}){y=e,v=t,x=n,k=o}function E(){return k}function M(){return`${b}/${y}/${v}`}function q(){return x}const S=e=>{try{return new URL(e,window.location.origin).toString()}catch{return e}},R=function(e,t,n){const r=o();var s;function i(){if(4==s.readyState)if(s.status.toString().match(/^20[0-9]$/)){var e=function(){var e=s.getResponseHeader("Content-Type"),t=s.responseText;if(e){var n=e.split(";");try{return"application/json"===n[0]?JSON.parse(t):t}catch(e){throw"Unable to convert response header"}}}();t.call(this,e,s)}else n.call(this,s.responseText,s)}function a(e,t){var n=[];for(var o in e)if(e.hasOwnProperty(o)){var r=t?t+"["+o+"]":o,s=e[o];n.push("object"==typeof s?a(s,r):encodeURIComponent(r)+"="+encodeURIComponent(s))}return n.join("&")}return r||(window.XMLHttpRequest?s=new XMLHttpRequest:window.ActiveXObject&&(s=new ActiveXObject("Microsoft.XMLHTTP"))),{request:function(){if(!r){if(window.XMLHttpRequest)s.onload=i;else{if(!window.ActiveXObject)throw"unable to process ajax";s.onreadystatechange=i}var t=a(e.params);if("get"==e.method.toLowerCase()&&"object"==typeof e.params){if(-1==e.url.indexOf("?"))e.url+="?";else{var n=e.url.split("?");n[1]&&n[1].split("=")[1]&&(e.url+="&")}e.url+=t}e.hasOwnProperty("async")||(e.async=!0),s.open(e.method,e.url,e.async),e.headers&&function(e){for(let t in e)s.setRequestHeader(t,e[t])}(e.headers),s.send(t)}}}};function _({di:e,iv:t},n){var o;const r=function(e,t){const n=t.length;return e.split("").map(((e,o)=>String.fromCharCode(e.charCodeAt(0)^t.charCodeAt(o%n)))).join("")}((o=e,"undefined"!=typeof Buffer?Buffer.from(o,"base64").toString("utf8"):decodeURIComponent(escape(atob(o)))),n+t);return JSON.parse(r)}function T(e,t,n,o){fetch(g,{method:"GET",headers:{[p]:e,[u]:f,"x-mfm-adaptor":t}}).then((e=>{if(!e.ok)throw e;return e.json()})).then((e=>{if(e){const{di:t,iv:o,_o:r,_mck:s,mk:i,r:l}=e,d=_({di:t,iv:o},r);w({_o:r,mk:i,_mck:s,_rules:l}),d&&(a(d),n(d,{_o:r,mk:i,_mck:s,_rules:l}))}})).catch((e=>{console.error("Error in loading mocked APIs:",e),o(e)}))}const C="MFM_TOKEN_ERROR",O=new class{constructor(e={}){o()||(this.token=e.token||("undefined"!=typeof localStorage?localStorage.getItem("MFM_TOKEN"):null),this.isAuthenticated=!!this.token,this.onAuthSuccess=e.onAuthSuccess||(()=>{}),this.mappings=e.mappings||[],this.rules=e.rules||[],this.widgetKey=e.widgetKey||null,this.interceptionEnabled="undefined"==typeof localStorage||"false"!==localStorage.getItem("MFM_INTERCEPTION_ENABLED"),this.setupMessageListeners())}setupMessageListeners(){"undefined"!=typeof window&&window.addEventListener("message",(e=>{const{type:t,payload:n}=e.data||{};if(t&&"string"==typeof t&&t.startsWith("MFM_"))switch(t){case"MFM_REQ_MAPPINGS":this.refreshMappings();break;case"MFM_REQ_SAVED_MAPPINGS":this.handleReqSavedMappings();break;case"MFM_SUBMIT_TOKEN":this.handleTokenSubmission(n?.token);break;case"MFM_DEL_CLIENT_TOKEN":this.handleTokenDeletion();break;case"MFM_TOGGLE_INTERCEPTION":this.interceptionEnabled=!!n?.enabled,"undefined"!=typeof localStorage&&localStorage.setItem("MFM_INTERCEPTION_ENABLED",this.interceptionEnabled)}}))}init(){if("undefined"!=typeof document&&this.checkVisibility()&&("undefined"!=typeof window&&Promise.resolve().then(n.bind(n,849)).then((()=>{window.MFM&&"function"==typeof window.MFM.run&&window.MFM.run()})).catch((e=>{console.error("[MockForMe] Failed to load mfm-widget",e)})),console.log("[MockForMe] Widget initialized"),this.token)){const e=this.getSavedMappings();e&&(this.mappings=e.mappings||[],this.rules=e.meta?._rules||[],this.onAuthSuccess(this.token,this.mappings,e.meta),this.updateMappings(this.mappings,e.meta))}}setWidgetKey(e){this.widgetKey=e,this.init()}checkVisibility(){return!this.widgetKey||"undefined"!=typeof localStorage&&localStorage.getItem("widgetKey")===this.widgetKey}handleTokenSubmission(e){e&&(this.token=e,this.isAuthenticated=!0,"undefined"!=typeof localStorage&&localStorage.setItem("MFM_TOKEN",e),this.refreshMappings())}handleTokenDeletion(){this.token=null,this.isAuthenticated=!1,"undefined"!=typeof localStorage&&(localStorage.removeItem("MFM_TOKEN"),localStorage.removeItem("MFM_CACHED_MAPPINGS")),this.mappings=[],this.rules=[],this.onAuthSuccess(null,[],{_rules:[]}),this.updateMappings([],{_rules:[]})}refreshMappings(){this.token&&T(this.token,"JAVASCRIPT",((e,t)=>{this.mappings=e||[],this.rules=t?._rules||[],this.saveMappings(e,t),this.onAuthSuccess(this.token,this.mappings,t),this.updateMappings(this.mappings,t)}),(e=>{console.error("[MockForMe] Failed to fetch mappings",e),e instanceof Response&&e.headers&&"true"===e.headers.get("mfm-invalid-token")&&this.sendMessage(C,{message:"Unauthorized: Invalid token"}),this.updateMappings([],{_rules:[]})}))}saveMappings(e,t){if("undefined"!=typeof localStorage)try{localStorage.setItem("MFM_CACHED_MAPPINGS",JSON.stringify({mappings:e,meta:t}))}catch(e){console.error("[MockForMe] Failed to save mappings to storage",e)}}handleReqSavedMappings(){const e=this.getSavedMappings();e?(this.mappings=e.mappings||[],this.rules=e.meta?._rules||[],this.onAuthSuccess(this.token,this.mappings,e.meta),this.updateMappings(this.mappings,e.meta)):this.refreshMappings()}getSavedMappings(){if("undefined"==typeof localStorage)return null;try{const e=localStorage.getItem("MFM_CACHED_MAPPINGS");return e?JSON.parse(e):null}catch(e){return null}}updateMappings(e,t){this.sendMessage("MFM_RES_MAPPINGS",{apis:e.map((e=>({method:e.apiMethod,url:e.apiEndpoint}))),rules:(t?._rules||[]).map((e=>{const t="object"==typeof e.rule&&null!==e.rule?e.rule:{},n={...e,...t},o=n.timingAction||{},r=o.activeAction||"MODIFY";let s="MODIFY";"delay"===r?s="DELAY":"delay_and_timeout"===r?s="TIMEOUT":"delay_and_redirect"===r&&(s="REDIRECT");const i={ruleName:n.ruleName||n._id||"Unnamed Rule",type:s,conditions:n.conditions||[],modificationActions:n.modificationActions||{}};return("MODIFY"!==s||o.activeAction)&&(i.timingAction=o),i})),token:this.token})}addRequest(e,t){if(!this.interceptionEnabled)return;const n=e=>{if(!e)return{};let t={};return"string"==typeof e?e.split("\r\n").forEach((e=>{const n=e.split(": "),o=n.shift();o&&(t[o]=n.join(": "))})):t="function"==typeof e.entries?Object.fromEntries(e.entries()):e,Object.keys(t).reduce(((e,n)=>(e[n.toLowerCase()]=t[n],e)),{})},o={requestId:t.requestId||Math.random().toString(36).substring(7),interceptionType:"mocked"===e?"MOCKED":"OTHER",request:{method:t.method,url:t.url,headers:n(t.requestHeaders||t.headers),body:t.requestBody||t.body},response:t.pending&&void 0===t.status?null:{statusCode:t.status,headers:n(t.responseHeaders),body:t.responseBody,endTime:(new Date).toISOString()},rule:t.rule};if(t.pending)this.sendMessage("MFM_REQ",o);else if(this.sendMessage("MFM_RES",o),o.response&&o.response.headers){const e=o.response.headers["mfm-invalid-token"];if("true"===e||!0===e){const{message:e}=t.responseBody;console.warn("[MockForMe] Invalid token detected from response headers"),this.sendMessage(C,{message:e||"Unauthorized: Invalid token detected from response headers"}),this.handleTokenDeletion()}}}sendMessage(e,t){"undefined"!=typeof window&&window.postMessage({type:e,payload:t},"*")}};class I{static match(e,t){if(!Array.isArray(t)||0===t.length)return!1;const{url:n,headers:o,queryParams:r,body:s}=e,i="undefined"!=typeof window?window.location.origin:globalThis.location?.origin||"http://localhost";for(const e of t){let t="";const{type:a,key:l,operator:d,value:c}=e;switch(a){case"URL":try{t=new URL(n,i).pathname}catch{t=n}break;case"QUERY_PARAM":if(r&&void 0!==r[l])t=String(r[l]);else try{t=new URL(n,i).searchParams.get(l)||""}catch{t=""}break;case"REQUEST_BODY":if(l){if("object"==typeof s&&null!==s)t=void 0!==s[l]?String(s[l]):"";else if("string"==typeof s)try{const e=JSON.parse(s);t=void 0!==e[l]?String(e[l]):""}catch{t=""}}else t="object"==typeof s?JSON.stringify(s):String(s||"");break;case"REQUEST_HEADER":if(l){const e=l?.toLowerCase();if(t="",o){const n=Object.keys(o).find((t=>t.toLowerCase()===e));t=n?String(o[n]):""}}else t=JSON.stringify(o||{});break;default:return!1}if(!this.evaluate(t,d,c))return!1}return!0}static evaluate(e,t,n){const o=t?.toLowerCase(),r=String(e),s=String(n);switch(o){case"contains":return r.includes(s);case"equal":case"equals":return r===s;case"regexp":try{let e=s;if(e.startsWith("/")&&e.lastIndexOf("/")>0){const t=e.lastIndexOf("/"),n=e.slice(1,t),o=e.slice(t+1);return new RegExp(n,o).test(r)}return new RegExp(e).test(r)}catch{return!1}default:return!1}}}class L{static async apply(e){if(!e||!e.activeAction)return{type:"passThrough",delay:0};const{activeAction:t,actions:n}=e,o=n?.[t];if(!o)return{type:"passThrough",delay:0};const r={type:"passThrough",delay:0},s=Number(o.value||0);switch(t){case"delay":r.delay=s,r.delay>0&&await new Promise((e=>setTimeout(e,1e3*r.delay)));break;case"redirect":case"delay_and_redirect":r.type="redirect",r.delay=s,r.redirectUrl=o.redirectUrl,r.delay>0&&await new Promise((e=>setTimeout(e,1e3*r.delay)));break;case"delay_and_timeout":r.type="timeout",r.delay=s,r.delay>0&&await new Promise((e=>setTimeout(e,1e3*r.delay)))}return r}}class N{static applyRequestModifications(e,t){if(!t)return e;let{url:n,method:o,headers:r,queryParams:s,body:i}={...e};r&&(r={...r}),s&&(s={...s});const{modifyQueryParams:a,modifyRequestBody:l,modifyRequestHeaders:d}=t;if(a?.enabled)try{const e=new URL(n,"undefined"!=typeof window?window.location.href:"http://localhost");Array.isArray(a.remove)&&a.remove.forEach((t=>{e.searchParams.delete(t),s&&delete s[t]})),Array.isArray(a.add)&&a.add.forEach((({key:t,value:n})=>{e.searchParams.set(t,n),s&&(s[t]=n)})),n=e.toString()}catch(e){console.error("[MockForMe] Failed to modify query params",e)}d?.enabled&&(r={...r},Array.isArray(d.remove)&&d.remove.forEach((e=>{const t=e.toLowerCase(),n=Object.keys(r).find((e=>e.toLowerCase()===t));n&&delete r[n]})),Array.isArray(d.add)&&d.add.forEach((({key:e,value:t})=>{r[e]=t})));const c=String(o||"GET").toUpperCase(),m="GET"===c||"HEAD"===c;if(l?.enabled&&!m)try{let e=null;if("string"==typeof i)try{e=JSON.parse(i)}catch{e={}}else if("object"==typeof i&&null!==i)try{e=JSON.parse(JSON.stringify(i))}catch{e={...i}}else(Array.isArray(l.add)&&l.add.length>0||Array.isArray(l.update)&&l.update.length>0)&&(e={});e&&(Array.isArray(l.remove)&&l.remove.forEach((t=>delete e[t])),Array.isArray(l.add)&&l.add.forEach((({key:t,value:n})=>e[t]=n)),Array.isArray(l.update)&&l.update.forEach((({key:t,value:n})=>e[t]=n)),i=JSON.stringify(e))}catch(e){console.error("[MockForMe] Failed to modify request body",e)}return{...e,url:n,headers:r,queryParams:s,body:i}}static applyResponseModifications(e,t){if(!t?.modifyResponseHeaders?.enabled)return e;const{modifyResponseHeaders:n}=t,o={...e};return Array.isArray(n.remove)&&n.remove.forEach((e=>{const t=e.toLowerCase(),n=Object.keys(o).find((e=>e.toLowerCase()===t));n&&delete o[n]})),Array.isArray(n.add)&&n.add.forEach((({key:e,value:t})=>{o[e]=t})),o}}class A{static match(e,t){if(!Array.isArray(t)||0===t.length)return null;for(const n of t){const t=n.rule||n;if(t.conditions&&Array.isArray(t.conditions)&&I.match(e,t.conditions)){const e=t.timingAction?.activeAction||"";return{action:e,config:t.timingAction?.actions?.[e]||{},rule:t}}}return null}static async apply(e,t){if(!e)return null;const n=e.rule||e,o=N.applyRequestModifications(t,n.modificationActions);return{...await L.apply(n.timingAction),modifiedRequest:o,rule:n}}static applyResponseModifications(e,t){return N.applyResponseModifications(e,t)}}class ${static apply({target:e=("undefined"!=typeof window?window:globalThis),originalFetch:t=e.fetch,ruleProvider:n=()=>[],mappingProvider:o=e=>null,onBeforeRequest:r=e=>{},onRuleMatch:s=async(e,t,n,o,r)=>null,onMockMatch:i=async(e,t,n,o,r)=>null,onOtherRequest:a=async(e,t,n,o)=>null,isEnabled:l=()=>!0}){t&&(e.fetch=async function(e,d={}){if(!l())return t(e,d);let c;try{const t="string"==typeof e?e:e.url,n=String(d.method||(e instanceof Request?e.method:"GET")).toUpperCase().trim(),o=Math.random().toString(36).substring(7);c={url:t,method:n,headers:d.headers||(e instanceof Request?e.headers:{}),body:d.body||(e instanceof Request?"{binary/stream}":null),requestId:o,queryParams:$.getQueryParams(t)},r(c)}catch(n){return console.warn("[MockForMe] Fetch Interceptor Setup Error:",n),t(e,d)}try{const r=n(),l=A.match(c,r);if(l){const n=await s(l,c,e,d,t);if(n)return n}const m=o(c);if(m){const n=await i(m,c,e,d,t);if(n)return n}const u=await a(c,e,d,t);if(u)return u}catch(e){if(e.message.includes("timed out")||"AbortError"===e.name||e.message.includes("rules"))throw e;throw console.warn("[MockForMe] Interceptor Hook Error:",e),e}return t(e,d)})}static getQueryParams(e){try{const t="undefined"!=typeof window?window.location.origin:"http://localhost",n=new URL(e,t).searchParams;return Object.fromEntries(n.entries())}catch{return{}}}}class j{static apply({target:e=("undefined"!=typeof window?window:{}),OriginalXHR:t=e.XMLHttpRequest,ruleProvider:n=()=>[],mappingProvider:o=e=>null,onBeforeRequest:r=e=>{},onRuleMatch:s=(e,t,n,o)=>{o.call(n.proxy,t.body)},onMockMatch:i=(e,t,n,o)=>{o.call(n.proxy,t.body)},onOtherRequest:a=(e,t,n)=>{n.call(t.proxy,e.body)},isEnabled:l=()=>!0}){t&&(e.XMLHttpRequest=class{constructor(){return this._xhr=new t,this._headers={},this._method=null,this._url=null,this._body=null,this._requestId=null,this._startTime=null,this._captured=!1,this._isMocked=!1,this.proxy=new Proxy(this,{get:(e,t)=>{if(t in e)return e[t];const n=e._xhr[t];return"function"==typeof n?n.bind(e._xhr):n},set:(e,t,n)=>t in e?(e[t]=n,!0):(e._xhr[t]=n,!0)}),this.proxy}_capture(e,t,n,o={}){if(this._captured)return;this._captured=!0;const r=e=>{const t=`on${e}`;(this[t]||this._xhr[t])?.(),this._xhr.dispatchEvent(new Event(e))};if("Aborted"!==e)try{Object.defineProperty(this.proxy,"responseText",{value:t,configurable:!0}),Object.defineProperty(this.proxy,"response",{value:t,configurable:!0}),Object.defineProperty(this.proxy,"status",{value:Number(e)||0,configurable:!0}),Object.defineProperty(this.proxy,"statusText",{value:200==e?"OK":"",configurable:!0})}catch(e){console.warn("[MockForMe] Error setting XHR props",e)}Object.defineProperty(this.proxy,"readyState",{value:4,configurable:!0}),r("readystatechange"),"Aborted"===e||o.aborted?r("abort"):0===e||"Error"===e||o.error?r("error"):"Timeout"===e||o.timeout?r("timeout"):r("load")}open(e,t,n=!0,o=null,r=null){this._method=(e||"").toUpperCase().trim();try{this._url=new URL(t,"undefined"!=typeof window?window.location.href:"http://localhost").toString()}catch(e){this._url=t}return this._xhr.open(e,t,n,o,r)}setRequestHeader(e,t){return this._headers[e]=t,this._xhr.setRequestHeader(e,t)}send(e){if(!l())return this._xhr.send(e);this._body=e,this._requestId=Math.random().toString(36).substring(7),this._startTime=Date.now();const t={url:this._url,method:this._method,headers:this._headers,body:this._body,requestId:this._requestId,startTime:this._startTime,queryParams:j.getQueryParams(this._url)};r(t);const d=n(),c=A.match(t,d),m=e=>this._xhr.send(e);if(c)return this._isMocked=!0,s(c,t,this,m);const u=o(t);return u?(this._isMocked=!0,i(u,t,this,m)):(this._isMocked=!1,a(t,this,m))}})}static getQueryParams(e){try{const t="undefined"!=typeof window?window.location.origin:"http://localhost",n=new URL(e,t).searchParams;return Object.fromEntries(n.entries())}catch{return{}}}}const P=(e,t=null,n=c)=>{if(o())return;let r="string"==typeof e?e:e?.token,s="object"==typeof e?e?.widgetKey:null;if(s?O.setWidgetKey(s):O.init(),n===c)try{r&&("undefined"!=typeof localStorage&&(localStorage.removeItem("mockforme-token"),localStorage.setItem("MFM_TOKEN",r)),O.token=r,O.isAuthenticated=!0),!r&&O.token&&(r=O.token),O.onAuthSuccess=(e,t,n)=>{a(t),w(n),O.updateMappings(t,n)}}catch(e){console.log("Error in showing mockforme widget",e)}t||={mappings:[],_o:null,mk:null,_mck:null,_rules:[]};const{mappings:i=[],_o:h,mk:b,_mck:y,_rules:v=[]}=t;return a(i),w({_o:h,mk:b,_mck:y,_rules:v}),{run:(e,t=()=>{})=>{if(function(e,t){if("undefined"!=typeof window){if(window._mfm_intercepted)return;window._mfm_intercepted=!0}const n=()=>O.token||e;$.apply({isEnabled:()=>O.interceptionEnabled,ruleProvider:()=>E(),mappingProvider:e=>{try{return d(new URL(e.url,window.location.origin).pathname,e.method)}catch{return null}},onRuleMatch:async(e,t,n,o,r)=>{const s=t.requestId||Math.random().toString(36).substring(7),i=Date.now();O.addRequest("mocked",{...t,requestId:s,pending:!0,startTime:i,rule:e});const a=await A.apply(e,t),{modifiedRequest:l,type:d,delay:c,redirectUrl:m}=a;if("timeout"!==d&&O.addRequest("mocked",{...l,requestId:s,pending:!0,startTime:i,rule:e}),"timeout"===d){const t=Date.now()-i;throw O.addRequest("mocked",{...l,requestId:s,status:"Aborted",pending:!1,duration:t,aborted:!0,rule:e}),new Error("Fetch timed out by rules")}if("redirect"===d&&!m)throw new Error("rules: Redirect missing URL");let u="redirect"===d?m:l.url,p={...o};l.headers&&(p.headers=l.headers),l.body&&(p.body=l.body);let f=null;if("redirect"===d){f=Math.random().toString(36).substring(7);const e={url:m,method:l.method,headers:p.headers||{},body:p.body,requestId:f,queryParams:$.getQueryParams(m),requestHeaders:p.headers||{},requestBody:p.body,pending:!0,startTime:Date.now()};O.addRequest("mocked",e)}return r(u,p).then((async e=>{const t=Date.now()-i;let n=Object.fromEntries(e.headers.entries());if(a.rule.modificationActions?.modifyResponseHeaders?.enabled&&(n=A.applyResponseModifications(n,a.rule.modificationActions)),"redirect"===d&&f){const t=e.clone(),o=t.headers.get("content-type")||"",r=Date.now()-i;try{let s;s=o.includes("application/json")?await t.json():await t.text(),O.addRequest("mocked",{url:m,method:l.method,requestId:f,status:e.status,pending:!1,duration:r,responseHeaders:n,responseBody:s,requestHeaders:p.headers||{},requestBody:p.body})}catch(t){O.addRequest("mocked",{url:m,method:l.method,requestId:f,status:e.status,pending:!1,duration:r,responseHeaders:n,requestHeaders:p.headers||{},requestBody:p.body})}}return O.addRequest("mocked",{...l,requestId:s,status:e.status,pending:!1,duration:t,responseHeaders:n,rule:a.rule}),e})).catch((e=>{const t=Date.now()-i,n="AbortError"===e.name||e.message.includes("aborted");if(O.addRequest("mocked",{...l,requestId:s,status:n?"Aborted":0,pending:!1,duration:t,rule:a.rule}),"redirect"===d&&f&&O.addRequest("mocked",{url:m,method:l.method,requestId:f,status:n?"Aborted":0,pending:!1,duration:t,error:!n}),"redirect"===d){const t=e.message||"Redirect failed";if(!t.includes("rules"))throw new Error(`rules: Redirect failed - ${t}`)}throw e}))},onMockMatch:async(e,o,r,s,i)=>{const a=o.requestId||Math.random().toString(36).substring(7),l=Date.now();O.addRequest("mocked",{...o,requestId:a,pending:!0,startTime:l});const d=n(),c=new URL(o.url,window.location.origin).search;let h=`${M()}${e.url}${c}`,b={[p]:d,[u]:f,"x-mfm-adaptor":t};const g=q();g&&e._ack&&(b["x-mfm-key"]=`${g}-${e._ack}`),e?._ri_&&(b._ri_=e._ri_);const y=r instanceof Request?r.headers:s.headers,v=new Headers(y||{});Object.entries(b).forEach((([e,t])=>v.set(e,t))),v.set("x-mfm-internal","true");let x=s.body;if(!x&&r instanceof Request){const e=r.clone();"GET"!==e.method&&"HEAD"!==e.method&&(x=await e.text())}const k={method:o.method,headers:v,credentials:r instanceof Request&&r.credentials||s.credentials||"include",mode:r instanceof Request&&r.mode||s.mode||"cors"};return t===m?(({actualUrl:e,url:t,method:n,headers:o,body:r,credentials:s,mode:i,rule:a})=>{const l=`${Date.now()}-${Math.random()}`,d=S(t);return new Promise(((t,c)=>{window.addEventListener("message",(function e(n){if(n.source!==window)return;const o=n.data;if("INTERCEPTED_RESPONSE"===o?.type&&o?.requestId===l){if(window.removeEventListener("message",e),o?.response?.error)return c(new Error(o.response.message));const{status:n,headers:r,body:s}=o.response,i=new Response(s,{status:n,headers:r});i._rawHeaders=r,t(i)}})),window.postMessage({type:"REQUEST_INTERCEPTED",requestId:l,payload:{actualUrl:e,url:d,method:n,headers:o,body:r,credentials:s,mode:i,rule:a}},"*")}))})({actualUrl:o.url,url:h,method:o.method,headers:Object.fromEntries(v.entries()),body:x,credentials:k.credentials,mode:k.mode}).then((e=>(e.clone().text().then((t=>{const n=Date.now()-l,r=e._rawHeaders||Object.fromEntries(e.headers.entries());O.addRequest("mocked",{...o,requestId:a,status:e.status,responseHeaders:r,responseBody:t,pending:!1,duration:n})})),e))):(x&&(k.body=x),i(h,k).then((async e=>{const t=e.clone(),n=t.headers.get("content-type")||"",r=Date.now()-l,s=n=>(O.addRequest("mocked",{...o,requestId:a,status:e.status,responseHeaders:Object.fromEntries(t.headers.entries()),responseBody:n,pending:!1,duration:r}),new Response("string"==typeof n?n:JSON.stringify(n),{status:e.status,headers:t.headers}));return n.includes("application/json")?t.json().then(s):t.text().then(s)})).catch((e=>{const t=Date.now()-l;return O.addRequest("mocked",{...o,requestId:a,status:0,pending:!1,duration:t}),i(r,s)})))},onOtherRequest:async(e,t,n,o)=>{const r=n?.headers||(t instanceof Request?t.headers:{});let s=!1;r instanceof Headers?s="true"===r.get("x-mfm-internal"):"object"==typeof r&&(s="true"===r["x-mfm-internal"]);const i=M();if(e.url.startsWith(i)&&(s=!0),"OPTIONS"===e.method||s)return o(t,n);const a=e.requestId,l=Date.now();return O.addRequest("other",{...e,requestId:a,pending:!0,startTime:l}),o(t,n).then((async t=>{const n=t.clone(),o=Date.now()-l,r=Object.fromEntries(t.headers.entries());O.addRequest("other",{...e,requestId:a,status:t.status,responseHeaders:r,pending:!0,duration:o});try{const s=await n.text();O.addRequest("other",{...e,requestId:a,status:t.status,responseHeaders:r,responseBody:s,pending:!1,duration:o})}catch(n){O.addRequest("other",{...e,requestId:a,status:t.status,responseHeaders:r,pending:!1,duration:o})}return t})).catch((t=>{const n=Date.now()-l,o="AbortError"===t.name||t.message.includes("aborted"),r="TimeoutError"===t.name||t.message.includes("timed out");throw O.addRequest("other",{...e,requestId:a,status:o?"Aborted":r?"Timeout":"Error",pending:!1,duration:n,aborted:o,timeout:r,error:!o&&!r}),t}))}}),j.apply({isEnabled:()=>O.interceptionEnabled,ruleProvider:()=>E(),mappingProvider:e=>{try{return d(new URL(e.url,window.location.origin).pathname,e.method)}catch{return null}},onRuleMatch:async(e,t,n,o)=>{const r=t.requestId,s=Date.now();O.addRequest("mocked",{...t,requestId:r,pending:!0,startTime:s,rule:e});const i=await A.apply(e,t),{modifiedRequest:a,type:l,redirectUrl:d}=i;"timeout"!==l&&O.addRequest("mocked",{...a,requestId:r,pending:!0,startTime:s,rule:e});let c=null;if("redirect"===l){c=Math.random().toString(36).substring(7);const e={url:d,method:a.method,headers:a.headers||{},body:a.body,requestId:c,queryParams:(()=>{try{const e="undefined"!=typeof window?window.location.origin:"http://localhost",t=new URL(d,e).searchParams;return Object.fromEntries(t.entries())}catch{return{}}})(),requestHeaders:a.headers||{},requestBody:a.body,pending:!0,startTime:Date.now()};O.addRequest("mocked",e)}const m=(e,t,o,m={})=>{const u=Date.now()-s;if(i.rule.modificationActions?.modifyResponseHeaders?.enabled){let e="string"==typeof o?Object.fromEntries(o.split("\r\n").filter((e=>e)).map((e=>e.split(": ")))):o;e=A.applyResponseModifications(e,i.rule.modificationActions),o=e}O.addRequest("mocked",{...a,requestId:r,status:e,responseBody:t,responseHeaders:o,pending:!1,duration:u,rule:i.rule,...m}),"redirect"===l&&c&&O.addRequest("mocked",{url:d,method:a.method,requestId:c,status:e,responseBody:t,responseHeaders:o,pending:!1,duration:u,requestHeaders:a.headers||{},requestBody:a.body,...m}),n._capture(e,t,o,m)};if("timeout"===l)return m("Aborted","Timed out by rule",{},{aborted:!0}),void n._xhr.abort();if("redirect"===l){if(!d)return void m(0,"Redirect missing URL",{},{error:!0});n._xhr.open(a.method,d,!0)}else a.url!==t.url&&n._xhr.open(a.method,a.url,!0);a.headers&&Object.entries(a.headers).forEach((([e,t])=>{try{n._xhr.setRequestHeader(e,t)}catch(e){}})),n._xhr.addEventListener("abort",(()=>m("Aborted","Aborted",{},{aborted:!0})),{once:!0}),n._xhr.addEventListener("error",(()=>m(0,"Error",{},{error:!0})),{once:!0}),n._xhr.addEventListener("timeout",(()=>m("Timeout","Timeout",{},{timeout:!0})),{once:!0}),n._xhr.addEventListener("load",(()=>m(n._xhr.status,n._xhr.responseText,n._xhr.getAllResponseHeaders())),{once:!0}),o(a.body)},onMockMatch:(e,o,r,s)=>{const i=o.requestId,a=Date.now(),l=n(),d=new URL(o.url,window.location.origin);let c=`${M()}${e.url}${d.search}`,h={[p]:l,[u]:f,"x-mfm-adaptor":t};const b=q();b&&e._ack&&(h["x-mfm-key"]=`${b}-${e._ack}`),e?._ri_&&(h._ri_=e._ri_),h["x-mfm-internal"]="true";const g={...o.headers,...h};O.addRequest("mocked",{...o,requestId:i,pending:!0,startTime:a});const y=(e,t,n,s={})=>{const l=Date.now()-a;O.addRequest("mocked",{...o,requestId:i,status:e,responseBody:t,responseHeaders:n,pending:!1,duration:l,...s}),r._capture(e,t,n,s)};if(r._xhr.addEventListener("abort",(()=>y("Aborted","Aborted",{},{aborted:!0})),{once:!0}),r._xhr.addEventListener("error",(()=>y(0,"Error",{},{error:!0})),{once:!0}),r._xhr.addEventListener("timeout",(()=>y("Timeout","Timeout",{},{timeout:!0})),{once:!0}),t===m)(({actualUrl:e,url:t,method:n,headers:o,body:r,onSuccess:s,onError:i,rule:a})=>{const l=`${Date.now()}-${Math.random()}`,d=S(t);window.addEventListener("message",(function e(t){if(t.source!==window)return;const n=t.data;if("INTERCEPTED_RESPONSE"===n.type&&n.requestId===l){if(window.removeEventListener("message",e),n.response?.error)return i?.(n.response.message);const{body:t,status:o,headers:r}=n.response;s?.({body:t,status:o,headers:r})}})),window.postMessage({type:"REQUEST_INTERCEPTED",requestId:l,payload:{actualUrl:e,url:d,method:n,headers:o,body:r,credentials:"same-origin",mode:"cors",rule:a}},"*")})({actualUrl:o.url,url:c,method:o.method,headers:g,body:o.body,onSuccess:({body:e,status:t,headers:n})=>y(t,e,n||{}),onError:e=>y(0,e.message||"XHR Error",{},{error:!0})});else{const e=new window.XMLHttpRequest;e.open(o.method,c,!0);for(const t in g)e.setRequestHeader(t,g[t]);e.withCredentials=r.proxy.withCredentials,e.onload=()=>y(e.status,e.responseText,e.getAllResponseHeaders()),e.onerror=()=>y(0,"Network Error",{},{error:!0}),e.ontimeout=()=>y("Timeout","Request timed out",{},{timeout:!0}),e.send(o.body)}},onOtherRequest:(e,t,n)=>{const o="true"===e.headers?.["x-mfm-internal"],r=M(),s=e.url.startsWith(r);if("OPTIONS"===e.method||o||s)return n(e.body);const i=Date.now();O.addRequest("other",{...e,pending:!0,startTime:i});const a=(n,o,r,s={})=>{const a=Date.now()-i;O.addRequest("other",{...e,status:n,responseBody:o,responseHeaders:r,pending:!1,duration:a,...s}),t._capture(n,o,r,s)};t._xhr.addEventListener("abort",(()=>a("Aborted","Aborted",{},{aborted:!0})),{once:!0}),t._xhr.addEventListener("error",(()=>a(0,"Error",{},{error:!0})),{once:!0}),t._xhr.addEventListener("timeout",(()=>a("Timeout","Timeout",{},{timeout:!0})),{once:!0}),t._xhr.addEventListener("load",(()=>a(t._xhr.status,t._xhr.responseText,t._xhr.getAllResponseHeaders())),{once:!0}),t._xhr.addEventListener("readystatechange",(()=>{if(t._xhr.readyState>=2&&!t._captured){const n=t._xhr.status;if(n>0){const o=Date.now()-i;O.addRequest("other",{...e,status:n,responseHeaders:t._xhr.getAllResponseHeaders(),pending:t._xhr.readyState<4,duration:o})}}})),n(e.body)}})}(r,n),h&&b)O.mappings=i,O.rules=v,e?.(i,{_o:h,mk:b,_mck:y,_rules:v});else if(r){const o=O.getSavedMappings();if(o&&o.mappings&&o.mappings.length>0)return O.mappings=o.mappings,O.rules=o.meta?._rules||[],a(o.mappings),w(o.meta),O.updateMappings(o.mappings,o.meta),void e?.(o.mappings,o.meta);!function(t,n,o,r){R({method:"get",url:g,async:!1,headers:{[p]:t,[u]:f,"x-mfm-adaptor":n}},(t=>{if(t)try{const{di:r,iv:s,_o:i,_mck:l,mk:d,r:c}=t,m=_({di:r,iv:s},i);w({_o:i,mk:d,_mck:l,_rules:c}),m&&(a(m),n=m,o={_o:i,mk:d,_mck:l,_rules:c},O.saveMappings(n,o),O.updateMappings(n,o),e?.(n,o))}catch(e){return void r(new Error("Unable to fetch mocked apis"))}var n,o}),(e=>{console.log("Error in loading mocked apis"),r(e)})).request()}(r,n,0,t)}},checkIfApiToBeMocked:d,getMappings:l,doFetchMappings:(e,t)=>{T(r||O.token,n,((t,n)=>{O.updateMappings(t,n),e?.(t,n)}),t)},recheckWidgetVisibility:()=>{O.init()}}},D=o();D||(globalThis.mockforme=P);let F=P;D&&(F=e=>({run:()=>{}}));const B=F;export{B as mockforme};