@dialstack/sdk-react 3.8.0 → 3.10.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 (51) hide show
  1. package/dist/ai-agent.cjs +1 -1
  2. package/dist/ai-agent.cjs.map +1 -1
  3. package/dist/ai-agent.mjs +1 -1
  4. package/dist/ai-agent.mjs.map +1 -1
  5. package/dist/call-history.cjs +1 -1
  6. package/dist/call-history.cjs.map +1 -1
  7. package/dist/call-history.mjs +1 -1
  8. package/dist/call-history.mjs.map +1 -1
  9. package/dist/call-logs.cjs +1 -1
  10. package/dist/call-logs.cjs.map +1 -1
  11. package/dist/call-logs.d.cts +4 -0
  12. package/dist/call-logs.d.ts +4 -0
  13. package/dist/call-logs.mjs +1 -1
  14. package/dist/call-logs.mjs.map +1 -1
  15. package/dist/dial-plan.cjs +1 -1
  16. package/dist/dial-plan.cjs.map +1 -1
  17. package/dist/dial-plan.d.cts +1 -1
  18. package/dist/dial-plan.d.ts +1 -1
  19. package/dist/dial-plan.mjs +1 -1
  20. package/dist/dial-plan.mjs.map +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +21 -2
  24. package/dist/index.d.ts +21 -2
  25. package/dist/index.mjs +1 -1
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/onboarding.cjs +1 -1
  28. package/dist/onboarding.cjs.map +1 -1
  29. package/dist/onboarding.mjs +1 -1
  30. package/dist/onboarding.mjs.map +1 -1
  31. package/dist/phone-number-ordering.cjs +1 -1
  32. package/dist/phone-number-ordering.cjs.map +1 -1
  33. package/dist/phone-number-ordering.mjs +1 -1
  34. package/dist/phone-number-ordering.mjs.map +1 -1
  35. package/dist/phone-numbers.cjs +1 -1
  36. package/dist/phone-numbers.cjs.map +1 -1
  37. package/dist/phone-numbers.mjs +1 -1
  38. package/dist/phone-numbers.mjs.map +1 -1
  39. package/dist/softphone.cjs +1 -1
  40. package/dist/softphone.cjs.map +1 -1
  41. package/dist/softphone.d.cts +86 -40
  42. package/dist/softphone.d.ts +86 -40
  43. package/dist/softphone.mjs +1 -1
  44. package/dist/softphone.mjs.map +1 -1
  45. package/dist/voicemails.cjs +1 -1
  46. package/dist/voicemails.cjs.map +1 -1
  47. package/dist/voicemails.d.cts +4 -0
  48. package/dist/voicemails.d.ts +4 -0
  49. package/dist/voicemails.mjs +1 -1
  50. package/dist/voicemails.mjs.map +1 -1
  51. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),n=require("@xyflow/react"),o=require("@dialstack/sdk-react"),a=require("dagre"),t=require("cmdk"),l=require("libphonenumber-js"),r=require("react-dom");function i(e,n,o,a){return new(o||(o=Promise))(function(t,l){function r(e){try{d(a.next(e))}catch(e){l(e)}}function i(e){try{d(a.throw(e))}catch(e){l(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o(function(e){e(n)})).then(r,i)}d((a=a.apply(e,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const d="smoothstep";function s(e,n){var o,a;return null!==(a=null===(o=e.visibleExits)||void 0===o?void 0:o.call(e,n))&&void 0!==a?a:e.exits}const c=({icon:n,label:o,timeout:a,subtitle:t})=>e.createElement("div",{className:"ds-dial-plan-node__header"},e.createElement("div",{className:"ds-dial-plan-node__icon"},n),e.createElement("span",{className:"ds-dial-plan-node__type-label"},o,void 0!==a&&e.createElement("span",{style:{textTransform:"none"}}," (",a,"s)")),t&&e.createElement("span",{className:"ds-dial-plan-node__name"},t)),u=({id:o,label:a})=>e.createElement("div",{className:"ds-dial-plan-node__exit-row"},e.createElement("span",{className:"ds-dial-plan-node__exit-label"},a),e.createElement(n.Handle,{type:"source",position:n.Position.Right,id:o,className:"ds-dial-plan-handle ds-dial-plan-handle--next"})),p=({exits:n,locale:o})=>0===n.length?null:e.createElement(e.Fragment,null,n.map(n=>e.createElement(u,{key:n.id,id:n.id,label:n.localeExitKey&&(null==o?void 0:o.exits[n.localeExitKey])||n.label})));function f(e,n){const o=e,a=(null==o?void 0:o[n])||(null==o?void 0:o[`${n}_id`]);return"string"==typeof a?a:""}function g(e,n){return{[e]:n,[`${e}_id`]:n}}function b(e,n){return e.startsWith("user_")?n.targetTypes.user:e.startsWith("rg_")?n.targetTypes.ringGroup:e.startsWith("dp_")?n.targetTypes.dialPlan:e.startsWith("qu_")?n.targetTypes.queue:e.startsWith("va_")?n.targetTypes.voiceApp:e.startsWith("svm_")?n.targetTypes.sharedVoicemail:n.nodeTypes.internalDial}function m(e){var n;return null!==(n=null==e?void 0:e.startsWith("dp_"))&&void 0!==n&&n}function v(e,n,o){const a=n.users.get(e),t=(null==a?void 0:a.name)||(null==a?void 0:a.email);return t&&(null==a?void 0:a.extension_number)?`${t} (${o.combobox.extensionLabel} ${a.extension_number})`:t}const h=({resourceId:n,onOpenResource:o,label:a})=>e.createElement("button",{type:"button",className:"ds-dial-plan-config-field__open-link",onClick:()=>o(n)},e.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"15 3 21 3 21 9"}),e.createElement("polyline",{points:"9 21 3 21 3 15"}),e.createElement("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.createElement("line",{x1:"3",y1:"21",x2:"10",y2:"14"})),a),_=({groups:n,value:o,loading:a=!1,placeholder:l="Search…",onSelect:r,onCreateResource:d,selectLabel:s="— Select —",noResultsLabel:c="No results found",loadingLabel:u="Loading…",createNewPrefix:p="+ Create new…",extensionLabel:f="Ext."})=>{const[g,b]=e.useState(!1),[m,v]=e.useState(""),h=e.useRef(null);e.useEffect(()=>{var e;if(!g)return;const n=null===(e=h.current)||void 0===e?void 0:e.getRootNode(),o=n instanceof ShadowRoot||n instanceof Document?n:document,a=e=>function(e){"Escape"===e.key&&(b(!1),v(""))}(e),t=e=>function(e){h.current&&!h.current.contains(e.target)&&(b(!1),v(""))}(e);return o.addEventListener("keydown",a),o.addEventListener("mousedown",t),()=>{o.removeEventListener("keydown",a),o.removeEventListener("mousedown",t)}},[g]);const _=e.useMemo(()=>{if(!o)return"";for(const e of n){const n=e.items.find(e=>e.id===o);if(n)return n.extension_number?`${n.name} (${f} ${n.extension_number})`:n.name}return""},[o,n,f]);if(!g)return e.createElement("button",{type:"button",className:"ds-resource-combobox__trigger",onClick:()=>b(!0)},e.createElement("span",{className:_?"":"ds-resource-combobox__trigger-placeholder"},_||s),e.createElement("svg",{className:"ds-resource-combobox__trigger-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"6 9 12 15 18 9"})));const x=n.some(e=>e.items.length>0);return e.createElement("div",{ref:h},e.createElement(t.Command,{className:"ds-resource-combobox",shouldFilter:!0,loop:!0},e.createElement(t.Command.Input,{className:"ds-resource-combobox__input",placeholder:l,value:m,onValueChange:v,autoFocus:!0}),e.createElement(t.Command.List,{className:"ds-resource-combobox__list"},e.createElement(t.Command.Empty,{className:"ds-resource-combobox__empty"},c),n.map(n=>e.createElement(t.Command.Group,{key:n.label,heading:n.label,className:"ds-resource-combobox__group"},n.items.map(a=>{var l;return e.createElement(t.Command.Item,{key:a.id,value:`${a.name} ${null!==(l=a.extension_number)&&void 0!==l?l:""} ${n.label} ${a.id}`,className:"ds-resource-combobox__item"+(a.id===o?" ds-resource-combobox__item--selected":""),onSelect:()=>{return e=a.id,n=a.extension_number?`${a.name} (${f} ${a.extension_number})`:a.name,r(e,n),b(!1),void v("");var e,n}},e.createElement("span",{className:"ds-resource-combobox__name"},a.name),a.extension_number&&e.createElement("span",{className:"ds-resource-combobox__ext"},"(",f," ",a.extension_number,")"),e.createElement("span",{className:"ds-resource-combobox__check"},a.id===o?"✓":""))}),d&&n.type&&e.createElement(t.Command.Item,{forceMount:!0,value:`create new ${n.label}`,className:"ds-resource-combobox__create",onSelect:()=>function(e){return i(this,void 0,void 0,function*(){if(!d)return;const n=yield d(e);n&&(r(n.id,n.extension_number?`${n.name} (${f} ${n.extension_number})`:n.name),b(!1),v(""))})}(n.type)},p))),!x&&!m&&a&&e.createElement("div",{className:"ds-resource-combobox__empty"},u))))},x=({label:n,htmlFor:o,action:a,children:t})=>e.createElement("div",{className:"ds-dial-plan-config-field"},a?e.createElement("div",{className:"ds-dial-plan-config-field__header"},e.createElement("label",{className:"ds-dial-plan-config-field__label",htmlFor:o},n),a):e.createElement("label",{className:"ds-dial-plan-config-field__label",htmlFor:o},n),t);function y(n,o,a,t){const[l,r]=e.useState([]),[d,s]=e.useState(!0),c=e.useMemo(()=>JSON.stringify(n),[n]),u=e.useCallback(()=>Promise.all(n.map(e=>o(e.type,e.options))).then(e=>{r(n.map((n,o)=>{var a,l;return{label:null!==(a=null==t?void 0:t.resourceGroups[n.labelKey])&&void 0!==a?a:n.fallback,type:n.type,items:null!==(l=e[o])&&void 0!==l?l:[]}}))}).catch(()=>{}).finally(()=>s(!1)),[o,t,c]);e.useEffect(()=>{u()},[u]);const p=e.useCallback(e=>i(this,void 0,void 0,function*(){var o;if(!a)return;const t=null===(o=n.find(n=>n.type===e))||void 0===o?void 0:o.options,l=yield a(e,t);return l&&(yield u()),l}),[a,u,c]);return{groups:l,loading:d,handleCreateResource:a?p:void 0}}const w=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("polyline",{points:"12 6 12 12 16 14"})),k=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})),E=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),e.createElement("circle",{cx:"9",cy:"7",r:"4"}),e.createElement("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),e.createElement("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})),N=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"23 7 23 1 17 1"}),e.createElement("line",{x1:"16",y1:"8",x2:"23",y2:"1"}),e.createElement("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})),C=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("circle",{cx:"5.5",cy:"11.5",r:"4.5"}),e.createElement("circle",{cx:"18.5",cy:"11.5",r:"4.5"}),e.createElement("line",{x1:"5.5",y1:"16",x2:"18.5",y2:"16"})),O=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M12 8V4H8"}),e.createElement("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),e.createElement("path",{d:"M2 14h2"}),e.createElement("path",{d:"M20 14h2"}),e.createElement("path",{d:"M15 13v2"}),e.createElement("path",{d:"M9 13v2"})),L=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("rect",{x:"3",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"3",y:"14",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"14",width:"7",height:"7"})),S=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91"}),e.createElement("line",{x1:"23",y1:"1",x2:"1",y2:"23"})),R=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.createElement("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.createElement("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})),z={type:"schedule",flowType:"schedule",localeKey:"schedule",label:"Schedule",description:"Route calls by schedule",color:"#0ea5e9",exits:[{id:"open",label:"Open",configKey:"open",localeExitKey:"open"},{id:"closed",label:"Closed",configKey:"closed",localeExitKey:"closed"},{id:"holiday",label:"Holiday",configKey:"holiday",localeExitKey:"holiday"}],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,onOpenResource:l,locale:r})=>{var i,d,s,c,u;const{groups:p,loading:b,handleCreateResource:m}=y([{type:"schedule",labelKey:"schedules",fallback:"Schedules"}],a,t,r),v=f(n,"schedule"),w=void 0!==n.holiday;return e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(i=null==r?void 0:r.configLabels.schedule)&&void 0!==i?i:"Schedule"},e.createElement(_,{groups:p,value:v,loading:b,placeholder:null!==(d=null==r?void 0:r.configLabels.searchSchedules)&&void 0!==d?d:"Search schedules…",onSelect:(e,n)=>o(g("schedule",e),{scheduleName:n}),onCreateResource:m,selectLabel:null==r?void 0:r.combobox.select,noResultsLabel:null==r?void 0:r.combobox.noResults,loadingLabel:null==r?void 0:r.combobox.loading,createNewPrefix:null==r?void 0:r.combobox.createNew,extensionLabel:null==r?void 0:r.combobox.extensionLabel}),v&&l&&e.createElement(h,{resourceId:v,onOpenResource:l,label:null!==(s=null==r?void 0:r.configLabels.openInNewTab)&&void 0!==s?s:"Open target details"})),e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("label",{className:"ds-dial-plan-config-field__checkbox"},e.createElement("input",{type:"checkbox",checked:w,onChange:e=>{return n=e.target.checked,o({holiday:n?null:void 0},{holidayEnabled:n});var n}}),e.createElement("span",null,null!==(c=null==r?void 0:r.configLabels.routeHolidaySeparately)&&void 0!==c?c:"Route holidays separately")),e.createElement("p",{className:"ds-dial-plan-config-field__hint"},null!==(u=null==r?void 0:r.configLabels.routeHolidaySeparatelyHint)&&void 0!==u?u:"When on, holidays route to a dedicated branch you wire below. Otherwise holidays follow the Closed exit.")))},defaultConfig:{schedule:"",schedule_id:""},icon:w,renderNode:(n,o)=>{const a=n.locale,t=o.exits.slice(0,n.holidayEnabled?3:2);return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.scheduleName}),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:t,locale:a})))},toFlowNode:e=>{const n=e;return{label:"Schedule",scheduleId:f(n.config,"schedule"),holidayEnabled:void 0!==n.config.holiday,originalNode:n}},collectResourceIds:(e,n)=>{const o=f(e,"schedule");o&&n.addSchedule(o)},enrichNode:(e,n,o)=>{const a=n.schedules.get(e.scheduleId);return Object.assign(Object.assign({},e),{scheduleName:null==a?void 0:a.name,locale:o})},onConfigChange:(e,n,o)=>{"holiday"in n&&void 0===n.holiday&&(o.setEdges(n=>{const a=n.filter(n=>!(n.source===e&&"holiday"===n.sourceHandle));return a.length!==n.length&&o.updateDirty(o.nodesRef.current,a),a}),requestAnimationFrame(()=>o.updateNodeInternals(e)))},serializeConfig:(e,n,o)=>{var a;return(null===(a=e.data)||void 0===a?void 0:a.holidayEnabled)&&void 0===o.holiday?Object.assign(Object.assign({},o),{holiday:null}):o}},T=({value:n,min:o,max:a,disabled:t=!1,onChange:l,locale:r})=>{var i;return e.createElement(x,{label:null!==(i=null==r?void 0:r.configLabels.timeout)&&void 0!==i?i:"Timeout (seconds)"},e.createElement("input",{className:"ds-dial-plan-config-field__input",type:"number",min:o,max:a,value:n,disabled:t,onChange:e=>l(Math.min(a,Math.max(o,Number(e.target.value)||o)))}))},j={type:"ring_all_users",flowType:"ringAllUsers",localeKey:"ringAllUsers",label:"Ring All",description:"Ring all account users",color:"#f59e0b",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({config:n,onConfigChange:o,locale:a})=>{var t;const l=null!==(t=n.timeout)&&void 0!==t?t:24;return e.createElement(T,{value:l,min:1,max:300,onChange:e=>o({timeout:e}),locale:a})},defaultConfig:{timeout:24},icon:E,renderNode:(n,o)=>e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:n.timeout}),o.exits.length>0&&e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale}))),toFlowNode:e=>{const n=e;return{label:"Ring All",timeout:n.config.timeout,originalNode:n}}};function A({label:n,value:o,options:a,onChange:t,hint:l}){return e.createElement(x,{label:n},e.createElement("div",{className:"ds-dial-plan-config-field__segmented",role:"radiogroup","aria-label":n},a.map(n=>{const a=n.value===o;return e.createElement("button",{key:n.value,type:"button",role:"radio","aria-checked":a,className:"ds-dial-plan-config-field__segmented-option"+(a?" ds-dial-plan-config-field__segmented-option--active":""),onClick:()=>{a||t(n.value)}},n.label)})),l&&e.createElement("p",{className:"ds-dial-plan-config-field__hint"},l))}const I={type:"internal_dial",flowType:"internalDial",localeKey:"internalDial",label:"Internal Extension",description:"Ring a user, group, or plan",color:"#22c55e",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({nodeId:n,config:o,nodeData:a,onConfigChange:t,listResources:l,onCreateResource:r,onOpenResource:i,locale:d})=>{var s,c,u,p,b,v,w,k;const{groups:E,loading:N,handleCreateResource:C}=y([{type:"user",labelKey:"users",fallback:"Users"},{type:"ring_group",labelKey:"ringGroups",fallback:"Ring Groups"},{type:"queue",labelKey:"queues",fallback:"Queues"},{type:"dial_plan",labelKey:"dialPlans",fallback:"Dial Plans"}],l,r,d),O=f(o,"target"),L=null!==(s=o.timeout)&&void 0!==s?s:30,S=null!==(c=o.timeout_override)&&void 0!==c&&c,R=S?1:0,z=!0===(null==a?void 0:a.timeoutInert),j=e.useRef(null);return e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(u=null==d?void 0:d.configLabels.target)&&void 0!==u?u:"Target"},e.createElement(_,{groups:E,value:O,loading:N,placeholder:null!==(p=null==d?void 0:d.configLabels.searchTargets)&&void 0!==p?p:"Search targets…",onSelect:(e,n)=>t(g("target",e),{targetName:n}),onCreateResource:C,selectLabel:null==d?void 0:d.combobox.select,noResultsLabel:null==d?void 0:d.combobox.noResults,loadingLabel:null==d?void 0:d.combobox.loading,createNewPrefix:null==d?void 0:d.combobox.createNew,extensionLabel:null==d?void 0:d.combobox.extensionLabel}),O&&i&&e.createElement(h,{resourceId:O,onOpenResource:i,label:null!==(b=null==d?void 0:d.configLabels.openInNewTab)&&void 0!==b?b:"Open target details"})),!m(O)&&e.createElement(e.Fragment,null,e.createElement(A,{label:null!==(v=null==d?void 0:d.configLabels.timeoutOverride)&&void 0!==v?v:"Override resource timeout",value:S?"on":"off",options:[{value:"off",label:null!==(w=null==d?void 0:d.configLabels.timeoutOverrideOff)&&void 0!==w?w:"Off"},{value:"on",label:null!==(k=null==d?void 0:d.configLabels.timeoutOverrideOn)&&void 0!==k?k:"On"}],onChange:e=>{if("on"===e)return j.current=0===L?{nodeId:n,timeout:0}:null,void t(0===L?{timeout_override:!0,timeout:1}:{timeout_override:!0});const o=j.current,a=o&&o.nodeId===n?o.timeout:void 0;j.current=null,t(void 0===a?{timeout_override:!1}:{timeout_override:!1,timeout:a})}}),e.createElement(T,{value:L,min:R,max:300,disabled:z,onChange:e=>{j.current=null,t({timeout:e})},locale:d})))},defaultConfig:{target:"",target_id:"",timeout:30,timeout_override:!0},icon:k,renderNode:(n,o)=>{const a=m(n.targetId);return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:a||n.timeoutInert?void 0:n.timeout,subtitle:n.targetName}),!a&&e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale})))},toFlowNode:e=>{var n;const o=e;return{label:"Internal Extension",targetId:f(o.config,"target"),timeout:o.config.timeout,timeoutOverride:null!==(n=o.config.timeout_override)&&void 0!==n&&n,originalNode:o}},visibleExits:e=>m(f(e,"target"))?[]:I.exits,collectResourceIds:(e,n)=>{const o=f(e,"target");o&&n.addTarget(o)},enrichNode:(e,n,o)=>{const a=e.targetId,t=v(a,n,o),l=b(a,o),r=e.timeout,i=!e.timeoutOverride&&0!==r&&function(e,n){var o;return void 0!==(null===(o=n.users.get(e))||void 0===o?void 0:o.timeout_seconds)}(a,n),d=e.timeoutOverride?function(e,n,o){var a;if(0===n)return 0;const t=null===(a=o.users.get(e))||void 0===a?void 0:a.timeout_seconds;return void 0===n?t:e.startsWith("user_")&&void 0!==t?Math.min(n,t):n}(a,r,n):r;return Object.assign(Object.assign({},e),{targetName:t,targetType:l,timeout:d,timeoutInert:i,locale:o})}};function F(e){if(!e)return"";const n=l.parsePhoneNumberFromString(e);if(!n)return e;return"US"===n.country||"1"===n.countryCallingCode?n.formatNational():n.formatInternational()}const P=e=>e.startsWith("+")?"+"+e.slice(1).replace(/\D/g,""):e.replace(/\D/g,""),M={type:"external_dial",flowType:"externalDial",localeKey:"externalDial",label:"External Number",description:"Ring an external phone number",color:"#f43f5e",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({nodeId:n,config:o,onConfigChange:a,onInvalidDraftChange:t,locale:r})=>{var i,d,s,c,u;const p=null!==(i=o.phone_number)&&void 0!==i?i:"",f=null!==(d=o.timeout)&&void 0!==d?d:60,[g,b]=e.useState(F(p)),[m,v]=e.useState(null),h=e.useId(),_=`${h}-phone`,y=`${h}-error`,[w,k]=e.useState({nodeId:n,e164:p});w.nodeId===n&&w.e164===p||(k({nodeId:n,e164:p}),b(F(p)),v(null)),e.useEffect(()=>(null==t||t(null!==m),()=>null==t?void 0:t(!1)),[m,t]);const E=null!==(s=null==r?void 0:r.configLabels.phoneNumberInvalid)&&void 0!==s?s:"Enter a valid phone number, for example (415) 555-1234.",N=e.useCallback(e=>{const n=P(e.target.value);b(n?new l.AsYouType("US").input(n):""),v(null);const o=(e=>{const n=e?l.parsePhoneNumberFromString(e,"US"):null;return(null==n?void 0:n.isValid())?n.number:null})(n);o?a({phone_number:o}):n||a({phone_number:""})},[a]),C=e.useCallback(()=>{const e=P(g);if(!e)return v(null),void a({phone_number:""});const n=l.parsePhoneNumberFromString(e,"US");if(null==n?void 0:n.isValid()){const e="US"===n.country||"1"===n.countryCallingCode;return b(e?n.formatNational():n.formatInternational()),v(null),void a({phone_number:n.number})}v(E)},[g,E,a]),O=e.useCallback(()=>{b(""),v(null),a({phone_number:""})},[a]);return e.createElement(e.Fragment,null,e.createElement(T,{value:f,min:1,max:120,onChange:e=>a({timeout:e}),locale:r}),e.createElement(x,{label:null!==(c=null==r?void 0:r.configLabels.phoneNumber)&&void 0!==c?c:"Phone Number",htmlFor:_},e.createElement("div",{className:"ds-dial-plan-config-field__input-wrapper"},e.createElement("input",{id:_,className:"ds-dial-plan-config-field__input",type:"tel",placeholder:"+1 415 555 1234",value:g,onChange:N,onBlur:C,"aria-invalid":!!m||void 0,"aria-describedby":m?y:void 0}),g&&e.createElement("button",{type:"button",className:"ds-dial-plan-config-field__clear",onClick:O,"aria-label":null!==(u=null==r?void 0:r.configLabels.clearPhoneNumber)&&void 0!==u?u:"Clear phone number"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5l7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})))),m&&e.createElement("p",{className:"ds-dial-plan-config-field__error",id:y,role:"alert"},m)))},defaultConfig:{phone_number:"",timeout:60},icon:N,renderNode:(n,o)=>e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:n.timeout,subtitle:n.phoneNumber}),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale}))),toFlowNode:e=>{const n=e;return{label:"External Number",phoneNumber:F(n.config.phone_number),timeout:n.config.timeout,originalNode:n}}},D={type:"voice_app",flowType:"voiceApp",localeKey:"voiceApp",label:"Voice App",description:"Route to a voice application",color:"#6366f1",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,onOpenResource:l,locale:r})=>{var i,d,s,c,u,p,b,m,v;const w=f(n,"voice_app"),k=null!==(i=n.mode)&&void 0!==i?i:"control",{groups:E,handleCreateResource:N}=y([{type:"voice_app",labelKey:"voiceApps",fallback:"Voice Apps",options:{notifyEligible:"notify"===k}}],a,t,r);return e.useEffect(()=>{var e,n;if("notify"!==k||!w)return;const a=null!==(n=null===(e=E[0])||void 0===e?void 0:e.items)&&void 0!==n?n:[];if(0===a.length)return;a.some(e=>e.id===w)||o(g("voice_app",""),{voiceAppName:void 0})},[k,w,E,o]),e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(d=null==r?void 0:r.configLabels.target)&&void 0!==d?d:"Target"},e.createElement(_,{groups:E,value:w,placeholder:null!==(s=null==r?void 0:r.configLabels.searchTargets)&&void 0!==s?s:"Search targets…",onSelect:(e,n)=>o(g("voice_app",e),{voiceAppName:n}),onCreateResource:N,selectLabel:null==r?void 0:r.combobox.select,noResultsLabel:null==r?void 0:r.combobox.noResults,loadingLabel:null==r?void 0:r.combobox.loading,createNewPrefix:null==r?void 0:r.combobox.createNew,extensionLabel:null==r?void 0:r.combobox.extensionLabel}),w&&l&&e.createElement(h,{resourceId:w,onOpenResource:l,label:null!==(c=null==r?void 0:r.configLabels.openInNewTab)&&void 0!==c?c:"Open target details"})),e.createElement(A,{label:null!==(u=null==r?void 0:r.configLabels.mode)&&void 0!==u?u:"Mode",value:k,options:[{value:"control",label:null!==(p=null==r?void 0:r.voiceAppMode.control)&&void 0!==p?p:"Control"},{value:"notify",label:null!==(b=null==r?void 0:r.voiceAppMode.notify)&&void 0!==b?b:"Notify"}],onChange:e=>o({mode:e}),hint:"notify"===k?null!==(m=null==r?void 0:r.voiceAppMode.notifyHint)&&void 0!==m?m:"Notifies the voice app of the call in the background. The dial plan keeps routing via Next without waiting.":null!==(v=null==r?void 0:r.voiceAppMode.controlHint)&&void 0!==v?v:"Hands the call off to the voice app, which takes over the conversation."}))},defaultConfig:{voice_app:"",voice_app_id:"",mode:"control"},icon:O,renderNode:(n,o)=>{var a,t,l,r;const i=n.locale,d="notify"===n.mode,s=d?null!==(a=null==i?void 0:i.voiceAppMode.notifyBadge)&&void 0!==a?a:"Notify mode":null!==(t=null==i?void 0:i.voiceAppMode.controlBadge)&&void 0!==t?t:"Control mode",p=d?null!==(l=null==i?void 0:i.exits.next)&&void 0!==l?l:"Next":null!==(r=null==i?void 0:i.exits.timeout)&&void 0!==r?r:"Timeout";return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.voiceAppName}),e.createElement("span",{className:"ds-dial-plan-node__badge"},s),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(u,{id:"next",label:p})))},toFlowNode:e=>{var n;const o=e;return{label:"Voice App",voiceAppId:f(o.config,"voice_app"),mode:null!==(n=o.config.mode)&&void 0!==n?n:"control",originalNode:o}},normalizeFromAlias:e=>{const n=e.config,o=f(n,"target"),a=n.next;return Object.assign(Object.assign({},e),{type:"voice_app",config:Object.assign(Object.assign(Object.assign({},g("voice_app",o)),{mode:"control"}),void 0!==a?{next:a}:{})})},collectResourceIds:(e,n)=>{const o=f(e,"voice_app");o&&n.addTarget(o)},enrichNode:(e,n,o)=>{const a=e.voiceAppId,t=a?v(a,n,o):void 0;return Object.assign(Object.assign({},e),{voiceAppName:t,locale:o})}},H={type:"voicemail",apiType:"internal_dial",flowType:"voicemail",localeKey:"voicemail",label:"Voicemail",description:"Send to voicemail",color:"#8b5cf6",exits:[],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,onOpenResource:l,locale:r})=>{var i,d,s;const{groups:c,loading:u,handleCreateResource:p}=y([{type:"user",labelKey:"users",fallback:"Users"},{type:"shared_voicemail",labelKey:"sharedVoicemails",fallback:"Shared Voicemails"}],a,t,r),b=f(n,"target");return e.createElement(x,{label:null!==(i=null==r?void 0:r.configLabels.target)&&void 0!==i?i:"Target"},e.createElement(_,{groups:c,value:b,loading:u,placeholder:null!==(d=null==r?void 0:r.configLabels.searchTargets)&&void 0!==d?d:"Search targets…",onSelect:(e,n)=>o(Object.assign(Object.assign({},g("target",e)),{timeout:0}),{targetName:n}),onCreateResource:p,selectLabel:null==r?void 0:r.combobox.select,noResultsLabel:null==r?void 0:r.combobox.noResults,loadingLabel:null==r?void 0:r.combobox.loading,createNewPrefix:null==r?void 0:r.combobox.createNew,extensionLabel:null==r?void 0:r.combobox.extensionLabel}),b&&l&&e.createElement(h,{resourceId:b,onOpenResource:l,label:null!==(s=null==r?void 0:r.configLabels.openInNewTab)&&void 0!==s?s:"Open target details"}))},defaultConfig:{target:"",target_id:"",timeout:0},icon:C,renderNode:(n,o)=>e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.targetName}),toFlowNode:e=>{const n=e;return{label:"Voicemail",targetId:f(n.config,"target"),timeout:0,originalNode:n}},collectResourceIds:(e,n)=>{const o=f(e,"target");o&&n.addTarget(o)},enrichNode:(e,n,o)=>{const a=e.targetId,t=v(a,n,o),l=b(a,o);return Object.assign(Object.assign({},e),{targetName:t,targetType:l,locale:o})}},$=["1","2","3","4","5","6","7","8","9","0","*","#"];function B(e){return"*"===e?"digit_star":"#"===e?"digit_hash":`digit_${e}`}const K=[{id:"timeout",label:"Timeout",configKey:"timeout_next_node",localeExitKey:"timeout"},{id:"invalid",label:"Invalid",configKey:"invalid_next_node",localeExitKey:"invalid"}],V={type:"menu",flowType:"menu",localeKey:"menu",label:"IVR Menu",description:"Play prompt and route by keypress",color:"#ec4899",exits:[...K],allowSelfLoop:!0,configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,locale:l})=>{var r,i,d,s,c,u,p,b,m;const{groups:v,loading:h,handleCreateResource:w}=y([{type:"audio_clip",labelKey:"audioClips",fallback:"Audio Clips"}],a,t,l),k=f(n,"prompt_clip"),E=null!==(r=n.timeout)&&void 0!==r?r:5,N=null!==(i=n.options)&&void 0!==i?i:[{digit:"1"}],C=null!==(d=n.extension_entry_enabled)&&void 0!==d&&d,O=new Set(N.map(e=>e.digit));return e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(s=null==l?void 0:l.configLabels.promptClip)&&void 0!==s?s:"Prompt"},e.createElement(_,{groups:v,value:k,loading:h,placeholder:null!==(c=null==l?void 0:l.configLabels.search)&&void 0!==c?c:"Search...",onSelect:(e,n)=>o(g("prompt_clip",e),{promptClipName:n}),onCreateResource:w,selectLabel:null==l?void 0:l.combobox.select,noResultsLabel:null==l?void 0:l.combobox.noResults,loadingLabel:null==l?void 0:l.combobox.loading,createNewPrefix:null==l?void 0:l.combobox.createNew})),e.createElement(T,{value:E,min:1,max:30,onChange:e=>o({timeout:e}),locale:l}),e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("label",{className:"ds-dial-plan-config-field__checkbox"},e.createElement("input",{type:"checkbox",checked:C,onChange:e=>o({extension_entry_enabled:e.target.checked})}),e.createElement("span",null,null!==(u=null==l?void 0:l.configLabels.extensionEntry)&&void 0!==u?u:"Allow extension dialing")),e.createElement("p",{className:"ds-dial-plan-config-field__hint"},null!==(p=null==l?void 0:l.configLabels.extensionEntryHint)&&void 0!==p?p:"When on, callers can key an extension instead of choosing an option.")),e.createElement(x,{label:null!==(b=null==l?void 0:l.configLabels.options)&&void 0!==b?b:"Options",action:e.createElement("button",{type:"button",className:"ds-dial-plan-menu-options__add",onClick:function(){const e=$.find(e=>!O.has(e));e&&o({options:[...N,{digit:e}]})},disabled:N.length>=12},"+ ",null!==(m=null==l?void 0:l.configLabels.addOption)&&void 0!==m?m:"Add")},e.createElement("div",{className:"ds-dial-plan-menu-options"},N.map((n,a)=>{var t,r,i,d,s,c;return e.createElement("div",{key:a,className:"ds-dial-plan-menu-options__card"},e.createElement("div",{className:"ds-dial-plan-menu-options__field ds-dial-plan-menu-options__field--label"},e.createElement("span",{className:"ds-dial-plan-menu-options__field-label"},null!==(t=null==l?void 0:l.configLabels.optionLabel)&&void 0!==t?t:"Label"," ",e.createElement("span",{className:"ds-dial-plan-menu-options__field-hint"},"(optional)")),e.createElement("input",{type:"text",className:"ds-dial-plan-config-field__input",value:null!==(r=n.label)&&void 0!==r?r:"",maxLength:20,placeholder:null!==(i=null==l?void 0:l.configLabels.optionLabelPlaceholder)&&void 0!==i?i:"e.g. Sales",onChange:e=>{return n=a,t=e.target.value,void o({options:N.map((e,o)=>{if(o!==n)return e;const a=Object.assign({},e);return t?a.label=t:delete a.label,a})});var n,t}})),e.createElement("div",{className:"ds-dial-plan-menu-options__field ds-dial-plan-menu-options__field--digit"},e.createElement("span",{className:"ds-dial-plan-menu-options__field-label"},null!==(d=null==l?void 0:l.configLabels.digit)&&void 0!==d?d:"Digit"),e.createElement("select",{className:"ds-dial-plan-config-field__input",value:n.digit,onChange:e=>{return n=a,t=e.target.value,void o({options:N.map((e,o)=>o===n?Object.assign(Object.assign({},e),{digit:t}):e)});var n,t}},$.filter(e=>e===n.digit||!O.has(e)).map(n=>e.createElement("option",{key:n,value:n},"*"===n?"✱":n)))),e.createElement("button",{type:"button",className:"ds-dial-plan-menu-options__remove",onClick:()=>{return e=a,void o({options:N.filter((n,o)=>o!==e)});var e},title:null!==(s=null==l?void 0:l.configLabels.removeOption)&&void 0!==s?s:"Remove","aria-label":null!==(c=null==l?void 0:l.configLabels.removeOption)&&void 0!==c?c:"Remove"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))))}))))},defaultConfig:{prompt_clip:"",prompt_clip_id:"",timeout:5,options:[{digit:"1"}],extension_entry_enabled:!1},icon:L,renderNode:(n,o)=>{var a;const t=null!==(a=n.options)&&void 0!==a?a:[],l=n.locale;return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:n.timeout,subtitle:n.promptClipName}),e.createElement("div",{className:"ds-dial-plan-node__exits"},t.map(n=>{const o="*"===n.digit?"✱":n.digit,a=n.label?`${n.label} — ${o}`:o;return e.createElement(u,{key:n.digit,id:B(n.digit),label:a})}),e.createElement(p,{exits:o.exits,locale:l})))},toFlowNode:e=>{const n=e;return{label:"IVR Menu",promptClipId:f(n.config,"prompt_clip"),timeout:n.config.timeout,options:n.config.options,originalNode:n}},createEdgesForNode:(e,n)=>{const o=e,a=[];o.config.timeout_next_node&&n.has(o.config.timeout_next_node)&&a.push({id:`${o.id}-timeout->${o.config.timeout_next_node}`,source:o.id,target:o.config.timeout_next_node,sourceHandle:"timeout",type:d}),o.config.invalid_next_node&&n.has(o.config.invalid_next_node)&&a.push({id:`${o.id}-invalid->${o.config.invalid_next_node}`,source:o.id,target:o.config.invalid_next_node,sourceHandle:"invalid",type:d});for(const e of o.config.options)if(e.next_node&&n.has(e.next_node)){const n=B(e.digit);a.push({id:`${o.id}-${n}->${e.next_node}`,source:o.id,target:e.next_node,sourceHandle:n,type:d})}return a},collectResourceIds:(e,n)=>{const o=f(e,"prompt_clip");o&&n.addAudioClip(o)},enrichNode:(e,n,o)=>{const a=n.audioClips.get(e.promptClipId);return Object.assign(Object.assign({},e),{promptClipName:null==a?void 0:a.name,locale:o})},resolveExitLabel:e=>{const n=function(e){if("digit_star"===e)return"*";if("digit_hash"===e)return"#";const n=e.match(/^digit_(\d)$/);return null==n?void 0:n[1]}(e);if(n)return"*"===n?"✱":n},onConfigChange:(e,n,o)=>{var a,t;if(!n.options)return;const l=n.options,r=new Set(l.map(e=>B(e.digit)));for(const e of K)r.add(e.id);const i=o.nodesRef.current.find(n=>n.id===e),d=null!==(t=null===(a=null==i?void 0:i.data)||void 0===a?void 0:a.options)&&void 0!==t?t:[],s=new Map;if(d.length===l.length)for(let e=0;e<l.length;e++){const n=B(d[e].digit),o=B(l[e].digit);n!==o&&s.set(n,o)}o.setEdges(n=>{const a=n.map(n=>{if(n.source!==e||!n.sourceHandle)return n;const o=s.get(n.sourceHandle);return o?Object.assign(Object.assign({},n),{sourceHandle:o,id:`${e}-${o}->${n.target}`}):n}).filter(n=>n.source!==e||!n.sourceHandle||r.has(n.sourceHandle));return(a.length!==n.length||s.size>0)&&o.updateDirty(o.nodesRef.current,a),a}),requestAnimationFrame(()=>o.updateNodeInternals(e))},serializeConfig:(e,n,o)=>{var a;const t=(null!==(a=o.options)&&void 0!==a?a:[]).map(o=>{const a=B(o.digit),t=n.find(n=>n.source===e.id&&n.sourceHandle===a),l={digit:o.digit};return o.label&&(l.label=o.label),t&&(l.next_node=t.target),l});return Object.assign(Object.assign({},o),{options:t})}},U={type:"audio_clip",flowType:"audioClip",localeKey:"audioClip",label:"Audio Clip",description:"Play an audio clip",color:"#14b8a6",exits:[{id:"next",label:"Next",configKey:"next",localeExitKey:"next"}],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,locale:l})=>{var r,i;const{groups:d,loading:s,handleCreateResource:c}=y([{type:"audio_clip",labelKey:"audioClips",fallback:"Audio Clips"}],a,t,l),u=f(n,"clip");return e.createElement(x,{label:null!==(r=null==l?void 0:l.configLabels.audioClip)&&void 0!==r?r:"Audio Clip"},e.createElement(_,{groups:d,value:u,loading:s,placeholder:null!==(i=null==l?void 0:l.configLabels.search)&&void 0!==i?i:"Search...",onSelect:(e,n)=>o(g("clip",e),{clipName:n}),onCreateResource:c,selectLabel:null==l?void 0:l.combobox.select,noResultsLabel:null==l?void 0:l.combobox.noResults,loadingLabel:null==l?void 0:l.combobox.loading,createNewPrefix:null==l?void 0:l.combobox.createNew}))},defaultConfig:{clip:"",clip_id:""},icon:R,renderNode:(n,o)=>e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.clipName}),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale}))),toFlowNode:e=>{const n=e;return{label:"Audio Clip",clipId:f(n.config,"clip"),originalNode:n}},normalizeFromAlias:e=>Object.assign(Object.assign({},e),{type:"audio_clip"}),collectResourceIds:(e,n)=>{const o=f(e,"clip");o&&n.addAudioClip(o)},enrichNode:(e,n,o)=>{const a=n.audioClips.get(e.clipId);return Object.assign(Object.assign({},e),{clipName:null==a?void 0:a.name,locale:o})}},W={type:"hang_up",flowType:"hangUp",localeKey:"hangUp",label:"Hang Up",description:"End the call",color:"#ef4444",exits:[],configPanel:({locale:n})=>{var o;return e.createElement("div",{className:"ds-dial-plan-config-panel__note"},null!==(o=null==n?void 0:n.nodeDescriptions.hangUp)&&void 0!==o?o:"End the call")},defaultConfig:{},icon:S,renderNode:(n,o)=>e.createElement(c,{icon:o.icon,label:n.label}),toFlowNode:e=>({label:"Hang Up",originalNode:e}),enrichNode:(e,n,o)=>Object.assign(Object.assign({},e),{label:o.nodeTypes.hangUp,locale:o})},q=new class{constructor(){this.byType=new Map,this.byFlowType=new Map,this.legacyTypeAliases=new Map}register(e){this.byType.set(e.type,e),this.byFlowType.set(e.flowType,e)}registerAlias(e,n){this.legacyTypeAliases.set(e,n)}get(e){return this.byType.get(e)}resolveType(e){var n;let o=this.byType.get(e.type);if(!o){const n=this.legacyTypeAliases.get(e.type);n&&(o=this.byType.get(n))}return(null==o?void 0:o.resolveAlias)&&null!==(n=o.resolveAlias(e))&&void 0!==n?n:o}getByFlowType(e){return this.byFlowType.get(e)}getAll(){return Array.from(this.byType.values())}getNodeTypesMap(){const e={};for(const n of this.byType.values())e[n.flowType]=n.component;return e}createEdgesForNode(e,n){const o=this.resolveType(e);if(!o)return[];if(o.createEdgesForNode)return o.createEdgesForNode(e,n);const a=e.config,t=[];for(const l of s(o,a)){const o=a[l.configKey];o&&n.has(o)&&t.push({id:`${e.id}-${l.id}->${o}`,source:e.id,target:o,sourceHandle:l.id,type:d})}return t}},G=(Y=q,e.memo(function({data:o,selected:a,type:t}){const l=Y.getByFlowType(null!=t?t:"");if(!l)return null;const r=l.renderNode(o,l),i=l.type.replace(/_/g,"-");return e.createElement("div",{className:`ds-dial-plan-node ds-dial-plan-node--themed ds-dial-plan-node--${i} ${a?"ds-dial-plan-node--selected":""}`,style:{"--node-color":l.color}},e.createElement(n.Handle,{type:"target",position:n.Position.Left,className:"ds-dial-plan-handle"}),r)}));var Y;const X=[z,j,I,M,D,H,V,U,W];for(const e of X)q.register(Object.assign(Object.assign({},e),{component:G}));const Z=q.get("internal_dial");Z&&(Z.resolveAlias=e=>{const n=e.config,o=f(n,"target");return o.startsWith("svm_")||0===n.timeout&&!n.next&&!m(o)?q.get("voicemail"):o.startsWith("va_")?q.get("voice_app"):void 0}),q.registerAlias("sound_clip","audio_clip");const Q="__start__";function J(e,n=q){var o;const a=[],t=[],l=new Map;for(const n of e.nodes)l.set(n.id,n);const r={id:Q,type:"start",position:{x:0,y:0},data:{label:"Start"}};a.push(r),e.entry_node&&l.has(e.entry_node)&&t.push({id:`${Q}->${e.entry_node}`,source:Q,target:e.entry_node,type:d});for(const r of e.nodes){const e=n.resolveType(r),i=null!==(o=r.position)&&void 0!==o?o:{x:0,y:0},d=e&&e.type!==r.type&&e.normalizeFromAlias?e.normalizeFromAlias(r):r;if(e){const n=e.toFlowNode(d),o={id:r.id,type:e.flowType,position:i,data:n};a.push(o)}else a.push({id:r.id,type:"default",position:i,data:{label:r.id,originalNode:r}});const s=n.createEdgesForNode(d,l);t.push(...s)}return e.nodes.some(e=>!e.position)?oe(a,t):{nodes:a,edges:t}}function ee(e,n,o){var a,t,l,r;const i=n.find(e=>e.source===Q),d=null!==(a=null==i?void 0:i.target)&&void 0!==a?a:"",c=[];for(const a of e){if(a.id===Q)continue;const e=o.getByFlowType(null!==(t=a.type)&&void 0!==t?t:"");if(!e||!(null===(l=a.data)||void 0===l?void 0:l.originalNode))continue;const i=a.data.originalNode,d=Object.assign({},i.config);for(const n of e.exits)d[n.configKey]=void 0;const u=s(e,d);for(const e of n){if(e.source!==a.id)continue;const n=u.find(n=>n.id===e.sourceHandle);n&&(d[n.configKey]=e.target)}const p=e.serializeConfig?e.serializeConfig(a,n,d):d;c.push({id:a.id,type:null!==(r=e.apiType)&&void 0!==r?r:i.type,position:a.position,config:p})}return{entry_node:d,nodes:c}}function ne(e){var n,o,a;if((null===(n=e.measured)||void 0===n?void 0:n.width)&&(null===(o=e.measured)||void 0===o?void 0:o.height))return{width:e.measured.width,height:e.measured.height};if("start"===e.type)return{width:60,height:60};if("schedule"===e.type)return{width:180,height:140};if("menu"===e.type){const n=e.data.options;return{width:180,height:60+28*((null!==(a=null==n?void 0:n.length)&&void 0!==a?a:1)+2)}}return{width:180,height:80}}function oe(e,n){var o;const t=new a.graphlib.Graph;t.setGraph({rankdir:"LR",nodesep:60,ranksep:80,marginx:40,marginy:40}),t.setDefaultEdgeLabel(()=>({}));for(const n of e){const{width:e,height:o}=ne(n);t.setNode(n.id,{width:e,height:o})}for(const e of n)t.setEdge(e.source,e.target);a.layout(t);const l=new Map;for(const n of e){const e=t.node(n.id),{width:o,height:a}=ne(n);l.set(n.id,{x:Math.round(e.x-o/2),y:Math.round(e.y-a/2)})}const r=new Map;for(const e of n){const n=r.get(e.source);n?n.push(e.target):r.set(e.source,[e.target])}const i=e=>{var n;const o=new Set([e]),a=[e];for(;a.length>0;){const e=a.shift();for(const t of null!==(n=r.get(e))&&void 0!==n?n:[])o.has(t)||(o.add(t),a.push(t))}return o};for(const a of e){const e=q.getByFlowType(null!==(o=a.type)&&void 0!==o?o:"");if(!e||e.exits.length<2)continue;const t=[];for(const o of e.exits){const e=n.find(e=>e.source===a.id&&e.sourceHandle===o.id);e&&t.push(e.target)}if(t.length<2)continue;const r=t[0],d=t[1],s=l.get(r),c=l.get(d);if(!s||!c)continue;if(s.y<=c.y)continue;const u=i(r),p=i(d);if([...u].some(e=>p.has(e)))continue;const f=s.y-c.y;for(const e of u){const n=l.get(e);n&&(n.y-=f)}for(const e of p){const n=l.get(e);n&&(n.y+=f)}}const d=e.find(e=>e.id===Q),s=l.get(Q),c=d&&s?d.position.x-s.x:0,u=d&&s?d.position.y-s.y:0;return{nodes:e.map(e=>{const n=l.get(e.id);return Object.assign(Object.assign({},e),{position:{x:n.x+c,y:n.y+u}})}),edges:n}}function ae(e,n,o,a){const t=q.getByFlowType(e),l=t?X.find(e=>{var n;return e.type===(null!==(n=t.apiType)&&void 0!==n?n:t.type)}):null;return(null==l?void 0:l.enrichNode)?l.enrichNode(n,o,a):n}const te=e.memo(function({data:o}){return e.createElement("div",{className:"ds-dial-plan-node ds-dial-plan-node--start"},e.createElement("div",{className:"ds-dial-plan-node__content"},e.createElement("span",{className:"ds-dial-plan-node__label"},o.label)),e.createElement(n.Handle,{type:"source",position:n.Position.Right,className:"ds-dial-plan-handle"}))}),le=({registry:n,onAddNode:o,locale:a})=>{const t=n.getAll();return e.createElement("div",{className:"ds-dial-plan-node-library"},t.map(n=>{var t,l;const r=null!==(t=null==a?void 0:a.nodeTypes[n.localeKey])&&void 0!==t?t:n.label,i=null!==(l=null==a?void 0:a.nodeDescriptions[n.localeKey])&&void 0!==l?l:n.description;return e.createElement("div",{key:n.type,className:`ds-dial-plan-node-library__item ds-dial-plan-node-library__item--${n.type}`,style:{"--node-color":n.color},draggable:!0,onClick:()=>o(n.type),onDragStart:e=>{const o=e.currentTarget.getBoundingClientRect(),a=(e.clientX-o.left)/o.width,t=(e.clientY-o.top)/o.height;e.dataTransfer.setData("application/reactflow",n.type),e.dataTransfer.setData("application/reactflow-grab-frac",`${a},${t}`),e.dataTransfer.effectAllowed="move"},title:i},e.createElement("span",{className:"ds-dial-plan-node-library__item-icon"},n.icon),e.createElement("span",{className:"ds-dial-plan-node-library__item-label"},r))}))},re=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"3 6 5 6 21 6"}),e.createElement("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})),ie=({node:n,registration:o,onConfigChange:a,onInvalidDraftChange:t,onDelete:l,onClose:r,listResources:i,onCreateResource:d,onOpenResource:s,locale:c})=>{var u,p,f;const g=e.useRef(null);e.useEffect(()=>{var e;const n=null===(e=g.current)||void 0===e?void 0:e.getRootNode(),o=n instanceof ShadowRoot||n instanceof Document?n:document,a=e=>function(e){"Escape"===e.key&&r()}(e);return o.addEventListener("keydown",a),()=>o.removeEventListener("keydown",a)},[r]);const b=n.data.originalNode,m=null!==(u=null==b?void 0:b.config)&&void 0!==u?u:{},v=o.configPanel;return e.createElement("div",{ref:g,className:"ds-dial-plan-config-panel"},e.createElement("div",{className:"ds-dial-plan-config-panel__header"},e.createElement("span",{className:"ds-dial-plan-config-panel__header-icon"},o.icon),e.createElement("span",{className:"ds-dial-plan-config-panel__header-label"},o.label),e.createElement("button",{type:"button",className:"ds-dial-plan-config-panel__delete",onClick:()=>{l(n.id),r()},title:null!==(p=null==c?void 0:c.panel.delete_)&&void 0!==p?p:"Delete"},re),e.createElement("button",{className:"ds-dial-plan-config-panel__close",onClick:r,title:null!==(f=null==c?void 0:c.panel.close)&&void 0!==f?f:"Close",type:"button"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e.createElement("div",{className:"ds-dial-plan-config-panel__body"},e.createElement(v,{nodeId:n.id,onInvalidDraftChange:t,config:m,nodeData:n.data,onConfigChange:(e,o)=>a(n.id,e,o),listResources:i,onCreateResource:d,onOpenResource:s,locale:c})))},de=e.memo(function({onAutoLayout:n,onSave:o,isDirty:a,hasInvalidDraft:t,locale:l}){var r;const i=null!==(r=null==l?void 0:l.toolbar)&&void 0!==r?r:{autoLayout:"Auto Layout",save:"Save"};return e.createElement("div",{className:"ds-dial-plan-editor-toolbar"},e.createElement("button",{className:"ds-dial-plan-editor-toolbar__button",onClick:n,title:i.autoLayout,type:"button"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},e.createElement("rect",{x:"3",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"14",width:"7",height:"7"}),e.createElement("line",{x1:"6.5",y1:"10",x2:"6.5",y2:"17"}),e.createElement("line",{x1:"6.5",y1:"17",x2:"14",y2:"17.5"})),e.createElement("span",null,i.autoLayout)),o&&e.createElement("button",{className:"ds-dial-plan-editor-toolbar__button",onClick:o,title:i.save,type:"button",disabled:!a||t},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},e.createElement("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),e.createElement("polyline",{points:"17 21 17 13 7 13 7 21"}),e.createElement("polyline",{points:"7 3 7 8 15 8"})),e.createElement("span",null,i.save)))});var se;const ce=!("undefined"==typeof window||void 0===window.document||"function"!=typeof HTMLElement.prototype.attachShadow||"undefined"==typeof navigator||/jsdom/i.test(null!==(se=navigator.userAgent)&&void 0!==se?se:"")||"undefined"!=typeof window&&"__STORYBOOK_PREVIEW__"in window),ue=({children:n,stylesheets:o,className:a,style:t})=>{const[l,i]=e.useState(null),d=e.useRef(null),s=e.useCallback(e=>{var n;if(d.current=e,!ce||!e)return;const o=null!==(n=e.shadowRoot)&&void 0!==n?n:e.attachShadow({mode:"open"});i(o)},[]);e.useEffect(()=>{ce&&d.current&&function(e,n){const o=e.shadowRoot;o&&(o.adoptedStyleSheets=n.map(e=>{const n=new CSSStyleSheet;return n.replaceSync(e),n}))}(d.current,o)},[o]);const c=e.useRef(null);return e.useEffect(()=>{if(!ce&&0!==o.length)return c.current||(c.current=document.createElement("style"),document.head.appendChild(c.current)),c.current.textContent=o.join("\n"),()=>{c.current&&(c.current.remove(),c.current=null)}},[o]),ce?e.createElement("div",{ref:s,className:a,style:t},l&&r.createPortal(n,l)):e.createElement("div",{className:a,style:t},n)},pe={nodeTypes:{start:"Start",schedule:"Schedule",internalDial:"Internal Extension",voicemail:"Voicemail",externalDial:"External Number",ringAllUsers:"Ring All Users",voiceApp:"Voice App",menu:"IVR Menu",audioClip:"Audio Clip",hangUp:"Hang Up"},exits:{open:"Open",closed:"Closed",holiday:"Holiday",next:"Next",timeout:"Timeout",invalid:"Invalid"},nodeDescriptions:{schedule:"Route calls by schedule",internalDial:"Ring a user, group, or plan",voicemail:"Send to voicemail",ringAllUsers:"Ring all users",externalDial:"Ring an external phone number",voiceApp:"Route to a voice application",menu:"Play prompt and route by keypress",audioClip:"Play an audio clip",hangUp:"End the call"},targetTypes:{user:"User",ringGroup:"Ring Group",dialPlan:"Dial Plan",queue:"Queue",voiceApp:"Voice App",sharedVoicemail:"Shared Voicemail"},resourceGroups:{users:"Users",ringGroups:"Ring Groups",dialPlans:"Dial Plans",queues:"Queues",voiceApps:"Voice Apps",sharedVoicemails:"Shared Voicemails",schedules:"Schedules",audioClips:"Audio Clips"},configLabels:{timeout:"Timeout (seconds)",target:"Target",schedule:"Schedule",search:"Search...",searchTargets:"Search targets...",searchSchedules:"Search schedules...",openInNewTab:"Open target details",promptClip:"Prompt",audioClip:"Audio Clip",digit:"Digit",options:"Options",addOption:"Add Option",removeOption:"Remove",optionLabel:"Label",optionLabelPlaceholder:"e.g. Sales",routeHolidaySeparately:"Route holidays separately",routeHolidaySeparatelyHint:"When on, holidays route to a dedicated branch you wire below. Otherwise holidays follow the Closed exit.",mode:"Mode",phoneNumber:"Phone Number",phoneNumberInvalid:"Enter a valid phone number, for example (415) 555-1234.",clearPhoneNumber:"Clear phone number",timeoutOverride:"Override resource timeout",timeoutOverrideOn:"On",timeoutOverrideOff:"Off",extensionEntry:"Allow extension dialing",extensionEntryHint:"When on, callers can key an extension instead of choosing an option."},voiceAppMode:{control:"Control",notify:"Notify",controlBadge:"Control mode",notifyBadge:"Notify mode",controlHint:"Hands the call off to the voice app, which takes over the conversation.",notifyHint:"Notifies the voice app of the call in the background. The dial plan keeps routing via Next without waiting."},toolbar:{autoLayout:"Auto Layout",save:"Save"},panel:{delete_:"Delete",close:"Close",connection:"Connection",from:"From",exit:"Exit",to:"To"},combobox:{select:"— Select —",search:"Search...",noResults:"No results found",loading:"Loading...",createNew:"+ Create new...",extensionLabel:"Ext.",noName:"(No name)"},status:{loading:"Loading dial plan...",loadError:"Failed to load dial plan",notFound:"No dial plan found",saveError:"Failed to save dial plan",newDialPlan:"New Dial Plan"}},fe={schedule:"A schedule must be selected in the Schedule node",schedule_id:"A schedule must be selected in the Schedule node",target:"A target must be selected in the Internal Extension node",target_id:"A target must be selected in the Internal Extension node",prompt_clip:"A prompt must be selected in the IVR Menu node",prompt_clip_id:"A prompt must be selected in the IVR Menu node",clip:"An audio clip must be selected in the Audio Clip node",clip_id:"An audio clip must be selected in the Audio Clip node",voice_app:"A voice app must be selected in the Voice App node",voice_app_id:"A voice app must be selected in the Voice App node",phone_number:"Enter a valid US phone number in the External Number node"},ge={schedule:"Schedule",internal_dial:"Internal Extension",ring_all_users:"Ring All",external_dial:"External Number"};const be={view:{editable:!1,interactive:!0,showChrome:!0},edit:{editable:!0,interactive:!0,showChrome:!0},preview:{editable:!1,interactive:!1,showChrome:!1}},me={id:"",name:"New Dial Plan",entry_node:"",nodes:[],created_at:"",updated_at:""},ve=Object.assign({start:te},q.getNodeTypesMap()),he={[d]:o=>{const{sourceX:a,sourceY:t,targetX:l,targetY:r,sourcePosition:i,targetPosition:d,markerEnd:s,style:c}=o,u=Math.abs(t-r),[p]=u<=1?n.getStraightPath({sourceX:a,sourceY:t,targetX:l,targetY:r}):n.getSmoothStepPath({sourceX:a,sourceY:t,targetX:l,targetY:r,sourcePosition:i,targetPosition:d,borderRadius:8});return e.createElement(n.BaseEdge,{path:p,markerEnd:s,style:c})}};function _e(e,n,o){return i(this,void 0,void 0,function*(){var a;const t=new Set,l=new Set,r=new Set,d=e=>!(null==o?void 0:o.only)||o.only.has(e);for(const n of e.nodes){const e=q.resolveType(n),o=e?X.find(n=>{var o;return n.type===(null!==(o=e.apiType)&&void 0!==o?o:e.type)}):null;null===(a=null==o?void 0:o.collectResourceIds)||void 0===a||a.call(o,n.config,{addSchedule:e=>{d(e)&&t.add(e)},addTarget:e=>{d(e)&&l.add(e)},addAudioClip:e=>{d(e)&&r.add(e)}})}const s=r.size>0?n.audioClips.list().catch(()=>[]):Promise.resolve([]),[c,u,...p]=yield Promise.all([Promise.all(Array.from(t).map(e=>i(this,void 0,void 0,function*(){try{return yield n.schedules.retrieve(e)}catch(e){return null}}))),s,...Array.from(l).map(e=>i(this,void 0,void 0,function*(){var a,t;const l=yield n.resolveRoutingTarget(e,o);return l?{id:l.id,name:l.name||l.id,extension_number:null!==(a=l.extension_number)&&void 0!==a?a:void 0,timeout_seconds:null!==(t=l.timeout_seconds)&&void 0!==t?t:void 0}:null}))]),f=new Map,g=new Map,b=new Map;for(const e of c)e&&f.set(e.id,e);for(const e of p)e&&g.set(e.id,e);for(const e of u)b.set(e.id,e);return{schedules:f,users:g,audioClips:b}})}const xe=e.forwardRef(function({dialPlanId:a,mode:t="view",locale:l=pe,onNodeClick:r,onLoaderStart:c,onLoaderEnd:u,onLoadError:p,onSave:g,onDirtyChange:m,onError:v,className:h,style:_,onCreateResource:x,onOpenResource:y},w){var k;const{editable:E,interactive:N,showChrome:C}=be[t],{dialstack:O}=o.useDialstackComponents(),L=n.useReactFlow(),S=n.useUpdateNodeInternals(),[R,z]=e.useState(!E||!!a),[T,j]=e.useState(null),[A,I]=n.useNodesState([]),[F,P,M]=n.useEdgesState([]),[D,H]=e.useState(null),[$,B]=e.useState(null),[K,V]=e.useState(!1),[U,W]=e.useState(!1);e.useEffect(()=>{var e,n;null===(n=(e=ce.current).onDirtyChange)||void 0===n||n.call(e,K)},[K]);const[G,Y]=e.useState(null),[Z,Q]=e.useState(0),ne=e.useRef(null),te=e.useRef(A),se=e.useRef(F);te.current=A,se.current=F;const ce=e.useRef({onLoaderStart:c,onLoaderEnd:u,onLoadError:p,onError:v,onSave:g,onDirtyChange:m});ce.current={onLoaderStart:c,onLoaderEnd:u,onLoadError:p,onError:v,onSave:g,onDirtyChange:m};const ue=e.useRef(null),xe=e.useRef({schedules:new Map,users:new Map,audioClips:new Map}),ye=e.useRef(!1);e.useEffect(()=>{let e=!1;return function(){i(this,void 0,void 0,function*(){var n,o,t,r,i,d,s,c;if(E&&!a){const{nodes:n,edges:o}=J(Object.assign(Object.assign({},me),{name:l.status.newDialPlan}),q);return void(e||(I(n),P(o),ue.current={nodes:n,edges:o},z(!1)))}z(!0),j(null),null===(o=(n=ce.current).onLoaderStart)||void 0===o||o.call(n);try{const n=yield O.dialPlans.retrieve(a);if(e)return;const o=yield _e(n,O);if(e)return;xe.current=o;const{nodes:i,edges:d}=J(n,q),s=function(e,n,o){return e.map(e=>{var a;const t=q.getByFlowType(null!==(a=e.type)&&void 0!==a?a:""),l=t?X.find(e=>{var n;return e.type===(null!==(n=t.apiType)&&void 0!==n?n:t.type)}):null;return(null==l?void 0:l.enrichNode)?Object.assign(Object.assign({},e),{data:l.enrichNode(e.data,n,o)}):Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{locale:o})})})}(i,o,l);I(s),P(d),ue.current={nodes:s,edges:d},Y({id:n.id,name:n.name}),z(!1),null===(r=(t=ce.current).onLoaderEnd)||void 0===r||r.call(t,n)}catch(n){if(!e){const e=n instanceof Error?n:new Error(String(n));j(e),z(!1),null===(d=(i=ce.current).onLoadError)||void 0===d||d.call(i,e),null===(c=(s=ce.current).onError)||void 0===c||c.call(s,e)}}})}(),()=>{e=!0}},[O,a,I,P]);const we=e.useCallback((e,n)=>{if(!ue.current)return;const o=(e,n)=>JSON.stringify({nodes:e.map(e=>({id:e.id,data:e.data,position:e.position})),edges:n.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle}))}),a=o(ue.current.nodes,ue.current.edges)!==o(e,n);V(a)},[]);e.useEffect(()=>{ye.current&&(ye.current=!1,we(A,F))},[A,F,we]);const ke=e.useCallback(e=>{M(e),e.some(e=>"remove"===e.type)&&queueMicrotask(()=>we(te.current,se.current))},[M,we]),Ee=e.useCallback(e=>{const n=te.current.filter(n=>n.id!==e).map(n=>{var o;const a=null===(o=n.data)||void 0===o?void 0:o.originalNode;if(!a)return n;const t=a.config;if(!t)return n;const l=Object.assign({},t);let r=!1;for(const n of Object.keys(l))l[n]===e&&(l[n]=void 0,r=!0);return r?Object.assign(Object.assign({},n),{data:Object.assign(Object.assign({},n.data),{originalNode:Object.assign(Object.assign({},a),{config:l})})}):n}),o=se.current.filter(n=>n.source!==e&&n.target!==e);I(n),P(o),we(n,o),D===e&&H(null)},[I,P,D,we]),Ne=e.useCallback(e=>{const o=new Set(e.filter(e=>"remove"===e.type&&"id"in e&&"__start__"!==e.id).map(e=>"id"in e?e.id:""));if(o.size>0){const e=te.current.filter(e=>!o.has(e.id)).map(e=>{var n;const a=null===(n=e.data)||void 0===n?void 0:n.originalNode;if(!a)return e;const t=a.config;if(!t)return e;const l=Object.assign({},t);let r=!1;for(const e of Object.keys(l))"string"==typeof l[e]&&o.has(l[e])&&(l[e]=void 0,r=!0);return r?Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{originalNode:Object.assign(Object.assign({},a),{config:l})})}):e}),n=se.current.filter(e=>!o.has(e.source)&&!o.has(e.target));I(e),P(n),we(e,n),D&&o.has(D)&&H(null)}const a=e.filter(e=>"remove"!==e.type&&!("position"===e.type&&"id"in e&&"__start__"===e.id));0!==a.length&&(a.some(e=>"position"===e.type&&!e.dragging)&&(ye.current=!0),I(e=>n.applyNodeChanges(a,e)))},[I,P,we,D]),Ce=e.useCallback((e,n,o)=>{var a,t;const l=q.get(e);if(!l)return;const r=`${e}_${crypto.randomUUID().replace(/-/g,"").slice(0,12)}`;let i=n;if(!i){const e=null===(a=ne.current)||void 0===a?void 0:a.getBoundingClientRect(),n=e?e.left+e.width/2:400,o=e?e.top+e.height/2:300;i=L.screenToFlowPosition({x:n,y:o})}const d={id:r,type:null!==(t=l.apiType)&&void 0!==t?t:e,config:Object.assign({},l.defaultConfig)},s=l.toFlowNode(d),c={id:r,type:l.flowType,position:i,data:s,selected:!0};if(I(e=>{const n=e.map(e=>e.selected?Object.assign(Object.assign({},e),{selected:!1}):e);return n.push(c),we(n,se.current),n}),H(r),o){const e=i;requestAnimationFrame(()=>{var n;const a=null===(n=ne.current)||void 0===n?void 0:n.querySelector(`[data-id="${CSS.escape(r)}"]`);if(!a)return;const t=a.offsetWidth,l=a.offsetHeight;t&&l&&I(n=>n.map(n=>n.id===r?Object.assign(Object.assign({},n),{position:{x:e.x-o.x*t,y:e.y-o.y*l}}):n))})}},[L,I,we]),Oe=e.useCallback(e=>{e.preventDefault();const n=e.dataTransfer.getData("application/reactflow");if(!n)return;const[o,a]=e.dataTransfer.getData("application/reactflow-grab-frac").split(","),t={x:Number(o),y:Number(a)},l=L.screenToFlowPosition({x:e.clientX,y:e.clientY});Ce(n,l,t)},[L,Ce]),Le=e.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},[]),Se=e.useCallback(e=>{var o,a,t;const l={id:`${e.source}-${null!==(o=e.sourceHandle)&&void 0!==o?o:""}->${e.target}`,source:e.source,target:e.target,sourceHandle:null!==(a=e.sourceHandle)&&void 0!==a?a:void 0,targetHandle:null!==(t=e.targetHandle)&&void 0!==t?t:void 0,type:d,markerEnd:{type:n.MarkerType.ArrowClosed,width:12,height:12,color:"#94a3b8"}};P(n=>{const o=n.filter(n=>{var o,a;return!(n.source===e.source&&(null!==(o=n.sourceHandle)&&void 0!==o?o:null)===(null!==(a=e.sourceHandle)&&void 0!==a?a:null))}),a=[...o,l];return we(te.current,a),a})},[P,we]),Re=e.useCallback((e,o)=>{P(a=>{var t,l,r;const i=a.filter(n=>{var a,t;return n.id!==e.id&&!(n.source===o.source&&(null!==(a=n.sourceHandle)&&void 0!==a?a:null)===(null!==(t=o.sourceHandle)&&void 0!==t?t:null))}),s=[...i,{id:`${o.source}-${null!==(t=o.sourceHandle)&&void 0!==t?t:""}->${o.target}`,source:o.source,target:o.target,sourceHandle:null!==(l=o.sourceHandle)&&void 0!==l?l:void 0,targetHandle:null!==(r=o.targetHandle)&&void 0!==r?r:void 0,type:d,markerEnd:{type:n.MarkerType.ArrowClosed,width:12,height:12,color:"#94a3b8"}}];return we(te.current,s),s})},[P,we]),ze=e.useCallback(e=>{var n;if(!e.source||!e.target||e.source!==e.target)return!0;const o=te.current.find(n=>n.id===e.source),a=q.getByFlowType(null!==(n=null==o?void 0:o.type)&&void 0!==n?n:"");return!0===(null==a?void 0:a.allowSelfLoop)},[te]),Te=e.useCallback((e,n,o)=>{var a,t;I(a=>{const t=a.map(a=>{var t;if(a.id!==e)return a;const r=function({flowType:e,data:n,configUpdates:o,displayUpdates:a,maps:t,locale:l}){const r=n.originalNode;if(!r)return null;const i=Object.assign(Object.assign({},r),{config:Object.assign(Object.assign({},r.config),o)}),d=q.getByFlowType(e),s=d?d.toFlowNode(i):Object.assign(Object.assign({},n),{originalNode:i}),c=f(o,"target")||void 0,u=c?b(c,l):void 0,p=d?X.find(e=>{var n;return e.type===(null!==(n=d.apiType)&&void 0!==n?n:d.type)}):null,g=Object.assign(Object.assign({},n),s),m=(null==p?void 0:p.enrichNode)?p.enrichNode(g,t,l):g;return Object.assign(Object.assign(Object.assign({},m),a),u&&{targetType:u})}({flowType:null!==(t=a.type)&&void 0!==t?t:"",data:a.data,configUpdates:n,displayUpdates:o,maps:xe.current,locale:l});return r?Object.assign(Object.assign({},a),{data:r}):a});return we(t,se.current),t});const r=te.current.find(n=>n.id===e),i=q.getByFlowType(null!==(a=null==r?void 0:r.type)&&void 0!==a?a:"");if(i){const o=null==r?void 0:r.data.originalNode,a=function(e,n){const o=s(e,n);return new Set(e.exits.filter(e=>!o.includes(e)).map(e=>e.id))}(i,Object.assign(Object.assign({},null==o?void 0:o.config),n));a.size>0&&P(n=>{const o=n.filter(n=>{var o;return!(n.source===e&&a.has(null!==(o=n.sourceHandle)&&void 0!==o?o:""))});return o.length===n.length?n:(we(te.current,o),o)})}const d=i?X.find(e=>{var n;return e.type===(null!==(n=i.apiType)&&void 0!==n?n:i.type)}):null;null===(t=null==d?void 0:d.onConfigChange)||void 0===t||t.call(d,e,n,{setEdges:P,updateNodeInternals:S,nodesRef:te,updateDirty:we});const c=f(n,"target");c&&requestAnimationFrame(()=>S(e)),c&&!xe.current.users.has(c)&&O.resolveRoutingTarget(c).then(n=>{var o,a;n&&(xe.current.users.set(c,{id:n.id,name:n.name||n.id,extension_number:null!==(o=n.extension_number)&&void 0!==o?o:void 0,timeout_seconds:null!==(a=n.timeout_seconds)&&void 0!==a?a:void 0}),I(n=>n.map(n=>{var o;return n.id===e?Object.assign(Object.assign({},n),{data:ae(null!==(o=n.type)&&void 0!==o?o:"",n.data,xe.current,l)}):n})))})},[O,I,P,we,S]),je=e.useCallback(()=>{const{nodes:e,edges:n}=oe(A,F);I(e),P(n),we(e,n),requestAnimationFrame(()=>L.fitView({padding:.2}))},[A,F,I,P,we,L]),Ae=e.useCallback((e,n)=>i(this,void 0,void 0,function*(){var o;try{const t={expand:["extensions"]};switch(e){case"schedule":return yield O.schedules.list();case"user":return(yield O.users.list(t)).map(e=>{var n,o,a;return{id:e.id,name:e.name||l.combobox.noName,extension_number:null===(a=null===(o=null===(n=e.extensions)||void 0===n?void 0:n.data)||void 0===o?void 0:o[0])||void 0===a?void 0:a.number}});case"ring_group":return yield O.ringGroups.list(t);case"queue":return yield O.queues.list({expand:t.expand});case"dial_plan":{const e=yield O.dialPlans.list(t),n=null!==(o=null==G?void 0:G.id)&&void 0!==o?o:a;return e.filter(e=>e.id!==n)}case"voice_app":{const e=yield O.voiceApps.list(t);if(!(null==n?void 0:n.notifyEligible))return e;try{const n=yield O.aiAgents.list({limit:100}),o=new Set(n.map(e=>e.voice_app_id));return e.filter(e=>!o.has(e.id))}catch(n){return e}}case"shared_voicemail":return yield O.sharedVoicemailBoxes.list();case"audio_clip":return yield O.audioClips.list();default:return[]}}catch(e){return[]}}),[O,a,G,l,Z]),Ie=e.useCallback(e=>i(this,void 0,void 0,function*(){const n=(e,n)=>ee(e,n,q).nodes,o=ue.current,a=[...n(te.current,se.current),...o?n(o.nodes,o.edges):[]],t=yield _e({nodes:a},O,{refresh:!0,only:e?new Set(e):void 0}),r=xe.current,i={schedules:new Map([...r.schedules,...t.schedules]),users:new Map([...r.users,...t.users]),audioClips:new Map([...r.audioClips,...t.audioClips])};xe.current=i;const d=e=>e.map(e=>{var n;return Object.assign(Object.assign({},e),{data:ae(null!==(n=e.type)&&void 0!==n?n:"",e.data,i,l)})}),s=ue.current;s&&(ue.current=Object.assign(Object.assign({},s),{nodes:d(s.nodes)})),I(e=>d(e)),Q(e=>e+1)}),[O,I]),Fe=e.useCallback(()=>i(this,void 0,void 0,function*(){var e,n,o,t,r,i;try{const r=te.current,i=se.current,d=ee(r,i,q),s=a?yield O.dialPlans.update(a,d):yield O.dialPlans.create(Object.assign({name:l.status.newDialPlan},d));ue.current={nodes:[...r],edges:[...i]},V(!1),null===(n=(e=ce.current).onDirtyChange)||void 0===n||n.call(e,!1),null===(t=(o=ce.current).onSave)||void 0===t||t.call(o,s)}catch(e){const n=e instanceof Error?e:new Error(String(e)),o=n.message.includes("/nodes/")?ee(te.current,se.current,q):null;if(o){const e=n.message.match(/^\/nodes\/(\d+)\//);if(null==e?void 0:e[1]){const n=o.nodes[parseInt(e[1],10)];n&&H(n.id)}}throw null===(i=(r=ce.current).onError)||void 0===i||i.call(r,new Error(function(e,n){var o,a,t;if(e.startsWith("voice_app notify mode is not supported on AI agent voice apps"))return"A Voice App used in Notify mode is backed by a Managed VoiceAI agent. Managed VoiceAI voice apps must use Control mode.";const l=e.indexOf(": "),r=l>0&&e.startsWith("/")?e.slice(0,l):"",i=l>0?e.slice(l+2):e,d=r.split("/").filter(Boolean);if("entry_node"===d[0])return"The Start node must be connected to another node";if("nodes"===d[0]&&i.includes("minItems"))return"The dial plan must have at least one node";if("nodes"===d[0]&&"config"===d[2]&&d[3]){const e=d[3];if(fe[e])return fe[e];const l=parseInt(null!==(o=d[1])&&void 0!==o?o:"",10),r=isNaN(l)||null===(a=null==n?void 0:n[l])||void 0===a?void 0:a.type,i=r?null!==(t=ge[r])&&void 0!==t?t:r:void 0;return i?`Invalid ${e.replace(/_/g," ")} in the ${i} node`:`Invalid ${e.replace(/_/g," ")}`}return r?i:e}(n.message,null==o?void 0:o.nodes))),e}}),[O,a]);e.useImperativeHandle(w,()=>({save:Fe,refreshResources:Ie}),[Fe,Ie]);const Pe=e.useCallback((e,n)=>{"__start__"!==n.id&&(H(n.id),B(null))},[]),Me=e.useCallback((e,n)=>{B(n.id),H(null)},[]),De=e.useCallback(e=>{const n=se.current.filter(n=>n.id!==e);P(n),we(te.current,n),B(null)},[P,we]),He=e.useCallback(()=>{H(null),B(null)},[]),$e=e.useCallback((e,n)=>{var o;if(!r)return;if("__start__"===n.id)return;const a=null===(o=n.data)||void 0===o?void 0:o.originalNode;a&&r(n.id,a)},[r]),Be=D?A.find(e=>e.id===D):null,Ke=Be?q.getByFlowType(null!==(k=Be.type)&&void 0!==k?k:""):null,Ve=$?F.find(e=>e.id===$):null,Ue=!(!Be||!Ke)||!!Ve;if(R)return e.createElement("div",{className:`ds-dial-plan-viewer ds-dial-plan-viewer--loading ${h||""}`,style:_},e.createElement("div",{className:"ds-dial-plan-viewer__loading"},e.createElement("div",{className:"ds-dial-plan-viewer__spinner"}),e.createElement("span",null,l.status.loading)));if(T)return e.createElement("div",{className:`ds-dial-plan-viewer ds-dial-plan-viewer--error ${h||""}`,style:_},e.createElement("div",{className:"ds-dial-plan-viewer__error"},e.createElement("span",null,l.status.loadError),e.createElement("span",{className:"ds-dial-plan-viewer__error-message"},T.message)));if(!E&&0===A.length)return e.createElement("div",{className:`ds-dial-plan-viewer ds-dial-plan-viewer--empty ${h||""}`,style:_},e.createElement("div",{className:"ds-dial-plan-viewer__empty"},e.createElement("span",null,l.status.notFound)));const We=e.createElement(n.ReactFlow,{nodes:A,edges:F,nodeTypes:ve,edgeTypes:he,onNodesChange:E?Ne:void 0,onEdgesChange:E?ke:void 0,onConnect:E?Se:void 0,onReconnect:E?Re:void 0,onEdgeClick:E?Me:void 0,isValidConnection:E?ze:void 0,edgesReconnectable:E,onNodeClick:E?Pe:r?$e:void 0,onPaneClick:E?He:void 0,nodesDraggable:E,nodesConnectable:E,elementsSelectable:E,selectionOnDrag:!1,selectNodesOnDrag:!1,panOnDrag:N,panOnScroll:!1,zoomOnScroll:N,zoomOnPinch:N,zoomOnDoubleClick:N,preventScrolling:N,connectionLineType:n.ConnectionLineType.SmoothStep,selectionKeyCode:null,multiSelectionKeyCode:null,deleteKeyCode:E?["Backspace","Delete"]:null,fitView:!0,fitViewOptions:{padding:N?.2:.15,minZoom:N?.5:0,maxZoom:1.5},minZoom:N?.3:0,maxZoom:2,defaultEdgeOptions:{type:d,animated:!1,markerEnd:{type:n.MarkerType.ArrowClosed,width:12,height:12,color:"#94a3b8"}},proOptions:{hideAttribution:!0}},C&&e.createElement(n.Background,{gap:20,size:1}),C&&e.createElement(n.Controls,{showInteractive:!1}),E&&e.createElement(de,{onAutoLayout:je,onSave:()=>{Fe().catch(()=>{})},isDirty:K,hasInvalidDraft:U}));return e.createElement("div",{className:`ds-dial-plan-editor ${"preview"===t?"ds-dial-plan-editor--preview":""} ${h||""}`,style:_},E&&e.createElement("div",{className:"ds-dial-plan-node-library-wrapper"},e.createElement(le,{registry:q,onAddNode:Ce})),e.createElement("div",{ref:ne,className:"ds-dial-plan-editor__canvas",onDrop:E?Oe:void 0,onDragOver:E?Le:void 0},We),E&&e.createElement("div",{className:"ds-dial-plan-config-panel-wrapper"+(Ue?" ds-dial-plan-config-panel-wrapper--open":"")},Be&&Ke&&e.createElement(ie,{node:Be,registration:Ke,onConfigChange:Te,onInvalidDraftChange:W,onDelete:Ee,onClose:()=>{H(null),I(e=>e.map(e=>e.selected?Object.assign(Object.assign({},e),{selected:!1}):e))},listResources:Ae,onCreateResource:x,onOpenResource:y,locale:l}),Ve&&e.createElement("div",{className:"ds-dial-plan-config-panel"},e.createElement("div",{className:"ds-dial-plan-config-panel__header"},e.createElement("span",{className:"ds-dial-plan-config-panel__header-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M4 8h8v8h8"}),e.createElement("polyline",{points:"17 13 20 16 17 19"}))),e.createElement("span",{className:"ds-dial-plan-config-panel__header-label"},l.panel.connection),e.createElement("button",{type:"button",className:"ds-dial-plan-config-panel__delete",onClick:()=>De(Ve.id),title:l.panel.delete_},re),e.createElement("button",{type:"button",className:"ds-dial-plan-config-panel__close",onClick:()=>{B(null),P(e=>e.map(e=>e.selected?Object.assign(Object.assign({},e),{selected:!1}):e))},title:l.panel.close},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e.createElement("div",{className:"ds-dial-plan-config-panel__body"},e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("span",{className:"ds-dial-plan-config-field__label"},l.panel.from),e.createElement("span",{className:"ds-dial-plan-edge-panel__value"},(()=>{var e,n,o;const a=A.find(e=>e.id===Ve.source),t=a?q.getByFlowType(null!==(e=a.type)&&void 0!==e?e:""):null,l=null!==(o=null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null==a?void 0:a.type)&&void 0!==o?o:Ve.source;return l.charAt(0).toUpperCase()+l.slice(1)})())),Ve.sourceHandle&&e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("span",{className:"ds-dial-plan-config-field__label"},l.panel.exit),e.createElement("span",{className:"ds-dial-plan-edge-panel__value"},(()=>{var e,n,o,a,t;const l=Ve.sourceHandle,r=A.find(e=>e.id===Ve.source),i=r?q.getByFlowType(null!==(e=r.type)&&void 0!==e?e:""):null,d=i?X.find(e=>{var n;return e.type===(null!==(n=i.apiType)&&void 0!==n?n:i.type)}):null;return null!==(t=null!==(o=null===(n=null==d?void 0:d.resolveExitLabel)||void 0===n?void 0:n.call(d,l))&&void 0!==o?o:null===(a=null==i?void 0:i.exits.find(e=>e.id===l))||void 0===a?void 0:a.label)&&void 0!==t?t:l})())),e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("span",{className:"ds-dial-plan-config-field__label"},l.panel.to),e.createElement("span",{className:"ds-dial-plan-edge-panel__value"},(()=>{var e,n,o;const a=A.find(e=>e.id===Ve.target),t=a?q.getByFlowType(null!==(e=a.type)&&void 0!==e?e:""):null,l=null!==(o=null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null==a?void 0:a.type)&&void 0!==o?o:Ve.target;return l.charAt(0).toUpperCase()+l.slice(1)})()))))))}),ye=["/* this gets exported as style.css and can be used for the default theming */\n/* these are the necessary styles for React/Svelte Flow, they get used by base.css and style.css */\n.react-flow {\n direction: ltr;\n\n --xy-edge-stroke-default: #b1b1b7;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #555;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(255, 255, 255, 0.5);\n\n --xy-minimap-background-color-default: #fff;\n --xy-minimap-mask-background-color-default: rgba(240, 240, 240, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #e2e2e2;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: transparent;\n --xy-background-pattern-dots-color-default: #91919a;\n --xy-background-pattern-lines-color-default: #eee;\n --xy-background-pattern-cross-color-default: #e2e2e2;\n background-color: var(--xy-background-color, var(--xy-background-color-default));\n --xy-node-color-default: inherit;\n --xy-node-border-default: 1px solid #1a192b;\n --xy-node-background-color-default: #fff;\n --xy-node-group-background-color-default: rgba(240, 240, 240, 0.25);\n --xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, 0.08);\n --xy-node-boxshadow-selected-default: 0 0 0 0.5px #1a192b;\n --xy-node-border-radius-default: 3px;\n\n --xy-handle-background-color-default: #1a192b;\n --xy-handle-border-color-default: #fff;\n\n --xy-selection-background-color-default: rgba(0, 89, 220, 0.08);\n --xy-selection-border-default: 1px dotted rgba(0, 89, 220, 0.8);\n\n --xy-controls-button-background-color-default: #fefefe;\n --xy-controls-button-background-color-hover-default: #f4f4f4;\n --xy-controls-button-color-default: inherit;\n --xy-controls-button-color-hover-default: inherit;\n --xy-controls-button-border-color-default: #eee;\n --xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, 0.08);\n\n --xy-edge-label-background-color-default: #ffffff;\n --xy-edge-label-color-default: inherit;\n --xy-resize-background-color-default: #3367d9;\n}\n.react-flow.dark {\n --xy-edge-stroke-default: #3e3e3e;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #727272;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(150, 150, 150, 0.25);\n\n --xy-minimap-background-color-default: #141414;\n --xy-minimap-mask-background-color-default: rgba(60, 60, 60, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #2b2b2b;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: #141414;\n --xy-background-pattern-dots-color-default: #555;\n --xy-background-pattern-lines-color-default: #333;\n --xy-background-pattern-cross-color-default: #333;\n --xy-node-color-default: #f8f8f8;\n --xy-node-border-default: 1px solid #3c3c3c;\n --xy-node-background-color-default: #1e1e1e;\n --xy-node-group-background-color-default: rgba(240, 240, 240, 0.25);\n --xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, 0.08);\n --xy-node-boxshadow-selected-default: 0 0 0 0.5px #999;\n\n --xy-handle-background-color-default: #bebebe;\n --xy-handle-border-color-default: #1e1e1e;\n\n --xy-selection-background-color-default: rgba(200, 200, 220, 0.08);\n --xy-selection-border-default: 1px dotted rgba(200, 200, 220, 0.8);\n\n --xy-controls-button-background-color-default: #2b2b2b;\n --xy-controls-button-background-color-hover-default: #3e3e3e;\n --xy-controls-button-color-default: #f8f8f8;\n --xy-controls-button-color-hover-default: #fff;\n --xy-controls-button-border-color-default: #5b5b5b;\n --xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, 0.08);\n\n --xy-edge-label-background-color-default: #141414;\n --xy-edge-label-color-default: #f8f8f8;\n}\n.react-flow__background {\n background-color: var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));\n pointer-events: none;\n z-index: -1;\n}\n.react-flow__container {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n}\n.react-flow__pane {\n z-index: 1;\n touch-action: none;\n}\n.react-flow__pane.draggable {\n cursor: grab;\n }\n.react-flow__pane.dragging {\n cursor: grabbing;\n }\n.react-flow__pane.selection {\n cursor: pointer;\n }\n.react-flow__viewport {\n transform-origin: 0 0;\n z-index: 2;\n pointer-events: none;\n}\n.react-flow__renderer {\n z-index: 4;\n}\n.react-flow__selection {\n z-index: 6;\n}\n.react-flow__nodesselection-rect:focus,\n.react-flow__nodesselection-rect:focus-visible {\n outline: none;\n}\n.react-flow__edge-path {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n stroke-width: var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));\n fill: none;\n}\n.react-flow__connection-path {\n stroke: var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));\n stroke-width: var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));\n fill: none;\n}\n.react-flow .react-flow__edges {\n position: absolute;\n}\n.react-flow .react-flow__edges svg {\n overflow: visible;\n position: absolute;\n pointer-events: none;\n }\n.react-flow__edge {\n pointer-events: visibleStroke;\n}\n.react-flow__edge.selectable {\n cursor: pointer;\n }\n.react-flow__edge.animated path {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\n.react-flow__edge.animated path.react-flow__edge-interaction {\n stroke-dasharray: none;\n animation: none;\n }\n.react-flow__edge.inactive {\n pointer-events: none;\n }\n.react-flow__edge.selected,\n .react-flow__edge:focus,\n .react-flow__edge:focus-visible {\n outline: none;\n }\n.react-flow__edge.selected .react-flow__edge-path,\n .react-flow__edge.selectable:focus .react-flow__edge-path,\n .react-flow__edge.selectable:focus-visible .react-flow__edge-path {\n stroke: var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default));\n }\n.react-flow__edge-textwrapper {\n pointer-events: all;\n }\n.react-flow__edge .react-flow__edge-text {\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n/* Arrowhead marker styles - use CSS custom properties as default */\n.react-flow__arrowhead polyline {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__arrowhead polyline.arrowclosed {\n fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__connection {\n pointer-events: none;\n}\n.react-flow__connection .animated {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\nsvg.react-flow__connectionline {\n z-index: 1001;\n overflow: visible;\n position: absolute;\n}\n.react-flow__nodes {\n pointer-events: none;\n transform-origin: 0 0;\n}\n.react-flow__node {\n position: absolute;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n pointer-events: all;\n transform-origin: 0 0;\n box-sizing: border-box;\n cursor: default;\n}\n.react-flow__node.selectable {\n cursor: pointer;\n }\n.react-flow__node.draggable {\n cursor: grab;\n pointer-events: all;\n }\n.react-flow__node.draggable.dragging {\n cursor: grabbing;\n }\n.react-flow__nodesselection {\n z-index: 3;\n transform-origin: left top;\n pointer-events: none;\n}\n.react-flow__nodesselection-rect {\n position: absolute;\n pointer-events: all;\n cursor: grab;\n }\n.react-flow__handle {\n position: absolute;\n pointer-events: none;\n min-width: 5px;\n min-height: 5px;\n width: 6px;\n height: 6px;\n background-color: var(--xy-handle-background-color, var(--xy-handle-background-color-default));\n border: 1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));\n border-radius: 100%;\n}\n.react-flow__handle.connectingfrom {\n pointer-events: all;\n }\n.react-flow__handle.connectionindicator {\n pointer-events: all;\n cursor: crosshair;\n }\n.react-flow__handle-bottom {\n top: auto;\n left: 50%;\n bottom: 0;\n transform: translate(-50%, 50%);\n }\n.react-flow__handle-top {\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-left {\n top: 50%;\n left: 0;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-right {\n top: 50%;\n right: 0;\n transform: translate(50%, -50%);\n }\n.react-flow__edgeupdater {\n cursor: move;\n pointer-events: all;\n}\n.react-flow__pane.selection .react-flow__panel {\n pointer-events: none;\n}\n.react-flow__panel {\n position: absolute;\n z-index: 5;\n margin: 15px;\n}\n.react-flow__panel.top {\n top: 0;\n }\n.react-flow__panel.bottom {\n bottom: 0;\n }\n.react-flow__panel.top.center, .react-flow__panel.bottom.center {\n left: 50%;\n transform: translateX(-15px) translateX(-50%);\n }\n.react-flow__panel.left {\n left: 0;\n }\n.react-flow__panel.right {\n right: 0;\n }\n.react-flow__panel.left.center, .react-flow__panel.right.center {\n top: 50%;\n transform: translateY(-15px) translateY(-50%);\n }\n.react-flow__attribution {\n font-size: 10px;\n background: var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));\n padding: 2px 3px;\n margin: 0;\n}\n.react-flow__attribution a {\n text-decoration: none;\n color: #999;\n }\n@keyframes dashdraw {\n from {\n stroke-dashoffset: 10;\n }\n}\n.react-flow__edgelabel-renderer {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n left: 0;\n top: 0;\n}\n.react-flow__viewport-portal {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n.react-flow__minimap {\n background: var(\n --xy-minimap-background-color-props,\n var(--xy-minimap-background-color, var(--xy-minimap-background-color-default))\n );\n}\n.react-flow__minimap-svg {\n display: block;\n }\n.react-flow__minimap-mask {\n fill: var(\n --xy-minimap-mask-background-color-props,\n var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default))\n );\n stroke: var(\n --xy-minimap-mask-stroke-color-props,\n var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-mask-stroke-width-props,\n var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default))\n );\n }\n.react-flow__minimap-node {\n fill: var(\n --xy-minimap-node-background-color-props,\n var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default))\n );\n stroke: var(\n --xy-minimap-node-stroke-color-props,\n var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-node-stroke-width-props,\n var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default))\n );\n }\n.react-flow__background-pattern.dots {\n fill: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default))\n );\n }\n.react-flow__background-pattern.lines {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default))\n );\n }\n.react-flow__background-pattern.cross {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default))\n );\n }\n.react-flow__controls {\n display: flex;\n flex-direction: column;\n box-shadow: var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default));\n}\n.react-flow__controls.horizontal {\n flex-direction: row;\n }\n.react-flow__controls-button {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 26px;\n width: 26px;\n padding: 4px;\n border: none;\n background: var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));\n border-bottom: 1px solid\n var(\n --xy-controls-button-border-color-props,\n var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default))\n );\n color: var(\n --xy-controls-button-color-props,\n var(--xy-controls-button-color, var(--xy-controls-button-color-default))\n );\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n.react-flow__controls-button svg {\n width: 100%;\n max-width: 12px;\n max-height: 12px;\n fill: currentColor;\n }\n.react-flow__edge.updating .react-flow__edge-path {\n stroke: #777;\n }\n.react-flow__edge-text {\n font-size: 10px;\n }\n.react-flow__node.selectable:focus,\n .react-flow__node.selectable:focus-visible {\n outline: none;\n }\n.react-flow__node-input,\n.react-flow__node-default,\n.react-flow__node-output,\n.react-flow__node-group {\n padding: 10px;\n border-radius: var(--xy-node-border-radius, var(--xy-node-border-radius-default));\n width: 150px;\n font-size: 12px;\n color: var(--xy-node-color, var(--xy-node-color-default));\n text-align: center;\n border: var(--xy-node-border, var(--xy-node-border-default));\n background-color: var(--xy-node-background-color, var(--xy-node-background-color-default));\n}\n.react-flow__node-input.selectable:hover, .react-flow__node-default.selectable:hover, .react-flow__node-output.selectable:hover, .react-flow__node-group.selectable:hover {\n box-shadow: var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default));\n }\n.react-flow__node-input.selectable.selected,\n .react-flow__node-input.selectable:focus,\n .react-flow__node-input.selectable:focus-visible,\n .react-flow__node-default.selectable.selected,\n .react-flow__node-default.selectable:focus,\n .react-flow__node-default.selectable:focus-visible,\n .react-flow__node-output.selectable.selected,\n .react-flow__node-output.selectable:focus,\n .react-flow__node-output.selectable:focus-visible,\n .react-flow__node-group.selectable.selected,\n .react-flow__node-group.selectable:focus,\n .react-flow__node-group.selectable:focus-visible {\n box-shadow: var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default));\n }\n.react-flow__node-group {\n background-color: var(--xy-node-group-background-color, var(--xy-node-group-background-color-default));\n}\n.react-flow__nodesselection-rect,\n.react-flow__selection {\n background: var(--xy-selection-background-color, var(--xy-selection-background-color-default));\n border: var(--xy-selection-border, var(--xy-selection-border-default));\n}\n.react-flow__nodesselection-rect:focus,\n .react-flow__nodesselection-rect:focus-visible,\n .react-flow__selection:focus,\n .react-flow__selection:focus-visible {\n outline: none;\n }\n.react-flow__controls-button:hover {\n background: var(\n --xy-controls-button-background-color-hover-props,\n var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default))\n );\n color: var(\n --xy-controls-button-color-hover-props,\n var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default))\n );\n }\n.react-flow__controls-button:disabled {\n pointer-events: none;\n }\n.react-flow__controls-button:disabled svg {\n fill-opacity: 0.4;\n }\n.react-flow__controls-button:last-child {\n border-bottom: none;\n }\n.react-flow__controls.horizontal .react-flow__controls-button {\n border-bottom: none;\n border-right: 1px solid\n var(\n --xy-controls-button-border-color-props,\n var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default))\n );\n }\n.react-flow__controls.horizontal .react-flow__controls-button:last-child {\n border-right: none;\n }\n.react-flow__resize-control {\n position: absolute;\n}\n.react-flow__resize-control.left,\n.react-flow__resize-control.right {\n cursor: ew-resize;\n}\n.react-flow__resize-control.top,\n.react-flow__resize-control.bottom {\n cursor: ns-resize;\n}\n.react-flow__resize-control.top.left,\n.react-flow__resize-control.bottom.right {\n cursor: nwse-resize;\n}\n.react-flow__resize-control.bottom.left,\n.react-flow__resize-control.top.right {\n cursor: nesw-resize;\n}\n/* handle styles */\n.react-flow__resize-control.handle {\n width: 5px;\n height: 5px;\n border: 1px solid #fff;\n border-radius: 1px;\n background-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n translate: -50% -50%;\n}\n.react-flow__resize-control.handle.left {\n left: 0;\n top: 50%;\n}\n.react-flow__resize-control.handle.right {\n left: 100%;\n top: 50%;\n}\n.react-flow__resize-control.handle.top {\n left: 50%;\n top: 0;\n}\n.react-flow__resize-control.handle.bottom {\n left: 50%;\n top: 100%;\n}\n.react-flow__resize-control.handle.top.left {\n left: 0;\n}\n.react-flow__resize-control.handle.bottom.left {\n left: 0;\n}\n.react-flow__resize-control.handle.top.right {\n left: 100%;\n}\n.react-flow__resize-control.handle.bottom.right {\n left: 100%;\n}\n/* line styles */\n.react-flow__resize-control.line {\n border-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n border-width: 0;\n border-style: solid;\n}\n.react-flow__resize-control.line.left,\n.react-flow__resize-control.line.right {\n width: 1px;\n transform: translate(-50%, 0);\n top: 0;\n height: 100%;\n}\n.react-flow__resize-control.line.left {\n left: 0;\n border-left-width: 1px;\n}\n.react-flow__resize-control.line.right {\n left: 100%;\n border-right-width: 1px;\n}\n.react-flow__resize-control.line.top,\n.react-flow__resize-control.line.bottom {\n height: 1px;\n transform: translate(0, -50%);\n left: 0;\n width: 100%;\n}\n.react-flow__resize-control.line.top {\n top: 0;\n border-top-width: 1px;\n}\n.react-flow__resize-control.line.bottom {\n border-bottom-width: 1px;\n top: 100%;\n}\n.react-flow__edge-textbg {\n fill: var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default));\n}\n.react-flow__edge-text {\n fill: var(--xy-edge-label-color, var(--xy-edge-label-color-default));\n}\n",'\n/* ============================================================================\n Shadow DOM Reset\n ============================================================================ */\n\n:host {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n}\n\n/* ============================================================================\n Container\n ============================================================================ */\n\n.ds-dial-plan-viewer {\n width: 100%;\n height: 100%;\n background: var(--ds-color-background, #ffffff);\n border-radius: var(--ds-border-radius, 8px);\n overflow: hidden;\n}\n\n/* ============================================================================\n Base Node Styles\n ============================================================================ */\n\n.ds-dial-plan-node {\n padding: 12px 16px;\n border-radius: var(--ds-border-radius, 8px);\n border: 2px solid var(--ds-color-border, #e2e8f0);\n background: var(--ds-color-background, #ffffff);\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n transition: border-color 0.15s ease, box-shadow 0.15s ease, outline-color 0.15s ease;\n min-width: 140px;\n outline: 3px solid transparent;\n outline-offset: 2px;\n}\n\n.ds-dial-plan-node--selected {\n border-color: var(--ds-color-primary, #3b82f6);\n outline-color: var(--ds-color-primary, #3b82f6);\n box-shadow: 0 0 16px 2px rgba(59, 130, 246, 0.4), 0 4px 12px rgba(59, 130, 246, 0.2);\n}\n\n.ds-dial-plan-node__content,\n.ds-dial-plan-node__header {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n}\n\n.ds-dial-plan-node__icon {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-node__label {\n font-weight: 600;\n color: var(--ds-color-text, #1e293b);\n text-align: center;\n}\n\n.ds-dial-plan-node__type-label {\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 500;\n color: var(--ds-color-text-secondary, #64748b);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.ds-dial-plan-node__name {\n font-weight: 600;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n text-align: center;\n}\n\n.ds-dial-plan-node__type {\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-node__exits {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin-top: 12px;\n padding-top: 10px;\n border-top: 1px solid var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-node__exit-row {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n position: relative;\n}\n\n.ds-dial-plan-node__exit-label {\n font-size: 11px;\n color: var(--ds-color-text-secondary, #64748b);\n white-space: nowrap;\n}\n\n/* Position handles at the right edge of exit rows */\n.ds-dial-plan-node__exit-row .ds-dial-plan-handle {\n position: absolute;\n right: -16px;\n}\n\n/* ============================================================================\n Start Node\n ============================================================================ */\n\n.ds-dial-plan-node--start {\n background: var(--ds-color-primary, #3b82f6);\n border-color: var(--ds-color-primary, #3b82f6);\n border-radius: 50%;\n width: 60px;\n height: 60px;\n min-width: auto;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.ds-dial-plan-node--start .ds-dial-plan-node__content {\n flex-direction: row;\n}\n\n.ds-dial-plan-node--start .ds-dial-plan-node__label {\n color: #ffffff;\n font-size: var(--ds-font-size-sm, 14px);\n}\n\n/* ============================================================================\n Node color theming (driven by --node-color CSS variable from registration)\n ============================================================================ */\n\n.ds-dial-plan-node--themed {\n border-color: var(--node-color);\n background: color-mix(in srgb, var(--node-color) 8%, white);\n}\n\n.ds-dial-plan-node--themed .ds-dial-plan-node__icon {\n color: var(--node-color);\n}\n\n.ds-dial-plan-node--themed.ds-dial-plan-node--selected {\n border-color: var(--node-color);\n outline-color: var(--node-color);\n box-shadow: 0 0 16px 2px color-mix(in srgb, var(--node-color) 40%, transparent),\n 0 4px 12px color-mix(in srgb, var(--node-color) 20%, transparent);\n}\n\n/* ============================================================================\n Per-type node colors (override --themed fallback with hand-crafted gradients)\n ============================================================================ */\n\n.ds-dial-plan-node--schedule {\n background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);\n border-color: var(--ds-color-info, #0ea5e9);\n min-height: 80px;\n}\n.ds-dial-plan-node--schedule .ds-dial-plan-node__icon { color: var(--ds-color-info, #0ea5e9); }\n.ds-dial-plan-node--schedule.ds-dial-plan-node--selected {\n border-color: var(--ds-color-info, #0ea5e9);\n outline-color: var(--ds-color-info, #0ea5e9);\n box-shadow: 0 0 16px 2px rgba(14, 165, 233, 0.4), 0 4px 12px rgba(14, 165, 233, 0.2);\n}\n\n.ds-dial-plan-node--internal-dial {\n background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);\n border-color: var(--ds-color-success, #22c55e);\n}\n.ds-dial-plan-node--internal-dial .ds-dial-plan-node__icon { color: var(--ds-color-success, #22c55e); }\n.ds-dial-plan-node--internal-dial.ds-dial-plan-node--selected {\n border-color: var(--ds-color-success, #22c55e);\n outline-color: var(--ds-color-success, #22c55e);\n box-shadow: 0 0 16px 2px rgba(34, 197, 94, 0.4), 0 4px 12px rgba(34, 197, 94, 0.2);\n}\n\n.ds-dial-plan-node--voicemail {\n background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);\n border-color: var(--ds-color-purple, #a855f7);\n}\n.ds-dial-plan-node--voicemail .ds-dial-plan-node__icon { color: var(--ds-color-purple, #a855f7); }\n.ds-dial-plan-node--voicemail.ds-dial-plan-node--selected {\n border-color: var(--ds-color-purple, #a855f7);\n outline-color: var(--ds-color-purple, #a855f7);\n box-shadow: 0 0 16px 2px rgba(168, 85, 247, 0.4), 0 4px 12px rgba(168, 85, 247, 0.2);\n}\n\n.ds-dial-plan-node--ring-all-users {\n background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);\n border-color: var(--ds-color-warning, #f59e0b);\n}\n.ds-dial-plan-node--ring-all-users .ds-dial-plan-node__icon { color: var(--ds-color-warning, #f59e0b); }\n.ds-dial-plan-node--ring-all-users.ds-dial-plan-node--selected {\n border-color: var(--ds-color-warning, #f59e0b);\n outline-color: var(--ds-color-warning, #f59e0b);\n box-shadow: 0 0 16px 2px rgba(245, 158, 11, 0.4), 0 4px 12px rgba(245, 158, 11, 0.2);\n}\n\n.ds-dial-plan-node--external-dial {\n background: linear-gradient(135deg, #fff1f2 0%, #fecdd3 100%);\n border-color: var(--ds-color-rose, #f43f5e);\n}\n.ds-dial-plan-node--external-dial .ds-dial-plan-node__icon { color: var(--ds-color-rose, #f43f5e); }\n.ds-dial-plan-node--external-dial.ds-dial-plan-node--selected {\n border-color: var(--ds-color-rose, #f43f5e);\n outline-color: var(--ds-color-rose, #f43f5e);\n box-shadow: 0 0 16px 2px rgba(244, 63, 94, 0.4), 0 4px 12px rgba(244, 63, 94, 0.2);\n}\n\n.ds-dial-plan-node--voice-app {\n border: 2px solid transparent;\n background:\n linear-gradient(135deg, #c7d2fe 0%, #ddd6fe 40%, #bae6fd 100%) padding-box,\n linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n position: relative;\n transition: box-shadow 0.15s ease;\n}\n.ds-dial-plan-node--voice-app .ds-dial-plan-node__icon { color: #4f46e5; }\n.ds-dial-plan-node--voice-app.ds-dial-plan-node--selected {\n border-color: transparent;\n outline: none;\n box-shadow: 0 0 16px 2px rgba(99, 102, 241, 0.4), 0 4px 12px rgba(56, 189, 248, 0.2);\n}\n.ds-dial-plan-node--voice-app::after {\n content: \'\';\n position: absolute;\n inset: -7px;\n border-radius: calc(var(--ds-border-radius, 8px) + 5px);\n border: 3px solid transparent;\n background: linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: xor;\n mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);\n mask-composite: exclude;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s ease;\n z-index: -1;\n}\n.ds-dial-plan-node--voice-app.ds-dial-plan-node--selected::after { opacity: 1; }\n\n.ds-dial-plan-node--menu {\n background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);\n border-color: #ec4899;\n}\n.ds-dial-plan-node--menu .ds-dial-plan-node__icon { color: #ec4899; }\n.ds-dial-plan-node--menu.ds-dial-plan-node--selected {\n border-color: #ec4899;\n outline-color: #ec4899;\n box-shadow: 0 0 16px 2px rgba(236, 72, 153, 0.4), 0 4px 12px rgba(236, 72, 153, 0.2);\n}\n\n.ds-dial-plan-node--audio-clip {\n background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);\n border-color: #14b8a6;\n}\n.ds-dial-plan-node--audio-clip .ds-dial-plan-node__icon { color: #14b8a6; }\n.ds-dial-plan-node--audio-clip.ds-dial-plan-node--selected {\n border-color: #14b8a6;\n outline-color: #14b8a6;\n box-shadow: 0 0 16px 2px rgba(20, 184, 166, 0.4), 0 4px 12px rgba(20, 184, 166, 0.2);\n}\n\n/* ============================================================================\n Menu Config Panel — Options List\n ============================================================================ */\n\n.ds-dial-plan-config-field__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 6px;\n}\n\n.ds-dial-plan-config-field__header .ds-dial-plan-config-field__label {\n margin: 0;\n}\n\n.ds-dial-plan-menu-options {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.ds-dial-plan-menu-options__card {\n display: flex;\n align-items: flex-end;\n gap: 6px;\n}\n\n.ds-dial-plan-menu-options__field {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n\n.ds-dial-plan-menu-options__field--digit {\n flex: 0 0 64px;\n}\n\n.ds-dial-plan-menu-options__field--label {\n flex: 1;\n}\n\n.ds-dial-plan-menu-options__field-label {\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.05em;\n text-transform: uppercase;\n color: var(--ds-color-text-muted, #94a3b8);\n}\n\n.ds-dial-plan-menu-options__field-hint {\n font-weight: 400;\n text-transform: none;\n letter-spacing: 0;\n opacity: 0.8;\n}\n\n.ds-dial-plan-menu-options__remove {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: none;\n color: var(--ds-color-text-muted, #94a3b8);\n cursor: pointer;\n border-radius: 4px;\n flex-shrink: 0;\n}\n\n.ds-dial-plan-menu-options__remove:hover {\n color: var(--ds-color-danger, #ef4444);\n background: rgba(239, 68, 68, 0.1);\n}\n\n.ds-dial-plan-menu-options__add {\n padding: 3px 10px;\n border: 1px solid var(--ds-color-primary, #6366f1);\n background: none;\n color: var(--ds-color-primary, #6366f1);\n cursor: pointer;\n border-radius: 4px;\n font-size: 11px;\n font-weight: 500;\n white-space: nowrap;\n}\n\n.ds-dial-plan-menu-options__add:hover:not(:disabled) {\n background: var(--ds-color-primary, #6366f1);\n color: #ffffff;\n}\n\n.ds-dial-plan-menu-options__add:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n/* ============================================================================\n Handles\n ============================================================================ */\n\n.ds-dial-plan-handle {\n width: 10px;\n height: 10px;\n background: var(--ds-color-border, #e2e8f0);\n border: 2px solid var(--ds-color-background, #ffffff);\n}\n\n.ds-dial-plan-handle--next {\n background: var(--ds-color-text-secondary, #64748b);\n}\n\n/* ============================================================================\n React Flow Overrides (both viewer and editor)\n ============================================================================ */\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-path {\n stroke: var(--ds-color-border, #94a3b8);\n stroke-width: 2;\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge.selected .react-flow__edge-path {\n stroke: var(--ds-color-primary, #3b82f6);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-text {\n font-size: var(--ds-font-size-xs, 12px);\n fill: var(--ds-color-text-secondary, #64748b);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__background {\n background-color: var(--ds-color-background, #ffffff);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__minimap {\n background: var(--ds-color-background, #ffffff);\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls {\n border-radius: var(--ds-border-radius, 8px);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button {\n background: var(--ds-color-background, #ffffff);\n border-color: var(--ds-color-border, #e2e8f0);\n color: var(--ds-color-text, #1e293b);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button:hover {\n background: var(--ds-color-background-hover, #f8fafc);\n}\n\n/* ============================================================================\n Loading, Error, and Empty States\n ============================================================================ */\n\n.ds-dial-plan-viewer--loading,\n.ds-dial-plan-viewer--error,\n.ds-dial-plan-viewer--empty {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.ds-dial-plan-viewer__loading,\n.ds-dial-plan-viewer__error,\n.ds-dial-plan-viewer__empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-viewer__spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--ds-color-border, #e2e8f0);\n border-top-color: var(--ds-color-primary, #3b82f6);\n border-radius: 50%;\n animation: ds-dial-plan-spin 0.8s linear infinite;\n}\n\n@keyframes ds-dial-plan-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.ds-dial-plan-viewer__error {\n color: var(--ds-color-danger, #ef4444);\n}\n\n.ds-dial-plan-viewer__error-message {\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n max-width: 300px;\n text-align: center;\n}\n\n/* ============================================================================\n Config Panel\n ============================================================================ */\n\n.ds-dial-plan-config-panel {\n width: 260px;\n height: 100%;\n background: var(--ds-color-background, #ffffff);\n border-left: 1px solid var(--ds-color-border, #e2e8f0);\n display: flex;\n flex-direction: column;\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n overflow-y: auto;\n}\n\n.ds-dial-plan-config-panel__header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n border-bottom: 1px solid var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-config-panel__header-icon {\n color: var(--ds-color-text-secondary, #64748b);\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-panel__header-label {\n flex: 1;\n font-weight: 600;\n color: var(--ds-color-text, #1e293b);\n}\n\n.ds-dial-plan-config-panel__delete {\n color: var(--ds-color-danger, #ef4444);\n background: none;\n border: none;\n padding: 2px;\n cursor: pointer;\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-panel__delete:hover {\n color: #dc2626;\n}\n\n.ds-dial-plan-config-panel__close {\n background: none;\n border: none;\n color: var(--ds-color-text-secondary, #64748b);\n cursor: pointer;\n padding: 2px;\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-panel__close:hover {\n color: var(--ds-color-text, #1e293b);\n}\n\n.ds-dial-plan-config-panel__body {\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.ds-dial-plan-config-field {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.ds-dial-plan-config-field__label {\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 500;\n color: var(--ds-color-text-secondary, #64748b);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.ds-dial-plan-config-field__select,\n.ds-dial-plan-config-field__input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n background: var(--ds-color-background, #ffffff);\n color: var(--ds-color-text, #1e293b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n outline: none;\n box-sizing: border-box;\n}\n\n.ds-dial-plan-config-field__checkbox {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n cursor: pointer;\n}\n\n.ds-dial-plan-config-field__hint {\n margin: 4px 0 0;\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n line-height: 1.4;\n}\n\n.ds-dial-plan-config-field__error {\n margin: 4px 0 0;\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-danger, #ef4444);\n line-height: 1.4;\n}\n\n.ds-dial-plan-config-field__input[aria-invalid=\'true\'] {\n border-color: var(--ds-color-danger, #ef4444);\n}\n\n.ds-dial-plan-edge-panel__value {\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-edge-panel__value {\n color: #e2e8f0;\n}\n\n.ds-dial-plan-config-field__open-link {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n background: none;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-primary, #3b82f6);\n cursor: pointer;\n font-family: inherit;\n}\n\n.ds-dial-plan-config-field__open-link:hover {\n text-decoration: underline;\n}\n\n.ds-dial-plan-config-field__select:focus,\n.ds-dial-plan-config-field__input:focus {\n border-color: var(--ds-color-primary, #3b82f6);\n box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);\n}\n\n.ds-dial-plan-config-field__input:disabled {\n background: #f1f5f9;\n color: var(--ds-color-text-secondary, #64748b);\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.ds-dial-plan-config-field__input-wrapper {\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-field__input-wrapper .ds-dial-plan-config-field__input {\n padding-right: 28px;\n}\n\n.ds-dial-plan-config-field__clear {\n position: absolute;\n right: 6px;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background: transparent;\n color: var(--ds-color-text-secondary, #64748b);\n cursor: pointer;\n}\n\n.ds-dial-plan-config-field__clear:hover {\n background: var(--ds-color-border, #e2e8f0);\n color: var(--ds-color-text, #1e293b);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__clear:hover {\n background: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n.ds-dial-plan-config-field__segmented {\n display: flex;\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n overflow: hidden;\n background: var(--ds-color-background, #ffffff);\n}\n\n.ds-dial-plan-config-field__segmented-option {\n flex: 1;\n padding: 6px 8px;\n border: none;\n background: transparent;\n color: var(--ds-color-text-secondary, #64748b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n cursor: pointer;\n}\n\n.ds-dial-plan-config-field__segmented-option + .ds-dial-plan-config-field__segmented-option {\n border-left: 1px solid var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-config-field__segmented-option--active {\n background: var(--ds-color-primary, #3b82f6);\n color: #ffffff;\n font-weight: 500;\n}\n\n.ds-dial-plan-config-field__hint {\n margin: 4px 0 0;\n font-size: var(--ds-font-size-xs, 11px);\n line-height: 1.4;\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-node__badge {\n display: block;\n width: fit-content;\n margin: 4px auto 0;\n padding: 2px 8px;\n border-radius: 999px;\n background: var(--ds-color-muted, #eef2ff);\n color: var(--ds-color-text-secondary, #64748b);\n font-size: var(--ds-font-size-xs, 11px);\n font-weight: 500;\n letter-spacing: 0.3px;\n text-align: center;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__badge {\n background: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n/* ============================================================================\n Resource Combobox\n ============================================================================ */\n\n.ds-resource-combobox {\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n background: var(--ds-color-background, #ffffff);\n overflow: hidden;\n}\n\n.ds-resource-combobox__trigger {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n background: var(--ds-color-background, #ffffff);\n color: var(--ds-color-text, #1e293b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n text-align: left;\n}\n\n.ds-resource-combobox__trigger:hover {\n border-color: var(--ds-color-primary, #3b82f6);\n}\n\n.ds-resource-combobox__trigger-placeholder {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-resource-combobox__trigger-chevron {\n color: var(--ds-color-text-secondary, #64748b);\n opacity: 0.5;\n flex-shrink: 0;\n}\n\n.ds-resource-combobox__input {\n width: 100%;\n padding: 8px 10px;\n border: none;\n border-bottom: 1px solid var(--ds-color-border, #e2e8f0);\n background: transparent;\n color: var(--ds-color-text, #1e293b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n outline: none;\n box-sizing: border-box;\n}\n\n.ds-resource-combobox__input::placeholder {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-resource-combobox__list {\n max-height: 400px;\n overflow-y: auto;\n padding: 4px 0;\n}\n\n.ds-resource-combobox__group [cmdk-group-heading] {\n padding: 6px 10px 2px;\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 500;\n color: var(--ds-color-text-secondary, #64748b);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.ds-resource-combobox__item {\n padding: 6px 10px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n border-radius: 0;\n}\n\n.ds-resource-combobox__item[data-selected="true"] {\n background: var(--ds-color-primary, #3b82f6);\n color: #ffffff;\n}\n\n.ds-resource-combobox__item--selected {\n font-weight: 500;\n}\n\n.ds-resource-combobox__name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ds-resource-combobox__ext {\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n margin-left: auto;\n padding-left: 8px;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.ds-resource-combobox__check {\n font-size: 12px;\n opacity: 0.7;\n width: 16px;\n text-align: center;\n flex-shrink: 0;\n}\n\n.ds-resource-combobox__create {\n padding: 6px 10px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-primary, #3b82f6);\n cursor: pointer;\n font-style: italic;\n}\n\n.ds-resource-combobox__create[data-selected="true"] {\n background: var(--ds-color-primary, #3b82f6);\n color: #ffffff;\n}\n\n.ds-resource-combobox__empty {\n padding: 12px 10px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text-secondary, #64748b);\n text-align: center;\n}\n\n/* ============================================================================\n Dark Mode\n Activated by .dark class on an ancestor (Tailwind / next-themes convention)\n or data-theme="dark" attribute.\n ============================================================================ */\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor {\n background: #1a1a2e;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node {\n background: #1e1e32;\n border-color: rgba(255, 255, 255, 0.1);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__label,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__name {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__icon,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__type-label,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__type,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__exit-label {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__exits {\n border-top-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--themed {\n background: color-mix(in srgb, var(--node-color) 20%, #1a1a2e);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--schedule {\n background: linear-gradient(135deg, #0c2d48 0%, #0a3761 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--internal-dial {\n background: linear-gradient(135deg, #052e16 0%, #064e3b 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--voicemail {\n background: linear-gradient(135deg, #2e1065 0%, #3b0764 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--ring-all-users {\n background: linear-gradient(135deg, #451a03 0%, #78350f 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--external-dial {\n background: linear-gradient(135deg, #4c0519 0%, #881337 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--voice-app {\n background:\n linear-gradient(135deg, #252262 0%, #3b1d7e 40%, #0c3a5e 100%) padding-box,\n linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--menu {\n background: linear-gradient(135deg, #500724 0%, #831843 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--audio-clip {\n background: linear-gradient(135deg, #042f2e 0%, #115e59 100%);\n}\n\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-handle {\n border-color: #1e1e32;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__background {\n background-color: #1a1a2e;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-path {\n stroke: rgba(255, 255, 255, 0.2);\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-text {\n fill: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__minimap {\n background: #1e1e32;\n border-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls {\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button {\n background: #1e1e32;\n border-color: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button:hover {\n background: #2a2a45;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer__loading,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer__empty {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer__spinner {\n border-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel {\n background: #1e1e32;\n border-left-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__header {\n border-bottom-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__header-label {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__close {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__close:hover {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__label {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__checkbox {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__select,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__input {\n background: #12122a;\n border-color: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__input:disabled {\n background: #1e1e38;\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__trigger {\n background: #12122a;\n border-color: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox {\n border-color: rgba(255, 255, 255, 0.1);\n background: #12122a;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__input {\n color: #e2e8f0;\n border-bottom-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__item {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__item--selected {\n color: #e2e8f0;\n}\n\n/* Node Library */\n\n.ds-dial-plan-node-library {\n width: 200px;\n height: 100%;\n background: var(--ds-color-background, #ffffff);\n border-right: 1px solid var(--ds-color-border, #e2e8f0);\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 12px;\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n overflow-y: auto;\n}\n\n.ds-dial-plan-node-library__item {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n padding: 10px 12px;\n border-radius: var(--ds-border-radius, 8px);\n border: 2px solid var(--node-color, var(--ds-color-border, #e2e8f0));\n background: color-mix(in srgb, var(--node-color, #ffffff) 10%, white);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n cursor: grab;\n transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;\n}\n\n.ds-dial-plan-node-library__item:hover {\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);\n transform: translateY(-1px);\n}\n\n.ds-dial-plan-node-library__item:active {\n cursor: grabbing;\n transform: scale(0.97);\n}\n\n/* Per-type library item colors */\n.ds-dial-plan-node-library__item--schedule { background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border-color: var(--ds-color-info, #0ea5e9); }\n.ds-dial-plan-node-library__item--internal_dial { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border-color: var(--ds-color-success, #22c55e); }\n.ds-dial-plan-node-library__item--voicemail { background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%); border-color: var(--ds-color-purple, #a855f7); }\n.ds-dial-plan-node-library__item--ring_all_users { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border-color: var(--ds-color-warning, #f59e0b); }\n.ds-dial-plan-node-library__item--external_dial { background: linear-gradient(135deg, #fff1f2 0%, #fecdd3 100%); border-color: var(--ds-color-rose, #f43f5e); }\n.ds-dial-plan-node-library__item--voice_app,\n.ds-dial-plan-node-library__item--voice_app:hover {\n border: 2px solid transparent;\n background: linear-gradient(135deg, #c7d2fe 0%, #ddd6fe 40%, #bae6fd 100%) padding-box, linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n}\n.ds-dial-plan-node-library__item--menu { background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%); border-color: #ec4899; }\n.ds-dial-plan-node-library__item--audio_clip { background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%); border-color: #14b8a6; }\n\n.ds-dial-plan-node-library__item-icon {\n display: flex;\n align-items: center;\n color: var(--node-color);\n}\n.ds-dial-plan-node-library__item--schedule .ds-dial-plan-node-library__item-icon { color: var(--ds-color-info, #0ea5e9); }\n.ds-dial-plan-node-library__item--internal_dial .ds-dial-plan-node-library__item-icon { color: var(--ds-color-success, #22c55e); }\n.ds-dial-plan-node-library__item--voicemail .ds-dial-plan-node-library__item-icon { color: var(--ds-color-purple, #a855f7); }\n.ds-dial-plan-node-library__item--ring_all_users .ds-dial-plan-node-library__item-icon { color: var(--ds-color-warning, #f59e0b); }\n.ds-dial-plan-node-library__item--external_dial .ds-dial-plan-node-library__item-icon { color: var(--ds-color-rose, #f43f5e); }\n.ds-dial-plan-node-library__item--voice_app .ds-dial-plan-node-library__item-icon { color: #4f46e5; }\n.ds-dial-plan-node-library__item--menu .ds-dial-plan-node-library__item-icon { color: #ec4899; }\n.ds-dial-plan-node-library__item--audio_clip .ds-dial-plan-node-library__item-icon { color: #14b8a6; }\n\n.ds-dial-plan-node-library__item-label {\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 600;\n color: var(--ds-color-text, #1e293b);\n text-align: center;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library {\n background: #1e1e32;\n border-right-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item {\n background: color-mix(in srgb, var(--node-color, #1e1e32) 20%, #1e1e32);\n border-color: rgba(255, 255, 255, 0.1);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--schedule { background: linear-gradient(135deg, #0c2d48 0%, #0a3761 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--internal_dial { background: linear-gradient(135deg, #052e16 0%, #064e3b 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--voicemail { background: linear-gradient(135deg, #2e1065 0%, #3b0764 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--ring_all_users { background: linear-gradient(135deg, #451a03 0%, #78350f 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--external_dial { background: linear-gradient(135deg, #4c0519 0%, #881337 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--voice_app { background: linear-gradient(135deg, #252262 0%, #3b1d7e 40%, #0c3a5e 100%) padding-box, linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box; }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--menu { background: linear-gradient(135deg, #500724 0%, #831843 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--audio_clip { background: linear-gradient(135deg, #042f2e 0%, #115e59 100%); }\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item-label {\n color: #e2e8f0;\n}\n\n/* ============================================================================\n Editor Toolbar\n ============================================================================ */\n\n.ds-dial-plan-editor-toolbar {\n position: absolute;\n top: 16px;\n right: 16px;\n z-index: 10;\n display: flex;\n gap: 8px;\n}\n\n.ds-dial-plan-editor-toolbar__button {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 12px;\n background: var(--ds-color-background, #ffffff);\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n color: var(--ds-color-text, #1e293b);\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n font-weight: 500;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.ds-dial-plan-editor-toolbar__button:hover {\n background: var(--ds-color-background-hover, #f1f5f9);\n border-color: var(--ds-color-border, #cbd5e1);\n}\n\n.ds-dial-plan-editor-toolbar__button:active {\n transform: scale(0.98);\n}\n\n.ds-dial-plan-editor-toolbar__button:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.ds-dial-plan-editor-toolbar__button:disabled:hover {\n background: var(--ds-color-background, #ffffff);\n border-color: var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-editor-toolbar__button svg {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button {\n background: #1e293b;\n border-color: #334155;\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button:hover {\n background: #334155;\n border-color: #475569;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button:disabled:hover {\n background: #1e293b;\n border-color: #334155;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button svg {\n color: #cbd5e1;\n}\n\n/* Editor Layout */\n\n.ds-dial-plan-editor {\n display: flex;\n width: 100%;\n height: 100%;\n flex: 1;\n min-height: 400px;\n background: var(--ds-color-background, #ffffff);\n overflow: hidden;\n}\n\n.ds-dial-plan-editor--preview {\n min-height: 0;\n}\n\n.ds-dial-plan-editor__canvas {\n flex: 1;\n position: relative;\n}\n\n/* Node Library wrapper */\n\n.ds-dial-plan-node-library-wrapper {\n width: 200px;\n flex-shrink: 0;\n align-self: stretch;\n overflow: hidden;\n}\n\n/* Config panel wrapper (slide-in animation) */\n\n.ds-dial-plan-config-panel-wrapper {\n width: 0;\n flex-shrink: 0;\n align-self: stretch;\n overflow: hidden;\n transition: width 0.2s ease;\n}\n\n.ds-dial-plan-config-panel-wrapper--open {\n width: 260px;\n}\n\n\n'],we=e.forwardRef((a,t)=>{var l;const{dialstack:r}=o.useDialstackComponents();o.useReportComponent("dial-plan");const i=function(n){const[o,a]=e.useState(()=>n.getAppearance());return e.useEffect(()=>{if("undefined"==typeof document)return;const e=document.createElement("div"),o=e=>{const n=e.detail;a(null==n?void 0:n.appearance)};return e.addEventListener("dialstack-appearance-update",o),n.addAppearanceTarget(e),()=>{n.removeAppearanceTarget(e),e.removeEventListener("dialstack-appearance-update",o)}},[n]),o}(r),d="dark"===(null==i?void 0:i.theme)?"dark":"light",s=null!==(l=a.theme)&&void 0!==l?l:d;return e.createElement(ue,{stylesheets:ye,className:a.className,style:Object.assign({width:"100%",height:"100%",flex:1,minHeight:0},a.style)},e.createElement("div",{"data-theme":s,style:{display:"flex",flexDirection:"column",flex:1,minHeight:0}},e.createElement(n.ReactFlowProvider,null,e.createElement(xe,Object.assign({ref:t},a)))))});we.displayName="DialPlan",exports.DialPlan=we;
1
+ "use strict";var e=require("react"),n=require("@xyflow/react"),o=require("@dialstack/sdk-react"),a=require("dagre"),t=require("cmdk"),l=require("libphonenumber-js"),r=require("react-dom");function i(e,n,o,a){return new(o||(o=Promise))(function(t,l){function r(e){try{d(a.next(e))}catch(e){l(e)}}function i(e){try{d(a.throw(e))}catch(e){l(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o(function(e){e(n)})).then(r,i)}d((a=a.apply(e,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const d="smoothstep";function s(e,n){var o,a;return null!==(a=null===(o=e.visibleExits)||void 0===o?void 0:o.call(e,n))&&void 0!==a?a:e.exits}const c=({icon:n,label:o,timeout:a,subtitle:t})=>e.createElement("div",{className:"ds-dial-plan-node__header"},e.createElement("div",{className:"ds-dial-plan-node__icon"},n),e.createElement("span",{className:"ds-dial-plan-node__type-label"},o,void 0!==a&&e.createElement("span",{style:{textTransform:"none"}}," (",a,"s)")),t&&e.createElement("span",{className:"ds-dial-plan-node__name"},t)),u=({id:o,label:a})=>e.createElement("div",{className:"ds-dial-plan-node__exit-row"},e.createElement("span",{className:"ds-dial-plan-node__exit-label"},a),e.createElement(n.Handle,{type:"source",position:n.Position.Right,id:o,className:"ds-dial-plan-handle ds-dial-plan-handle--next"})),p=({exits:n,locale:o})=>0===n.length?null:e.createElement(e.Fragment,null,n.map(n=>e.createElement(u,{key:n.id,id:n.id,label:n.localeExitKey&&(null==o?void 0:o.exits[n.localeExitKey])||n.label})));function f(e,n){const o=e,a=(null==o?void 0:o[n])||(null==o?void 0:o[`${n}_id`]);return"string"==typeof a?a:""}function g(e,n){return{[e]:n,[`${e}_id`]:n}}function b(e,n){return e.startsWith("user_")?n.targetTypes.user:e.startsWith("rg_")?n.targetTypes.ringGroup:e.startsWith("dp_")?n.targetTypes.dialPlan:e.startsWith("qu_")?n.targetTypes.queue:e.startsWith("va_")?n.targetTypes.voiceApp:e.startsWith("svm_")?n.targetTypes.sharedVoicemail:n.nodeTypes.internalDial}function m(e){var n;return null!==(n=null==e?void 0:e.startsWith("dp_"))&&void 0!==n&&n}function v(e,n,o){const a=n.users.get(e),t=(null==a?void 0:a.name)||(null==a?void 0:a.email);return t&&(null==a?void 0:a.extension_number)?`${t} (${o.combobox.extensionLabel} ${a.extension_number})`:t}const h=({resourceId:n,onOpenResource:o,label:a})=>e.createElement("button",{type:"button",className:"ds-dial-plan-config-field__open-link",onClick:()=>o(n)},e.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"15 3 21 3 21 9"}),e.createElement("polyline",{points:"9 21 3 21 3 15"}),e.createElement("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.createElement("line",{x1:"3",y1:"21",x2:"10",y2:"14"})),a),_=({groups:n,value:o,loading:a=!1,placeholder:l="Search…",onSelect:r,onCreateResource:d,selectLabel:s="— Select —",noResultsLabel:c="No results found",loadingLabel:u="Loading…",createNewPrefix:p="+ Create new…",extensionLabel:f="Ext."})=>{const[g,b]=e.useState(!1),[m,v]=e.useState(""),h=e.useRef(null);e.useEffect(()=>{var e;if(!g)return;const n=null===(e=h.current)||void 0===e?void 0:e.getRootNode(),o=n instanceof ShadowRoot||n instanceof Document?n:document,a=e=>function(e){"Escape"===e.key&&(b(!1),v(""))}(e),t=e=>function(e){h.current&&!h.current.contains(e.target)&&(b(!1),v(""))}(e);return o.addEventListener("keydown",a),o.addEventListener("mousedown",t),()=>{o.removeEventListener("keydown",a),o.removeEventListener("mousedown",t)}},[g]);const _=e.useMemo(()=>{if(!o)return"";for(const e of n){const n=e.items.find(e=>e.id===o);if(n)return n.extension_number?`${n.name} (${f} ${n.extension_number})`:n.name}return""},[o,n,f]);if(!g)return e.createElement("button",{type:"button",className:"ds-resource-combobox__trigger",onClick:()=>b(!0)},e.createElement("span",{className:_?"":"ds-resource-combobox__trigger-placeholder"},_||s),e.createElement("svg",{className:"ds-resource-combobox__trigger-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"6 9 12 15 18 9"})));const x=n.some(e=>e.items.length>0);return e.createElement("div",{ref:h},e.createElement(t.Command,{className:"ds-resource-combobox",shouldFilter:!0,loop:!0},e.createElement(t.Command.Input,{className:"ds-resource-combobox__input",placeholder:l,value:m,onValueChange:v,autoFocus:!0}),e.createElement(t.Command.List,{className:"ds-resource-combobox__list"},e.createElement(t.Command.Empty,{className:"ds-resource-combobox__empty"},c),n.map(n=>e.createElement(t.Command.Group,{key:n.label,heading:n.label,className:"ds-resource-combobox__group"},n.items.map(a=>{var l;return e.createElement(t.Command.Item,{key:a.id,value:`${a.name} ${null!==(l=a.extension_number)&&void 0!==l?l:""} ${n.label} ${a.id}`,className:"ds-resource-combobox__item"+(a.id===o?" ds-resource-combobox__item--selected":""),onSelect:()=>{return e=a.id,n=a.extension_number?`${a.name} (${f} ${a.extension_number})`:a.name,r(e,n),b(!1),void v("");var e,n}},e.createElement("span",{className:"ds-resource-combobox__name"},a.name),a.extension_number&&e.createElement("span",{className:"ds-resource-combobox__ext"},"(",f," ",a.extension_number,")"),e.createElement("span",{className:"ds-resource-combobox__check"},a.id===o?"✓":""))}),d&&n.type&&e.createElement(t.Command.Item,{forceMount:!0,value:`create new ${n.label}`,className:"ds-resource-combobox__create",onSelect:()=>function(e){return i(this,void 0,void 0,function*(){if(!d)return;const n=yield d(e);n&&(r(n.id,n.extension_number?`${n.name} (${f} ${n.extension_number})`:n.name),b(!1),v(""))})}(n.type)},p))),!x&&!m&&a&&e.createElement("div",{className:"ds-resource-combobox__empty"},u))))},x=({label:n,htmlFor:o,action:a,children:t})=>e.createElement("div",{className:"ds-dial-plan-config-field"},a?e.createElement("div",{className:"ds-dial-plan-config-field__header"},e.createElement("label",{className:"ds-dial-plan-config-field__label",htmlFor:o},n),a):e.createElement("label",{className:"ds-dial-plan-config-field__label",htmlFor:o},n),t);function y(n,o,a,t){const[l,r]=e.useState([]),[d,s]=e.useState(!0),c=e.useMemo(()=>JSON.stringify(n),[n]),u=e.useCallback(()=>Promise.all(n.map(e=>o(e.type,e.options))).then(e=>{r(n.map((n,o)=>{var a,l;return{label:null!==(a=null==t?void 0:t.resourceGroups[n.labelKey])&&void 0!==a?a:n.fallback,type:n.type,items:null!==(l=e[o])&&void 0!==l?l:[]}}))}).catch(()=>{}).finally(()=>s(!1)),[o,t,c]);e.useEffect(()=>{u()},[u]);const p=e.useCallback(e=>i(this,void 0,void 0,function*(){var o;if(!a)return;const t=null===(o=n.find(n=>n.type===e))||void 0===o?void 0:o.options,l=yield a(e,t);return l&&(yield u()),l}),[a,u,c]);return{groups:l,loading:d,handleCreateResource:a?p:void 0}}const w=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("polyline",{points:"12 6 12 12 16 14"})),k=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})),E=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),e.createElement("circle",{cx:"9",cy:"7",r:"4"}),e.createElement("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),e.createElement("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})),N=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"23 7 23 1 17 1"}),e.createElement("line",{x1:"16",y1:"8",x2:"23",y2:"1"}),e.createElement("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})),C=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("circle",{cx:"5.5",cy:"11.5",r:"4.5"}),e.createElement("circle",{cx:"18.5",cy:"11.5",r:"4.5"}),e.createElement("line",{x1:"5.5",y1:"16",x2:"18.5",y2:"16"})),L=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M12 8V4H8"}),e.createElement("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),e.createElement("path",{d:"M2 14h2"}),e.createElement("path",{d:"M20 14h2"}),e.createElement("path",{d:"M15 13v2"}),e.createElement("path",{d:"M9 13v2"})),O=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("rect",{x:"3",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"3",y:"14",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"14",width:"7",height:"7"})),S=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91"}),e.createElement("line",{x1:"23",y1:"1",x2:"1",y2:"23"})),R=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.createElement("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.createElement("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})),z={type:"schedule",flowType:"schedule",localeKey:"schedule",label:"Schedule",description:"Route calls by schedule",color:"#0ea5e9",exits:[{id:"open",label:"Open",configKey:"open",localeExitKey:"open"},{id:"closed",label:"Closed",configKey:"closed",localeExitKey:"closed"},{id:"holiday",label:"Holiday",configKey:"holiday",localeExitKey:"holiday"}],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,onOpenResource:l,locale:r})=>{var i,d,s,c,u;const{groups:p,loading:b,handleCreateResource:m}=y([{type:"schedule",labelKey:"schedules",fallback:"Schedules"}],a,t,r),v=f(n,"schedule"),w=void 0!==n.holiday;return e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(i=null==r?void 0:r.configLabels.schedule)&&void 0!==i?i:"Schedule"},e.createElement(_,{groups:p,value:v,loading:b,placeholder:null!==(d=null==r?void 0:r.configLabels.searchSchedules)&&void 0!==d?d:"Search schedules…",onSelect:(e,n)=>o(g("schedule",e),{scheduleName:n}),onCreateResource:m,selectLabel:null==r?void 0:r.combobox.select,noResultsLabel:null==r?void 0:r.combobox.noResults,loadingLabel:null==r?void 0:r.combobox.loading,createNewPrefix:null==r?void 0:r.combobox.createNew,extensionLabel:null==r?void 0:r.combobox.extensionLabel}),v&&l&&e.createElement(h,{resourceId:v,onOpenResource:l,label:null!==(s=null==r?void 0:r.configLabels.openInNewTab)&&void 0!==s?s:"Open target details"})),e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("label",{className:"ds-dial-plan-config-field__checkbox"},e.createElement("input",{type:"checkbox",checked:w,onChange:e=>{return n=e.target.checked,o({holiday:n?null:void 0},{holidayEnabled:n});var n}}),e.createElement("span",null,null!==(c=null==r?void 0:r.configLabels.routeHolidaySeparately)&&void 0!==c?c:"Route holidays separately")),e.createElement("p",{className:"ds-dial-plan-config-field__hint"},null!==(u=null==r?void 0:r.configLabels.routeHolidaySeparatelyHint)&&void 0!==u?u:"When on, holidays route to a dedicated branch you wire below. Otherwise holidays follow the Closed exit.")))},defaultConfig:{schedule:"",schedule_id:""},icon:w,renderNode:(n,o)=>{const a=n.locale,t=o.exits.slice(0,n.holidayEnabled?3:2);return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.scheduleName}),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:t,locale:a})))},toFlowNode:e=>{const n=e;return{label:"Schedule",scheduleId:f(n.config,"schedule"),holidayEnabled:void 0!==n.config.holiday,originalNode:n}},collectResourceIds:(e,n)=>{const o=f(e,"schedule");o&&n.addSchedule(o)},enrichNode:(e,n,o)=>{const a=n.schedules.get(e.scheduleId);return Object.assign(Object.assign({},e),{scheduleName:null==a?void 0:a.name,locale:o})},onConfigChange:(e,n,o)=>{"holiday"in n&&void 0===n.holiday&&(o.setEdges(n=>{const a=n.filter(n=>!(n.source===e&&"holiday"===n.sourceHandle));return a.length!==n.length&&o.updateDirty(o.nodesRef.current,a),a}),requestAnimationFrame(()=>o.updateNodeInternals(e)))},serializeConfig:(e,n,o)=>{var a;return(null===(a=e.data)||void 0===a?void 0:a.holidayEnabled)&&void 0===o.holiday?Object.assign(Object.assign({},o),{holiday:null}):o}},T=({value:n,min:o,max:a,disabled:t=!1,onChange:l,locale:r})=>{var i;return e.createElement(x,{label:null!==(i=null==r?void 0:r.configLabels.timeout)&&void 0!==i?i:"Timeout (seconds)"},e.createElement("input",{className:"ds-dial-plan-config-field__input",type:"number",min:o,max:a,value:n,disabled:t,onChange:e=>l(Math.min(a,Math.max(o,Number(e.target.value)||o)))}))},j={type:"ring_all_users",flowType:"ringAllUsers",localeKey:"ringAllUsers",label:"Ring All",description:"Ring all account users",color:"#f59e0b",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({config:n,onConfigChange:o,locale:a})=>{var t;const l=null!==(t=n.timeout)&&void 0!==t?t:24;return e.createElement(T,{value:l,min:1,max:300,onChange:e=>o({timeout:e}),locale:a})},defaultConfig:{timeout:24},icon:E,renderNode:(n,o)=>e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:n.timeout}),o.exits.length>0&&e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale}))),toFlowNode:e=>{const n=e;return{label:"Ring All",timeout:n.config.timeout,originalNode:n}}};function A({label:n,value:o,options:a,onChange:t,hint:l}){return e.createElement(x,{label:n},e.createElement("div",{className:"ds-dial-plan-config-field__segmented",role:"radiogroup","aria-label":n},a.map(n=>{const a=n.value===o;return e.createElement("button",{key:n.value,type:"button",role:"radio","aria-checked":a,className:"ds-dial-plan-config-field__segmented-option"+(a?" ds-dial-plan-config-field__segmented-option--active":""),onClick:()=>{a||t(n.value)}},n.label)})),l&&e.createElement("p",{className:"ds-dial-plan-config-field__hint"},l))}const I={type:"internal_dial",flowType:"internalDial",localeKey:"internalDial",label:"Internal Extension",description:"Ring a user, group, or plan",color:"#22c55e",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({nodeId:n,config:o,nodeData:a,onConfigChange:t,listResources:l,onCreateResource:r,onOpenResource:i,locale:d})=>{var s,c,u,p,b,v,w,k;const{groups:E,loading:N,handleCreateResource:C}=y([{type:"user",labelKey:"users",fallback:"Users"},{type:"ring_group",labelKey:"ringGroups",fallback:"Ring Groups"},{type:"queue",labelKey:"queues",fallback:"Queues"},{type:"dial_plan",labelKey:"dialPlans",fallback:"Dial Plans"}],l,r,d),L=f(o,"target"),O=null!==(s=o.timeout)&&void 0!==s?s:30,S=null!==(c=o.timeout_override)&&void 0!==c&&c,R=S?1:0,z=!0===(null==a?void 0:a.timeoutInert),j=e.useRef(null);return e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(u=null==d?void 0:d.configLabels.target)&&void 0!==u?u:"Target"},e.createElement(_,{groups:E,value:L,loading:N,placeholder:null!==(p=null==d?void 0:d.configLabels.searchTargets)&&void 0!==p?p:"Search targets…",onSelect:(e,n)=>t(g("target",e),{targetName:n}),onCreateResource:C,selectLabel:null==d?void 0:d.combobox.select,noResultsLabel:null==d?void 0:d.combobox.noResults,loadingLabel:null==d?void 0:d.combobox.loading,createNewPrefix:null==d?void 0:d.combobox.createNew,extensionLabel:null==d?void 0:d.combobox.extensionLabel}),L&&i&&e.createElement(h,{resourceId:L,onOpenResource:i,label:null!==(b=null==d?void 0:d.configLabels.openInNewTab)&&void 0!==b?b:"Open target details"})),!m(L)&&e.createElement(e.Fragment,null,e.createElement(A,{label:null!==(v=null==d?void 0:d.configLabels.timeoutOverride)&&void 0!==v?v:"Override resource timeout",value:S?"on":"off",options:[{value:"off",label:null!==(w=null==d?void 0:d.configLabels.timeoutOverrideOff)&&void 0!==w?w:"Off"},{value:"on",label:null!==(k=null==d?void 0:d.configLabels.timeoutOverrideOn)&&void 0!==k?k:"On"}],onChange:e=>{if("on"===e)return j.current=0===O?{nodeId:n,timeout:0}:null,void t(0===O?{timeout_override:!0,timeout:1}:{timeout_override:!0});const o=j.current,a=o&&o.nodeId===n?o.timeout:void 0;j.current=null,t(void 0===a?{timeout_override:!1}:{timeout_override:!1,timeout:a})}}),e.createElement(T,{value:O,min:R,max:300,disabled:z,onChange:e=>{j.current=null,t({timeout:e})},locale:d})))},defaultConfig:{target:"",target_id:"",timeout:30,timeout_override:!0},icon:k,renderNode:(n,o)=>{const a=m(n.targetId);return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:a||n.timeoutInert?void 0:n.timeout,subtitle:n.targetName}),!a&&e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale})))},toFlowNode:e=>{var n;const o=e;return{label:"Internal Extension",targetId:f(o.config,"target"),timeout:o.config.timeout,timeoutOverride:null!==(n=o.config.timeout_override)&&void 0!==n&&n,originalNode:o}},visibleExits:e=>m(f(e,"target"))?[]:I.exits,collectResourceIds:(e,n)=>{const o=f(e,"target");o&&n.addTarget(o)},enrichNode:(e,n,o)=>{const a=e.targetId,t=v(a,n,o),l=b(a,o),r=e.timeout,i=!e.timeoutOverride&&0!==r&&function(e,n){var o;return void 0!==(null===(o=n.users.get(e))||void 0===o?void 0:o.timeout_seconds)}(a,n),d=e.timeoutOverride?function(e,n,o){var a;if(0===n)return 0;const t=null===(a=o.users.get(e))||void 0===a?void 0:a.timeout_seconds;return void 0===n?t:e.startsWith("user_")&&void 0!==t?Math.min(n,t):n}(a,r,n):r;return Object.assign(Object.assign({},e),{targetName:t,targetType:l,timeout:d,timeoutInert:i,locale:o})}};function F(e){if(!e)return"";const n=l.parsePhoneNumberFromString(e);if(!n)return e;return"US"===n.country||"1"===n.countryCallingCode?n.formatNational():n.formatInternational()}const P=e=>e.startsWith("+")?"+"+e.slice(1).replace(/\D/g,""):e.replace(/\D/g,""),D=({value:n,listResources:o,onSelect:a,locale:t})=>{var l,r;const{groups:i,loading:d}=y([{type:"phone_number",labelKey:"phoneNumbers",fallback:"Phone Numbers"}],o,void 0,t);return e.createElement(x,{label:null!==(l=null==t?void 0:t.configLabels.callerIdNumber)&&void 0!==l?l:"Number to show"},e.createElement(_,{groups:i,value:n,loading:d,placeholder:null!==(r=null==t?void 0:t.configLabels.searchPhoneNumbers)&&void 0!==r?r:"Search phone numbers...",onSelect:e=>a(e),selectLabel:null==t?void 0:t.combobox.select,noResultsLabel:null==t?void 0:t.combobox.noResults,loadingLabel:null==t?void 0:t.combobox.loading}))},M={type:"external_dial",flowType:"externalDial",localeKey:"externalDial",label:"External Number",description:"Ring an external phone number",color:"#f43f5e",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({nodeId:n,config:o,onConfigChange:a,onInvalidDraftChange:t,listResources:r,locale:i})=>{var d,s,c,u,p,f,g,b,m,v,h,_;const y=null!==(d=o.phone_number)&&void 0!==d?d:"",w=null!==(s=o.timeout)&&void 0!==s?s:60,k=null!==(c=o.caller_id)&&void 0!==c?c:"original",E=null!==(u=o.caller_id_did)&&void 0!==u?u:"",N="did"===k&&!E,[C,L]=e.useState(F(y)),[O,S]=e.useState(null),R=e.useId(),z=`${R}-phone`,j=`${R}-error`,[I,M]=e.useState({nodeId:n,e164:y});I.nodeId===n&&I.e164===y||(M({nodeId:n,e164:y}),L(F(y)),S(null)),e.useEffect(()=>(null==t||t(null!==O||N),()=>null==t?void 0:t(!1)),[O,N,t]);const H=null!==(p=null==i?void 0:i.configLabels.phoneNumberInvalid)&&void 0!==p?p:"Enter a valid phone number, for example (415) 555-1234.",$=e.useCallback(e=>{const n=P(e.target.value);L(n?new l.AsYouType("US").input(n):""),S(null);const o=(e=>{const n=e?l.parsePhoneNumberFromString(e,"US"):null;return(null==n?void 0:n.isValid())?n.number:null})(n);o?a({phone_number:o}):n||a({phone_number:""})},[a]),K=e.useCallback(()=>{const e=P(C);if(!e)return S(null),void a({phone_number:""});const n=l.parsePhoneNumberFromString(e,"US");if(null==n?void 0:n.isValid()){const e="US"===n.country||"1"===n.countryCallingCode;return L(e?n.formatNational():n.formatInternational()),S(null),void a({phone_number:n.number})}S(H)},[C,H,a]),B=e.useCallback(()=>{L(""),S(null),a({phone_number:""})},[a]);return e.createElement(e.Fragment,null,e.createElement(T,{value:w,min:1,max:120,onChange:e=>a({timeout:e}),locale:i}),e.createElement(x,{label:null!==(f=null==i?void 0:i.configLabels.phoneNumber)&&void 0!==f?f:"Phone Number",htmlFor:z},e.createElement("div",{className:"ds-dial-plan-config-field__input-wrapper"},e.createElement("input",{id:z,className:"ds-dial-plan-config-field__input",type:"tel",placeholder:"+1 415 555 1234",value:C,onChange:$,onBlur:K,"aria-invalid":!!O||void 0,"aria-describedby":O?j:void 0}),C&&e.createElement("button",{type:"button",className:"ds-dial-plan-config-field__clear",onClick:B,"aria-label":null!==(g=null==i?void 0:i.configLabels.clearPhoneNumber)&&void 0!==g?g:"Clear phone number"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5l7 7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})))),O&&e.createElement("p",{className:"ds-dial-plan-config-field__error",id:j,role:"alert"},O)),e.createElement(A,{label:null!==(b=null==i?void 0:i.configLabels.callerId)&&void 0!==b?b:"Caller ID",value:k,options:[{value:"original",label:null!==(m=null==i?void 0:i.configLabels.callerIdOriginal)&&void 0!==m?m:"Original caller"},{value:"called_number",label:null!==(v=null==i?void 0:i.configLabels.callerIdCalledNumber)&&void 0!==v?v:"Number called"},{value:"did",label:null!==(h=null==i?void 0:i.configLabels.callerIdSpecific)&&void 0!==h?h:"Specific number"}],onChange:e=>a({caller_id:"original"===e?void 0:e,caller_id_did:void 0}),hint:null!==(_=null==i?void 0:i.configLabels.callerIdHint)&&void 0!==_?_:"Show the number that was called so the person you forward to knows it's coming from your office."}),"did"===k&&e.createElement(D,{value:E,listResources:r,onSelect:e=>a({caller_id_did:e}),locale:i}))},defaultConfig:{phone_number:"",timeout:60},icon:N,renderNode:(n,o)=>e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:n.timeout,subtitle:n.phoneNumber}),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale}))),toFlowNode:e=>{const n=e;return{label:"External Number",phoneNumber:F(n.config.phone_number),timeout:n.config.timeout,originalNode:n}}},H={type:"voice_app",flowType:"voiceApp",localeKey:"voiceApp",label:"Voice App",description:"Route to a voice application",color:"#6366f1",exits:[{id:"next",label:"Timeout",configKey:"next",localeExitKey:"timeout"}],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,onOpenResource:l,locale:r})=>{var i,d,s,c,u,p,b,m,v;const w=f(n,"voice_app"),k=null!==(i=n.mode)&&void 0!==i?i:"control",{groups:E,handleCreateResource:N}=y([{type:"voice_app",labelKey:"voiceApps",fallback:"Voice Apps",options:{notifyEligible:"notify"===k}}],a,t,r);return e.useEffect(()=>{var e,n;if("notify"!==k||!w)return;const a=null!==(n=null===(e=E[0])||void 0===e?void 0:e.items)&&void 0!==n?n:[];if(0===a.length)return;a.some(e=>e.id===w)||o(g("voice_app",""),{voiceAppName:void 0})},[k,w,E,o]),e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(d=null==r?void 0:r.configLabels.target)&&void 0!==d?d:"Target"},e.createElement(_,{groups:E,value:w,placeholder:null!==(s=null==r?void 0:r.configLabels.searchTargets)&&void 0!==s?s:"Search targets…",onSelect:(e,n)=>o(g("voice_app",e),{voiceAppName:n}),onCreateResource:N,selectLabel:null==r?void 0:r.combobox.select,noResultsLabel:null==r?void 0:r.combobox.noResults,loadingLabel:null==r?void 0:r.combobox.loading,createNewPrefix:null==r?void 0:r.combobox.createNew,extensionLabel:null==r?void 0:r.combobox.extensionLabel}),w&&l&&e.createElement(h,{resourceId:w,onOpenResource:l,label:null!==(c=null==r?void 0:r.configLabels.openInNewTab)&&void 0!==c?c:"Open target details"})),e.createElement(A,{label:null!==(u=null==r?void 0:r.configLabels.mode)&&void 0!==u?u:"Mode",value:k,options:[{value:"control",label:null!==(p=null==r?void 0:r.voiceAppMode.control)&&void 0!==p?p:"Control"},{value:"notify",label:null!==(b=null==r?void 0:r.voiceAppMode.notify)&&void 0!==b?b:"Notify"}],onChange:e=>o({mode:e}),hint:"notify"===k?null!==(m=null==r?void 0:r.voiceAppMode.notifyHint)&&void 0!==m?m:"Notifies the voice app of the call in the background. The dial plan keeps routing via Next without waiting.":null!==(v=null==r?void 0:r.voiceAppMode.controlHint)&&void 0!==v?v:"Hands the call off to the voice app, which takes over the conversation."}))},defaultConfig:{voice_app:"",voice_app_id:"",mode:"control"},icon:L,renderNode:(n,o)=>{var a,t,l,r;const i=n.locale,d="notify"===n.mode,s=d?null!==(a=null==i?void 0:i.voiceAppMode.notifyBadge)&&void 0!==a?a:"Notify mode":null!==(t=null==i?void 0:i.voiceAppMode.controlBadge)&&void 0!==t?t:"Control mode",p=d?null!==(l=null==i?void 0:i.exits.next)&&void 0!==l?l:"Next":null!==(r=null==i?void 0:i.exits.timeout)&&void 0!==r?r:"Timeout";return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.voiceAppName}),e.createElement("span",{className:"ds-dial-plan-node__badge"},s),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(u,{id:"next",label:p})))},toFlowNode:e=>{var n;const o=e;return{label:"Voice App",voiceAppId:f(o.config,"voice_app"),mode:null!==(n=o.config.mode)&&void 0!==n?n:"control",originalNode:o}},normalizeFromAlias:e=>{const n=e.config,o=f(n,"target"),a=n.next;return Object.assign(Object.assign({},e),{type:"voice_app",config:Object.assign(Object.assign(Object.assign({},g("voice_app",o)),{mode:"control"}),void 0!==a?{next:a}:{})})},collectResourceIds:(e,n)=>{const o=f(e,"voice_app");o&&n.addTarget(o)},enrichNode:(e,n,o)=>{const a=e.voiceAppId,t=a?v(a,n,o):void 0;return Object.assign(Object.assign({},e),{voiceAppName:t,locale:o})}},$={type:"voicemail",apiType:"internal_dial",flowType:"voicemail",localeKey:"voicemail",label:"Voicemail",description:"Send to voicemail",color:"#8b5cf6",exits:[],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,onOpenResource:l,locale:r})=>{var i,d,s;const{groups:c,loading:u,handleCreateResource:p}=y([{type:"user",labelKey:"users",fallback:"Users"},{type:"shared_voicemail",labelKey:"sharedVoicemails",fallback:"Shared Voicemails"}],a,t,r),b=f(n,"target");return e.createElement(x,{label:null!==(i=null==r?void 0:r.configLabels.target)&&void 0!==i?i:"Target"},e.createElement(_,{groups:c,value:b,loading:u,placeholder:null!==(d=null==r?void 0:r.configLabels.searchTargets)&&void 0!==d?d:"Search targets…",onSelect:(e,n)=>o(Object.assign(Object.assign({},g("target",e)),{timeout:0}),{targetName:n}),onCreateResource:p,selectLabel:null==r?void 0:r.combobox.select,noResultsLabel:null==r?void 0:r.combobox.noResults,loadingLabel:null==r?void 0:r.combobox.loading,createNewPrefix:null==r?void 0:r.combobox.createNew,extensionLabel:null==r?void 0:r.combobox.extensionLabel}),b&&l&&e.createElement(h,{resourceId:b,onOpenResource:l,label:null!==(s=null==r?void 0:r.configLabels.openInNewTab)&&void 0!==s?s:"Open target details"}))},defaultConfig:{target:"",target_id:"",timeout:0},icon:C,renderNode:(n,o)=>e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.targetName}),toFlowNode:e=>{const n=e;return{label:"Voicemail",targetId:f(n.config,"target"),timeout:0,originalNode:n}},collectResourceIds:(e,n)=>{const o=f(e,"target");o&&n.addTarget(o)},enrichNode:(e,n,o)=>{const a=e.targetId,t=v(a,n,o),l=b(a,o);return Object.assign(Object.assign({},e),{targetName:t,targetType:l,locale:o})}},K=["1","2","3","4","5","6","7","8","9","0","*","#"];function B(e){return"*"===e?"digit_star":"#"===e?"digit_hash":`digit_${e}`}const V=[{id:"timeout",label:"Timeout",configKey:"timeout_next_node",localeExitKey:"timeout"},{id:"invalid",label:"Invalid",configKey:"invalid_next_node",localeExitKey:"invalid"}],U={type:"menu",flowType:"menu",localeKey:"menu",label:"IVR Menu",description:"Play prompt and route by keypress",color:"#ec4899",exits:[...V],allowSelfLoop:!0,configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,locale:l})=>{var r,i,d,s,c,u,p,b,m;const{groups:v,loading:h,handleCreateResource:w}=y([{type:"audio_clip",labelKey:"audioClips",fallback:"Audio Clips"}],a,t,l),k=f(n,"prompt_clip"),E=null!==(r=n.timeout)&&void 0!==r?r:5,N=null!==(i=n.options)&&void 0!==i?i:[{digit:"1"}],C=null!==(d=n.extension_entry_enabled)&&void 0!==d&&d,L=new Set(N.map(e=>e.digit));return e.createElement(e.Fragment,null,e.createElement(x,{label:null!==(s=null==l?void 0:l.configLabels.promptClip)&&void 0!==s?s:"Prompt"},e.createElement(_,{groups:v,value:k,loading:h,placeholder:null!==(c=null==l?void 0:l.configLabels.search)&&void 0!==c?c:"Search...",onSelect:(e,n)=>o(g("prompt_clip",e),{promptClipName:n}),onCreateResource:w,selectLabel:null==l?void 0:l.combobox.select,noResultsLabel:null==l?void 0:l.combobox.noResults,loadingLabel:null==l?void 0:l.combobox.loading,createNewPrefix:null==l?void 0:l.combobox.createNew})),e.createElement(T,{value:E,min:1,max:30,onChange:e=>o({timeout:e}),locale:l}),e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("label",{className:"ds-dial-plan-config-field__checkbox"},e.createElement("input",{type:"checkbox",checked:C,onChange:e=>o({extension_entry_enabled:e.target.checked})}),e.createElement("span",null,null!==(u=null==l?void 0:l.configLabels.extensionEntry)&&void 0!==u?u:"Allow extension dialing")),e.createElement("p",{className:"ds-dial-plan-config-field__hint"},null!==(p=null==l?void 0:l.configLabels.extensionEntryHint)&&void 0!==p?p:"When on, callers can key an extension instead of choosing an option.")),e.createElement(x,{label:null!==(b=null==l?void 0:l.configLabels.options)&&void 0!==b?b:"Options",action:e.createElement("button",{type:"button",className:"ds-dial-plan-menu-options__add",onClick:function(){const e=K.find(e=>!L.has(e));e&&o({options:[...N,{digit:e}]})},disabled:N.length>=12},"+ ",null!==(m=null==l?void 0:l.configLabels.addOption)&&void 0!==m?m:"Add")},e.createElement("div",{className:"ds-dial-plan-menu-options"},N.map((n,a)=>{var t,r,i,d,s,c;return e.createElement("div",{key:a,className:"ds-dial-plan-menu-options__card"},e.createElement("div",{className:"ds-dial-plan-menu-options__field ds-dial-plan-menu-options__field--label"},e.createElement("span",{className:"ds-dial-plan-menu-options__field-label"},null!==(t=null==l?void 0:l.configLabels.optionLabel)&&void 0!==t?t:"Label"," ",e.createElement("span",{className:"ds-dial-plan-menu-options__field-hint"},"(optional)")),e.createElement("input",{type:"text",className:"ds-dial-plan-config-field__input",value:null!==(r=n.label)&&void 0!==r?r:"",maxLength:20,placeholder:null!==(i=null==l?void 0:l.configLabels.optionLabelPlaceholder)&&void 0!==i?i:"e.g. Sales",onChange:e=>{return n=a,t=e.target.value,void o({options:N.map((e,o)=>{if(o!==n)return e;const a=Object.assign({},e);return t?a.label=t:delete a.label,a})});var n,t}})),e.createElement("div",{className:"ds-dial-plan-menu-options__field ds-dial-plan-menu-options__field--digit"},e.createElement("span",{className:"ds-dial-plan-menu-options__field-label"},null!==(d=null==l?void 0:l.configLabels.digit)&&void 0!==d?d:"Digit"),e.createElement("select",{className:"ds-dial-plan-config-field__input",value:n.digit,onChange:e=>{return n=a,t=e.target.value,void o({options:N.map((e,o)=>o===n?Object.assign(Object.assign({},e),{digit:t}):e)});var n,t}},K.filter(e=>e===n.digit||!L.has(e)).map(n=>e.createElement("option",{key:n,value:n},"*"===n?"✱":n)))),e.createElement("button",{type:"button",className:"ds-dial-plan-menu-options__remove",onClick:()=>{return e=a,void o({options:N.filter((n,o)=>o!==e)});var e},title:null!==(s=null==l?void 0:l.configLabels.removeOption)&&void 0!==s?s:"Remove","aria-label":null!==(c=null==l?void 0:l.configLabels.removeOption)&&void 0!==c?c:"Remove"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))))}))))},defaultConfig:{prompt_clip:"",prompt_clip_id:"",timeout:5,options:[{digit:"1"}],extension_entry_enabled:!1},icon:O,renderNode:(n,o)=>{var a;const t=null!==(a=n.options)&&void 0!==a?a:[],l=n.locale;return e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,timeout:n.timeout,subtitle:n.promptClipName}),e.createElement("div",{className:"ds-dial-plan-node__exits"},t.map(n=>{const o="*"===n.digit?"✱":n.digit,a=n.label?`${n.label} — ${o}`:o;return e.createElement(u,{key:n.digit,id:B(n.digit),label:a})}),e.createElement(p,{exits:o.exits,locale:l})))},toFlowNode:e=>{const n=e;return{label:"IVR Menu",promptClipId:f(n.config,"prompt_clip"),timeout:n.config.timeout,options:n.config.options,originalNode:n}},createEdgesForNode:(e,n)=>{const o=e,a=[];o.config.timeout_next_node&&n.has(o.config.timeout_next_node)&&a.push({id:`${o.id}-timeout->${o.config.timeout_next_node}`,source:o.id,target:o.config.timeout_next_node,sourceHandle:"timeout",type:d}),o.config.invalid_next_node&&n.has(o.config.invalid_next_node)&&a.push({id:`${o.id}-invalid->${o.config.invalid_next_node}`,source:o.id,target:o.config.invalid_next_node,sourceHandle:"invalid",type:d});for(const e of o.config.options)if(e.next_node&&n.has(e.next_node)){const n=B(e.digit);a.push({id:`${o.id}-${n}->${e.next_node}`,source:o.id,target:e.next_node,sourceHandle:n,type:d})}return a},collectResourceIds:(e,n)=>{const o=f(e,"prompt_clip");o&&n.addAudioClip(o)},enrichNode:(e,n,o)=>{const a=n.audioClips.get(e.promptClipId);return Object.assign(Object.assign({},e),{promptClipName:null==a?void 0:a.name,locale:o})},resolveExitLabel:e=>{const n=function(e){if("digit_star"===e)return"*";if("digit_hash"===e)return"#";const n=e.match(/^digit_(\d)$/);return null==n?void 0:n[1]}(e);if(n)return"*"===n?"✱":n},onConfigChange:(e,n,o)=>{var a,t;if(!n.options)return;const l=n.options,r=new Set(l.map(e=>B(e.digit)));for(const e of V)r.add(e.id);const i=o.nodesRef.current.find(n=>n.id===e),d=null!==(t=null===(a=null==i?void 0:i.data)||void 0===a?void 0:a.options)&&void 0!==t?t:[],s=new Map;if(d.length===l.length)for(let e=0;e<l.length;e++){const n=B(d[e].digit),o=B(l[e].digit);n!==o&&s.set(n,o)}o.setEdges(n=>{const a=n.map(n=>{if(n.source!==e||!n.sourceHandle)return n;const o=s.get(n.sourceHandle);return o?Object.assign(Object.assign({},n),{sourceHandle:o,id:`${e}-${o}->${n.target}`}):n}).filter(n=>n.source!==e||!n.sourceHandle||r.has(n.sourceHandle));return(a.length!==n.length||s.size>0)&&o.updateDirty(o.nodesRef.current,a),a}),requestAnimationFrame(()=>o.updateNodeInternals(e))},serializeConfig:(e,n,o)=>{var a;const t=(null!==(a=o.options)&&void 0!==a?a:[]).map(o=>{const a=B(o.digit),t=n.find(n=>n.source===e.id&&n.sourceHandle===a),l={digit:o.digit};return o.label&&(l.label=o.label),t&&(l.next_node=t.target),l});return Object.assign(Object.assign({},o),{options:t})}},W={type:"audio_clip",flowType:"audioClip",localeKey:"audioClip",label:"Audio Clip",description:"Play an audio clip",color:"#14b8a6",exits:[{id:"next",label:"Next",configKey:"next",localeExitKey:"next"}],configPanel:({config:n,onConfigChange:o,listResources:a,onCreateResource:t,locale:l})=>{var r,i;const{groups:d,loading:s,handleCreateResource:c}=y([{type:"audio_clip",labelKey:"audioClips",fallback:"Audio Clips"}],a,t,l),u=f(n,"clip");return e.createElement(x,{label:null!==(r=null==l?void 0:l.configLabels.audioClip)&&void 0!==r?r:"Audio Clip"},e.createElement(_,{groups:d,value:u,loading:s,placeholder:null!==(i=null==l?void 0:l.configLabels.search)&&void 0!==i?i:"Search...",onSelect:(e,n)=>o(g("clip",e),{clipName:n}),onCreateResource:c,selectLabel:null==l?void 0:l.combobox.select,noResultsLabel:null==l?void 0:l.combobox.noResults,loadingLabel:null==l?void 0:l.combobox.loading,createNewPrefix:null==l?void 0:l.combobox.createNew}))},defaultConfig:{clip:"",clip_id:""},icon:R,renderNode:(n,o)=>e.createElement(e.Fragment,null,e.createElement(c,{icon:o.icon,label:n.label,subtitle:n.clipName}),e.createElement("div",{className:"ds-dial-plan-node__exits"},e.createElement(p,{exits:o.exits,locale:n.locale}))),toFlowNode:e=>{const n=e;return{label:"Audio Clip",clipId:f(n.config,"clip"),originalNode:n}},normalizeFromAlias:e=>Object.assign(Object.assign({},e),{type:"audio_clip"}),collectResourceIds:(e,n)=>{const o=f(e,"clip");o&&n.addAudioClip(o)},enrichNode:(e,n,o)=>{const a=n.audioClips.get(e.clipId);return Object.assign(Object.assign({},e),{clipName:null==a?void 0:a.name,locale:o})}},q={type:"hang_up",flowType:"hangUp",localeKey:"hangUp",label:"Hang Up",description:"End the call",color:"#ef4444",exits:[],configPanel:({locale:n})=>{var o;return e.createElement("div",{className:"ds-dial-plan-config-panel__note"},null!==(o=null==n?void 0:n.nodeDescriptions.hangUp)&&void 0!==o?o:"End the call")},defaultConfig:{},icon:S,renderNode:(n,o)=>e.createElement(c,{icon:o.icon,label:n.label}),toFlowNode:e=>({label:"Hang Up",originalNode:e}),enrichNode:(e,n,o)=>Object.assign(Object.assign({},e),{label:o.nodeTypes.hangUp,locale:o})},G=new class{constructor(){this.byType=new Map,this.byFlowType=new Map,this.legacyTypeAliases=new Map}register(e){this.byType.set(e.type,e),this.byFlowType.set(e.flowType,e)}registerAlias(e,n){this.legacyTypeAliases.set(e,n)}get(e){return this.byType.get(e)}resolveType(e){var n;let o=this.byType.get(e.type);if(!o){const n=this.legacyTypeAliases.get(e.type);n&&(o=this.byType.get(n))}return(null==o?void 0:o.resolveAlias)&&null!==(n=o.resolveAlias(e))&&void 0!==n?n:o}getByFlowType(e){return this.byFlowType.get(e)}getAll(){return Array.from(this.byType.values())}getNodeTypesMap(){const e={};for(const n of this.byType.values())e[n.flowType]=n.component;return e}createEdgesForNode(e,n){const o=this.resolveType(e);if(!o)return[];if(o.createEdgesForNode)return o.createEdgesForNode(e,n);const a=e.config,t=[];for(const l of s(o,a)){const o=a[l.configKey];o&&n.has(o)&&t.push({id:`${e.id}-${l.id}->${o}`,source:e.id,target:o,sourceHandle:l.id,type:d})}return t}},Y=(X=G,e.memo(function({data:o,selected:a,type:t}){const l=X.getByFlowType(null!=t?t:"");if(!l)return null;const r=l.renderNode(o,l),i=l.type.replace(/_/g,"-");return e.createElement("div",{className:`ds-dial-plan-node ds-dial-plan-node--themed ds-dial-plan-node--${i} ${a?"ds-dial-plan-node--selected":""}`,style:{"--node-color":l.color}},e.createElement(n.Handle,{type:"target",position:n.Position.Left,className:"ds-dial-plan-handle"}),r)}));var X;const Z=[z,j,I,M,H,$,U,W,q];for(const e of Z)G.register(Object.assign(Object.assign({},e),{component:Y}));const Q=G.get("internal_dial");Q&&(Q.resolveAlias=e=>{const n=e.config,o=f(n,"target");return o.startsWith("svm_")||0===n.timeout&&!n.next&&!m(o)?G.get("voicemail"):o.startsWith("va_")?G.get("voice_app"):void 0}),G.registerAlias("sound_clip","audio_clip");const J="__start__";function ee(e,n=G){var o;const a=[],t=[],l=new Map;for(const n of e.nodes)l.set(n.id,n);const r={id:J,type:"start",position:{x:0,y:0},data:{label:"Start"}};a.push(r),e.entry_node&&l.has(e.entry_node)&&t.push({id:`${J}->${e.entry_node}`,source:J,target:e.entry_node,type:d});for(const r of e.nodes){const e=n.resolveType(r),i=null!==(o=r.position)&&void 0!==o?o:{x:0,y:0},d=e&&e.type!==r.type&&e.normalizeFromAlias?e.normalizeFromAlias(r):r;if(e){const n=e.toFlowNode(d),o={id:r.id,type:e.flowType,position:i,data:n};a.push(o)}else a.push({id:r.id,type:"default",position:i,data:{label:r.id,originalNode:r}});const s=n.createEdgesForNode(d,l);t.push(...s)}return e.nodes.some(e=>!e.position)?ae(a,t):{nodes:a,edges:t}}function ne(e,n,o){var a,t,l,r;const i=n.find(e=>e.source===J),d=null!==(a=null==i?void 0:i.target)&&void 0!==a?a:"",c=[];for(const a of e){if(a.id===J)continue;const e=o.getByFlowType(null!==(t=a.type)&&void 0!==t?t:"");if(!e||!(null===(l=a.data)||void 0===l?void 0:l.originalNode))continue;const i=a.data.originalNode,d=Object.assign({},i.config);for(const n of e.exits)d[n.configKey]=void 0;const u=s(e,d);for(const e of n){if(e.source!==a.id)continue;const n=u.find(n=>n.id===e.sourceHandle);n&&(d[n.configKey]=e.target)}const p=e.serializeConfig?e.serializeConfig(a,n,d):d;c.push({id:a.id,type:null!==(r=e.apiType)&&void 0!==r?r:i.type,position:a.position,config:p})}return{entry_node:d,nodes:c}}function oe(e){var n,o,a;if((null===(n=e.measured)||void 0===n?void 0:n.width)&&(null===(o=e.measured)||void 0===o?void 0:o.height))return{width:e.measured.width,height:e.measured.height};if("start"===e.type)return{width:60,height:60};if("schedule"===e.type)return{width:180,height:140};if("menu"===e.type){const n=e.data.options;return{width:180,height:60+28*((null!==(a=null==n?void 0:n.length)&&void 0!==a?a:1)+2)}}return{width:180,height:80}}function ae(e,n){var o;const t=new a.graphlib.Graph;t.setGraph({rankdir:"LR",nodesep:60,ranksep:80,marginx:40,marginy:40}),t.setDefaultEdgeLabel(()=>({}));for(const n of e){const{width:e,height:o}=oe(n);t.setNode(n.id,{width:e,height:o})}for(const e of n)t.setEdge(e.source,e.target);a.layout(t);const l=new Map;for(const n of e){const e=t.node(n.id),{width:o,height:a}=oe(n);l.set(n.id,{x:Math.round(e.x-o/2),y:Math.round(e.y-a/2)})}const r=new Map;for(const e of n){const n=r.get(e.source);n?n.push(e.target):r.set(e.source,[e.target])}const i=e=>{var n;const o=new Set([e]),a=[e];for(;a.length>0;){const e=a.shift();for(const t of null!==(n=r.get(e))&&void 0!==n?n:[])o.has(t)||(o.add(t),a.push(t))}return o};for(const a of e){const e=G.getByFlowType(null!==(o=a.type)&&void 0!==o?o:"");if(!e||e.exits.length<2)continue;const t=[];for(const o of e.exits){const e=n.find(e=>e.source===a.id&&e.sourceHandle===o.id);e&&t.push(e.target)}if(t.length<2)continue;const r=t[0],d=t[1],s=l.get(r),c=l.get(d);if(!s||!c)continue;if(s.y<=c.y)continue;const u=i(r),p=i(d);if([...u].some(e=>p.has(e)))continue;const f=s.y-c.y;for(const e of u){const n=l.get(e);n&&(n.y-=f)}for(const e of p){const n=l.get(e);n&&(n.y+=f)}}const d=e.find(e=>e.id===J),s=l.get(J),c=d&&s?d.position.x-s.x:0,u=d&&s?d.position.y-s.y:0;return{nodes:e.map(e=>{const n=l.get(e.id);return Object.assign(Object.assign({},e),{position:{x:n.x+c,y:n.y+u}})}),edges:n}}function te(e,n,o,a){const t=G.getByFlowType(e),l=t?Z.find(e=>{var n;return e.type===(null!==(n=t.apiType)&&void 0!==n?n:t.type)}):null;return(null==l?void 0:l.enrichNode)?l.enrichNode(n,o,a):n}const le=e.memo(function({data:o}){return e.createElement("div",{className:"ds-dial-plan-node ds-dial-plan-node--start"},e.createElement("div",{className:"ds-dial-plan-node__content"},e.createElement("span",{className:"ds-dial-plan-node__label"},o.label)),e.createElement(n.Handle,{type:"source",position:n.Position.Right,className:"ds-dial-plan-handle"}))}),re=({registry:n,onAddNode:o,locale:a})=>{const t=n.getAll();return e.createElement("div",{className:"ds-dial-plan-node-library"},t.map(n=>{var t,l;const r=null!==(t=null==a?void 0:a.nodeTypes[n.localeKey])&&void 0!==t?t:n.label,i=null!==(l=null==a?void 0:a.nodeDescriptions[n.localeKey])&&void 0!==l?l:n.description;return e.createElement("div",{key:n.type,className:`ds-dial-plan-node-library__item ds-dial-plan-node-library__item--${n.type}`,style:{"--node-color":n.color},draggable:!0,onClick:()=>o(n.type),onDragStart:e=>{const o=e.currentTarget.getBoundingClientRect(),a=(e.clientX-o.left)/o.width,t=(e.clientY-o.top)/o.height;e.dataTransfer.setData("application/reactflow",n.type),e.dataTransfer.setData("application/reactflow-grab-frac",`${a},${t}`),e.dataTransfer.effectAllowed="move"},title:i},e.createElement("span",{className:"ds-dial-plan-node-library__item-icon"},n.icon),e.createElement("span",{className:"ds-dial-plan-node-library__item-label"},r))}))},ie=e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"3 6 5 6 21 6"}),e.createElement("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})),de=({node:n,registration:o,onConfigChange:a,onInvalidDraftChange:t,onDelete:l,onClose:r,listResources:i,onCreateResource:d,onOpenResource:s,locale:c})=>{var u,p,f;const g=e.useRef(null);e.useEffect(()=>{var e;const n=null===(e=g.current)||void 0===e?void 0:e.getRootNode(),o=n instanceof ShadowRoot||n instanceof Document?n:document,a=e=>function(e){"Escape"===e.key&&r()}(e);return o.addEventListener("keydown",a),()=>o.removeEventListener("keydown",a)},[r]);const b=n.data.originalNode,m=null!==(u=null==b?void 0:b.config)&&void 0!==u?u:{},v=o.configPanel;return e.createElement("div",{ref:g,className:"ds-dial-plan-config-panel"},e.createElement("div",{className:"ds-dial-plan-config-panel__header"},e.createElement("span",{className:"ds-dial-plan-config-panel__header-icon"},o.icon),e.createElement("span",{className:"ds-dial-plan-config-panel__header-label"},o.label),e.createElement("button",{type:"button",className:"ds-dial-plan-config-panel__delete",onClick:()=>{l(n.id),r()},title:null!==(p=null==c?void 0:c.panel.delete_)&&void 0!==p?p:"Delete"},ie),e.createElement("button",{className:"ds-dial-plan-config-panel__close",onClick:r,title:null!==(f=null==c?void 0:c.panel.close)&&void 0!==f?f:"Close",type:"button"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e.createElement("div",{className:"ds-dial-plan-config-panel__body"},e.createElement(v,{nodeId:n.id,onInvalidDraftChange:t,config:m,nodeData:n.data,onConfigChange:(e,o)=>a(n.id,e,o),listResources:i,onCreateResource:d,onOpenResource:s,locale:c})))},se=e.memo(function({onAutoLayout:n,onSave:o,isDirty:a,hasInvalidDraft:t,locale:l}){var r;const i=null!==(r=null==l?void 0:l.toolbar)&&void 0!==r?r:{autoLayout:"Auto Layout",save:"Save"};return e.createElement("div",{className:"ds-dial-plan-editor-toolbar"},e.createElement("button",{className:"ds-dial-plan-editor-toolbar__button",onClick:n,title:i.autoLayout,type:"button"},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},e.createElement("rect",{x:"3",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"3",width:"7",height:"7"}),e.createElement("rect",{x:"14",y:"14",width:"7",height:"7"}),e.createElement("line",{x1:"6.5",y1:"10",x2:"6.5",y2:"17"}),e.createElement("line",{x1:"6.5",y1:"17",x2:"14",y2:"17.5"})),e.createElement("span",null,i.autoLayout)),o&&e.createElement("button",{className:"ds-dial-plan-editor-toolbar__button",onClick:o,title:i.save,type:"button",disabled:!a||t},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},e.createElement("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),e.createElement("polyline",{points:"17 21 17 13 7 13 7 21"}),e.createElement("polyline",{points:"7 3 7 8 15 8"})),e.createElement("span",null,i.save)))});var ce;const ue=!("undefined"==typeof window||void 0===window.document||"function"!=typeof HTMLElement.prototype.attachShadow||"undefined"==typeof navigator||/jsdom/i.test(null!==(ce=navigator.userAgent)&&void 0!==ce?ce:"")||"undefined"!=typeof window&&"__STORYBOOK_PREVIEW__"in window),pe=({children:n,stylesheets:o,className:a,style:t})=>{const[l,i]=e.useState(null),d=e.useRef(null),s=e.useCallback(e=>{var n;if(d.current=e,!ue||!e)return;const o=null!==(n=e.shadowRoot)&&void 0!==n?n:e.attachShadow({mode:"open"});i(o)},[]);e.useEffect(()=>{ue&&d.current&&function(e,n){const o=e.shadowRoot;o&&(o.adoptedStyleSheets=n.map(e=>{const n=new CSSStyleSheet;return n.replaceSync(e),n}))}(d.current,o)},[o]);const c=e.useRef(null);return e.useEffect(()=>{if(!ue&&0!==o.length)return c.current||(c.current=document.createElement("style"),document.head.appendChild(c.current)),c.current.textContent=o.join("\n"),()=>{c.current&&(c.current.remove(),c.current=null)}},[o]),ue?e.createElement("div",{ref:s,className:a,style:t},l&&r.createPortal(n,l)):e.createElement("div",{className:a,style:t},n)},fe={nodeTypes:{start:"Start",schedule:"Schedule",internalDial:"Internal Extension",voicemail:"Voicemail",externalDial:"External Number",ringAllUsers:"Ring All Users",voiceApp:"Voice App",menu:"IVR Menu",audioClip:"Audio Clip",hangUp:"Hang Up"},exits:{open:"Open",closed:"Closed",holiday:"Holiday",next:"Next",timeout:"Timeout",invalid:"Invalid"},nodeDescriptions:{schedule:"Route calls by schedule",internalDial:"Ring a user, group, or plan",voicemail:"Send to voicemail",ringAllUsers:"Ring all users",externalDial:"Ring an external phone number",voiceApp:"Route to a voice application",menu:"Play prompt and route by keypress",audioClip:"Play an audio clip",hangUp:"End the call"},targetTypes:{user:"User",ringGroup:"Ring Group",dialPlan:"Dial Plan",queue:"Queue",voiceApp:"Voice App",sharedVoicemail:"Shared Voicemail"},resourceGroups:{users:"Users",ringGroups:"Ring Groups",dialPlans:"Dial Plans",queues:"Queues",voiceApps:"Voice Apps",sharedVoicemails:"Shared Voicemails",schedules:"Schedules",audioClips:"Audio Clips",phoneNumbers:"Phone Numbers"},configLabels:{timeout:"Timeout (seconds)",target:"Target",schedule:"Schedule",search:"Search...",searchTargets:"Search targets...",searchSchedules:"Search schedules...",openInNewTab:"Open target details",promptClip:"Prompt",audioClip:"Audio Clip",digit:"Digit",options:"Options",addOption:"Add Option",removeOption:"Remove",optionLabel:"Label",optionLabelPlaceholder:"e.g. Sales",routeHolidaySeparately:"Route holidays separately",routeHolidaySeparatelyHint:"When on, holidays route to a dedicated branch you wire below. Otherwise holidays follow the Closed exit.",mode:"Mode",phoneNumber:"Phone Number",phoneNumberInvalid:"Enter a valid phone number, for example (415) 555-1234.",clearPhoneNumber:"Clear phone number",timeoutOverride:"Override resource timeout",timeoutOverrideOn:"On",timeoutOverrideOff:"Off",extensionEntry:"Allow extension dialing",extensionEntryHint:"When on, callers can key an extension instead of choosing an option.",callerId:"Caller ID",callerIdOriginal:"Original caller",callerIdCalledNumber:"Number called",callerIdSpecific:"Specific number",callerIdHint:"Show the number that was called so the person you forward to knows it's coming from your office.",callerIdNumber:"Number to show",searchPhoneNumbers:"Search phone numbers..."},voiceAppMode:{control:"Control",notify:"Notify",controlBadge:"Control mode",notifyBadge:"Notify mode",controlHint:"Hands the call off to the voice app, which takes over the conversation.",notifyHint:"Notifies the voice app of the call in the background. The dial plan keeps routing via Next without waiting."},toolbar:{autoLayout:"Auto Layout",save:"Save"},panel:{delete_:"Delete",close:"Close",connection:"Connection",from:"From",exit:"Exit",to:"To"},combobox:{select:"— Select —",search:"Search...",noResults:"No results found",loading:"Loading...",createNew:"+ Create new...",extensionLabel:"Ext.",noName:"(No name)"},status:{loading:"Loading dial plan...",loadError:"Failed to load dial plan",notFound:"No dial plan found",saveError:"Failed to save dial plan",newDialPlan:"New Dial Plan"}},ge={schedule:"A schedule must be selected in the Schedule node",schedule_id:"A schedule must be selected in the Schedule node",target:"A target must be selected in the Internal Extension node",target_id:"A target must be selected in the Internal Extension node",prompt_clip:"A prompt must be selected in the IVR Menu node",prompt_clip_id:"A prompt must be selected in the IVR Menu node",clip:"An audio clip must be selected in the Audio Clip node",clip_id:"An audio clip must be selected in the Audio Clip node",voice_app:"A voice app must be selected in the Voice App node",voice_app_id:"A voice app must be selected in the Voice App node",phone_number:"Enter a valid US phone number in the External Number node"},be={schedule:"Schedule",internal_dial:"Internal Extension",ring_all_users:"Ring All",external_dial:"External Number"};const me={view:{editable:!1,interactive:!0,showChrome:!0},edit:{editable:!0,interactive:!0,showChrome:!0},preview:{editable:!1,interactive:!1,showChrome:!1}},ve={id:"",name:"New Dial Plan",entry_node:"",nodes:[],created_at:"",updated_at:""},he=Object.assign({start:le},G.getNodeTypesMap()),_e={[d]:o=>{const{sourceX:a,sourceY:t,targetX:l,targetY:r,sourcePosition:i,targetPosition:d,markerEnd:s,style:c}=o,u=Math.abs(t-r),[p]=u<=1?n.getStraightPath({sourceX:a,sourceY:t,targetX:l,targetY:r}):n.getSmoothStepPath({sourceX:a,sourceY:t,targetX:l,targetY:r,sourcePosition:i,targetPosition:d,borderRadius:8});return e.createElement(n.BaseEdge,{path:p,markerEnd:s,style:c})}};function xe(e,n,o){return i(this,void 0,void 0,function*(){var a;const t=new Set,l=new Set,r=new Set,d=e=>!(null==o?void 0:o.only)||o.only.has(e);for(const n of e.nodes){const e=G.resolveType(n),o=e?Z.find(n=>{var o;return n.type===(null!==(o=e.apiType)&&void 0!==o?o:e.type)}):null;null===(a=null==o?void 0:o.collectResourceIds)||void 0===a||a.call(o,n.config,{addSchedule:e=>{d(e)&&t.add(e)},addTarget:e=>{d(e)&&l.add(e)},addAudioClip:e=>{d(e)&&r.add(e)}})}const s=r.size>0?n.audioClips.list().catch(()=>[]):Promise.resolve([]),[c,u,...p]=yield Promise.all([Promise.all(Array.from(t).map(e=>i(this,void 0,void 0,function*(){try{return yield n.schedules.retrieve(e)}catch(e){return null}}))),s,...Array.from(l).map(e=>i(this,void 0,void 0,function*(){var a,t;const l=yield n.resolveRoutingTarget(e,o);return l?{id:l.id,name:l.name||l.id,extension_number:null!==(a=l.extension_number)&&void 0!==a?a:void 0,timeout_seconds:null!==(t=l.timeout_seconds)&&void 0!==t?t:void 0}:null}))]),f=new Map,g=new Map,b=new Map;for(const e of c)e&&f.set(e.id,e);for(const e of p)e&&g.set(e.id,e);for(const e of u)b.set(e.id,e);return{schedules:f,users:g,audioClips:b}})}const ye=e.forwardRef(function({dialPlanId:a,mode:t="view",locale:l=fe,onNodeClick:r,onLoaderStart:c,onLoaderEnd:u,onLoadError:p,onSave:g,onDirtyChange:m,onError:v,className:h,style:_,onCreateResource:x,onOpenResource:y},w){var k;const{editable:E,interactive:N,showChrome:C}=me[t],{dialstack:L}=o.useDialstackComponents(),O=n.useReactFlow(),S=n.useUpdateNodeInternals(),[R,z]=e.useState(!E||!!a),[T,j]=e.useState(null),[A,I]=n.useNodesState([]),[P,D,M]=n.useEdgesState([]),[H,$]=e.useState(null),[K,B]=e.useState(null),[V,U]=e.useState(!1),[W,q]=e.useState(!1);e.useEffect(()=>{var e,n;null===(n=(e=ue.current).onDirtyChange)||void 0===n||n.call(e,V)},[V]);const[Y,X]=e.useState(null),[Q,J]=e.useState(0),oe=e.useRef(null),le=e.useRef(A),ce=e.useRef(P);le.current=A,ce.current=P;const ue=e.useRef({onLoaderStart:c,onLoaderEnd:u,onLoadError:p,onError:v,onSave:g,onDirtyChange:m});ue.current={onLoaderStart:c,onLoaderEnd:u,onLoadError:p,onError:v,onSave:g,onDirtyChange:m};const pe=e.useRef(null),ye=e.useRef({schedules:new Map,users:new Map,audioClips:new Map}),we=e.useRef(!1);e.useEffect(()=>{let e=!1;return function(){i(this,void 0,void 0,function*(){var n,o,t,r,i,d,s,c;if(E&&!a){const{nodes:n,edges:o}=ee(Object.assign(Object.assign({},ve),{name:l.status.newDialPlan}),G);return void(e||(I(n),D(o),pe.current={nodes:n,edges:o},z(!1)))}z(!0),j(null),null===(o=(n=ue.current).onLoaderStart)||void 0===o||o.call(n);try{const n=yield L.dialPlans.retrieve(a);if(e)return;const o=yield xe(n,L);if(e)return;ye.current=o;const{nodes:i,edges:d}=ee(n,G),s=function(e,n,o){return e.map(e=>{var a;const t=G.getByFlowType(null!==(a=e.type)&&void 0!==a?a:""),l=t?Z.find(e=>{var n;return e.type===(null!==(n=t.apiType)&&void 0!==n?n:t.type)}):null;return(null==l?void 0:l.enrichNode)?Object.assign(Object.assign({},e),{data:l.enrichNode(e.data,n,o)}):Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{locale:o})})})}(i,o,l);I(s),D(d),pe.current={nodes:s,edges:d},X({id:n.id,name:n.name}),z(!1),null===(r=(t=ue.current).onLoaderEnd)||void 0===r||r.call(t,n)}catch(n){if(!e){const e=n instanceof Error?n:new Error(String(n));j(e),z(!1),null===(d=(i=ue.current).onLoadError)||void 0===d||d.call(i,e),null===(c=(s=ue.current).onError)||void 0===c||c.call(s,e)}}})}(),()=>{e=!0}},[L,a,I,D]);const ke=e.useCallback((e,n)=>{if(!pe.current)return;const o=(e,n)=>JSON.stringify({nodes:e.map(e=>({id:e.id,data:e.data,position:e.position})),edges:n.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle}))}),a=o(pe.current.nodes,pe.current.edges)!==o(e,n);U(a)},[]);e.useEffect(()=>{we.current&&(we.current=!1,ke(A,P))},[A,P,ke]);const Ee=e.useCallback(e=>{M(e),e.some(e=>"remove"===e.type)&&queueMicrotask(()=>ke(le.current,ce.current))},[M,ke]),Ne=e.useCallback(e=>{const n=le.current.filter(n=>n.id!==e).map(n=>{var o;const a=null===(o=n.data)||void 0===o?void 0:o.originalNode;if(!a)return n;const t=a.config;if(!t)return n;const l=Object.assign({},t);let r=!1;for(const n of Object.keys(l))l[n]===e&&(l[n]=void 0,r=!0);return r?Object.assign(Object.assign({},n),{data:Object.assign(Object.assign({},n.data),{originalNode:Object.assign(Object.assign({},a),{config:l})})}):n}),o=ce.current.filter(n=>n.source!==e&&n.target!==e);I(n),D(o),ke(n,o),H===e&&$(null)},[I,D,H,ke]),Ce=e.useCallback(e=>{const o=new Set(e.filter(e=>"remove"===e.type&&"id"in e&&"__start__"!==e.id).map(e=>"id"in e?e.id:""));if(o.size>0){const e=le.current.filter(e=>!o.has(e.id)).map(e=>{var n;const a=null===(n=e.data)||void 0===n?void 0:n.originalNode;if(!a)return e;const t=a.config;if(!t)return e;const l=Object.assign({},t);let r=!1;for(const e of Object.keys(l))"string"==typeof l[e]&&o.has(l[e])&&(l[e]=void 0,r=!0);return r?Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{originalNode:Object.assign(Object.assign({},a),{config:l})})}):e}),n=ce.current.filter(e=>!o.has(e.source)&&!o.has(e.target));I(e),D(n),ke(e,n),H&&o.has(H)&&$(null)}const a=e.filter(e=>"remove"!==e.type&&!("position"===e.type&&"id"in e&&"__start__"===e.id));0!==a.length&&(a.some(e=>"position"===e.type&&!e.dragging)&&(we.current=!0),I(e=>n.applyNodeChanges(a,e)))},[I,D,ke,H]),Le=e.useCallback((e,n,o)=>{var a,t;const l=G.get(e);if(!l)return;const r=`${e}_${crypto.randomUUID().replace(/-/g,"").slice(0,12)}`;let i=n;if(!i){const e=null===(a=oe.current)||void 0===a?void 0:a.getBoundingClientRect(),n=e?e.left+e.width/2:400,o=e?e.top+e.height/2:300;i=O.screenToFlowPosition({x:n,y:o})}const d={id:r,type:null!==(t=l.apiType)&&void 0!==t?t:e,config:Object.assign({},l.defaultConfig)},s=l.toFlowNode(d),c={id:r,type:l.flowType,position:i,data:s,selected:!0};if(I(e=>{const n=e.map(e=>e.selected?Object.assign(Object.assign({},e),{selected:!1}):e);return n.push(c),ke(n,ce.current),n}),$(r),o){const e=i;requestAnimationFrame(()=>{var n;const a=null===(n=oe.current)||void 0===n?void 0:n.querySelector(`[data-id="${CSS.escape(r)}"]`);if(!a)return;const t=a.offsetWidth,l=a.offsetHeight;t&&l&&I(n=>n.map(n=>n.id===r?Object.assign(Object.assign({},n),{position:{x:e.x-o.x*t,y:e.y-o.y*l}}):n))})}},[O,I,ke]),Oe=e.useCallback(e=>{e.preventDefault();const n=e.dataTransfer.getData("application/reactflow");if(!n)return;const[o,a]=e.dataTransfer.getData("application/reactflow-grab-frac").split(","),t={x:Number(o),y:Number(a)},l=O.screenToFlowPosition({x:e.clientX,y:e.clientY});Le(n,l,t)},[O,Le]),Se=e.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},[]),Re=e.useCallback(e=>{var o,a,t;const l={id:`${e.source}-${null!==(o=e.sourceHandle)&&void 0!==o?o:""}->${e.target}`,source:e.source,target:e.target,sourceHandle:null!==(a=e.sourceHandle)&&void 0!==a?a:void 0,targetHandle:null!==(t=e.targetHandle)&&void 0!==t?t:void 0,type:d,markerEnd:{type:n.MarkerType.ArrowClosed,width:12,height:12,color:"#94a3b8"}};D(n=>{const o=n.filter(n=>{var o,a;return!(n.source===e.source&&(null!==(o=n.sourceHandle)&&void 0!==o?o:null)===(null!==(a=e.sourceHandle)&&void 0!==a?a:null))}),a=[...o,l];return ke(le.current,a),a})},[D,ke]),ze=e.useCallback((e,o)=>{D(a=>{var t,l,r;const i=a.filter(n=>{var a,t;return n.id!==e.id&&!(n.source===o.source&&(null!==(a=n.sourceHandle)&&void 0!==a?a:null)===(null!==(t=o.sourceHandle)&&void 0!==t?t:null))}),s=[...i,{id:`${o.source}-${null!==(t=o.sourceHandle)&&void 0!==t?t:""}->${o.target}`,source:o.source,target:o.target,sourceHandle:null!==(l=o.sourceHandle)&&void 0!==l?l:void 0,targetHandle:null!==(r=o.targetHandle)&&void 0!==r?r:void 0,type:d,markerEnd:{type:n.MarkerType.ArrowClosed,width:12,height:12,color:"#94a3b8"}}];return ke(le.current,s),s})},[D,ke]),Te=e.useCallback(e=>{var n;if(!e.source||!e.target||e.source!==e.target)return!0;const o=le.current.find(n=>n.id===e.source),a=G.getByFlowType(null!==(n=null==o?void 0:o.type)&&void 0!==n?n:"");return!0===(null==a?void 0:a.allowSelfLoop)},[le]),je=e.useCallback((e,n,o)=>{var a,t;I(a=>{const t=a.map(a=>{var t;if(a.id!==e)return a;const r=function({flowType:e,data:n,configUpdates:o,displayUpdates:a,maps:t,locale:l}){const r=n.originalNode;if(!r)return null;const i=Object.assign(Object.assign({},r),{config:Object.assign(Object.assign({},r.config),o)}),d=G.getByFlowType(e),s=d?d.toFlowNode(i):Object.assign(Object.assign({},n),{originalNode:i}),c=f(o,"target")||void 0,u=c?b(c,l):void 0,p=d?Z.find(e=>{var n;return e.type===(null!==(n=d.apiType)&&void 0!==n?n:d.type)}):null,g=Object.assign(Object.assign({},n),s),m=(null==p?void 0:p.enrichNode)?p.enrichNode(g,t,l):g;return Object.assign(Object.assign(Object.assign({},m),a),u&&{targetType:u})}({flowType:null!==(t=a.type)&&void 0!==t?t:"",data:a.data,configUpdates:n,displayUpdates:o,maps:ye.current,locale:l});return r?Object.assign(Object.assign({},a),{data:r}):a});return ke(t,ce.current),t});const r=le.current.find(n=>n.id===e),i=G.getByFlowType(null!==(a=null==r?void 0:r.type)&&void 0!==a?a:"");if(i){const o=null==r?void 0:r.data.originalNode,a=function(e,n){const o=s(e,n);return new Set(e.exits.filter(e=>!o.includes(e)).map(e=>e.id))}(i,Object.assign(Object.assign({},null==o?void 0:o.config),n));a.size>0&&D(n=>{const o=n.filter(n=>{var o;return!(n.source===e&&a.has(null!==(o=n.sourceHandle)&&void 0!==o?o:""))});return o.length===n.length?n:(ke(le.current,o),o)})}const d=i?Z.find(e=>{var n;return e.type===(null!==(n=i.apiType)&&void 0!==n?n:i.type)}):null;null===(t=null==d?void 0:d.onConfigChange)||void 0===t||t.call(d,e,n,{setEdges:D,updateNodeInternals:S,nodesRef:le,updateDirty:ke});const c=f(n,"target");c&&requestAnimationFrame(()=>S(e)),c&&!ye.current.users.has(c)&&L.resolveRoutingTarget(c).then(n=>{var o,a;n&&(ye.current.users.set(c,{id:n.id,name:n.name||n.id,extension_number:null!==(o=n.extension_number)&&void 0!==o?o:void 0,timeout_seconds:null!==(a=n.timeout_seconds)&&void 0!==a?a:void 0}),I(n=>n.map(n=>{var o;return n.id===e?Object.assign(Object.assign({},n),{data:te(null!==(o=n.type)&&void 0!==o?o:"",n.data,ye.current,l)}):n})))})},[L,I,D,ke,S]),Ae=e.useCallback(()=>{const{nodes:e,edges:n}=ae(A,P);I(e),D(n),ke(e,n),requestAnimationFrame(()=>O.fitView({padding:.2}))},[A,P,I,D,ke,O]),Ie=e.useCallback((e,n)=>i(this,void 0,void 0,function*(){var o;try{const t={expand:["extensions"]};switch(e){case"schedule":return yield L.schedules.list();case"user":return(yield L.users.list(t)).map(e=>{var n,o,a;return{id:e.id,name:e.name||l.combobox.noName,extension_number:null===(a=null===(o=null===(n=e.extensions)||void 0===n?void 0:n.data)||void 0===o?void 0:o[0])||void 0===a?void 0:a.number}});case"ring_group":return yield L.ringGroups.list(t);case"queue":return yield L.queues.list({expand:t.expand});case"dial_plan":{const e=yield L.dialPlans.list(t),n=null!==(o=null==Y?void 0:Y.id)&&void 0!==o?o:a;return e.filter(e=>e.id!==n)}case"voice_app":{const e=yield L.voiceApps.list(t);if(!(null==n?void 0:n.notifyEligible))return e;try{const n=yield L.aiAgents.list({limit:100}),o=new Set(n.map(e=>e.voice_app_id));return e.filter(e=>!o.has(e.id))}catch(n){return e}}case"shared_voicemail":return yield L.sharedVoicemailBoxes.list();case"audio_clip":return yield L.audioClips.list();case"phone_number":return(yield L.fetchAllPages(e=>L.phoneNumbers.list(e))).filter(e=>"active"===e.status&&e.outbound_enabled).sort((e,n)=>e.phone_number.localeCompare(n.phone_number)).map(e=>({id:e.id,name:e.caller_id_name?`${F(e.phone_number)} · ${e.caller_id_name}`:F(e.phone_number)}));default:return[]}}catch(e){return[]}}),[L,a,Y,l,Q]),Fe=e.useCallback(e=>i(this,void 0,void 0,function*(){const n=(e,n)=>ne(e,n,G).nodes,o=pe.current,a=[...n(le.current,ce.current),...o?n(o.nodes,o.edges):[]],t=yield xe({nodes:a},L,{refresh:!0,only:e?new Set(e):void 0}),r=ye.current,i={schedules:new Map([...r.schedules,...t.schedules]),users:new Map([...r.users,...t.users]),audioClips:new Map([...r.audioClips,...t.audioClips])};ye.current=i;const d=e=>e.map(e=>{var n;return Object.assign(Object.assign({},e),{data:te(null!==(n=e.type)&&void 0!==n?n:"",e.data,i,l)})}),s=pe.current;s&&(pe.current=Object.assign(Object.assign({},s),{nodes:d(s.nodes)})),I(e=>d(e)),J(e=>e+1)}),[L,I]),Pe=e.useCallback(()=>i(this,void 0,void 0,function*(){var e,n,o,t,r,i;try{const r=le.current,i=ce.current,d=ne(r,i,G),s=a?yield L.dialPlans.update(a,d):yield L.dialPlans.create(Object.assign({name:l.status.newDialPlan},d));pe.current={nodes:[...r],edges:[...i]},U(!1),null===(n=(e=ue.current).onDirtyChange)||void 0===n||n.call(e,!1),null===(t=(o=ue.current).onSave)||void 0===t||t.call(o,s)}catch(e){const n=e instanceof Error?e:new Error(String(e)),o=n.message.includes("/nodes/")?ne(le.current,ce.current,G):null;if(o){const e=n.message.match(/^\/nodes\/(\d+)\//);if(null==e?void 0:e[1]){const n=o.nodes[parseInt(e[1],10)];n&&$(n.id)}}throw null===(i=(r=ue.current).onError)||void 0===i||i.call(r,new Error(function(e,n){var o,a,t;if(e.startsWith("voice_app notify mode is not supported on AI agent voice apps"))return"A Voice App used in Notify mode is backed by a Managed VoiceAI agent. Managed VoiceAI voice apps must use Control mode.";const l=e.indexOf(": "),r=l>0&&e.startsWith("/")?e.slice(0,l):"",i=l>0?e.slice(l+2):e,d=r.split("/").filter(Boolean);if("entry_node"===d[0])return"The Start node must be connected to another node";if("nodes"===d[0]&&i.includes("minItems"))return"The dial plan must have at least one node";if("nodes"===d[0]&&"config"===d[2]&&d[3]){const e=d[3];if(ge[e])return ge[e];const l=parseInt(null!==(o=d[1])&&void 0!==o?o:"",10),r=isNaN(l)||null===(a=null==n?void 0:n[l])||void 0===a?void 0:a.type,i=r?null!==(t=be[r])&&void 0!==t?t:r:void 0;return i?`Invalid ${e.replace(/_/g," ")} in the ${i} node`:`Invalid ${e.replace(/_/g," ")}`}return r?i:e}(n.message,null==o?void 0:o.nodes))),e}}),[L,a]);e.useImperativeHandle(w,()=>({save:Pe,refreshResources:Fe}),[Pe,Fe]);const De=e.useCallback((e,n)=>{"__start__"!==n.id&&($(n.id),B(null))},[]),Me=e.useCallback((e,n)=>{B(n.id),$(null)},[]),He=e.useCallback(e=>{const n=ce.current.filter(n=>n.id!==e);D(n),ke(le.current,n),B(null)},[D,ke]),$e=e.useCallback(()=>{$(null),B(null)},[]),Ke=e.useCallback((e,n)=>{var o;if(!r)return;if("__start__"===n.id)return;const a=null===(o=n.data)||void 0===o?void 0:o.originalNode;a&&r(n.id,a)},[r]),Be=H?A.find(e=>e.id===H):null,Ve=Be?G.getByFlowType(null!==(k=Be.type)&&void 0!==k?k:""):null,Ue=K?P.find(e=>e.id===K):null,We=!(!Be||!Ve)||!!Ue;if(R)return e.createElement("div",{className:`ds-dial-plan-viewer ds-dial-plan-viewer--loading ${h||""}`,style:_},e.createElement("div",{className:"ds-dial-plan-viewer__loading"},e.createElement("div",{className:"ds-dial-plan-viewer__spinner"}),e.createElement("span",null,l.status.loading)));if(T)return e.createElement("div",{className:`ds-dial-plan-viewer ds-dial-plan-viewer--error ${h||""}`,style:_},e.createElement("div",{className:"ds-dial-plan-viewer__error"},e.createElement("span",null,l.status.loadError),e.createElement("span",{className:"ds-dial-plan-viewer__error-message"},T.message)));if(!E&&0===A.length)return e.createElement("div",{className:`ds-dial-plan-viewer ds-dial-plan-viewer--empty ${h||""}`,style:_},e.createElement("div",{className:"ds-dial-plan-viewer__empty"},e.createElement("span",null,l.status.notFound)));const qe=e.createElement(n.ReactFlow,{nodes:A,edges:P,nodeTypes:he,edgeTypes:_e,onNodesChange:E?Ce:void 0,onEdgesChange:E?Ee:void 0,onConnect:E?Re:void 0,onReconnect:E?ze:void 0,onEdgeClick:E?Me:void 0,isValidConnection:E?Te:void 0,edgesReconnectable:E,onNodeClick:E?De:r?Ke:void 0,onPaneClick:E?$e:void 0,nodesDraggable:E,nodesConnectable:E,elementsSelectable:E,selectionOnDrag:!1,selectNodesOnDrag:!1,panOnDrag:N,panOnScroll:!1,zoomOnScroll:N,zoomOnPinch:N,zoomOnDoubleClick:N,preventScrolling:N,connectionLineType:n.ConnectionLineType.SmoothStep,selectionKeyCode:null,multiSelectionKeyCode:null,deleteKeyCode:E?["Backspace","Delete"]:null,fitView:!0,fitViewOptions:{padding:N?.2:.15,minZoom:N?.5:0,maxZoom:1.5},minZoom:N?.3:0,maxZoom:2,defaultEdgeOptions:{type:d,animated:!1,markerEnd:{type:n.MarkerType.ArrowClosed,width:12,height:12,color:"#94a3b8"}},proOptions:{hideAttribution:!0}},C&&e.createElement(n.Background,{gap:20,size:1}),C&&e.createElement(n.Controls,{showInteractive:!1}),E&&e.createElement(se,{onAutoLayout:Ae,onSave:()=>{Pe().catch(()=>{})},isDirty:V,hasInvalidDraft:W}));return e.createElement("div",{className:`ds-dial-plan-editor ${"preview"===t?"ds-dial-plan-editor--preview":""} ${h||""}`,style:_},E&&e.createElement("div",{className:"ds-dial-plan-node-library-wrapper"},e.createElement(re,{registry:G,onAddNode:Le})),e.createElement("div",{ref:oe,className:"ds-dial-plan-editor__canvas",onDrop:E?Oe:void 0,onDragOver:E?Se:void 0},qe),E&&e.createElement("div",{className:"ds-dial-plan-config-panel-wrapper"+(We?" ds-dial-plan-config-panel-wrapper--open":"")},Be&&Ve&&e.createElement(de,{node:Be,registration:Ve,onConfigChange:je,onInvalidDraftChange:q,onDelete:Ne,onClose:()=>{$(null),I(e=>e.map(e=>e.selected?Object.assign(Object.assign({},e),{selected:!1}):e))},listResources:Ie,onCreateResource:x,onOpenResource:y,locale:l}),Ue&&e.createElement("div",{className:"ds-dial-plan-config-panel"},e.createElement("div",{className:"ds-dial-plan-config-panel__header"},e.createElement("span",{className:"ds-dial-plan-config-panel__header-icon"},e.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M4 8h8v8h8"}),e.createElement("polyline",{points:"17 13 20 16 17 19"}))),e.createElement("span",{className:"ds-dial-plan-config-panel__header-label"},l.panel.connection),e.createElement("button",{type:"button",className:"ds-dial-plan-config-panel__delete",onClick:()=>He(Ue.id),title:l.panel.delete_},ie),e.createElement("button",{type:"button",className:"ds-dial-plan-config-panel__close",onClick:()=>{B(null),D(e=>e.map(e=>e.selected?Object.assign(Object.assign({},e),{selected:!1}):e))},title:l.panel.close},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e.createElement("div",{className:"ds-dial-plan-config-panel__body"},e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("span",{className:"ds-dial-plan-config-field__label"},l.panel.from),e.createElement("span",{className:"ds-dial-plan-edge-panel__value"},(()=>{var e,n,o;const a=A.find(e=>e.id===Ue.source),t=a?G.getByFlowType(null!==(e=a.type)&&void 0!==e?e:""):null,l=null!==(o=null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null==a?void 0:a.type)&&void 0!==o?o:Ue.source;return l.charAt(0).toUpperCase()+l.slice(1)})())),Ue.sourceHandle&&e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("span",{className:"ds-dial-plan-config-field__label"},l.panel.exit),e.createElement("span",{className:"ds-dial-plan-edge-panel__value"},(()=>{var e,n,o,a,t;const l=Ue.sourceHandle,r=A.find(e=>e.id===Ue.source),i=r?G.getByFlowType(null!==(e=r.type)&&void 0!==e?e:""):null,d=i?Z.find(e=>{var n;return e.type===(null!==(n=i.apiType)&&void 0!==n?n:i.type)}):null;return null!==(t=null!==(o=null===(n=null==d?void 0:d.resolveExitLabel)||void 0===n?void 0:n.call(d,l))&&void 0!==o?o:null===(a=null==i?void 0:i.exits.find(e=>e.id===l))||void 0===a?void 0:a.label)&&void 0!==t?t:l})())),e.createElement("div",{className:"ds-dial-plan-config-field"},e.createElement("span",{className:"ds-dial-plan-config-field__label"},l.panel.to),e.createElement("span",{className:"ds-dial-plan-edge-panel__value"},(()=>{var e,n,o;const a=A.find(e=>e.id===Ue.target),t=a?G.getByFlowType(null!==(e=a.type)&&void 0!==e?e:""):null,l=null!==(o=null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null==a?void 0:a.type)&&void 0!==o?o:Ue.target;return l.charAt(0).toUpperCase()+l.slice(1)})()))))))}),we=["/* this gets exported as style.css and can be used for the default theming */\n/* these are the necessary styles for React/Svelte Flow, they get used by base.css and style.css */\n.react-flow {\n direction: ltr;\n\n --xy-edge-stroke-default: #b1b1b7;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #555;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(255, 255, 255, 0.5);\n\n --xy-minimap-background-color-default: #fff;\n --xy-minimap-mask-background-color-default: rgba(240, 240, 240, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #e2e2e2;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: transparent;\n --xy-background-pattern-dots-color-default: #91919a;\n --xy-background-pattern-lines-color-default: #eee;\n --xy-background-pattern-cross-color-default: #e2e2e2;\n background-color: var(--xy-background-color, var(--xy-background-color-default));\n --xy-node-color-default: inherit;\n --xy-node-border-default: 1px solid #1a192b;\n --xy-node-background-color-default: #fff;\n --xy-node-group-background-color-default: rgba(240, 240, 240, 0.25);\n --xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, 0.08);\n --xy-node-boxshadow-selected-default: 0 0 0 0.5px #1a192b;\n --xy-node-border-radius-default: 3px;\n\n --xy-handle-background-color-default: #1a192b;\n --xy-handle-border-color-default: #fff;\n\n --xy-selection-background-color-default: rgba(0, 89, 220, 0.08);\n --xy-selection-border-default: 1px dotted rgba(0, 89, 220, 0.8);\n\n --xy-controls-button-background-color-default: #fefefe;\n --xy-controls-button-background-color-hover-default: #f4f4f4;\n --xy-controls-button-color-default: inherit;\n --xy-controls-button-color-hover-default: inherit;\n --xy-controls-button-border-color-default: #eee;\n --xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, 0.08);\n\n --xy-edge-label-background-color-default: #ffffff;\n --xy-edge-label-color-default: inherit;\n --xy-resize-background-color-default: #3367d9;\n}\n.react-flow.dark {\n --xy-edge-stroke-default: #3e3e3e;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #727272;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(150, 150, 150, 0.25);\n\n --xy-minimap-background-color-default: #141414;\n --xy-minimap-mask-background-color-default: rgba(60, 60, 60, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #2b2b2b;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: #141414;\n --xy-background-pattern-dots-color-default: #555;\n --xy-background-pattern-lines-color-default: #333;\n --xy-background-pattern-cross-color-default: #333;\n --xy-node-color-default: #f8f8f8;\n --xy-node-border-default: 1px solid #3c3c3c;\n --xy-node-background-color-default: #1e1e1e;\n --xy-node-group-background-color-default: rgba(240, 240, 240, 0.25);\n --xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, 0.08);\n --xy-node-boxshadow-selected-default: 0 0 0 0.5px #999;\n\n --xy-handle-background-color-default: #bebebe;\n --xy-handle-border-color-default: #1e1e1e;\n\n --xy-selection-background-color-default: rgba(200, 200, 220, 0.08);\n --xy-selection-border-default: 1px dotted rgba(200, 200, 220, 0.8);\n\n --xy-controls-button-background-color-default: #2b2b2b;\n --xy-controls-button-background-color-hover-default: #3e3e3e;\n --xy-controls-button-color-default: #f8f8f8;\n --xy-controls-button-color-hover-default: #fff;\n --xy-controls-button-border-color-default: #5b5b5b;\n --xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, 0.08);\n\n --xy-edge-label-background-color-default: #141414;\n --xy-edge-label-color-default: #f8f8f8;\n}\n.react-flow__background {\n background-color: var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));\n pointer-events: none;\n z-index: -1;\n}\n.react-flow__container {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n}\n.react-flow__pane {\n z-index: 1;\n touch-action: none;\n}\n.react-flow__pane.draggable {\n cursor: grab;\n }\n.react-flow__pane.dragging {\n cursor: grabbing;\n }\n.react-flow__pane.selection {\n cursor: pointer;\n }\n.react-flow__viewport {\n transform-origin: 0 0;\n z-index: 2;\n pointer-events: none;\n}\n.react-flow__renderer {\n z-index: 4;\n}\n.react-flow__selection {\n z-index: 6;\n}\n.react-flow__nodesselection-rect:focus,\n.react-flow__nodesselection-rect:focus-visible {\n outline: none;\n}\n.react-flow__edge-path {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n stroke-width: var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));\n fill: none;\n}\n.react-flow__connection-path {\n stroke: var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));\n stroke-width: var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));\n fill: none;\n}\n.react-flow .react-flow__edges {\n position: absolute;\n}\n.react-flow .react-flow__edges svg {\n overflow: visible;\n position: absolute;\n pointer-events: none;\n }\n.react-flow__edge {\n pointer-events: visibleStroke;\n}\n.react-flow__edge.selectable {\n cursor: pointer;\n }\n.react-flow__edge.animated path {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\n.react-flow__edge.animated path.react-flow__edge-interaction {\n stroke-dasharray: none;\n animation: none;\n }\n.react-flow__edge.inactive {\n pointer-events: none;\n }\n.react-flow__edge.selected,\n .react-flow__edge:focus,\n .react-flow__edge:focus-visible {\n outline: none;\n }\n.react-flow__edge.selected .react-flow__edge-path,\n .react-flow__edge.selectable:focus .react-flow__edge-path,\n .react-flow__edge.selectable:focus-visible .react-flow__edge-path {\n stroke: var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default));\n }\n.react-flow__edge-textwrapper {\n pointer-events: all;\n }\n.react-flow__edge .react-flow__edge-text {\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n/* Arrowhead marker styles - use CSS custom properties as default */\n.react-flow__arrowhead polyline {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__arrowhead polyline.arrowclosed {\n fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__connection {\n pointer-events: none;\n}\n.react-flow__connection .animated {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\nsvg.react-flow__connectionline {\n z-index: 1001;\n overflow: visible;\n position: absolute;\n}\n.react-flow__nodes {\n pointer-events: none;\n transform-origin: 0 0;\n}\n.react-flow__node {\n position: absolute;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n pointer-events: all;\n transform-origin: 0 0;\n box-sizing: border-box;\n cursor: default;\n}\n.react-flow__node.selectable {\n cursor: pointer;\n }\n.react-flow__node.draggable {\n cursor: grab;\n pointer-events: all;\n }\n.react-flow__node.draggable.dragging {\n cursor: grabbing;\n }\n.react-flow__nodesselection {\n z-index: 3;\n transform-origin: left top;\n pointer-events: none;\n}\n.react-flow__nodesselection-rect {\n position: absolute;\n pointer-events: all;\n cursor: grab;\n }\n.react-flow__handle {\n position: absolute;\n pointer-events: none;\n min-width: 5px;\n min-height: 5px;\n width: 6px;\n height: 6px;\n background-color: var(--xy-handle-background-color, var(--xy-handle-background-color-default));\n border: 1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));\n border-radius: 100%;\n}\n.react-flow__handle.connectingfrom {\n pointer-events: all;\n }\n.react-flow__handle.connectionindicator {\n pointer-events: all;\n cursor: crosshair;\n }\n.react-flow__handle-bottom {\n top: auto;\n left: 50%;\n bottom: 0;\n transform: translate(-50%, 50%);\n }\n.react-flow__handle-top {\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-left {\n top: 50%;\n left: 0;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-right {\n top: 50%;\n right: 0;\n transform: translate(50%, -50%);\n }\n.react-flow__edgeupdater {\n cursor: move;\n pointer-events: all;\n}\n.react-flow__pane.selection .react-flow__panel {\n pointer-events: none;\n}\n.react-flow__panel {\n position: absolute;\n z-index: 5;\n margin: 15px;\n}\n.react-flow__panel.top {\n top: 0;\n }\n.react-flow__panel.bottom {\n bottom: 0;\n }\n.react-flow__panel.top.center, .react-flow__panel.bottom.center {\n left: 50%;\n transform: translateX(-15px) translateX(-50%);\n }\n.react-flow__panel.left {\n left: 0;\n }\n.react-flow__panel.right {\n right: 0;\n }\n.react-flow__panel.left.center, .react-flow__panel.right.center {\n top: 50%;\n transform: translateY(-15px) translateY(-50%);\n }\n.react-flow__attribution {\n font-size: 10px;\n background: var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));\n padding: 2px 3px;\n margin: 0;\n}\n.react-flow__attribution a {\n text-decoration: none;\n color: #999;\n }\n@keyframes dashdraw {\n from {\n stroke-dashoffset: 10;\n }\n}\n.react-flow__edgelabel-renderer {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n left: 0;\n top: 0;\n}\n.react-flow__viewport-portal {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n.react-flow__minimap {\n background: var(\n --xy-minimap-background-color-props,\n var(--xy-minimap-background-color, var(--xy-minimap-background-color-default))\n );\n}\n.react-flow__minimap-svg {\n display: block;\n }\n.react-flow__minimap-mask {\n fill: var(\n --xy-minimap-mask-background-color-props,\n var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default))\n );\n stroke: var(\n --xy-minimap-mask-stroke-color-props,\n var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-mask-stroke-width-props,\n var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default))\n );\n }\n.react-flow__minimap-node {\n fill: var(\n --xy-minimap-node-background-color-props,\n var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default))\n );\n stroke: var(\n --xy-minimap-node-stroke-color-props,\n var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-node-stroke-width-props,\n var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default))\n );\n }\n.react-flow__background-pattern.dots {\n fill: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default))\n );\n }\n.react-flow__background-pattern.lines {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default))\n );\n }\n.react-flow__background-pattern.cross {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default))\n );\n }\n.react-flow__controls {\n display: flex;\n flex-direction: column;\n box-shadow: var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default));\n}\n.react-flow__controls.horizontal {\n flex-direction: row;\n }\n.react-flow__controls-button {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 26px;\n width: 26px;\n padding: 4px;\n border: none;\n background: var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));\n border-bottom: 1px solid\n var(\n --xy-controls-button-border-color-props,\n var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default))\n );\n color: var(\n --xy-controls-button-color-props,\n var(--xy-controls-button-color, var(--xy-controls-button-color-default))\n );\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n.react-flow__controls-button svg {\n width: 100%;\n max-width: 12px;\n max-height: 12px;\n fill: currentColor;\n }\n.react-flow__edge.updating .react-flow__edge-path {\n stroke: #777;\n }\n.react-flow__edge-text {\n font-size: 10px;\n }\n.react-flow__node.selectable:focus,\n .react-flow__node.selectable:focus-visible {\n outline: none;\n }\n.react-flow__node-input,\n.react-flow__node-default,\n.react-flow__node-output,\n.react-flow__node-group {\n padding: 10px;\n border-radius: var(--xy-node-border-radius, var(--xy-node-border-radius-default));\n width: 150px;\n font-size: 12px;\n color: var(--xy-node-color, var(--xy-node-color-default));\n text-align: center;\n border: var(--xy-node-border, var(--xy-node-border-default));\n background-color: var(--xy-node-background-color, var(--xy-node-background-color-default));\n}\n.react-flow__node-input.selectable:hover, .react-flow__node-default.selectable:hover, .react-flow__node-output.selectable:hover, .react-flow__node-group.selectable:hover {\n box-shadow: var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default));\n }\n.react-flow__node-input.selectable.selected,\n .react-flow__node-input.selectable:focus,\n .react-flow__node-input.selectable:focus-visible,\n .react-flow__node-default.selectable.selected,\n .react-flow__node-default.selectable:focus,\n .react-flow__node-default.selectable:focus-visible,\n .react-flow__node-output.selectable.selected,\n .react-flow__node-output.selectable:focus,\n .react-flow__node-output.selectable:focus-visible,\n .react-flow__node-group.selectable.selected,\n .react-flow__node-group.selectable:focus,\n .react-flow__node-group.selectable:focus-visible {\n box-shadow: var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default));\n }\n.react-flow__node-group {\n background-color: var(--xy-node-group-background-color, var(--xy-node-group-background-color-default));\n}\n.react-flow__nodesselection-rect,\n.react-flow__selection {\n background: var(--xy-selection-background-color, var(--xy-selection-background-color-default));\n border: var(--xy-selection-border, var(--xy-selection-border-default));\n}\n.react-flow__nodesselection-rect:focus,\n .react-flow__nodesselection-rect:focus-visible,\n .react-flow__selection:focus,\n .react-flow__selection:focus-visible {\n outline: none;\n }\n.react-flow__controls-button:hover {\n background: var(\n --xy-controls-button-background-color-hover-props,\n var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default))\n );\n color: var(\n --xy-controls-button-color-hover-props,\n var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default))\n );\n }\n.react-flow__controls-button:disabled {\n pointer-events: none;\n }\n.react-flow__controls-button:disabled svg {\n fill-opacity: 0.4;\n }\n.react-flow__controls-button:last-child {\n border-bottom: none;\n }\n.react-flow__controls.horizontal .react-flow__controls-button {\n border-bottom: none;\n border-right: 1px solid\n var(\n --xy-controls-button-border-color-props,\n var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default))\n );\n }\n.react-flow__controls.horizontal .react-flow__controls-button:last-child {\n border-right: none;\n }\n.react-flow__resize-control {\n position: absolute;\n}\n.react-flow__resize-control.left,\n.react-flow__resize-control.right {\n cursor: ew-resize;\n}\n.react-flow__resize-control.top,\n.react-flow__resize-control.bottom {\n cursor: ns-resize;\n}\n.react-flow__resize-control.top.left,\n.react-flow__resize-control.bottom.right {\n cursor: nwse-resize;\n}\n.react-flow__resize-control.bottom.left,\n.react-flow__resize-control.top.right {\n cursor: nesw-resize;\n}\n/* handle styles */\n.react-flow__resize-control.handle {\n width: 5px;\n height: 5px;\n border: 1px solid #fff;\n border-radius: 1px;\n background-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n translate: -50% -50%;\n}\n.react-flow__resize-control.handle.left {\n left: 0;\n top: 50%;\n}\n.react-flow__resize-control.handle.right {\n left: 100%;\n top: 50%;\n}\n.react-flow__resize-control.handle.top {\n left: 50%;\n top: 0;\n}\n.react-flow__resize-control.handle.bottom {\n left: 50%;\n top: 100%;\n}\n.react-flow__resize-control.handle.top.left {\n left: 0;\n}\n.react-flow__resize-control.handle.bottom.left {\n left: 0;\n}\n.react-flow__resize-control.handle.top.right {\n left: 100%;\n}\n.react-flow__resize-control.handle.bottom.right {\n left: 100%;\n}\n/* line styles */\n.react-flow__resize-control.line {\n border-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n border-width: 0;\n border-style: solid;\n}\n.react-flow__resize-control.line.left,\n.react-flow__resize-control.line.right {\n width: 1px;\n transform: translate(-50%, 0);\n top: 0;\n height: 100%;\n}\n.react-flow__resize-control.line.left {\n left: 0;\n border-left-width: 1px;\n}\n.react-flow__resize-control.line.right {\n left: 100%;\n border-right-width: 1px;\n}\n.react-flow__resize-control.line.top,\n.react-flow__resize-control.line.bottom {\n height: 1px;\n transform: translate(0, -50%);\n left: 0;\n width: 100%;\n}\n.react-flow__resize-control.line.top {\n top: 0;\n border-top-width: 1px;\n}\n.react-flow__resize-control.line.bottom {\n border-bottom-width: 1px;\n top: 100%;\n}\n.react-flow__edge-textbg {\n fill: var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default));\n}\n.react-flow__edge-text {\n fill: var(--xy-edge-label-color, var(--xy-edge-label-color-default));\n}\n",'\n/* ============================================================================\n Shadow DOM Reset\n ============================================================================ */\n\n:host {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n}\n\n/* ============================================================================\n Container\n ============================================================================ */\n\n.ds-dial-plan-viewer {\n width: 100%;\n height: 100%;\n background: var(--ds-color-background, #ffffff);\n border-radius: var(--ds-border-radius, 8px);\n overflow: hidden;\n}\n\n/* ============================================================================\n Base Node Styles\n ============================================================================ */\n\n.ds-dial-plan-node {\n padding: 12px 16px;\n border-radius: var(--ds-border-radius, 8px);\n border: 2px solid var(--ds-color-border, #e2e8f0);\n background: var(--ds-color-background, #ffffff);\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n transition: border-color 0.15s ease, box-shadow 0.15s ease, outline-color 0.15s ease;\n min-width: 140px;\n outline: 3px solid transparent;\n outline-offset: 2px;\n}\n\n.ds-dial-plan-node--selected {\n border-color: var(--ds-color-primary, #3b82f6);\n outline-color: var(--ds-color-primary, #3b82f6);\n box-shadow: 0 0 16px 2px rgba(59, 130, 246, 0.4), 0 4px 12px rgba(59, 130, 246, 0.2);\n}\n\n.ds-dial-plan-node__content,\n.ds-dial-plan-node__header {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n}\n\n.ds-dial-plan-node__icon {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-node__label {\n font-weight: 600;\n color: var(--ds-color-text, #1e293b);\n text-align: center;\n}\n\n.ds-dial-plan-node__type-label {\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 500;\n color: var(--ds-color-text-secondary, #64748b);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.ds-dial-plan-node__name {\n font-weight: 600;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n text-align: center;\n}\n\n.ds-dial-plan-node__type {\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-node__exits {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin-top: 12px;\n padding-top: 10px;\n border-top: 1px solid var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-node__exit-row {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n position: relative;\n}\n\n.ds-dial-plan-node__exit-label {\n font-size: 11px;\n color: var(--ds-color-text-secondary, #64748b);\n white-space: nowrap;\n}\n\n/* Position handles at the right edge of exit rows */\n.ds-dial-plan-node__exit-row .ds-dial-plan-handle {\n position: absolute;\n right: -16px;\n}\n\n/* ============================================================================\n Start Node\n ============================================================================ */\n\n.ds-dial-plan-node--start {\n background: var(--ds-color-primary, #3b82f6);\n border-color: var(--ds-color-primary, #3b82f6);\n border-radius: 50%;\n width: 60px;\n height: 60px;\n min-width: auto;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.ds-dial-plan-node--start .ds-dial-plan-node__content {\n flex-direction: row;\n}\n\n.ds-dial-plan-node--start .ds-dial-plan-node__label {\n color: #ffffff;\n font-size: var(--ds-font-size-sm, 14px);\n}\n\n/* ============================================================================\n Node color theming (driven by --node-color CSS variable from registration)\n ============================================================================ */\n\n.ds-dial-plan-node--themed {\n border-color: var(--node-color);\n background: color-mix(in srgb, var(--node-color) 8%, white);\n}\n\n.ds-dial-plan-node--themed .ds-dial-plan-node__icon {\n color: var(--node-color);\n}\n\n.ds-dial-plan-node--themed.ds-dial-plan-node--selected {\n border-color: var(--node-color);\n outline-color: var(--node-color);\n box-shadow: 0 0 16px 2px color-mix(in srgb, var(--node-color) 40%, transparent),\n 0 4px 12px color-mix(in srgb, var(--node-color) 20%, transparent);\n}\n\n/* ============================================================================\n Per-type node colors (override --themed fallback with hand-crafted gradients)\n ============================================================================ */\n\n.ds-dial-plan-node--schedule {\n background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);\n border-color: var(--ds-color-info, #0ea5e9);\n min-height: 80px;\n}\n.ds-dial-plan-node--schedule .ds-dial-plan-node__icon { color: var(--ds-color-info, #0ea5e9); }\n.ds-dial-plan-node--schedule.ds-dial-plan-node--selected {\n border-color: var(--ds-color-info, #0ea5e9);\n outline-color: var(--ds-color-info, #0ea5e9);\n box-shadow: 0 0 16px 2px rgba(14, 165, 233, 0.4), 0 4px 12px rgba(14, 165, 233, 0.2);\n}\n\n.ds-dial-plan-node--internal-dial {\n background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);\n border-color: var(--ds-color-success, #22c55e);\n}\n.ds-dial-plan-node--internal-dial .ds-dial-plan-node__icon { color: var(--ds-color-success, #22c55e); }\n.ds-dial-plan-node--internal-dial.ds-dial-plan-node--selected {\n border-color: var(--ds-color-success, #22c55e);\n outline-color: var(--ds-color-success, #22c55e);\n box-shadow: 0 0 16px 2px rgba(34, 197, 94, 0.4), 0 4px 12px rgba(34, 197, 94, 0.2);\n}\n\n.ds-dial-plan-node--voicemail {\n background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);\n border-color: var(--ds-color-purple, #a855f7);\n}\n.ds-dial-plan-node--voicemail .ds-dial-plan-node__icon { color: var(--ds-color-purple, #a855f7); }\n.ds-dial-plan-node--voicemail.ds-dial-plan-node--selected {\n border-color: var(--ds-color-purple, #a855f7);\n outline-color: var(--ds-color-purple, #a855f7);\n box-shadow: 0 0 16px 2px rgba(168, 85, 247, 0.4), 0 4px 12px rgba(168, 85, 247, 0.2);\n}\n\n.ds-dial-plan-node--ring-all-users {\n background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);\n border-color: var(--ds-color-warning, #f59e0b);\n}\n.ds-dial-plan-node--ring-all-users .ds-dial-plan-node__icon { color: var(--ds-color-warning, #f59e0b); }\n.ds-dial-plan-node--ring-all-users.ds-dial-plan-node--selected {\n border-color: var(--ds-color-warning, #f59e0b);\n outline-color: var(--ds-color-warning, #f59e0b);\n box-shadow: 0 0 16px 2px rgba(245, 158, 11, 0.4), 0 4px 12px rgba(245, 158, 11, 0.2);\n}\n\n.ds-dial-plan-node--external-dial {\n background: linear-gradient(135deg, #fff1f2 0%, #fecdd3 100%);\n border-color: var(--ds-color-rose, #f43f5e);\n}\n.ds-dial-plan-node--external-dial .ds-dial-plan-node__icon { color: var(--ds-color-rose, #f43f5e); }\n.ds-dial-plan-node--external-dial.ds-dial-plan-node--selected {\n border-color: var(--ds-color-rose, #f43f5e);\n outline-color: var(--ds-color-rose, #f43f5e);\n box-shadow: 0 0 16px 2px rgba(244, 63, 94, 0.4), 0 4px 12px rgba(244, 63, 94, 0.2);\n}\n\n.ds-dial-plan-node--voice-app {\n border: 2px solid transparent;\n background:\n linear-gradient(135deg, #c7d2fe 0%, #ddd6fe 40%, #bae6fd 100%) padding-box,\n linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n position: relative;\n transition: box-shadow 0.15s ease;\n}\n.ds-dial-plan-node--voice-app .ds-dial-plan-node__icon { color: #4f46e5; }\n.ds-dial-plan-node--voice-app.ds-dial-plan-node--selected {\n border-color: transparent;\n outline: none;\n box-shadow: 0 0 16px 2px rgba(99, 102, 241, 0.4), 0 4px 12px rgba(56, 189, 248, 0.2);\n}\n.ds-dial-plan-node--voice-app::after {\n content: \'\';\n position: absolute;\n inset: -7px;\n border-radius: calc(var(--ds-border-radius, 8px) + 5px);\n border: 3px solid transparent;\n background: linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);\n -webkit-mask-composite: xor;\n mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);\n mask-composite: exclude;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.15s ease;\n z-index: -1;\n}\n.ds-dial-plan-node--voice-app.ds-dial-plan-node--selected::after { opacity: 1; }\n\n.ds-dial-plan-node--menu {\n background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);\n border-color: #ec4899;\n}\n.ds-dial-plan-node--menu .ds-dial-plan-node__icon { color: #ec4899; }\n.ds-dial-plan-node--menu.ds-dial-plan-node--selected {\n border-color: #ec4899;\n outline-color: #ec4899;\n box-shadow: 0 0 16px 2px rgba(236, 72, 153, 0.4), 0 4px 12px rgba(236, 72, 153, 0.2);\n}\n\n.ds-dial-plan-node--audio-clip {\n background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);\n border-color: #14b8a6;\n}\n.ds-dial-plan-node--audio-clip .ds-dial-plan-node__icon { color: #14b8a6; }\n.ds-dial-plan-node--audio-clip.ds-dial-plan-node--selected {\n border-color: #14b8a6;\n outline-color: #14b8a6;\n box-shadow: 0 0 16px 2px rgba(20, 184, 166, 0.4), 0 4px 12px rgba(20, 184, 166, 0.2);\n}\n\n/* ============================================================================\n Menu Config Panel — Options List\n ============================================================================ */\n\n.ds-dial-plan-config-field__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 6px;\n}\n\n.ds-dial-plan-config-field__header .ds-dial-plan-config-field__label {\n margin: 0;\n}\n\n.ds-dial-plan-menu-options {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.ds-dial-plan-menu-options__card {\n display: flex;\n align-items: flex-end;\n gap: 6px;\n}\n\n.ds-dial-plan-menu-options__field {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n}\n\n.ds-dial-plan-menu-options__field--digit {\n flex: 0 0 64px;\n}\n\n.ds-dial-plan-menu-options__field--label {\n flex: 1;\n}\n\n.ds-dial-plan-menu-options__field-label {\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.05em;\n text-transform: uppercase;\n color: var(--ds-color-text-muted, #94a3b8);\n}\n\n.ds-dial-plan-menu-options__field-hint {\n font-weight: 400;\n text-transform: none;\n letter-spacing: 0;\n opacity: 0.8;\n}\n\n.ds-dial-plan-menu-options__remove {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: none;\n background: none;\n color: var(--ds-color-text-muted, #94a3b8);\n cursor: pointer;\n border-radius: 4px;\n flex-shrink: 0;\n}\n\n.ds-dial-plan-menu-options__remove:hover {\n color: var(--ds-color-danger, #ef4444);\n background: rgba(239, 68, 68, 0.1);\n}\n\n.ds-dial-plan-menu-options__add {\n padding: 3px 10px;\n border: 1px solid var(--ds-color-primary, #6366f1);\n background: none;\n color: var(--ds-color-primary, #6366f1);\n cursor: pointer;\n border-radius: 4px;\n font-size: 11px;\n font-weight: 500;\n white-space: nowrap;\n}\n\n.ds-dial-plan-menu-options__add:hover:not(:disabled) {\n background: var(--ds-color-primary, #6366f1);\n color: #ffffff;\n}\n\n.ds-dial-plan-menu-options__add:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n/* ============================================================================\n Handles\n ============================================================================ */\n\n.ds-dial-plan-handle {\n width: 10px;\n height: 10px;\n background: var(--ds-color-border, #e2e8f0);\n border: 2px solid var(--ds-color-background, #ffffff);\n}\n\n.ds-dial-plan-handle--next {\n background: var(--ds-color-text-secondary, #64748b);\n}\n\n/* ============================================================================\n React Flow Overrides (both viewer and editor)\n ============================================================================ */\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-path {\n stroke: var(--ds-color-border, #94a3b8);\n stroke-width: 2;\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge.selected .react-flow__edge-path {\n stroke: var(--ds-color-primary, #3b82f6);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-text {\n font-size: var(--ds-font-size-xs, 12px);\n fill: var(--ds-color-text-secondary, #64748b);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__background {\n background-color: var(--ds-color-background, #ffffff);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__minimap {\n background: var(--ds-color-background, #ffffff);\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls {\n border-radius: var(--ds-border-radius, 8px);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button {\n background: var(--ds-color-background, #ffffff);\n border-color: var(--ds-color-border, #e2e8f0);\n color: var(--ds-color-text, #1e293b);\n}\n\n:is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button:hover {\n background: var(--ds-color-background-hover, #f8fafc);\n}\n\n/* ============================================================================\n Loading, Error, and Empty States\n ============================================================================ */\n\n.ds-dial-plan-viewer--loading,\n.ds-dial-plan-viewer--error,\n.ds-dial-plan-viewer--empty {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.ds-dial-plan-viewer__loading,\n.ds-dial-plan-viewer__error,\n.ds-dial-plan-viewer__empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-viewer__spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--ds-color-border, #e2e8f0);\n border-top-color: var(--ds-color-primary, #3b82f6);\n border-radius: 50%;\n animation: ds-dial-plan-spin 0.8s linear infinite;\n}\n\n@keyframes ds-dial-plan-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.ds-dial-plan-viewer__error {\n color: var(--ds-color-danger, #ef4444);\n}\n\n.ds-dial-plan-viewer__error-message {\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n max-width: 300px;\n text-align: center;\n}\n\n/* ============================================================================\n Config Panel\n ============================================================================ */\n\n.ds-dial-plan-config-panel {\n width: 260px;\n height: 100%;\n background: var(--ds-color-background, #ffffff);\n border-left: 1px solid var(--ds-color-border, #e2e8f0);\n display: flex;\n flex-direction: column;\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n overflow-y: auto;\n}\n\n.ds-dial-plan-config-panel__header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n border-bottom: 1px solid var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-config-panel__header-icon {\n color: var(--ds-color-text-secondary, #64748b);\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-panel__header-label {\n flex: 1;\n font-weight: 600;\n color: var(--ds-color-text, #1e293b);\n}\n\n.ds-dial-plan-config-panel__delete {\n color: var(--ds-color-danger, #ef4444);\n background: none;\n border: none;\n padding: 2px;\n cursor: pointer;\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-panel__delete:hover {\n color: #dc2626;\n}\n\n.ds-dial-plan-config-panel__close {\n background: none;\n border: none;\n color: var(--ds-color-text-secondary, #64748b);\n cursor: pointer;\n padding: 2px;\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-panel__close:hover {\n color: var(--ds-color-text, #1e293b);\n}\n\n.ds-dial-plan-config-panel__body {\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.ds-dial-plan-config-field {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n.ds-dial-plan-config-field__label {\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 500;\n color: var(--ds-color-text-secondary, #64748b);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.ds-dial-plan-config-field__select,\n.ds-dial-plan-config-field__input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n background: var(--ds-color-background, #ffffff);\n color: var(--ds-color-text, #1e293b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n outline: none;\n box-sizing: border-box;\n}\n\n.ds-dial-plan-config-field__checkbox {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n cursor: pointer;\n}\n\n.ds-dial-plan-config-field__hint {\n margin: 4px 0 0;\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n line-height: 1.4;\n}\n\n.ds-dial-plan-config-field__error {\n margin: 4px 0 0;\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-danger, #ef4444);\n line-height: 1.4;\n}\n\n.ds-dial-plan-config-field__input[aria-invalid=\'true\'] {\n border-color: var(--ds-color-danger, #ef4444);\n}\n\n.ds-dial-plan-edge-panel__value {\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-edge-panel__value {\n color: #e2e8f0;\n}\n\n.ds-dial-plan-config-field__open-link {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n background: none;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-primary, #3b82f6);\n cursor: pointer;\n font-family: inherit;\n}\n\n.ds-dial-plan-config-field__open-link:hover {\n text-decoration: underline;\n}\n\n.ds-dial-plan-config-field__select:focus,\n.ds-dial-plan-config-field__input:focus {\n border-color: var(--ds-color-primary, #3b82f6);\n box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);\n}\n\n.ds-dial-plan-config-field__input:disabled {\n background: #f1f5f9;\n color: var(--ds-color-text-secondary, #64748b);\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.ds-dial-plan-config-field__input-wrapper {\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.ds-dial-plan-config-field__input-wrapper .ds-dial-plan-config-field__input {\n padding-right: 28px;\n}\n\n.ds-dial-plan-config-field__clear {\n position: absolute;\n right: 6px;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background: transparent;\n color: var(--ds-color-text-secondary, #64748b);\n cursor: pointer;\n}\n\n.ds-dial-plan-config-field__clear:hover {\n background: var(--ds-color-border, #e2e8f0);\n color: var(--ds-color-text, #1e293b);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__clear:hover {\n background: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n.ds-dial-plan-config-field__segmented {\n display: flex;\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n overflow: hidden;\n background: var(--ds-color-background, #ffffff);\n}\n\n.ds-dial-plan-config-field__segmented-option {\n flex: 1;\n padding: 6px 8px;\n border: none;\n background: transparent;\n color: var(--ds-color-text-secondary, #64748b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n cursor: pointer;\n}\n\n.ds-dial-plan-config-field__segmented-option + .ds-dial-plan-config-field__segmented-option {\n border-left: 1px solid var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-config-field__segmented-option--active {\n background: var(--ds-color-primary, #3b82f6);\n color: #ffffff;\n font-weight: 500;\n}\n\n.ds-dial-plan-config-field__hint {\n margin: 4px 0 0;\n font-size: var(--ds-font-size-xs, 11px);\n line-height: 1.4;\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-dial-plan-node__badge {\n display: block;\n width: fit-content;\n margin: 4px auto 0;\n padding: 2px 8px;\n border-radius: 999px;\n background: var(--ds-color-muted, #eef2ff);\n color: var(--ds-color-text-secondary, #64748b);\n font-size: var(--ds-font-size-xs, 11px);\n font-weight: 500;\n letter-spacing: 0.3px;\n text-align: center;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__badge {\n background: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n/* ============================================================================\n Resource Combobox\n ============================================================================ */\n\n.ds-resource-combobox {\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n background: var(--ds-color-background, #ffffff);\n overflow: hidden;\n}\n\n.ds-resource-combobox__trigger {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n background: var(--ds-color-background, #ffffff);\n color: var(--ds-color-text, #1e293b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n text-align: left;\n}\n\n.ds-resource-combobox__trigger:hover {\n border-color: var(--ds-color-primary, #3b82f6);\n}\n\n.ds-resource-combobox__trigger-placeholder {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-resource-combobox__trigger-chevron {\n color: var(--ds-color-text-secondary, #64748b);\n opacity: 0.5;\n flex-shrink: 0;\n}\n\n.ds-resource-combobox__input {\n width: 100%;\n padding: 8px 10px;\n border: none;\n border-bottom: 1px solid var(--ds-color-border, #e2e8f0);\n background: transparent;\n color: var(--ds-color-text, #1e293b);\n font-size: var(--ds-font-size-sm, 14px);\n font-family: inherit;\n outline: none;\n box-sizing: border-box;\n}\n\n.ds-resource-combobox__input::placeholder {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n.ds-resource-combobox__list {\n max-height: 400px;\n overflow-y: auto;\n padding: 4px 0;\n}\n\n.ds-resource-combobox__group [cmdk-group-heading] {\n padding: 6px 10px 2px;\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 500;\n color: var(--ds-color-text-secondary, #64748b);\n text-transform: uppercase;\n letter-spacing: 0.5px;\n}\n\n.ds-resource-combobox__item {\n padding: 6px 10px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text, #1e293b);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n border-radius: 0;\n}\n\n.ds-resource-combobox__item[data-selected="true"] {\n background: var(--ds-color-primary, #3b82f6);\n color: #ffffff;\n}\n\n.ds-resource-combobox__item--selected {\n font-weight: 500;\n}\n\n.ds-resource-combobox__name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ds-resource-combobox__ext {\n font-size: var(--ds-font-size-xs, 12px);\n color: var(--ds-color-text-secondary, #64748b);\n margin-left: auto;\n padding-left: 8px;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.ds-resource-combobox__check {\n font-size: 12px;\n opacity: 0.7;\n width: 16px;\n text-align: center;\n flex-shrink: 0;\n}\n\n.ds-resource-combobox__create {\n padding: 6px 10px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-primary, #3b82f6);\n cursor: pointer;\n font-style: italic;\n}\n\n.ds-resource-combobox__create[data-selected="true"] {\n background: var(--ds-color-primary, #3b82f6);\n color: #ffffff;\n}\n\n.ds-resource-combobox__empty {\n padding: 12px 10px;\n font-size: var(--ds-font-size-sm, 14px);\n color: var(--ds-color-text-secondary, #64748b);\n text-align: center;\n}\n\n/* ============================================================================\n Dark Mode\n Activated by .dark class on an ancestor (Tailwind / next-themes convention)\n or data-theme="dark" attribute.\n ============================================================================ */\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor {\n background: #1a1a2e;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node {\n background: #1e1e32;\n border-color: rgba(255, 255, 255, 0.1);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__label,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__name {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__icon,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__type-label,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__type,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__exit-label {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node__exits {\n border-top-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--themed {\n background: color-mix(in srgb, var(--node-color) 20%, #1a1a2e);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--schedule {\n background: linear-gradient(135deg, #0c2d48 0%, #0a3761 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--internal-dial {\n background: linear-gradient(135deg, #052e16 0%, #064e3b 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--voicemail {\n background: linear-gradient(135deg, #2e1065 0%, #3b0764 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--ring-all-users {\n background: linear-gradient(135deg, #451a03 0%, #78350f 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--external-dial {\n background: linear-gradient(135deg, #4c0519 0%, #881337 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--voice-app {\n background:\n linear-gradient(135deg, #252262 0%, #3b1d7e 40%, #0c3a5e 100%) padding-box,\n linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--menu {\n background: linear-gradient(135deg, #500724 0%, #831843 100%);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node--audio-clip {\n background: linear-gradient(135deg, #042f2e 0%, #115e59 100%);\n}\n\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-handle {\n border-color: #1e1e32;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__background {\n background-color: #1a1a2e;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-path {\n stroke: rgba(255, 255, 255, 0.2);\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__edge-text {\n fill: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__minimap {\n background: #1e1e32;\n border-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls {\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button {\n background: #1e1e32;\n border-color: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) :is(.ds-dial-plan-viewer, .ds-dial-plan-editor) .react-flow__controls-button:hover {\n background: #2a2a45;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer__loading,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer__empty {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-viewer__spinner {\n border-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel {\n background: #1e1e32;\n border-left-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__header {\n border-bottom-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__header-label {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__close {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-panel__close:hover {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__label {\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__checkbox {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__select,\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__input {\n background: #12122a;\n border-color: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-config-field__input:disabled {\n background: #1e1e38;\n color: #94a3b8;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__trigger {\n background: #12122a;\n border-color: rgba(255, 255, 255, 0.1);\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox {\n border-color: rgba(255, 255, 255, 0.1);\n background: #12122a;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__input {\n color: #e2e8f0;\n border-bottom-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__item {\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-resource-combobox__item--selected {\n color: #e2e8f0;\n}\n\n/* Node Library */\n\n.ds-dial-plan-node-library {\n width: 200px;\n height: 100%;\n background: var(--ds-color-background, #ffffff);\n border-right: 1px solid var(--ds-color-border, #e2e8f0);\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 12px;\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n overflow-y: auto;\n}\n\n.ds-dial-plan-node-library__item {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n padding: 10px 12px;\n border-radius: var(--ds-border-radius, 8px);\n border: 2px solid var(--node-color, var(--ds-color-border, #e2e8f0));\n background: color-mix(in srgb, var(--node-color, #ffffff) 10%, white);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n cursor: grab;\n transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;\n}\n\n.ds-dial-plan-node-library__item:hover {\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);\n transform: translateY(-1px);\n}\n\n.ds-dial-plan-node-library__item:active {\n cursor: grabbing;\n transform: scale(0.97);\n}\n\n/* Per-type library item colors */\n.ds-dial-plan-node-library__item--schedule { background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border-color: var(--ds-color-info, #0ea5e9); }\n.ds-dial-plan-node-library__item--internal_dial { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border-color: var(--ds-color-success, #22c55e); }\n.ds-dial-plan-node-library__item--voicemail { background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%); border-color: var(--ds-color-purple, #a855f7); }\n.ds-dial-plan-node-library__item--ring_all_users { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border-color: var(--ds-color-warning, #f59e0b); }\n.ds-dial-plan-node-library__item--external_dial { background: linear-gradient(135deg, #fff1f2 0%, #fecdd3 100%); border-color: var(--ds-color-rose, #f43f5e); }\n.ds-dial-plan-node-library__item--voice_app,\n.ds-dial-plan-node-library__item--voice_app:hover {\n border: 2px solid transparent;\n background: linear-gradient(135deg, #c7d2fe 0%, #ddd6fe 40%, #bae6fd 100%) padding-box, linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box;\n}\n.ds-dial-plan-node-library__item--menu { background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%); border-color: #ec4899; }\n.ds-dial-plan-node-library__item--audio_clip { background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%); border-color: #14b8a6; }\n\n.ds-dial-plan-node-library__item-icon {\n display: flex;\n align-items: center;\n color: var(--node-color);\n}\n.ds-dial-plan-node-library__item--schedule .ds-dial-plan-node-library__item-icon { color: var(--ds-color-info, #0ea5e9); }\n.ds-dial-plan-node-library__item--internal_dial .ds-dial-plan-node-library__item-icon { color: var(--ds-color-success, #22c55e); }\n.ds-dial-plan-node-library__item--voicemail .ds-dial-plan-node-library__item-icon { color: var(--ds-color-purple, #a855f7); }\n.ds-dial-plan-node-library__item--ring_all_users .ds-dial-plan-node-library__item-icon { color: var(--ds-color-warning, #f59e0b); }\n.ds-dial-plan-node-library__item--external_dial .ds-dial-plan-node-library__item-icon { color: var(--ds-color-rose, #f43f5e); }\n.ds-dial-plan-node-library__item--voice_app .ds-dial-plan-node-library__item-icon { color: #4f46e5; }\n.ds-dial-plan-node-library__item--menu .ds-dial-plan-node-library__item-icon { color: #ec4899; }\n.ds-dial-plan-node-library__item--audio_clip .ds-dial-plan-node-library__item-icon { color: #14b8a6; }\n\n.ds-dial-plan-node-library__item-label {\n font-size: var(--ds-font-size-xs, 12px);\n font-weight: 600;\n color: var(--ds-color-text, #1e293b);\n text-align: center;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library {\n background: #1e1e32;\n border-right-color: rgba(255, 255, 255, 0.1);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item {\n background: color-mix(in srgb, var(--node-color, #1e1e32) 20%, #1e1e32);\n border-color: rgba(255, 255, 255, 0.1);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--schedule { background: linear-gradient(135deg, #0c2d48 0%, #0a3761 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--internal_dial { background: linear-gradient(135deg, #052e16 0%, #064e3b 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--voicemail { background: linear-gradient(135deg, #2e1065 0%, #3b0764 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--ring_all_users { background: linear-gradient(135deg, #451a03 0%, #78350f 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--external_dial { background: linear-gradient(135deg, #4c0519 0%, #881337 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--voice_app { background: linear-gradient(135deg, #252262 0%, #3b1d7e 40%, #0c3a5e 100%) padding-box, linear-gradient(135deg, #38bdf8 0%, #818cf8 35%, #a855f7 60%, #ec4899 100%) border-box; }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--menu { background: linear-gradient(135deg, #500724 0%, #831843 100%); }\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item--audio_clip { background: linear-gradient(135deg, #042f2e 0%, #115e59 100%); }\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-node-library__item-label {\n color: #e2e8f0;\n}\n\n/* ============================================================================\n Editor Toolbar\n ============================================================================ */\n\n.ds-dial-plan-editor-toolbar {\n position: absolute;\n top: 16px;\n right: 16px;\n z-index: 10;\n display: flex;\n gap: 8px;\n}\n\n.ds-dial-plan-editor-toolbar__button {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 12px;\n background: var(--ds-color-background, #ffffff);\n border: 1px solid var(--ds-color-border, #e2e8f0);\n border-radius: var(--ds-border-radius, 8px);\n color: var(--ds-color-text, #1e293b);\n font-family: var(--ds-font-family, -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif);\n font-size: var(--ds-font-size-sm, 14px);\n font-weight: 500;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.ds-dial-plan-editor-toolbar__button:hover {\n background: var(--ds-color-background-hover, #f1f5f9);\n border-color: var(--ds-color-border, #cbd5e1);\n}\n\n.ds-dial-plan-editor-toolbar__button:active {\n transform: scale(0.98);\n}\n\n.ds-dial-plan-editor-toolbar__button:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.ds-dial-plan-editor-toolbar__button:disabled:hover {\n background: var(--ds-color-background, #ffffff);\n border-color: var(--ds-color-border, #e2e8f0);\n}\n\n.ds-dial-plan-editor-toolbar__button svg {\n color: var(--ds-color-text-secondary, #64748b);\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button {\n background: #1e293b;\n border-color: #334155;\n color: #e2e8f0;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button:hover {\n background: #334155;\n border-color: #475569;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button:disabled:hover {\n background: #1e293b;\n border-color: #334155;\n}\n\n:is(.dark, [data-theme="dark"]) .ds-dial-plan-editor-toolbar__button svg {\n color: #cbd5e1;\n}\n\n/* Editor Layout */\n\n.ds-dial-plan-editor {\n display: flex;\n width: 100%;\n height: 100%;\n flex: 1;\n min-height: 400px;\n background: var(--ds-color-background, #ffffff);\n overflow: hidden;\n}\n\n.ds-dial-plan-editor--preview {\n min-height: 0;\n}\n\n.ds-dial-plan-editor__canvas {\n flex: 1;\n position: relative;\n}\n\n/* Node Library wrapper */\n\n.ds-dial-plan-node-library-wrapper {\n width: 200px;\n flex-shrink: 0;\n align-self: stretch;\n overflow: hidden;\n}\n\n/* Config panel wrapper (slide-in animation) */\n\n.ds-dial-plan-config-panel-wrapper {\n width: 0;\n flex-shrink: 0;\n align-self: stretch;\n overflow: hidden;\n transition: width 0.2s ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ds-dial-plan-config-panel-wrapper {\n transition: none;\n }\n}\n\n.ds-dial-plan-config-panel-wrapper--open {\n width: 260px;\n}\n\n\n'],ke=e.forwardRef((a,t)=>{var l;const{dialstack:r}=o.useDialstackComponents();o.useReportComponent("dial-plan");const i=function(n){const[o,a]=e.useState(()=>n.getAppearance());return e.useEffect(()=>{if("undefined"==typeof document)return;const e=document.createElement("div"),o=e=>{const n=e.detail;a(null==n?void 0:n.appearance)};return e.addEventListener("dialstack-appearance-update",o),n.addAppearanceTarget(e),()=>{n.removeAppearanceTarget(e),e.removeEventListener("dialstack-appearance-update",o)}},[n]),o}(r),d="dark"===(null==i?void 0:i.theme)?"dark":"light",s=null!==(l=a.theme)&&void 0!==l?l:d;return e.createElement(pe,{stylesheets:we,className:a.className,style:Object.assign({width:"100%",height:"100%",flex:1,minHeight:0},a.style)},e.createElement("div",{"data-theme":s,style:{display:"flex",flexDirection:"column",flex:1,minHeight:0}},e.createElement(n.ReactFlowProvider,null,e.createElement(ye,Object.assign({ref:t},a)))))});ke.displayName="DialPlan",exports.DialPlan=ke;
2
2
  //# sourceMappingURL=dial-plan.cjs.map