@kizenapps/cli 0.3.0 → 0.4.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.
Files changed (75) hide show
  1. package/dist/chunk-4OYGMEFM.js +3675 -0
  2. package/dist/chunk-4OYGMEFM.js.map +1 -0
  3. package/dist/chunk-4Z6S6LWP.js +6134 -0
  4. package/dist/chunk-4Z6S6LWP.js.map +1 -0
  5. package/dist/chunk-5WPGAZLP.js +6136 -0
  6. package/dist/chunk-5WPGAZLP.js.map +1 -0
  7. package/dist/chunk-6XGFZ4W5.js +3673 -0
  8. package/dist/chunk-6XGFZ4W5.js.map +1 -0
  9. package/dist/chunk-KMKDY2I6.js +46 -0
  10. package/dist/chunk-KMKDY2I6.js.map +1 -0
  11. package/dist/chunk-LSHHXCC6.js +3639 -0
  12. package/dist/chunk-LSHHXCC6.js.map +1 -0
  13. package/dist/chunk-NNDSADQG.js +3641 -0
  14. package/dist/chunk-NNDSADQG.js.map +1 -0
  15. package/dist/chunk-SEGVTWSK.js +44 -0
  16. package/dist/chunk-SEGVTWSK.js.map +1 -0
  17. package/dist/devtools-HNR7DD7Q.js +68 -0
  18. package/dist/devtools-HNR7DD7Q.js.map +1 -0
  19. package/dist/devtools-HW3UQAHH.js +69 -0
  20. package/dist/devtools-HW3UQAHH.js.map +1 -0
  21. package/dist/devtools-KXIXZGBY.js +64 -0
  22. package/dist/devtools-KXIXZGBY.js.map +1 -0
  23. package/dist/devtools-PDXM3L35.js +67 -0
  24. package/dist/devtools-PDXM3L35.js.map +1 -0
  25. package/dist/devtools-SDEASRYI.js +66 -0
  26. package/dist/devtools-SDEASRYI.js.map +1 -0
  27. package/dist/devtools-XBEEGBQ4.js +66 -0
  28. package/dist/devtools-XBEEGBQ4.js.map +1 -0
  29. package/dist/dist-4P5P64FK.js +8474 -0
  30. package/dist/dist-4P5P64FK.js.map +1 -0
  31. package/dist/dist-AVHDSU4X.js +137 -0
  32. package/dist/dist-AVHDSU4X.js.map +1 -0
  33. package/dist/dist-NUJOSN7W.js +8472 -0
  34. package/dist/dist-NUJOSN7W.js.map +1 -0
  35. package/dist/dist-QHDMIBVE.js +135 -0
  36. package/dist/dist-QHDMIBVE.js.map +1 -0
  37. package/dist/electron/icon.png +0 -0
  38. package/dist/electron/main.js +45 -3
  39. package/dist/electron/main.js.map +1 -1
  40. package/dist/electron/preload.cjs +5 -0
  41. package/dist/gzip-size-K37OQCQ2.js +137 -0
  42. package/dist/gzip-size-K37OQCQ2.js.map +1 -0
  43. package/dist/gzip-size-SHZBT5GU.js +139 -0
  44. package/dist/gzip-size-SHZBT5GU.js.map +1 -0
  45. package/dist/index.js +577 -168
  46. package/dist/index.js.map +1 -1
  47. package/dist/viewer/assets/calendarSource.worker-C9iglnKD.js +24 -0
  48. package/dist/viewer/assets/expression.worker-Cin-WNVB.js +5 -0
  49. package/dist/viewer/assets/floatingFrame.worker-CWLtchq3.js +23 -0
  50. package/dist/viewer/assets/generic.worker-DRXu0-5B.js +23 -0
  51. package/dist/viewer/assets/index-BERinSUs.css +2 -0
  52. package/dist/viewer/assets/index-BExFCUNb.js +582 -0
  53. package/dist/viewer/assets/index-BTnaSAbf.js +582 -0
  54. package/dist/viewer/assets/index-BsYWmcLM.css +2 -0
  55. package/dist/viewer/assets/index-C9gGMSH0.js +582 -0
  56. package/dist/viewer/assets/index-CGp_x2sR.js +582 -0
  57. package/dist/viewer/assets/index-D1lc5mUR.js +582 -0
  58. package/dist/viewer/assets/index-DBXDPp8Y.css +2 -0
  59. package/dist/viewer/assets/index-DUFimvi2.js +582 -0
  60. package/dist/viewer/assets/index-DVM12um9.js +582 -0
  61. package/dist/viewer/assets/index-DiwdXOw0.css +2 -0
  62. package/dist/viewer/assets/index-DxGbfW9l.js +582 -0
  63. package/dist/viewer/assets/index-o7N1iv71.js +582 -0
  64. package/dist/viewer/assets/index-wLgWfI8W.js +582 -0
  65. package/dist/viewer/assets/recordDetail.worker-BIHPFt8Y.js +23 -0
  66. package/dist/viewer/icon.png +0 -0
  67. package/dist/viewer/index.html +2 -2
  68. package/package.json +17 -13
  69. package/dist/viewer/assets/calendarSource.worker-DF0wAwJR.js +0 -24
  70. package/dist/viewer/assets/expression.worker-_W4VR2xe.js +0 -5
  71. package/dist/viewer/assets/floatingFrame.worker-DXcDBfqJ.js +0 -23
  72. package/dist/viewer/assets/generic.worker-CsqlYndL.js +0 -23
  73. package/dist/viewer/assets/index-CW_UqFf3.css +0 -1
  74. package/dist/viewer/assets/index-DaB01Qok.js +0 -637
  75. package/dist/viewer/assets/recordDetail.worker-Ccm59Np6.js +0 -23
@@ -0,0 +1,23 @@
1
+ (function(){var e={QUERY_REQUEST:`query:request`,UI_OUTPUT:`outputui`,IFRAME_OUTPUT:`iframeoutput`,POSTFORMDATA_REQUEST:`postformdata:request`,SETSTATE:`setstate`,DONE:`done`,RUN:`run`,OPEN_WINDOW:`openwindow`,COMMUNICATE:`communicate`,HIDE:`hide`,SHOW:`show`,EXPAND:`expand`,COLLAPSE:`collapse`,HIDE_HEADER:`hideheader`,SHOW_HEADER:`showheader`,OPEN_CREATE_RECORD_MODAL_REQUEST:`opencreaterecordmodal:request`,OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:`opencreaterelatedrecordmodal:request`,SHOW_TOAST:`showtoast`,CLEAR_TOASTS:`cleartoasts`,REFRESH_TIMELINE:`refreshtimeline`,REFRESH_ENTITY:`refreshentity`,UPLOADFILE_REQUEST:`uploadfile:request`,UPDATE_SESSION_DATA:`updatesessiondata`,INSTALL_THIRD_PARTY_SCRIPT_REQUEST:`installthirdpartyscript:request`,PROMPT_REQUEST:`prompt:request`,DYNAMIC_PROMPT_REQUEST:`dynamicprompt:request`,RELEASE_BLOCKING_SCRIPT:`releaseblockingscript`,AUTHORIZE:`authorize`,COPY_TO_CLIPBOARD:`copytoclipboard`},t={QUERY_RESPONSE:`query:response`,POSTFORMDATA_RESPONSE:`postformdata:response`,ERROR:`error`,UPLOADFILE_RESPONSE:`uploadfile:response`,UPLOADFILE_PROGRESS:`uploadfile:progress`,INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:`installthirdpartyscript:response`,PROMPT_RESPONSE:`prompt:response`,REFRESH_ENTITY_RESPONSE:`refreshentity:response`,CREATE_RECORD_RESPONSE:`createrecord:response`,CREATE_RELATED_RECORD_RESPONSE:`createrelatedrecord:response`},n={RUN_FRAME_SCRIPT:`runframescript`,SEND_MESSAGE_TO_FRAME:`sendmessagetoframe`,CALL_THIRD_PARTY_SCRIPT:`callthirdpartyscript`},r=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,i=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,a={FRESHWORKS:`freshworks`,INTERCOM:`intercom`},o=e=>{if(r.test(e))return a.FRESHWORKS;if(i.test(e))return a.INTERCOM};a.FRESHWORKS,a.INTERCOM,a.FRESHWORKS,a.INTERCOM,a.FRESHWORKS,a.INTERCOM;var s=class{instance;scriptUrl;integration;constructor(e,t){this.instance=e,this.scriptUrl=t;let n=o(t);if(n)this.integration=n;else throw Error(`Error: Disallowed script url: ${t}`)}get type(){return this.integration}call(...t){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.CALL_THIRD_PARTY_SCRIPT,eventName:`thirdParty:${n.CALL_THIRD_PARTY_SCRIPT}`,recipient:{script:this.scriptUrl,type:this.type},params:t}))}},c=e=>({key:`action__${e.api_name}`,type:`custom_object`,label:e.name,allow_multiple:!0}),l=(e,t)=>{let n=(e.fields??[]).filter(e=>e.type!==`container`&&e.type!==`description`).map(e=>({...e,when:t?`(${t}) && (${e.when??`true`})`:e.when})),r=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>l(e,e.when)),i=e.actions?.filter(e=>e.hint_object_name)??[];return[...n,...r,...i.map(e=>({...c(e),match_hint:e.hint_object_name??``}))]},u=(e,t)=>{let n=l(e).reduce((e,t)=>({...e,[t.key]:t}),{}),r=Object.keys(t),i={};return r.forEach(e=>{let r=t[e],a=n[e];if(a?.type){switch(a.type){case`boolean`:let t=r;if(!t)return;i[e]=t.value;return;case`custom_object`:{let t=r;if(!t)return;i[e]={objectId:t.value?.id,objectName:t.value?.objectName};return}case`field`:{let t=r;if(!t?.value)return;Array.isArray(t.value)?i[e]=t.value.map(e=>({fieldId:e.value,fieldName:e.label,objectId:t.associatedObject?.id,objectName:t.associatedObject?.name})):typeof t.value==`object`&&typeof t.associatedObject==`object`&&(i[e]={fieldId:t.value.value,fieldName:t.value.label,objectId:t.associatedObject.id,objectName:t.associatedObject.name});return}case`number`:{let t=r;if(!t)return;try{let n=Number(t.value);if(!n&&n!==0)return;i[e]=n}catch{i[e]=NaN}return}case`select`:{let t=r;if(!t)return;i[e]=t.value;return}case`text`:{let t=r?.value;if(t){i[e]=t;return}let n=a.default;n&&(i[e]=n);return}case`description`:case`container`:return}return r?.value}}),i},d=(t,n)=>r=>async(i,a,o)=>new Promise((s,c)=>{let l=n.register(s,c);t.postMessage(JSON.stringify({action:e.QUERY_REQUEST,id:l,method:r,url:i,payload:a,options:o}))}),f=(t,n)=>(r,i,a=!0)=>new Promise((o,s)=>{let c=n.register(o,s);t.postMessage(JSON.stringify({action:e.POSTFORMDATA_REQUEST,url:r,id:c,payload:i,createNewTab:a}))}),p=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.PROMPT_REQUEST,id:o,config:r}))}),m=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.DYNAMIC_PROMPT_REQUEST,id:o,config:r}))}),h=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.UPLOADFILE_REQUEST,id:o,payload:r}))}),g=(t,n)=>(r,i)=>new Promise((a,o)=>{let s=n.register(a,o);t.postMessage(JSON.stringify({action:e.INSTALL_THIRD_PARTY_SCRIPT_REQUEST,url:r,id:s,args:i}))}),_=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.REFRESH_ENTITY,id:o,entityId:r}))}),v=(t,n)=>r=>new Promise((i,a)=>{let o=n.register(i,a);t.postMessage(JSON.stringify({action:e.OPEN_CREATE_RECORD_MODAL_REQUEST,id:o,entityId:r}))}),y=(t,n)=>(r,i)=>new Promise((a,o)=>{let s=n.register(a,o);t.postMessage(JSON.stringify({action:e.OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST,id:s,objectId:r,relatedEntityId:i}))}),b=(e,n,r)=>{switch(e){case t.QUERY_RESPONSE:{let{id:e,data:t,error:i}=JSON.parse(n.data);i?r.reject(e,i):r.resolve(e,t);break}case t.POSTFORMDATA_RESPONSE:{let{id:e,success:t}=JSON.parse(n.data);t?r.resolve(e):r.reject(e);break}case t.UPLOADFILE_RESPONSE:{let{id:e,data:t,error:i}=JSON.parse(n.data);t?r.resolve(e,t):r.reject(e,i);break}case t.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);t.success?r.resolve(e,t):r.reject(e);break}case t.PROMPT_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.CREATE_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.CREATE_RELATED_RECORD_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);r.resolve(e,t);break}case t.REFRESH_ENTITY_RESPONSE:{let{id:e,data:t}=JSON.parse(n.data);t.success?r.resolve(e,!0):r.reject(e);break}}},x=`integration:${n.RUN_FRAME_SCRIPT}`,S=class{instance;constructor(e){this.instance=e}runFrameScript(t,r,i){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.RUN_FRAME_SCRIPT,eventName:x,recipient:{frame:t,script:r},args:i}))}sendMessageToOwnFrame(t,r){this.instance.postMessage(JSON.stringify({action:e.COMMUNICATE,type:n.SEND_MESSAGE_TO_FRAME,args:{payload:t,path:r}}))}},C=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},w=(e,t,n={},r=``)=>`(function() { ${r}
2
+ return ${`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(n)}, utils: __kizen_utils })`}; })()`,T=class{user;teamMember;business;clientObject;appPath;dataCache=new Map;queryOptions={};api;postFormData;executionTimer=0;setupExecutions=0;cleanupExecutions=0;isDebug=!1;scriptBody;internalState={indicator:`none`};console=console;instance;breakOnException=!1;args;communicate;shouldPreserve=!1;uploadFileHandler;internalSessionData;pluginComponentId;installThirdPartyScriptHandler;promptHandler;dynamicPromptHandler;refreshEntityHandler;openCreateRecordHandler;openCreateRelatedRecordHandler;runnerType;pluginApiName;tempPromptState={};partialLocation;constructor({user:e,teamMember:t,business:n,clientObject:r,appPath:i,isDebug:a,kizenRequest:o,postFormData:s,scriptBody:c,instance:l,args:u,uploadFile:d,sessionData:f,pluginComponentId:p,installThirdPartyScript:m,prompt:h,refreshEntity:g,openCreateRecord:_,openCreateRelatedRecord:v,pluginApiName:y,dynamicPrompt:b,location:x}){this.user=e,this.teamMember=t,this.business=n,this.clientObject=r,this.partialLocation=x,this.appPath=i,this.isDebug=a??!1,this.api={get:o(`get`),post:o(`post`),put:o(`put`),delete:o(`delete`),patch:o(`patch`)},this.postFormData=s,this.scriptBody=c,this.instance=l,this.communicate=new S(l),this.uploadFileHandler=d,this.internalSessionData=f??{},this.pluginComponentId=p,this.installThirdPartyScriptHandler=m,this.promptHandler=h,this.refreshEntityHandler=g,this.openCreateRecordHandler=_,this.openCreateRelatedRecordHandler=v,this.runnerType=`base`,this.pluginApiName=y,this.dynamicPromptHandler=b;try{this.args=JSON.parse(u??`{}`)}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:t.ERROR,error:e?.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split(`-`)}parsePhone(e){return e.replace(/\+/g,``)}openWindow(t,n=`_blank`){this.instance.postMessage(JSON.stringify({action:e.OPEN_WINDOW,url:t,target:n,features:`noopener noreferrer`}))}authorize(t,n={}){if(!t)throw Error(`Service name is required to authorize`);this.instance.postMessage(JSON.stringify({action:e.AUTHORIZE,serviceName:t,config:{successRedirectPath:n.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:n.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw Error(`Service name is required to get a service url`);let n=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith(`/`)?`${n}${t}`:`${n}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){return{profile:{id:this.teamMember?.id??``,full_name:this.teamMember?.full_name??``,first_name:this.teamMember?.first_name??``,last_name:this.teamMember?.last_name??``,email:this.teamMember?.email??``,phone:this.teamMember?.phone??``,created:this.teamMember?.created??``,crm_client_id:this.user?.crm_client_id??``}}}get sessionData(){return this.internalSessionData}get config(){return this.args.__kizen_clean_config?new Proxy(this.args.__kizen_clean_config??{},{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t===`toJSON`)return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){let e=this.args.__kizen_user_config?.__kizen_clean_config;return e?new Proxy(e,{get:(e,t)=>{if(Reflect.has(e,t))return Reflect.get(e,t)}}):{}}setSessionData(t){if(typeof t!=`object`)throw Error(`Invalid session update with type ${typeof t}`);if(Array.isArray(t))throw Error(`Invalid session update with type array`);this.internalSessionData={...this.internalSessionData,...t},this.instance.postMessage(JSON.stringify({action:e.UPDATE_SESSION_DATA,update:t}))}async get(e,t){try{if(this.isRelativeUrl(e)){let n=this.dataCache.get(e);if(n&&!t?.ignoreCache)return t?.returnErrors?[n.data,null]:n.data;let{data:r}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return this.dataCache.set(e,{ts:Date.now(),data:r}),t?.returnErrors?[r,null]:r}else{let n=await fetch(e,{method:`GET`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await C(n);let r=await n.json();return t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);return(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config?.[this.pluginComponentId]??{}}async setUserConfig(e){if(!this.args.pluginId||!this.pluginComponentId)throw Error(`User config is not available for scripts not associated to a plugin or plugin component`);let t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t?.config,[this.pluginComponentId]:{...t?.config?.[this.pluginComponentId],...e}}})}async patch(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.patch(e,t,{...this.queryOptions,headers:n?.headers});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`PATCH`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await C(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async patchWithErrors(e,t,n){return this.patch(e,t,{...n,returnErrors:!0})}async post(e,t,n){try{if(this.isRelativeUrl(e)){let{data:r}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(n?.headers)});return n?.returnErrors?[r,null]:r}else{let r=await fetch(e,{method:`POST`,body:t?JSON.stringify(t):null,headers:new Headers(n?.headers),credentials:n?.credentials??`same-origin`});if(!r.ok)throw await C(r);let i=await r.json();return n?.returnErrors?[i,null]:i}}catch(e){if(n?.returnErrors)return[null,e];this.onError(e)}}async postWithErrors(e,t,n){return this.post(e,t,{...n,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){let{data:n}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t?.headers)});return t?.returnErrors?[n,null]:n}else{let n=await fetch(e,{method:`DELETE`,headers:new Headers(t?.headers),credentials:t?.credentials??`same-origin`});if(!n.ok)throw await C(n);let r=null;return n.status!==204&&(r=await n.json()),t?.returnErrors?[r,null]:r}}catch(e){if(t?.returnErrors)return[null,e];this.onError(e)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(t,n){this.instance.postMessage(JSON.stringify({action:e.SHOW_TOAST,message:t,toastOptions:n}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:e.CLEAR_TOASTS}))}outputUI(t){this.instance.postMessage(JSON.stringify({action:e.UI_OUTPUT,markup:t}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){let t=`__kizen_state`,n=`const __kizen_utils = {};
3
+ `;if(e.registerUtils){let t=Object.keys(e.registerUtils);n+=t.map(t=>{let n=e.registerUtils?.[t];if(typeof n!=`function`)throw Error(`Registered util ${t} is not a function, got ${typeof n}`);return`__kizen_utils["${t}"] = (${n.toString()});`}).join(`
4
+ `)}let r=e.content?.map(e=>{let r=``;`optionMapper`in e&&(r=w(e.optionMapper,t,e.args,n));let i=``;`getFetchUrl`in e&&(i=w(e.getFetchUrl,t,e.args,n));let a=``;`getHeaders`in e&&(a=w(e.getHeaders,t,e.args,n));let o=``;return`getBody`in e&&(o=w(e.getBody,t,e.args,n)),{...e,optionMapper:r,getFetchUrl:i,getHeaders:a,getBody:o}}),i={...e,content:r},a={fields:i.content},o=await this.dynamicPromptHandler(i),s=u(a,o.values);return{...o,values:s}}outputIframe(t,n,r){this.instance.postMessage(JSON.stringify({action:e.IFRAME_OUTPUT,url:t,allow:n,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,n)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>{t(r.result)},r.onerror=e=>{n(e)}})}async uploadFile(e,t,n=!1){let r=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:r,fileName:t??`file_`+String(Date.now()),isPublic:n})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw Error(`Setup must be called exactly once, and should never be called by a script directly.`);if(this.cleanupExecutions!==0)throw Error(`Setup was called after cleanup`);this.isDebug&&this.console.log(`Running script:
5
+
6
+ ${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw Error(`Cleanup must be called exactly once, and should never be called by a script directly.`);if(this.setupExecutions!==1)throw Error(`Cleanup was called before setup`);this.cleanupExecutions++,this.setIndicator(`none`);let t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e=`none`){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(t,n){this.instance.postMessage(JSON.stringify({action:e.DONE,result:n,preserve:t}))}setState(t){this.instance.postMessage(JSON.stringify({action:e.SETSTATE,state:t}))}isRelativeUrl(e){return e.startsWith(`/`)}buildHeaders(e={}){return{...e,"X-Request-Type":`kizen-ui-scripting-api`}}refreshTimelineForId(t){t&&this.instance.postMessage(JSON.stringify({action:e.REFRESH_TIMELINE,entityId:t}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{let t=await this.installThirdPartyScriptHandler(e,this.args);return new s(this.instance,t.url)}catch{this.onError(Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:e.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(t){this.instance.postMessage(JSON.stringify({action:e.COPY_TO_CLIPBOARD,text:t}))}createDateObject(e){if(typeof e!=`string`)throw Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw Error(`Date string ${e} is not in the format YYYY-MM-DD`);let t=e.split(`-`).map(e=>parseInt(e,10));if(t.length<3)throw Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},E=e=>e.object_type===`pipeline`||e.fetch_url===`pipeline`,D=class extends T{objectId;entityId;actionObjectId;actionEntityId;constructor({objectId:e,entityId:t,actionObjectId:n,actionEntityId:r,...i}){super(i),this.objectId=e,this.entityId=t,this.actionObjectId=n,this.actionEntityId=r,this.runnerType=`recordDetail`}async currentObject(){if(this.objectId)return this.getObjectDetail(this.objectId)}async currentEntity(){if(this.entityId&&this.objectId)return this.getEntity(this.objectId,this.entityId)}async actionEntity(){if(this.actionEntityId&&this.actionObjectId)return this.getEntity(this.actionObjectId,this.actionEntityId)}getFieldValue(e,t){return e.fields?.[t]?.value}async getClientEntity(e){return await this.get(`/client/${e}`)}isClientObject(e){return e===this.clientObject?.id}async getEntity(e,t){try{return this.isClientObject(e)?await this.getClientEntity(t):E(await this.get(`/custom-objects/${e}`))?await this.getPipelineEntity(e,t):await this.getCustomEntity(e,t)}catch(e){this.onError(e)}}async getRelatedEntitiesForField(e,t,n){try{let r=(await this.getEntity(e,t)).fields?.[n];if(!r)return this.onError(Error(`Field not found for ID ${n}`)),[];let i=(await this.getObjectDetail(e))?.related_objects?.find(e=>e.field_id===r.id);return i?(await Promise.all(r.value.map(e=>e.id===void 0?null:this.getEntity(i.related_object,e.id)).filter(e=>e!==null))).filter(Boolean):(this.onError(Error(`Related object not found`)),[])}catch(e){this.onError(e)}return[]}async getPipelineEntity(e,t){return await this.get(`/pipelines/${e}/entity-records/${t}`)}async getCustomEntity(e,t){return await this.get(`/custom-objects/${e}/entity-records/${t}`)}async getObjectDetail(e){try{return await this.get(`/custom-objects/${e}/detail`)}catch(e){this.onError(e)}}refreshTimeline(){this.refreshTimelineForId(this.entityId)}refreshEntity(){this.refreshEntityForId(this.entityId)}},O=()=>{let e=new Date().getTime();return typeof performance<`u`&&typeof performance.now==`function`&&(e+=performance.now()),`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t===`x`?n:n&3|8).toString(16)})},k=Object.getPrototypeOf(async function(){}).constructor,A=e=>{let t=`
7
+ const __cleanup = this.__cleanup.bind(this);
8
+ const __error = this.onError.bind(this);
9
+ {
10
+ this.__setup();
11
+ }
12
+ try {
13
+ ${e}
14
+ } catch (ex) {
15
+ __error(ex);
16
+ } finally {
17
+ __cleanup();
18
+ }
19
+ `;try{return{fn:new k(t),functionBody:t}}catch{let e=`
20
+ this.__setup();
21
+ this.onError({ message: "The script has a syntax error and could not be parsed" });
22
+ this.__cleanup();
23
+ `;return{fn:new k(e),functionBody:e}}},j=new class{promises;isDebug;constructor({isDebug:e=!1}){this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,n){this.promises.set(e,{resolve:t,reject:n})}id(){return O()}register(e,t){let n=this.id();return this.set(n,e,t),n}resolve(e,t){this.get(e)?.resolve(t),this.delete(e)}reject(e,t){this.get(e)?.reject(t),this.delete(e)}}({isDebug:!1});self.onmessage=async t=>{let{action:n,script:r,setup:i,args:a,sessionData:o={},pluginComponentId:s,pluginApiName:c,location:l}=JSON.parse(t.data);if(n===e.RUN&&i&&r){let{fn:e,functionBody:t}=A(r),n=new D({user:i.user,teamMember:i.teamMember,business:i.business,entityId:i.entityId??``,objectId:i.objectId??``,clientObject:i.clientObject,appPath:i.appPath,isDebug:i.isDebug,scriptBody:r,functionBody:t,instance:self,kizenRequest:d(self,j),postFormData:f(self,j),uploadFile:h(self,j),installThirdPartyScript:g(self,j),args:a??``,sessionData:o,pluginComponentId:s,prompt:p(self,j),dynamicPrompt:m(self,j),refreshEntity:_(self,j),openCreateRecord:v(self,j),openCreateRelatedRecord:y(self,j),pluginApiName:c,location:l});await e.bind(n)()}else b(n,t,j)}})();
Binary file
@@ -6,8 +6,8 @@
6
6
  <title>Kizen App Development Toolkit</title>
7
7
  <link rel="icon" href="/favicon.png" type="image/png" />
8
8
  <link rel="manifest" href="/manifest.json" />
9
- <script type="module" crossorigin src="/assets/index-DaB01Qok.js"></script>
10
- <link rel="stylesheet" crossorigin href="/assets/index-CW_UqFf3.css">
9
+ <script type="module" crossorigin src="/assets/index-wLgWfI8W.js"></script>
10
+ <link rel="stylesheet" crossorigin href="/assets/index-DiwdXOw0.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizenapps/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "CLI tool for running Kizen plugin apps locally",
5
5
  "license": "GPL-3.0",
6
6
  "type": "module",
@@ -31,36 +31,40 @@
31
31
  "@fortawesome/react-fontawesome": "^3.3.0",
32
32
  "@kizenapps/engine": "^0.3.1",
33
33
  "@kizenapps/packager": "^0.1.0",
34
- "@tanstack/react-query": "^5.96.2",
34
+ "@tanstack/react-query": "^5.97.0",
35
35
  "@tanstack/react-router": "^1.168.10",
36
- "electron": "^33.0.0",
37
- "commander": "^12.0.0",
38
- "ink": "^5.0.0",
39
- "react": "^18.3.0",
36
+ "commander": "^14.0.3",
37
+ "electron": "^41.2.0",
38
+ "ink": "^7.0.0",
39
+ "react": "^19.2.0",
40
+ "react-dom": "^19.2.0",
40
41
  "ws": "^8.18.0"
41
42
  },
42
43
  "pnpm": {
43
44
  "onlyBuiltDependencies": [
44
45
  "esbuild",
45
46
  "electron"
46
- ]
47
+ ],
48
+ "allowedDeprecatedVersions": {
49
+ "boolean": "3.2.0"
50
+ }
47
51
  },
48
52
  "devDependencies": {
49
53
  "@tailwindcss/vite": "^4.2.2",
50
- "@types/node": "^25.5.2",
51
- "@types/react": "^18.0.0",
52
- "@types/react-dom": "^18.0.0",
54
+ "@types/node": "^25.6.0",
55
+ "@types/react": "^19.0.0",
56
+ "@types/react-dom": "^19.0.0",
53
57
  "@types/ws": "^8.5.0",
54
- "@vitejs/plugin-react": "^4.3.0",
58
+ "@vitejs/plugin-react": "^6.0.1",
55
59
  "concurrently": "^9.2.1",
56
60
  "eslint": "^9.0.0",
57
61
  "eslint-plugin-react-hooks": "^7.0.1",
58
- "prettier": "^3.0.0",
62
+ "prettier": "^3.8.2",
59
63
  "react-dom": "^18.3.0",
60
64
  "tailwindcss": "^4.2.2",
61
65
  "tsup": "^8.0.0",
62
66
  "typescript": "^6.0.2",
63
67
  "typescript-eslint": "^8.0.0",
64
- "vite": "^5.4.0"
68
+ "vite": "^8.0.8"
65
69
  }
66
70
  }
@@ -1,24 +0,0 @@
1
- var V=Object.defineProperty;var Z=(u,d,m)=>d in u?V(u,d,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[d]=m;var i=(u,d,m)=>Z(u,typeof d!="symbol"?d+"":d,m);(function(){"use strict";var u={QUERY_REQUEST:"query:request",UI_OUTPUT:"outputui",IFRAME_OUTPUT:"iframeoutput",POSTFORMDATA_REQUEST:"postformdata:request",SETSTATE:"setstate",DONE:"done",RUN:"run",OPEN_WINDOW:"openwindow",COMMUNICATE:"communicate",SHOW_TOAST:"showtoast",CLEAR_TOASTS:"cleartoasts",REFRESH_TIMELINE:"refreshtimeline",UPDATE_SESSION_DATA:"updatesessiondata",PROMPT_REQUEST:"prompt:request",DYNAMIC_PROMPT_REQUEST:"dynamicprompt:request",RELEASE_BLOCKING_SCRIPT:"releaseblockingscript",AUTHORIZE:"authorize",COPY_TO_CLIPBOARD:"copytoclipboard"},d={QUERY_RESPONSE:"query:response",POSTFORMDATA_RESPONSE:"postformdata:response",ERROR:"error",UPLOADFILE_RESPONSE:"uploadfile:response",INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:"installthirdpartyscript:response",PROMPT_RESPONSE:"prompt:response",REFRESH_ENTITY_RESPONSE:"refreshentity:response",CREATE_RECORD_RESPONSE:"createrecord:response",CREATE_RELATED_RECORD_RESPONSE:"createrelatedrecord:response"},m={RUN_FRAME_SCRIPT:"runframescript",SEND_MESSAGE_TO_FRAME:"sendmessagetoframe",CALL_THIRD_PARTY_SCRIPT:"callthirdpartyscript"},C=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,v=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,w={FRESHWORKS:"freshworks",INTERCOM:"intercom"},I=e=>{if(C.test(e))return w.FRESHWORKS;if(v.test(e))return w.INTERCOM},A=class{constructor(e,t){i(this,"instance");i(this,"scriptUrl");i(this,"integration");this.instance=e,this.scriptUrl=t;const r=I(t);if(r)this.integration=r;else throw new Error(`Error: Disallowed script url: ${t}`)}get type(){return this.integration}call(...e){this.instance.postMessage(JSON.stringify({action:u.COMMUNICATE,type:m.CALL_THIRD_PARTY_SCRIPT,eventName:`thirdParty:${m.CALL_THIRD_PARTY_SCRIPT}`,recipient:{script:this.scriptUrl,type:this.type},params:e}))}},M=()=>{let e=new Date().getTime();return typeof performance<"u"&&typeof performance.now=="function"&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t==="x"?r:r&3|8).toString(16)})},P=Object.getPrototypeOf(async function(){}).constructor,D=e=>{const t=`
2
- const __cleanup = this.__cleanup.bind(this);
3
- const __error = this.onError.bind(this);
4
- let __kizen_internal_result;
5
- {
6
- this.__setup();
7
- }
8
- try {
9
- __kizen_internal_result = await (async () => { ${e} })();
10
- } catch (ex) {
11
- __error(ex);
12
- } finally {
13
- __cleanup(__kizen_internal_result);
14
- }
15
- `;try{return{fn:new P(t),functionBody:t}}catch{const r=`
16
- this.__setup();
17
- this.onError({ message: "The script has a syntax error and could not be parsed" });
18
- this.__cleanup();
19
- `;return{fn:new P(r),functionBody:r}}},x=class{constructor({isDebug:e=!1}){i(this,"promises");i(this,"isDebug");this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,r){this.promises.set(e,{resolve:t,reject:r})}id(){return M()}register(e,t){const r=this.id();return this.set(r,e,t),r}resolve(e,t){var r;(r=this.get(e))==null||r.resolve(t),this.delete(e)}reject(e,t){var r;(r=this.get(e))==null||r.reject(t),this.delete(e)}},U=e=>({key:`action__${e.api_name}`,type:"custom_object",label:e.name,allow_multiple:!0}),b=(e,t)=>{var o;const r=(e.fields??[]).filter(n=>n.type!=="container"&&n.type!=="description").map(n=>({...n,when:t?`(${t}) && (${n.when??"true"})`:n.when})),a=(e.fields??[]).filter(n=>n.type==="container").flatMap(n=>b(n,n.when)),c=((o=e.actions)==null?void 0:o.filter(n=>n.hint_object_name))??[];return[...r,...a,...c.map(n=>({...U(n),match_hint:n.hint_object_name??""}))]},H=(e,t)=>{const s=b(e).reduce((o,n)=>({...o,[n.key]:n}),{}),a=Object.keys(t),c={};return a.forEach(o=>{var h,p;const n=t[o],g=s[o];if(g!=null&&g.type){switch(g.type){case"boolean":const E=n;if(!E)return;c[o]=E.value;return;case"custom_object":{const l=n;if(!l)return;c[o]={objectId:(h=l.value)==null?void 0:h.id,objectName:(p=l.value)==null?void 0:p.objectName};return}case"field":{const l=n;if(!(l!=null&&l.value))return;Array.isArray(l.value)?c[o]=l.value.map(f=>{var S,T;return{fieldId:f.value,fieldName:f.label,objectId:(S=l.associatedObject)==null?void 0:S.id,objectName:(T=l.associatedObject)==null?void 0:T.name}}):typeof l.value=="object"&&typeof l.associatedObject=="object"&&(c[o]={fieldId:l.value.value,fieldName:l.value.label,objectId:l.associatedObject.id,objectName:l.associatedObject.name});return}case"number":{const l=n;if(!l)return;try{const f=Number(l.value);if(!f&&f!==0)return;c[o]=f}catch{c[o]=NaN}return}case"select":{const l=n;if(!l)return;c[o]=l.value;return}case"text":{const l=n,f=l==null?void 0:l.value;if(f){c[o]=f;return}const S=g.default;S&&(c[o]=S);return}case"description":case"container":return}return n==null?void 0:n.value}}),c},j=(e,t)=>r=>async(s,a,c)=>new Promise((o,n)=>{const g=t.register(o,n);e.postMessage(JSON.stringify({action:u.QUERY_REQUEST,id:g,method:r,url:s,payload:a,options:c}))}),F=(e,t)=>(r,s,a=!0)=>new Promise((c,o)=>{const n=t.register(c,o);e.postMessage(JSON.stringify({action:u.POSTFORMDATA_REQUEST,url:r,id:n,payload:s,createNewTab:a}))}),$=(e,t)=>r=>new Promise((s,a)=>{const c=t.register(s,a);e.postMessage(JSON.stringify({action:u.PROMPT_REQUEST,id:c,config:r}))}),J=(e,t)=>r=>new Promise((s,a)=>{const c=t.register(s,a);e.postMessage(JSON.stringify({action:u.DYNAMIC_PROMPT_REQUEST,id:c,config:r}))}),L=(e,t,r)=>{switch(e){case d.QUERY_RESPONSE:{const{id:s,data:a,error:c}=JSON.parse(t.data);c?r.reject(s,c):r.resolve(s,a);break}case d.POSTFORMDATA_RESPONSE:{const{id:s,success:a}=JSON.parse(t.data);a?r.resolve(s):r.reject(s);break}case d.UPLOADFILE_RESPONSE:{const{id:s,data:a,error:c}=JSON.parse(t.data);a?r.resolve(s,a):r.reject(s,c);break}case d.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);a.success?r.resolve(s,a):r.reject(s);break}case d.PROMPT_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case d.CREATE_RECORD_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case d.CREATE_RELATED_RECORD_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case d.REFRESH_ENTITY_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);a.success?r.resolve(s,!0):r.reject(s);break}}},k=`integration:${m.RUN_FRAME_SCRIPT}`,B=class{constructor(e){i(this,"instance");this.instance=e}runFrameScript(e,t,r){this.instance.postMessage(JSON.stringify({action:u.COMMUNICATE,type:m.RUN_FRAME_SCRIPT,eventName:k,recipient:{frame:e,script:t},args:r}))}sendMessageToOwnFrame(e,t){this.instance.postMessage(JSON.stringify({action:u.COMMUNICATE,type:m.SEND_MESSAGE_TO_FRAME,args:{payload:e,path:t}}))}},y=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},O=(e,t,r={},s="")=>{const c=`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(r)}, utils: __kizen_utils })`;return`(function() { ${s}
20
- return ${c}; })()`},W=class{constructor({user:e,teamMember:t,business:r,clientObject:s,appPath:a,isDebug:c,kizenRequest:o,postFormData:n,scriptBody:g,instance:h,args:p,uploadFile:E,sessionData:l,pluginComponentId:f,installThirdPartyScript:S,prompt:T,refreshEntity:Y,openCreateRecord:z,openCreateRelatedRecord:q,pluginApiName:Q,dynamicPrompt:G,location:K}){i(this,"user");i(this,"teamMember");i(this,"business");i(this,"clientObject");i(this,"appPath");i(this,"dataCache",new Map);i(this,"queryOptions",{});i(this,"api");i(this,"postFormData");i(this,"executionTimer",0);i(this,"setupExecutions",0);i(this,"cleanupExecutions",0);i(this,"isDebug",!1);i(this,"scriptBody");i(this,"internalState",{indicator:"none"});i(this,"console",console);i(this,"instance");i(this,"breakOnException",!1);i(this,"args");i(this,"communicate");i(this,"shouldPreserve",!1);i(this,"uploadFileHandler");i(this,"internalSessionData");i(this,"pluginComponentId");i(this,"installThirdPartyScriptHandler");i(this,"promptHandler");i(this,"dynamicPromptHandler");i(this,"refreshEntityHandler");i(this,"openCreateRecordHandler");i(this,"openCreateRelatedRecordHandler");i(this,"runnerType");i(this,"pluginApiName");i(this,"tempPromptState",{});i(this,"partialLocation");this.user=e,this.teamMember=t,this.business=r,this.clientObject=s,this.partialLocation=K,this.appPath=a,this.isDebug=c??!1,this.api={get:o("get"),post:o("post"),put:o("put"),delete:o("delete"),patch:o("patch")},this.postFormData=n,this.scriptBody=g,this.instance=h,this.communicate=new B(h),this.uploadFileHandler=E,this.internalSessionData=l??{},this.pluginComponentId=f,this.installThirdPartyScriptHandler=S,this.promptHandler=T,this.refreshEntityHandler=Y,this.openCreateRecordHandler=z,this.openCreateRelatedRecordHandler=q,this.runnerType="base",this.pluginApiName=Q,this.dynamicPromptHandler=G;try{this.args=JSON.parse(p??"{}")}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:d.ERROR,error:e==null?void 0:e.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split("-")}parsePhone(e){return e.replace(/\+/g,"")}openWindow(e,t="_blank"){this.instance.postMessage(JSON.stringify({action:u.OPEN_WINDOW,url:e,target:t,features:"noopener noreferrer"}))}authorize(e,t={}){if(!e)throw new Error("Service name is required to authorize");this.instance.postMessage(JSON.stringify({action:u.AUTHORIZE,serviceName:e,config:{successRedirectPath:t.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:t.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw new Error("Service name is required to get a service url");const r=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith("/")?`${r}${t}`:`${r}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){var e,t,r,s,a,c,o,n;return{profile:{id:((e=this.teamMember)==null?void 0:e.id)??"",full_name:((t=this.teamMember)==null?void 0:t.full_name)??"",first_name:((r=this.teamMember)==null?void 0:r.first_name)??"",last_name:((s=this.teamMember)==null?void 0:s.last_name)??"",email:((a=this.teamMember)==null?void 0:a.email)??"",phone:((c=this.teamMember)==null?void 0:c.phone)??"",created:((o=this.teamMember)==null?void 0:o.created)??"",crm_client_id:((n=this.user)==null?void 0:n.crm_client_id)??""}}}get sessionData(){return this.internalSessionData}get config(){return!this.args.__kizen_clean_config?{}:new Proxy(this.args.__kizen_clean_config??{},{get:(r,s)=>{if(Reflect.has(r,s))return Reflect.get(r,s)}})}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t==="toJSON")return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw new Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){var r;const e=(r=this.args.__kizen_user_config)==null?void 0:r.__kizen_clean_config;return e?new Proxy(e,{get:(s,a)=>{if(Reflect.has(s,a))return Reflect.get(s,a)}}):{}}setSessionData(e){if(typeof e!="object")throw new Error(`Invalid session update with type ${typeof e}`);if(Array.isArray(e))throw new Error("Invalid session update with type array");this.internalSessionData={...this.internalSessionData,...e},this.instance.postMessage(JSON.stringify({action:u.UPDATE_SESSION_DATA,update:e}))}async get(e,t){try{if(this.isRelativeUrl(e)){const r=this.dataCache.get(e);if(r&&!(t!=null&&t.ignoreCache))return t!=null&&t.returnErrors?[r.data,null]:r.data;const{data:s}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t==null?void 0:t.headers)});return this.dataCache.set(e,{ts:Date.now(),data:s}),t!=null&&t.returnErrors?[s,null]:s}else{const r=await fetch(e,{method:"GET",headers:new Headers(t==null?void 0:t.headers),credentials:(t==null?void 0:t.credentials)??"same-origin"});if(!r.ok)throw await y(r);const s=await r.json();return t!=null&&t.returnErrors?[s,null]:s}}catch(r){if(t!=null&&t.returnErrors)return[null,r];this.onError(r)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){var t;if(!this.args.pluginId||!this.pluginComponentId)throw new Error("User config is not available for scripts not associated to a plugin or plugin component");return((t=(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config)==null?void 0:t[this.pluginComponentId])??{}}async setUserConfig(e){var s;if(!this.args.pluginId||!this.pluginComponentId)throw new Error("User config is not available for scripts not associated to a plugin or plugin component");const t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t==null?void 0:t.config,[this.pluginComponentId]:{...(s=t==null?void 0:t.config)==null?void 0:s[this.pluginComponentId],...e}}})}async patch(e,t,r){try{if(this.isRelativeUrl(e)){const{data:s}=await this.api.patch(e,t,{...this.queryOptions,headers:r==null?void 0:r.headers});return r!=null&&r.returnErrors?[s,null]:s}else{const s=await fetch(e,{method:"PATCH",body:t?JSON.stringify(t):null,headers:new Headers(r==null?void 0:r.headers),credentials:(r==null?void 0:r.credentials)??"same-origin"});if(!s.ok)throw await y(s);const a=await s.json();return r!=null&&r.returnErrors?[a,null]:a}}catch(s){if(r!=null&&r.returnErrors)return[null,s];this.onError(s)}}async patchWithErrors(e,t,r){return this.patch(e,t,{...r,returnErrors:!0})}async post(e,t,r){try{if(this.isRelativeUrl(e)){const{data:s}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(r==null?void 0:r.headers)});return r!=null&&r.returnErrors?[s,null]:s}else{const s=await fetch(e,{method:"POST",body:t?JSON.stringify(t):null,headers:new Headers(r==null?void 0:r.headers),credentials:(r==null?void 0:r.credentials)??"same-origin"});if(!s.ok)throw await y(s);const a=await s.json();return r!=null&&r.returnErrors?[a,null]:a}}catch(s){if(r!=null&&r.returnErrors)return[null,s];this.onError(s)}}async postWithErrors(e,t,r){return this.post(e,t,{...r,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){const{data:r}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t==null?void 0:t.headers)});return t!=null&&t.returnErrors?[r,null]:r}else{const r=await fetch(e,{method:"DELETE",headers:new Headers(t==null?void 0:t.headers),credentials:(t==null?void 0:t.credentials)??"same-origin"});if(!r.ok)throw await y(r);let s=null;return r.status!==204&&(s=await r.json()),t!=null&&t.returnErrors?[s,null]:s}}catch(r){if(t!=null&&t.returnErrors)return[null,r];this.onError(r)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(e,t){this.instance.postMessage(JSON.stringify({action:u.SHOW_TOAST,message:e,toastOptions:t}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:u.CLEAR_TOASTS}))}outputUI(e){this.instance.postMessage(JSON.stringify({action:u.UI_OUTPUT,markup:e}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){var g;const t="__kizen_state";let r=`const __kizen_utils = {};
21
- `;if(e.registerUtils){const h=Object.keys(e.registerUtils);r+=h.map(p=>{var l;const E=(l=e.registerUtils)==null?void 0:l[p];if(typeof E!="function")throw new Error(`Registered util ${p} is not a function, got ${typeof E}`);return`__kizen_utils["${p}"] = (${E.toString()});`}).join(`
22
- `)}const s=(g=e.content)==null?void 0:g.map(h=>{let p="";"optionMapper"in h&&(p=O(h.optionMapper,t,h.args,r));let E="";"getFetchUrl"in h&&(E=O(h.getFetchUrl,t,h.args,r));let l="";"getHeaders"in h&&(l=O(h.getHeaders,t,h.args,r));let f="";return"getBody"in h&&(f=O(h.getBody,t,h.args,r)),{...h,optionMapper:p,getFetchUrl:E,getHeaders:l,getBody:f}}),a={...e,content:s},c={fields:a.content},o=await this.dynamicPromptHandler(a),n=H(c,o.values);return{...o,values:n}}outputIframe(e,t,r){this.instance.postMessage(JSON.stringify({action:u.IFRAME_OUTPUT,url:e,allow:t,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,r)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>{t(s.result)},s.onerror=a=>{r(a)}})}async uploadFile(e,t,r=!1){const s=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:s,fileName:t??"file_"+String(Date.now()),isPublic:r})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw new Error("Setup must be called exactly once, and should never be called by a script directly.");if(this.cleanupExecutions!==0)throw new Error("Setup was called after cleanup");this.isDebug&&this.console.log(`Running script:
23
-
24
- ${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw new Error("Cleanup must be called exactly once, and should never be called by a script directly.");if(this.setupExecutions!==1)throw new Error("Cleanup was called before setup");this.cleanupExecutions++,this.setIndicator("none");const t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e="none"){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(e,t){this.instance.postMessage(JSON.stringify({action:u.DONE,result:t,preserve:e}))}setState(e){this.instance.postMessage(JSON.stringify({action:u.SETSTATE,state:e}))}isRelativeUrl(e){return e.startsWith("/")}buildHeaders(e={}){return{...e,"X-Request-Type":"kizen-ui-scripting-api"}}refreshTimelineForId(e){e&&this.instance.postMessage(JSON.stringify({action:u.REFRESH_TIMELINE,entityId:e}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{const t=await this.installThirdPartyScriptHandler(e,this.args);return new A(this.instance,t.url)}catch{this.onError(new Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:u.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(e){this.instance.postMessage(JSON.stringify({action:u.COPY_TO_CLIPBOARD,text:e}))}createDateObject(e){if(typeof e!="string")throw new Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error(`Date string ${e} is not in the format YYYY-MM-DD`);const t=e.split("-").map(s=>parseInt(s,10));if(t.length<3)throw new Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},_=new x({isDebug:!1}),N=null,R=e=>()=>new Promise((t,r)=>{r(new Error(`${e} is not supported in calendar source scripts`))});self.onmessage=async e=>{const t=JSON.parse(e.data),{action:r,script:s,setup:a,args:c,sessionData:o={},pluginComponentId:n,pluginApiName:g,location:h}=t;if(r===u.RUN&&a&&s){const{fn:p,functionBody:E}=D(s);N=new W({user:a.user,teamMember:a.teamMember,business:a.business,clientObject:a.clientObject,isDebug:a.isDebug,appPath:a.appPath,scriptBody:s,functionBody:E,instance:self,kizenRequest:j(self,_),postFormData:F(self,_),uploadFile:R("uploadFile"),installThirdPartyScript:R("installThirdPartyScript"),args:c??"",sessionData:o,pluginComponentId:n,prompt:$(self,_),dynamicPrompt:J(self,_),refreshEntity:R("refreshEntity"),openCreateRecord:R("openCreateRecord"),openCreateRelatedRecord:R("openCreateRelatedRecord"),pluginApiName:g,location:h}),await p.bind(N)()}else L(r,e,_)}})();
@@ -1,5 +0,0 @@
1
- (function(){"use strict";var a=(e,t)=>e.replace(/{{(.*?)}}/g,(s,r)=>o(r,t)),l=(e,t,n)=>{const s=`return ${a(e,t)};`;return n&&console.log(`Initial expression:
2
- ${e}
3
-
4
- Interpreted as:
5
- ${s}`),new Function(s)()},o=(e,t)=>{const n=t[e];return n&&typeof n.value<"u"?JSON.stringify(n.value):"null"};self.onmessage=e=>{const t=JSON.parse(e.data),{expression:n,args:s,isDebug:r=!1}=t,u=l(n,s,r);self.postMessage(JSON.stringify({result:u}))}})();
@@ -1,23 +0,0 @@
1
- var te=Object.defineProperty;var re=(l,h,S)=>h in l?te(l,h,{enumerable:!0,configurable:!0,writable:!0,value:S}):l[h]=S;var c=(l,h,S)=>re(l,typeof h!="symbol"?h+"":h,S);(function(){"use strict";var l={QUERY_REQUEST:"query:request",UI_OUTPUT:"outputui",IFRAME_OUTPUT:"iframeoutput",POSTFORMDATA_REQUEST:"postformdata:request",SETSTATE:"setstate",DONE:"done",RUN:"run",OPEN_WINDOW:"openwindow",COMMUNICATE:"communicate",HIDE:"hide",SHOW:"show",EXPAND:"expand",COLLAPSE:"collapse",HIDE_HEADER:"hideheader",SHOW_HEADER:"showheader",OPEN_CREATE_RECORD_MODAL_REQUEST:"opencreaterecordmodal:request",OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:"opencreaterelatedrecordmodal:request",SHOW_TOAST:"showtoast",CLEAR_TOASTS:"cleartoasts",REFRESH_TIMELINE:"refreshtimeline",REFRESH_ENTITY:"refreshentity",UPLOADFILE_REQUEST:"uploadfile:request",UPDATE_SESSION_DATA:"updatesessiondata",INSTALL_THIRD_PARTY_SCRIPT_REQUEST:"installthirdpartyscript:request",PROMPT_REQUEST:"prompt:request",DYNAMIC_PROMPT_REQUEST:"dynamicprompt:request",RELEASE_BLOCKING_SCRIPT:"releaseblockingscript",AUTHORIZE:"authorize",COPY_TO_CLIPBOARD:"copytoclipboard"},h={QUERY_RESPONSE:"query:response",POSTFORMDATA_RESPONSE:"postformdata:response",ERROR:"error",UPLOADFILE_RESPONSE:"uploadfile:response",INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:"installthirdpartyscript:response",PROMPT_RESPONSE:"prompt:response",REFRESH_ENTITY_RESPONSE:"refreshentity:response",CREATE_RECORD_RESPONSE:"createrecord:response",CREATE_RELATED_RECORD_RESPONSE:"createrelatedrecord:response"},S={RUN_FRAME_SCRIPT:"runframescript",SEND_MESSAGE_TO_FRAME:"sendmessagetoframe",CALL_THIRD_PARTY_SCRIPT:"callthirdpartyscript"},P=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,b=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,T={FRESHWORKS:"freshworks",INTERCOM:"intercom"},A=e=>{if(P.test(e))return T.FRESHWORKS;if(b.test(e))return T.INTERCOM},C=class{constructor(e,t){c(this,"instance");c(this,"scriptUrl");c(this,"integration");this.instance=e,this.scriptUrl=t;const r=A(t);if(r)this.integration=r;else throw new Error(`Error: Disallowed script url: ${t}`)}get type(){return this.integration}call(...e){this.instance.postMessage(JSON.stringify({action:l.COMMUNICATE,type:S.CALL_THIRD_PARTY_SCRIPT,eventName:`thirdParty:${S.CALL_THIRD_PARTY_SCRIPT}`,recipient:{script:this.scriptUrl,type:this.type},params:e}))}},I=e=>({key:`action__${e.api_name}`,type:"custom_object",label:e.name,allow_multiple:!0}),N=(e,t)=>{var o;const r=(e.fields??[]).filter(i=>i.type!=="container"&&i.type!=="description").map(i=>({...i,when:t?`(${t}) && (${i.when??"true"})`:i.when})),a=(e.fields??[]).filter(i=>i.type==="container").flatMap(i=>N(i,i.when)),n=((o=e.actions)==null?void 0:o.filter(i=>i.hint_object_name))??[];return[...r,...a,...n.map(i=>({...I(i),match_hint:i.hint_object_name??""}))]},D=(e,t)=>{const s=N(e).reduce((o,i)=>({...o,[i.key]:i}),{}),a=Object.keys(t),n={};return a.forEach(o=>{var d,f;const i=t[o],E=s[o];if(E!=null&&E.type){switch(E.type){case"boolean":const p=i;if(!p)return;n[o]=p.value;return;case"custom_object":{const u=i;if(!u)return;n[o]={objectId:(d=u.value)==null?void 0:d.id,objectName:(f=u.value)==null?void 0:f.objectName};return}case"field":{const u=i;if(!(u!=null&&u.value))return;Array.isArray(u.value)?n[o]=u.value.map(g=>{var m,y;return{fieldId:g.value,fieldName:g.label,objectId:(m=u.associatedObject)==null?void 0:m.id,objectName:(y=u.associatedObject)==null?void 0:y.name}}):typeof u.value=="object"&&typeof u.associatedObject=="object"&&(n[o]={fieldId:u.value.value,fieldName:u.value.label,objectId:u.associatedObject.id,objectName:u.associatedObject.name});return}case"number":{const u=i;if(!u)return;try{const g=Number(u.value);if(!g&&g!==0)return;n[o]=g}catch{n[o]=NaN}return}case"select":{const u=i;if(!u)return;n[o]=u.value;return}case"text":{const u=i,g=u==null?void 0:u.value;if(g){n[o]=g;return}const m=E.default;m&&(n[o]=m);return}case"description":case"container":return}return i==null?void 0:i.value}}),n},M=(e,t)=>r=>async(s,a,n)=>new Promise((o,i)=>{const E=t.register(o,i);e.postMessage(JSON.stringify({action:l.QUERY_REQUEST,id:E,method:r,url:s,payload:a,options:n}))}),v=(e,t)=>(r,s,a=!0)=>new Promise((n,o)=>{const i=t.register(n,o);e.postMessage(JSON.stringify({action:l.POSTFORMDATA_REQUEST,url:r,id:i,payload:s,createNewTab:a}))}),H=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:l.PROMPT_REQUEST,id:n,config:r}))}),x=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:l.DYNAMIC_PROMPT_REQUEST,id:n,config:r}))}),U=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:l.UPLOADFILE_REQUEST,id:n,payload:r}))}),F=(e,t)=>(r,s)=>new Promise((a,n)=>{const o=t.register(a,n);e.postMessage(JSON.stringify({action:l.INSTALL_THIRD_PARTY_SCRIPT_REQUEST,url:r,id:o,args:s}))}),L=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:l.REFRESH_ENTITY,id:n,entityId:r}))}),j=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:l.OPEN_CREATE_RECORD_MODAL_REQUEST,id:n,entityId:r}))}),J=(e,t)=>(r,s)=>new Promise((a,n)=>{const o=t.register(a,n);e.postMessage(JSON.stringify({action:l.OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST,id:o,objectId:r,relatedEntityId:s}))}),$=(e,t,r)=>{switch(e){case h.QUERY_RESPONSE:{const{id:s,data:a,error:n}=JSON.parse(t.data);n?r.reject(s,n):r.resolve(s,a);break}case h.POSTFORMDATA_RESPONSE:{const{id:s,success:a}=JSON.parse(t.data);a?r.resolve(s):r.reject(s);break}case h.UPLOADFILE_RESPONSE:{const{id:s,data:a,error:n}=JSON.parse(t.data);a?r.resolve(s,a):r.reject(s,n);break}case h.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);a.success?r.resolve(s,a):r.reject(s);break}case h.PROMPT_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case h.CREATE_RECORD_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case h.CREATE_RELATED_RECORD_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case h.REFRESH_ENTITY_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);a.success?r.resolve(s,!0):r.reject(s);break}}},k=`integration:${S.RUN_FRAME_SCRIPT}`,B=class{constructor(e){c(this,"instance");this.instance=e}runFrameScript(e,t,r){this.instance.postMessage(JSON.stringify({action:l.COMMUNICATE,type:S.RUN_FRAME_SCRIPT,eventName:k,recipient:{frame:e,script:t},args:r}))}sendMessageToOwnFrame(e,t){this.instance.postMessage(JSON.stringify({action:l.COMMUNICATE,type:S.SEND_MESSAGE_TO_FRAME,args:{payload:e,path:t}}))}},_=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},O=(e,t,r={},s="")=>{const n=`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(r)}, utils: __kizen_utils })`;return`(function() { ${s}
2
- return ${n}; })()`},W=class{constructor({user:e,teamMember:t,business:r,clientObject:s,appPath:a,isDebug:n,kizenRequest:o,postFormData:i,scriptBody:E,instance:d,args:f,uploadFile:p,sessionData:u,pluginComponentId:g,installThirdPartyScript:m,prompt:y,refreshEntity:G,openCreateRecord:K,openCreateRelatedRecord:V,pluginApiName:X,dynamicPrompt:Z,location:ee}){c(this,"user");c(this,"teamMember");c(this,"business");c(this,"clientObject");c(this,"appPath");c(this,"dataCache",new Map);c(this,"queryOptions",{});c(this,"api");c(this,"postFormData");c(this,"executionTimer",0);c(this,"setupExecutions",0);c(this,"cleanupExecutions",0);c(this,"isDebug",!1);c(this,"scriptBody");c(this,"internalState",{indicator:"none"});c(this,"console",console);c(this,"instance");c(this,"breakOnException",!1);c(this,"args");c(this,"communicate");c(this,"shouldPreserve",!1);c(this,"uploadFileHandler");c(this,"internalSessionData");c(this,"pluginComponentId");c(this,"installThirdPartyScriptHandler");c(this,"promptHandler");c(this,"dynamicPromptHandler");c(this,"refreshEntityHandler");c(this,"openCreateRecordHandler");c(this,"openCreateRelatedRecordHandler");c(this,"runnerType");c(this,"pluginApiName");c(this,"tempPromptState",{});c(this,"partialLocation");this.user=e,this.teamMember=t,this.business=r,this.clientObject=s,this.partialLocation=ee,this.appPath=a,this.isDebug=n??!1,this.api={get:o("get"),post:o("post"),put:o("put"),delete:o("delete"),patch:o("patch")},this.postFormData=i,this.scriptBody=E,this.instance=d,this.communicate=new B(d),this.uploadFileHandler=p,this.internalSessionData=u??{},this.pluginComponentId=g,this.installThirdPartyScriptHandler=m,this.promptHandler=y,this.refreshEntityHandler=G,this.openCreateRecordHandler=K,this.openCreateRelatedRecordHandler=V,this.runnerType="base",this.pluginApiName=X,this.dynamicPromptHandler=Z;try{this.args=JSON.parse(f??"{}")}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:h.ERROR,error:e==null?void 0:e.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split("-")}parsePhone(e){return e.replace(/\+/g,"")}openWindow(e,t="_blank"){this.instance.postMessage(JSON.stringify({action:l.OPEN_WINDOW,url:e,target:t,features:"noopener noreferrer"}))}authorize(e,t={}){if(!e)throw new Error("Service name is required to authorize");this.instance.postMessage(JSON.stringify({action:l.AUTHORIZE,serviceName:e,config:{successRedirectPath:t.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:t.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw new Error("Service name is required to get a service url");const r=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith("/")?`${r}${t}`:`${r}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){var e,t,r,s,a,n,o,i;return{profile:{id:((e=this.teamMember)==null?void 0:e.id)??"",full_name:((t=this.teamMember)==null?void 0:t.full_name)??"",first_name:((r=this.teamMember)==null?void 0:r.first_name)??"",last_name:((s=this.teamMember)==null?void 0:s.last_name)??"",email:((a=this.teamMember)==null?void 0:a.email)??"",phone:((n=this.teamMember)==null?void 0:n.phone)??"",created:((o=this.teamMember)==null?void 0:o.created)??"",crm_client_id:((i=this.user)==null?void 0:i.crm_client_id)??""}}}get sessionData(){return this.internalSessionData}get config(){return!this.args.__kizen_clean_config?{}:new Proxy(this.args.__kizen_clean_config??{},{get:(r,s)=>{if(Reflect.has(r,s))return Reflect.get(r,s)}})}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t==="toJSON")return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw new Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){var r;const e=(r=this.args.__kizen_user_config)==null?void 0:r.__kizen_clean_config;return e?new Proxy(e,{get:(s,a)=>{if(Reflect.has(s,a))return Reflect.get(s,a)}}):{}}setSessionData(e){if(typeof e!="object")throw new Error(`Invalid session update with type ${typeof e}`);if(Array.isArray(e))throw new Error("Invalid session update with type array");this.internalSessionData={...this.internalSessionData,...e},this.instance.postMessage(JSON.stringify({action:l.UPDATE_SESSION_DATA,update:e}))}async get(e,t){try{if(this.isRelativeUrl(e)){const r=this.dataCache.get(e);if(r&&!(t!=null&&t.ignoreCache))return t!=null&&t.returnErrors?[r.data,null]:r.data;const{data:s}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t==null?void 0:t.headers)});return this.dataCache.set(e,{ts:Date.now(),data:s}),t!=null&&t.returnErrors?[s,null]:s}else{const r=await fetch(e,{method:"GET",headers:new Headers(t==null?void 0:t.headers),credentials:(t==null?void 0:t.credentials)??"same-origin"});if(!r.ok)throw await _(r);const s=await r.json();return t!=null&&t.returnErrors?[s,null]:s}}catch(r){if(t!=null&&t.returnErrors)return[null,r];this.onError(r)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){var t;if(!this.args.pluginId||!this.pluginComponentId)throw new Error("User config is not available for scripts not associated to a plugin or plugin component");return((t=(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config)==null?void 0:t[this.pluginComponentId])??{}}async setUserConfig(e){var s;if(!this.args.pluginId||!this.pluginComponentId)throw new Error("User config is not available for scripts not associated to a plugin or plugin component");const t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t==null?void 0:t.config,[this.pluginComponentId]:{...(s=t==null?void 0:t.config)==null?void 0:s[this.pluginComponentId],...e}}})}async patch(e,t,r){try{if(this.isRelativeUrl(e)){const{data:s}=await this.api.patch(e,t,{...this.queryOptions,headers:r==null?void 0:r.headers});return r!=null&&r.returnErrors?[s,null]:s}else{const s=await fetch(e,{method:"PATCH",body:t?JSON.stringify(t):null,headers:new Headers(r==null?void 0:r.headers),credentials:(r==null?void 0:r.credentials)??"same-origin"});if(!s.ok)throw await _(s);const a=await s.json();return r!=null&&r.returnErrors?[a,null]:a}}catch(s){if(r!=null&&r.returnErrors)return[null,s];this.onError(s)}}async patchWithErrors(e,t,r){return this.patch(e,t,{...r,returnErrors:!0})}async post(e,t,r){try{if(this.isRelativeUrl(e)){const{data:s}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(r==null?void 0:r.headers)});return r!=null&&r.returnErrors?[s,null]:s}else{const s=await fetch(e,{method:"POST",body:t?JSON.stringify(t):null,headers:new Headers(r==null?void 0:r.headers),credentials:(r==null?void 0:r.credentials)??"same-origin"});if(!s.ok)throw await _(s);const a=await s.json();return r!=null&&r.returnErrors?[a,null]:a}}catch(s){if(r!=null&&r.returnErrors)return[null,s];this.onError(s)}}async postWithErrors(e,t,r){return this.post(e,t,{...r,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){const{data:r}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t==null?void 0:t.headers)});return t!=null&&t.returnErrors?[r,null]:r}else{const r=await fetch(e,{method:"DELETE",headers:new Headers(t==null?void 0:t.headers),credentials:(t==null?void 0:t.credentials)??"same-origin"});if(!r.ok)throw await _(r);let s=null;return r.status!==204&&(s=await r.json()),t!=null&&t.returnErrors?[s,null]:s}}catch(r){if(t!=null&&t.returnErrors)return[null,r];this.onError(r)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(e,t){this.instance.postMessage(JSON.stringify({action:l.SHOW_TOAST,message:e,toastOptions:t}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:l.CLEAR_TOASTS}))}outputUI(e){this.instance.postMessage(JSON.stringify({action:l.UI_OUTPUT,markup:e}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){var E;const t="__kizen_state";let r=`const __kizen_utils = {};
3
- `;if(e.registerUtils){const d=Object.keys(e.registerUtils);r+=d.map(f=>{var u;const p=(u=e.registerUtils)==null?void 0:u[f];if(typeof p!="function")throw new Error(`Registered util ${f} is not a function, got ${typeof p}`);return`__kizen_utils["${f}"] = (${p.toString()});`}).join(`
4
- `)}const s=(E=e.content)==null?void 0:E.map(d=>{let f="";"optionMapper"in d&&(f=O(d.optionMapper,t,d.args,r));let p="";"getFetchUrl"in d&&(p=O(d.getFetchUrl,t,d.args,r));let u="";"getHeaders"in d&&(u=O(d.getHeaders,t,d.args,r));let g="";return"getBody"in d&&(g=O(d.getBody,t,d.args,r)),{...d,optionMapper:f,getFetchUrl:p,getHeaders:u,getBody:g}}),a={...e,content:s},n={fields:a.content},o=await this.dynamicPromptHandler(a),i=D(n,o.values);return{...o,values:i}}outputIframe(e,t,r){this.instance.postMessage(JSON.stringify({action:l.IFRAME_OUTPUT,url:e,allow:t,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,r)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>{t(s.result)},s.onerror=a=>{r(a)}})}async uploadFile(e,t,r=!1){const s=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:s,fileName:t??"file_"+String(Date.now()),isPublic:r})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw new Error("Setup must be called exactly once, and should never be called by a script directly.");if(this.cleanupExecutions!==0)throw new Error("Setup was called after cleanup");this.isDebug&&this.console.log(`Running script:
5
-
6
- ${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw new Error("Cleanup must be called exactly once, and should never be called by a script directly.");if(this.setupExecutions!==1)throw new Error("Cleanup was called before setup");this.cleanupExecutions++,this.setIndicator("none");const t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e="none"){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(e,t){this.instance.postMessage(JSON.stringify({action:l.DONE,result:t,preserve:e}))}setState(e){this.instance.postMessage(JSON.stringify({action:l.SETSTATE,state:e}))}isRelativeUrl(e){return e.startsWith("/")}buildHeaders(e={}){return{...e,"X-Request-Type":"kizen-ui-scripting-api"}}refreshTimelineForId(e){e&&this.instance.postMessage(JSON.stringify({action:l.REFRESH_TIMELINE,entityId:e}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{const t=await this.installThirdPartyScriptHandler(e,this.args);return new C(this.instance,t.url)}catch{this.onError(new Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:l.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(e){this.instance.postMessage(JSON.stringify({action:l.COPY_TO_CLIPBOARD,text:e}))}createDateObject(e){if(typeof e!="string")throw new Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error(`Date string ${e} is not in the format YYYY-MM-DD`);const t=e.split("-").map(s=>parseInt(s,10));if(t.length<3)throw new Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},Y=class extends W{constructor(e){super(e),this.runnerType="floatingFrame"}hide(e={}){this.instance.postMessage(JSON.stringify({action:l.HIDE,config:e}))}hideHeader(){this.instance.postMessage(JSON.stringify({action:l.HIDE_HEADER}))}showHeader(){this.instance.postMessage(JSON.stringify({action:l.SHOW_HEADER}))}show(e={}){this.instance.postMessage(JSON.stringify({action:l.SHOW,config:e}))}expand(){this.instance.postMessage(JSON.stringify({action:l.EXPAND}))}collapse(){this.instance.postMessage(JSON.stringify({action:l.COLLAPSE}))}afterSetup(){this.show()}},Q=()=>{let e=new Date().getTime();return typeof performance<"u"&&typeof performance.now=="function"&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t==="x"?r:r&3|8).toString(16)})},w=Object.getPrototypeOf(async function(){}).constructor,q=e=>{const t=`
7
- const __cleanup = this.__cleanup.bind(this);
8
- const __error = this.onError.bind(this);
9
- {
10
- this.__setup();
11
- }
12
- try {
13
- ${e}
14
- } catch (ex) {
15
- __error(ex);
16
- } finally {
17
- __cleanup();
18
- }
19
- `;try{return{fn:new w(t),functionBody:t}}catch{const r=`
20
- this.__setup();
21
- this.onError({ message: "The script has a syntax error and could not be parsed" });
22
- this.__cleanup();
23
- `;return{fn:new w(r),functionBody:r}}},z=class{constructor({isDebug:e=!1}){c(this,"promises");c(this,"isDebug");this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,r){this.promises.set(e,{resolve:t,reject:r})}id(){return Q()}register(e,t){const r=this.id();return this.set(r,e,t),r}resolve(e,t){var r;(r=this.get(e))==null||r.resolve(t),this.delete(e)}reject(e,t){var r;(r=this.get(e))==null||r.reject(t),this.delete(e)}},R=new z({isDebug:!1});self.onmessage=async e=>{const t=JSON.parse(e.data),{action:r,script:s,setup:a,args:n,sessionData:o={},pluginComponentId:i,pluginApiName:E,location:d}=t;if(r===l.RUN&&a&&s){const{fn:f,functionBody:p}=q(s),u=new Y({user:a.user,teamMember:a.teamMember,business:a.business,clientObject:a.clientObject,appPath:a.appPath,isDebug:a.isDebug,scriptBody:s,functionBody:p,instance:self,kizenRequest:M(self,R),postFormData:v(self,R),uploadFile:U(self,R),installThirdPartyScript:F(self,R),args:n??"",sessionData:o,pluginComponentId:i,prompt:H(self,R),dynamicPrompt:x(self,R),refreshEntity:L(self,R),openCreateRecord:j(self,R),openCreateRelatedRecord:J(self,R),pluginApiName:E,location:d});await f.bind(u)()}else $(r,e,R)}})();
@@ -1,23 +0,0 @@
1
- var te=Object.defineProperty;var re=(u,h,R)=>h in u?te(u,h,{enumerable:!0,configurable:!0,writable:!0,value:R}):u[h]=R;var c=(u,h,R)=>re(u,typeof h!="symbol"?h+"":h,R);(function(){"use strict";var u={QUERY_REQUEST:"query:request",UI_OUTPUT:"outputui",IFRAME_OUTPUT:"iframeoutput",POSTFORMDATA_REQUEST:"postformdata:request",SETSTATE:"setstate",DONE:"done",RUN:"run",OPEN_WINDOW:"openwindow",COMMUNICATE:"communicate",OPEN_CREATE_RECORD_MODAL_REQUEST:"opencreaterecordmodal:request",OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:"opencreaterelatedrecordmodal:request",SHOW_TOAST:"showtoast",CLEAR_TOASTS:"cleartoasts",REFRESH_TIMELINE:"refreshtimeline",REFRESH_ENTITY:"refreshentity",UPLOADFILE_REQUEST:"uploadfile:request",UPDATE_SESSION_DATA:"updatesessiondata",INSTALL_THIRD_PARTY_SCRIPT_REQUEST:"installthirdpartyscript:request",PROMPT_REQUEST:"prompt:request",DYNAMIC_PROMPT_REQUEST:"dynamicprompt:request",RELEASE_BLOCKING_SCRIPT:"releaseblockingscript",AUTHORIZE:"authorize",COPY_TO_CLIPBOARD:"copytoclipboard"},h={QUERY_RESPONSE:"query:response",POSTFORMDATA_RESPONSE:"postformdata:response",ERROR:"error",UPLOADFILE_RESPONSE:"uploadfile:response",INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:"installthirdpartyscript:response",PROMPT_RESPONSE:"prompt:response",REFRESH_ENTITY_RESPONSE:"refreshentity:response",CREATE_RECORD_RESPONSE:"createrecord:response",CREATE_RELATED_RECORD_RESPONSE:"createrelatedrecord:response"},R={RUN_FRAME_SCRIPT:"runframescript",SEND_MESSAGE_TO_FRAME:"sendmessagetoframe",CALL_THIRD_PARTY_SCRIPT:"callthirdpartyscript"},b=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,C=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,y={FRESHWORKS:"freshworks",INTERCOM:"intercom"},A=e=>{if(b.test(e))return y.FRESHWORKS;if(C.test(e))return y.INTERCOM},I=class{constructor(e,t){c(this,"instance");c(this,"scriptUrl");c(this,"integration");this.instance=e,this.scriptUrl=t;const r=A(t);if(r)this.integration=r;else throw new Error(`Error: Disallowed script url: ${t}`)}get type(){return this.integration}call(...e){this.instance.postMessage(JSON.stringify({action:u.COMMUNICATE,type:R.CALL_THIRD_PARTY_SCRIPT,eventName:`thirdParty:${R.CALL_THIRD_PARTY_SCRIPT}`,recipient:{script:this.scriptUrl,type:this.type},params:e}))}},v=()=>{let e=new Date().getTime();return typeof performance<"u"&&typeof performance.now=="function"&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t==="x"?r:r&3|8).toString(16)})},P=Object.getPrototypeOf(async function(){}).constructor,M=e=>{const t=`
2
- const __cleanup = this.__cleanup.bind(this);
3
- const __error = this.onError.bind(this);
4
- {
5
- this.__setup();
6
- }
7
- try {
8
- ${e}
9
- } catch (ex) {
10
- __error(ex);
11
- } finally {
12
- __cleanup();
13
- }
14
- `;try{return{fn:new P(t),functionBody:t}}catch{const r=`
15
- this.__setup();
16
- this.onError({ message: "The script has a syntax error and could not be parsed" });
17
- this.__cleanup();
18
- `;return{fn:new P(r),functionBody:r}}},D=class{constructor({isDebug:e=!1}){c(this,"promises");c(this,"isDebug");this.promises=new Map,this.isDebug=e}delete(e){this.isDebug&&console.log(`Deleting promise ${e}`),this.promises.delete(e)}get(e){return this.isDebug&&console.log(`Getting promise ${e}`),this.promises.get(e)}set(e,t,r){this.promises.set(e,{resolve:t,reject:r})}id(){return v()}register(e,t){const r=this.id();return this.set(r,e,t),r}resolve(e,t){var r;(r=this.get(e))==null||r.resolve(t),this.delete(e)}reject(e,t){var r;(r=this.get(e))==null||r.reject(t),this.delete(e)}},U=e=>({key:`action__${e.api_name}`,type:"custom_object",label:e.name,allow_multiple:!0}),w=(e,t)=>{var o;const r=(e.fields??[]).filter(i=>i.type!=="container"&&i.type!=="description").map(i=>({...i,when:t?`(${t}) && (${i.when??"true"})`:i.when})),a=(e.fields??[]).filter(i=>i.type==="container").flatMap(i=>w(i,i.when)),n=((o=e.actions)==null?void 0:o.filter(i=>i.hint_object_name))??[];return[...r,...a,...n.map(i=>({...U(i),match_hint:i.hint_object_name??""}))]},x=(e,t)=>{const s=w(e).reduce((o,i)=>({...o,[i.key]:i}),{}),a=Object.keys(t),n={};return a.forEach(o=>{var d,f;const i=t[o],E=s[o];if(E!=null&&E.type){switch(E.type){case"boolean":const p=i;if(!p)return;n[o]=p.value;return;case"custom_object":{const l=i;if(!l)return;n[o]={objectId:(d=l.value)==null?void 0:d.id,objectName:(f=l.value)==null?void 0:f.objectName};return}case"field":{const l=i;if(!(l!=null&&l.value))return;Array.isArray(l.value)?n[o]=l.value.map(g=>{var m,T;return{fieldId:g.value,fieldName:g.label,objectId:(m=l.associatedObject)==null?void 0:m.id,objectName:(T=l.associatedObject)==null?void 0:T.name}}):typeof l.value=="object"&&typeof l.associatedObject=="object"&&(n[o]={fieldId:l.value.value,fieldName:l.value.label,objectId:l.associatedObject.id,objectName:l.associatedObject.name});return}case"number":{const l=i;if(!l)return;try{const g=Number(l.value);if(!g&&g!==0)return;n[o]=g}catch{n[o]=NaN}return}case"select":{const l=i;if(!l)return;n[o]=l.value;return}case"text":{const l=i,g=l==null?void 0:l.value;if(g){n[o]=g;return}const m=E.default;m&&(n[o]=m);return}case"description":case"container":return}return i==null?void 0:i.value}}),n},H=(e,t)=>r=>async(s,a,n)=>new Promise((o,i)=>{const E=t.register(o,i);e.postMessage(JSON.stringify({action:u.QUERY_REQUEST,id:E,method:r,url:s,payload:a,options:n}))}),F=(e,t)=>(r,s,a=!0)=>new Promise((n,o)=>{const i=t.register(n,o);e.postMessage(JSON.stringify({action:u.POSTFORMDATA_REQUEST,url:r,id:i,payload:s,createNewTab:a}))}),j=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:u.PROMPT_REQUEST,id:n,config:r}))}),L=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:u.DYNAMIC_PROMPT_REQUEST,id:n,config:r}))}),J=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:u.UPLOADFILE_REQUEST,id:n,payload:r}))}),$=(e,t)=>(r,s)=>new Promise((a,n)=>{const o=t.register(a,n);e.postMessage(JSON.stringify({action:u.INSTALL_THIRD_PARTY_SCRIPT_REQUEST,url:r,id:o,args:s}))}),k=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:u.REFRESH_ENTITY,id:n,entityId:r}))}),B=(e,t)=>r=>new Promise((s,a)=>{const n=t.register(s,a);e.postMessage(JSON.stringify({action:u.OPEN_CREATE_RECORD_MODAL_REQUEST,id:n,entityId:r}))}),Y=(e,t)=>(r,s)=>new Promise((a,n)=>{const o=t.register(a,n);e.postMessage(JSON.stringify({action:u.OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST,id:o,objectId:r,relatedEntityId:s}))}),Q=(e,t,r)=>{switch(e){case h.QUERY_RESPONSE:{const{id:s,data:a,error:n}=JSON.parse(t.data);n?r.reject(s,n):r.resolve(s,a);break}case h.POSTFORMDATA_RESPONSE:{const{id:s,success:a}=JSON.parse(t.data);a?r.resolve(s):r.reject(s);break}case h.UPLOADFILE_RESPONSE:{const{id:s,data:a,error:n}=JSON.parse(t.data);a?r.resolve(s,a):r.reject(s,n);break}case h.INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);a.success?r.resolve(s,a):r.reject(s);break}case h.PROMPT_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case h.CREATE_RECORD_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case h.CREATE_RELATED_RECORD_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);r.resolve(s,a);break}case h.REFRESH_ENTITY_RESPONSE:{const{id:s,data:a}=JSON.parse(t.data);a.success?r.resolve(s,!0):r.reject(s);break}}},W=`integration:${R.RUN_FRAME_SCRIPT}`,q=class{constructor(e){c(this,"instance");this.instance=e}runFrameScript(e,t,r){this.instance.postMessage(JSON.stringify({action:u.COMMUNICATE,type:R.RUN_FRAME_SCRIPT,eventName:W,recipient:{frame:e,script:t},args:r}))}sendMessageToOwnFrame(e,t){this.instance.postMessage(JSON.stringify({action:u.COMMUNICATE,type:R.SEND_MESSAGE_TO_FRAME,args:{payload:e,path:t}}))}},_=async e=>{let t=null;try{t=await e.json()}catch{}return{status:e.status,statusText:e.statusText,body:t}},O=(e,t,r={},s="")=>{const n=`(${e.toString()})({ state: {{${t}}}, args: ${JSON.stringify(r)}, utils: __kizen_utils })`;return`(function() { ${s}
19
- return ${n}; })()`},z=class{constructor({user:e,teamMember:t,business:r,clientObject:s,appPath:a,isDebug:n,kizenRequest:o,postFormData:i,scriptBody:E,instance:d,args:f,uploadFile:p,sessionData:l,pluginComponentId:g,installThirdPartyScript:m,prompt:T,refreshEntity:G,openCreateRecord:K,openCreateRelatedRecord:V,pluginApiName:Z,dynamicPrompt:X,location:ee}){c(this,"user");c(this,"teamMember");c(this,"business");c(this,"clientObject");c(this,"appPath");c(this,"dataCache",new Map);c(this,"queryOptions",{});c(this,"api");c(this,"postFormData");c(this,"executionTimer",0);c(this,"setupExecutions",0);c(this,"cleanupExecutions",0);c(this,"isDebug",!1);c(this,"scriptBody");c(this,"internalState",{indicator:"none"});c(this,"console",console);c(this,"instance");c(this,"breakOnException",!1);c(this,"args");c(this,"communicate");c(this,"shouldPreserve",!1);c(this,"uploadFileHandler");c(this,"internalSessionData");c(this,"pluginComponentId");c(this,"installThirdPartyScriptHandler");c(this,"promptHandler");c(this,"dynamicPromptHandler");c(this,"refreshEntityHandler");c(this,"openCreateRecordHandler");c(this,"openCreateRelatedRecordHandler");c(this,"runnerType");c(this,"pluginApiName");c(this,"tempPromptState",{});c(this,"partialLocation");this.user=e,this.teamMember=t,this.business=r,this.clientObject=s,this.partialLocation=ee,this.appPath=a,this.isDebug=n??!1,this.api={get:o("get"),post:o("post"),put:o("put"),delete:o("delete"),patch:o("patch")},this.postFormData=i,this.scriptBody=E,this.instance=d,this.communicate=new q(d),this.uploadFileHandler=p,this.internalSessionData=l??{},this.pluginComponentId=g,this.installThirdPartyScriptHandler=m,this.promptHandler=T,this.refreshEntityHandler=G,this.openCreateRecordHandler=K,this.openCreateRelatedRecordHandler=V,this.runnerType="base",this.pluginApiName=Z,this.dynamicPromptHandler=X;try{this.args=JSON.parse(f??"{}")}catch{this.args={}}}onError(e){if(this.breakOnException)debugger;this.instance.postMessage(JSON.stringify({action:h.ERROR,error:e==null?void 0:e.message}))}set debug(e){this.isDebug=e,this.breakOnException=e}set preserve(e){this.shouldPreserve=e}get preserve(){return this.shouldPreserve}parseDate(e){return e.split("-")}parsePhone(e){return e.replace(/\+/g,"")}openWindow(e,t="_blank"){this.instance.postMessage(JSON.stringify({action:u.OPEN_WINDOW,url:e,target:t,features:"noopener noreferrer"}))}authorize(e,t={}){if(!e)throw new Error("Service name is required to authorize");this.instance.postMessage(JSON.stringify({action:u.AUTHORIZE,serviceName:e,config:{successRedirectPath:t.successRedirectPath??`/marketplace/${this.pluginApiName}/auth`,errorRedirectPath:t.errorRedirectPath??`/marketplace/${this.pluginApiName}/auth`}}))}getServiceUrl(e,t){if(!e)throw new Error("Service name is required to get a service url");const r=`/external-integrations/proxy/${this.pluginApiName}/${e}`;return t.startsWith("/")?`${r}${t}`:`${r}/${t}`}get currentBusiness(){return this.business}get applicationPath(){return this.appPath}get currentUser(){var e,t,r,s,a,n,o,i;return{profile:{id:((e=this.teamMember)==null?void 0:e.id)??"",full_name:((t=this.teamMember)==null?void 0:t.full_name)??"",first_name:((r=this.teamMember)==null?void 0:r.first_name)??"",last_name:((s=this.teamMember)==null?void 0:s.last_name)??"",email:((a=this.teamMember)==null?void 0:a.email)??"",phone:((n=this.teamMember)==null?void 0:n.phone)??"",created:((o=this.teamMember)==null?void 0:o.created)??"",crm_client_id:((i=this.user)==null?void 0:i.crm_client_id)??""}}}get sessionData(){return this.internalSessionData}get config(){return!this.args.__kizen_clean_config?{}:new Proxy(this.args.__kizen_clean_config??{},{get:(r,s)=>{if(Reflect.has(r,s))return Reflect.get(r,s)}})}get location(){return new Proxy(this.partialLocation,{get:(e,t)=>{if(t==="toJSON")return()=>this.partialLocation;if(Reflect.has(e,t))return Reflect.get(e,t);throw new Error(`Property ${String(t)} is not available on location object for plugin apps`)}})}get userConfig(){var r;const e=(r=this.args.__kizen_user_config)==null?void 0:r.__kizen_clean_config;return e?new Proxy(e,{get:(s,a)=>{if(Reflect.has(s,a))return Reflect.get(s,a)}}):{}}setSessionData(e){if(typeof e!="object")throw new Error(`Invalid session update with type ${typeof e}`);if(Array.isArray(e))throw new Error("Invalid session update with type array");this.internalSessionData={...this.internalSessionData,...e},this.instance.postMessage(JSON.stringify({action:u.UPDATE_SESSION_DATA,update:e}))}async get(e,t){try{if(this.isRelativeUrl(e)){const r=this.dataCache.get(e);if(r&&!(t!=null&&t.ignoreCache))return t!=null&&t.returnErrors?[r.data,null]:r.data;const{data:s}=await this.api.get(e,{...this.queryOptions,headers:this.buildHeaders(t==null?void 0:t.headers)});return this.dataCache.set(e,{ts:Date.now(),data:s}),t!=null&&t.returnErrors?[s,null]:s}else{const r=await fetch(e,{method:"GET",headers:new Headers(t==null?void 0:t.headers),credentials:(t==null?void 0:t.credentials)??"same-origin"});if(!r.ok)throw await _(r);const s=await r.json();return t!=null&&t.returnErrors?[s,null]:s}}catch(r){if(t!=null&&t.returnErrors)return[null,r];this.onError(r)}}async getWithErrors(e,t){return this.get(e,{...t,returnErrors:!0})}async getUserConfig(){var t;if(!this.args.pluginId||!this.pluginComponentId)throw new Error("User config is not available for scripts not associated to a plugin or plugin component");return((t=(await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0})).config)==null?void 0:t[this.pluginComponentId])??{}}async setUserConfig(e){var s;if(!this.args.pluginId||!this.pluginComponentId)throw new Error("User config is not available for scripts not associated to a plugin or plugin component");const t=await this.get(`/employee/mine/configs/plugins/${this.args.pluginId}`,{ignoreCache:!0});return await this.post(`/employee/mine/configs/plugins/${this.args.pluginId}`,{config:{...t==null?void 0:t.config,[this.pluginComponentId]:{...(s=t==null?void 0:t.config)==null?void 0:s[this.pluginComponentId],...e}}})}async patch(e,t,r){try{if(this.isRelativeUrl(e)){const{data:s}=await this.api.patch(e,t,{...this.queryOptions,headers:r==null?void 0:r.headers});return r!=null&&r.returnErrors?[s,null]:s}else{const s=await fetch(e,{method:"PATCH",body:t?JSON.stringify(t):null,headers:new Headers(r==null?void 0:r.headers),credentials:(r==null?void 0:r.credentials)??"same-origin"});if(!s.ok)throw await _(s);const a=await s.json();return r!=null&&r.returnErrors?[a,null]:a}}catch(s){if(r!=null&&r.returnErrors)return[null,s];this.onError(s)}}async patchWithErrors(e,t,r){return this.patch(e,t,{...r,returnErrors:!0})}async post(e,t,r){try{if(this.isRelativeUrl(e)){const{data:s}=await this.api.post(e,t,{...this.queryOptions,headers:this.buildHeaders(r==null?void 0:r.headers)});return r!=null&&r.returnErrors?[s,null]:s}else{const s=await fetch(e,{method:"POST",body:t?JSON.stringify(t):null,headers:new Headers(r==null?void 0:r.headers),credentials:(r==null?void 0:r.credentials)??"same-origin"});if(!s.ok)throw await _(s);const a=await s.json();return r!=null&&r.returnErrors?[a,null]:a}}catch(s){if(r!=null&&r.returnErrors)return[null,s];this.onError(s)}}async postWithErrors(e,t,r){return this.post(e,t,{...r,returnErrors:!0})}async delete(e,t){try{if(this.isRelativeUrl(e)){const{data:r}=await this.api.delete(e,{...this.queryOptions,headers:this.buildHeaders(t==null?void 0:t.headers)});return t!=null&&t.returnErrors?[r,null]:r}else{const r=await fetch(e,{method:"DELETE",headers:new Headers(t==null?void 0:t.headers),credentials:(t==null?void 0:t.credentials)??"same-origin"});if(!r.ok)throw await _(r);let s=null;return r.status!==204&&(s=await r.json()),t!=null&&t.returnErrors?[s,null]:s}}catch(r){if(t!=null&&t.returnErrors)return[null,r];this.onError(r)}}async deleteWithErrors(e,t){return this.delete(e,{...t,returnErrors:!0})}async openCreateRecordModal(e){return this.openCreateRecordHandler(e)}async openCreateRelatedRecordModal(e,t){return this.openCreateRelatedRecordHandler(e,t)}showToast(e,t){this.instance.postMessage(JSON.stringify({action:u.SHOW_TOAST,message:e,toastOptions:t}))}clearToasts(){this.instance.postMessage(JSON.stringify({action:u.CLEAR_TOASTS}))}outputUI(e){this.instance.postMessage(JSON.stringify({action:u.UI_OUTPUT,markup:e}))}prompt(e){return this.promptHandler(e)}async dynamicPrompt(e){var E;const t="__kizen_state";let r=`const __kizen_utils = {};
20
- `;if(e.registerUtils){const d=Object.keys(e.registerUtils);r+=d.map(f=>{var l;const p=(l=e.registerUtils)==null?void 0:l[f];if(typeof p!="function")throw new Error(`Registered util ${f} is not a function, got ${typeof p}`);return`__kizen_utils["${f}"] = (${p.toString()});`}).join(`
21
- `)}const s=(E=e.content)==null?void 0:E.map(d=>{let f="";"optionMapper"in d&&(f=O(d.optionMapper,t,d.args,r));let p="";"getFetchUrl"in d&&(p=O(d.getFetchUrl,t,d.args,r));let l="";"getHeaders"in d&&(l=O(d.getHeaders,t,d.args,r));let g="";return"getBody"in d&&(g=O(d.getBody,t,d.args,r)),{...d,optionMapper:f,getFetchUrl:p,getHeaders:l,getBody:g}}),a={...e,content:s},n={fields:a.content},o=await this.dynamicPromptHandler(a),i=x(n,o.values);return{...o,values:i}}outputIframe(e,t,r){this.instance.postMessage(JSON.stringify({action:u.IFRAME_OUTPUT,url:e,allow:t,sandbox:r,preserve:this.preserve}))}getBase64EncodedBlob(e){return new Promise((t,r)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>{t(s.result)},s.onerror=a=>{r(a)}})}async uploadFile(e,t,r=!1){const s=await this.getBase64EncodedBlob(e);return await this.uploadFileHandler({file:s,fileName:t??"file_"+String(Date.now()),isPublic:r})}afterSetup(){}__setup(){if(this.setupExecutions!==0)throw new Error("Setup must be called exactly once, and should never be called by a script directly.");if(this.cleanupExecutions!==0)throw new Error("Setup was called after cleanup");this.isDebug&&this.console.log(`Running script:
22
-
23
- ${this.scriptBody}`),this.setupExecutions++,this.executionTimer=performance.now(),this.afterSetup()}__cleanup(e){if(this.cleanupExecutions!==0)throw new Error("Cleanup must be called exactly once, and should never be called by a script directly.");if(this.setupExecutions!==1)throw new Error("Cleanup was called before setup");this.cleanupExecutions++,this.setIndicator("none");const t=performance.now();this.isDebug&&this.console.log(`Script execution took ${String(t-this.executionTimer)}ms`),this.done(this.preserve,e)}setIndicator(e="none"){this.internalState.indicator=e,this.setState({indicator:e})}wait(e){return new Promise(t=>setTimeout(t,e))}done(e,t){this.instance.postMessage(JSON.stringify({action:u.DONE,result:t,preserve:e}))}setState(e){this.instance.postMessage(JSON.stringify({action:u.SETSTATE,state:e}))}isRelativeUrl(e){return e.startsWith("/")}buildHeaders(e={}){return{...e,"X-Request-Type":"kizen-ui-scripting-api"}}refreshTimelineForId(e){e&&this.instance.postMessage(JSON.stringify({action:u.REFRESH_TIMELINE,entityId:e}))}refreshEntityForId(e){if(e)return this.refreshEntityHandler(e)}async installThirdPartyScript(e){try{const t=await this.installThirdPartyScriptHandler(e,this.args);return new I(this.instance,t.url)}catch{this.onError(new Error(`Third party script ${e} could not be installed.`))}}releaseBlockingScript(){this.instance.postMessage(JSON.stringify({action:u.RELEASE_BLOCKING_SCRIPT}))}copyToClipboard(e){this.instance.postMessage(JSON.stringify({action:u.COPY_TO_CLIPBOARD,text:e}))}createDateObject(e){if(typeof e!="string")throw new Error(`Invalid date string ${String(e)}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error(`Date string ${e} is not in the format YYYY-MM-DD`);const t=e.split("-").map(s=>parseInt(s,10));if(t.length<3)throw new Error(`Date string ${e} could not be parsed into valid date parts`);return new Date(t[0],t[1]-1,t[2])}formatDateForResponse(e){return e.getTime()}},S=new D({isDebug:!1}),N=null;self.onmessage=async e=>{const t=JSON.parse(e.data),{action:r,script:s,setup:a,args:n,sessionData:o={},pluginComponentId:i,pluginApiName:E,location:d}=t;if(r===u.RUN&&a&&s){const{fn:f,functionBody:p}=M(s);N=new z({user:a.user,teamMember:a.teamMember,business:a.business,clientObject:a.clientObject,isDebug:a.isDebug,appPath:a.appPath,scriptBody:s,functionBody:p,instance:self,kizenRequest:H(self,S),postFormData:F(self,S),uploadFile:J(self,S),installThirdPartyScript:$(self,S),args:n??"",sessionData:o,pluginComponentId:i,prompt:j(self,S),dynamicPrompt:L(self,S),refreshEntity:k(self,S),openCreateRecord:B(self,S),openCreateRelatedRecord:Y(self,S),pluginApiName:E,location:d}),await f.bind(N)()}else Q(r,e,S)}})();
@@ -1 +0,0 @@
1
- /*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;--color-red-100:oklch(93.6% .032 17.717);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-700:oklch(50.5% .213 27.518);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-700:oklch(55.5% .163 48.998);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-700:oklch(55.4% .135 66.442);--color-green-100:oklch(96.2% .044 156.743);--color-green-400:oklch(79.2% .209 151.711);--color-green-700:oklch(52.7% .154 150.069);--color-neutral-50:oklch(98.5% 0 0);--color-neutral-100:oklch(97% 0 0);--color-neutral-200:oklch(92.2% 0 0);--color-neutral-300:oklch(87% 0 0);--color-neutral-400:oklch(70.8% 0 0);--color-neutral-500:oklch(55.6% 0 0);--color-neutral-600:oklch(43.9% 0 0);--color-neutral-700:oklch(37.1% 0 0);--color-neutral-800:oklch(26.9% 0 0);--color-neutral-900:oklch(20.5% 0 0);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-widest:.1em;--radius-lg:.5rem;--radius-xl:.75rem;--animate-spin:spin 1s linear infinite;--blur-sm:8px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.top-0{top:calc(var(--spacing) * 0)}.top-4{top:calc(var(--spacing) * 4)}.top-full{top:100%}.bottom-0{bottom:calc(var(--spacing) * 0)}.left-0{left:calc(var(--spacing) * 0)}.left-1\/2{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-\[99999\]{z-index:99999}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing) * 0)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.block{display:block}.flex{display:flex}.hidden{display:none}.h-2{height:calc(var(--spacing) * 2)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-6{height:calc(var(--spacing) * 6)}.h-10{height:calc(var(--spacing) * 10)}.h-48{height:calc(var(--spacing) * 48)}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-\[60vh\]{max-height:60vh}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-\[200px\]{min-height:200px}.min-h-screen{min-height:100vh}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-6{width:calc(var(--spacing) * 6)}.w-10{width:calc(var(--spacing) * 10)}.w-28{width:calc(var(--spacing) * 28)}.w-\[26rem\]{width:26rem}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.animate-spin{animation:var(--animate-spin)}.cursor-grab{cursor:grab}.cursor-help{cursor:help}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-black\/8{border-color:#00000014}@supports (color:color-mix(in lab,red,red)){.border-black\/8{border-color:color-mix(in oklab,var(--color-black) 8%,transparent)}}.border-black\/10{border-color:#0000001a}@supports (color:color-mix(in lab,red,red)){.border-black\/10{border-color:color-mix(in oklab,var(--color-black) 10%,transparent)}}.border-black\/20{border-color:#0003}@supports (color:color-mix(in lab,red,red)){.border-black\/20{border-color:color-mix(in oklab,var(--color-black) 20%,transparent)}}.border-neutral-300{border-color:var(--color-neutral-300)}.border-neutral-700{border-color:var(--color-neutral-700)}.border-neutral-800{border-color:var(--color-neutral-800)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black) 30%,transparent)}}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400\/60{background-color:#05df7299}@supports (color:color-mix(in lab,red,red)){.bg-green-400\/60{background-color:color-mix(in oklab,var(--color-green-400) 60%,transparent)}}.bg-neutral-50{background-color:var(--color-neutral-50)}.bg-neutral-100{background-color:var(--color-neutral-100)}.bg-neutral-800{background-color:var(--color-neutral-800)}.bg-neutral-900{background-color:var(--color-neutral-900)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400\/60{background-color:#ff656899}@supports (color:color-mix(in lab,red,red)){.bg-red-400\/60{background-color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/80{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.bg-white\/80{background-color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.bg-white\/85{background-color:#ffffffd9}@supports (color:color-mix(in lab,red,red)){.bg-white\/85{background-color:color-mix(in oklab,var(--color-white) 85%,transparent)}}.bg-yellow-100{background-color:var(--color-yellow-100)}.bg-yellow-400\/60{background-color:#fac80099}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/60{background-color:color-mix(in oklab,var(--color-yellow-400) 60%,transparent)}}.object-cover{object-fit:cover}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-12{padding-block:calc(var(--spacing) * 12)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.whitespace-pre{white-space:pre}.text-amber-700{color:var(--color-amber-700)}.text-green-700{color:var(--color-green-700)}.text-neutral-100{color:var(--color-neutral-100)}.text-neutral-200{color:var(--color-neutral-200)}.text-neutral-400{color:var(--color-neutral-400)}.text-neutral-500{color:var(--color-neutral-500)}.text-neutral-600{color:var(--color-neutral-600)}.text-neutral-700{color:var(--color-neutral-700)}.text-neutral-800{color:var(--color-neutral-800)}.text-neutral-900{color:var(--color-neutral-900)}.text-red-500{color:var(--color-red-500)}.text-red-700{color:var(--color-red-700)}.text-white{color:var(--color-white)}.text-yellow-700{color:var(--color-yellow-700)}.uppercase{text-transform:uppercase}.accent-neutral-800{accent-color:var(--color-neutral-800)}.opacity-30{opacity:.3}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.hover\:bg-black\/5:hover{background-color:#0000000d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/5:hover{background-color:color-mix(in oklab,var(--color-black) 5%,transparent)}}.hover\:bg-neutral-100:hover{background-color:var(--color-neutral-100)}.hover\:bg-neutral-700:hover{background-color:var(--color-neutral-700)}.hover\:text-neutral-200:hover{color:var(--color-neutral-200)}.hover\:text-neutral-700:hover{color:var(--color-neutral-700)}}.focus\:border-neutral-400:focus{border-color:var(--color-neutral-400)}.focus\:border-neutral-500:focus{border-color:var(--color-neutral-500)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-neutral-400:focus{--tw-ring-color:var(--color-neutral-400)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:opacity-50:disabled{opacity:.5}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}